1
0
mirror of https://github.com/akpaevj/onecmonitor.git synced 2026-06-15 21:32:34 +02:00
Files

244 lines
11 KiB
Plaintext

@inject IDbContextFactory<AppDbContext> ContextFactory
@using Blazor.Diagrams.Components.Renderers
@using Microsoft.EntityFrameworkCore
@using OneSwiss.Common.Extensions
@using OneSwiss.Common.Models.MaintenanceTasks
@using OneSwiss.Server.Extensions
@using OneSwiss.Server.Models
@implements IDisposable
<MudCard>
<MudCardHeader Style="@("background-color: " + Node.Step.Kind.GetKindColor())">
<MudText>@Node.Step.Kind.GetDisplay()</MudText>
</MudCardHeader>
<MudCardContent>
@if (Node.Step.Kind == MaintenanceStepKind.StartExternalDataProcessor)
{
<MudSelect Class="mb-1" Label="Файл EPF" For="@(() => Node.Step.StartExternalDataProcessorStep.FileId)"
@bind-Value="@Node.Step.StartExternalDataProcessorStep.FileId" Clearable="true">
@foreach (var item in _context.Files.Where(c => c.FileType == FileType.Epf).ToList())
{
<MudSelectItem Value="@((Guid?)item.Id)">@item.ToString()</MudSelectItem>
}
</MudSelect>
}
@if (Node.Step.Kind == MaintenanceStepKind.ExecuteOneScript)
{
<MudSwitch Class="mb-1" Label="Режим отладки" @bind-Value="@Node.Step.ExecuteOneScriptStep.DebugMode"
@bind-Value:after="SetNeedRender" Color="Color.Primary"/>
@if (Node.Step.ExecuteOneScriptStep.DebugMode)
{
<MudTextField Class="mb-1" Label="Файл скрипта"
For="@(() => Node.Step.ExecuteOneScriptStep.ExecutablePath)"
@bind-Value="@Node.Step.ExecuteOneScriptStep.ExecutablePath"/>
}
else
{
<MudSelect Class="mb-1" Label="Файл OSPX" For="@(() => Node.Step.ExecuteOneScriptStep.FileId)"
@bind-Value="@Node.Step.ExecuteOneScriptStep.FileId" Clearable="true">
@foreach (var item in _context.Files.Where(c => c.FileType == FileType.Ospx).ToList())
{
<MudSelectItem Value="@((Guid?)item.Id)">@item.ToString()</MudSelectItem>
}
</MudSelect>
}
}
@if (Node.Step.Kind == MaintenanceStepKind.LockConnections)
{
<MudTextField Class="mb-1" Label="Код доступа" For="@(() => Node.Step.LockConnectionsStep.AccessCode)"
@bind-Value="@Node.Step.LockConnectionsStep.AccessCode"/>
<MudTextField Class="mb-1" Label="Сообщение" For="@(() => Node.Step.LockConnectionsStep.Message)"
@bind-Value="@Node.Step.LockConnectionsStep.Message"/>
}
@if (Node.Step.Kind == MaintenanceStepKind.DeleteExtension)
{
<MudTextField Class="mb-1" Label="Регулярное выражение имени расширения"
For="@(() => Node.Step.DeleteExtensionStep.ExtensionName)"
@bind-Value="@Node.Step.DeleteExtensionStep.ExtensionName"/>
}
@if (Node.Step.Kind == MaintenanceStepKind.LoadConfiguration)
{
<MudSwitch Class="mb-1" Label="Из хранилища"
@bind-Value="@Node.Step.LoadConfigurationStep.FromConfigRepository"
@bind-Value:after="SetNeedRenderTask" Color="Color.Primary"/>
@if (Node.Step.LoadConfigurationStep.FromConfigRepository)
{
<MudSelect Class="mb-1" Label="Хранилище"
For="@(() => Node.Step.LoadConfigurationStep.ConfigurationRepositoryId)"
@bind-Value="@Node.Step.LoadConfigurationStep.ConfigurationRepositoryId" Clearable="true">
@foreach (var item in _context.ConfigRepositories.Where(c => c.CredentialsId != null).ToList())
{
<MudSelectItem Value="@((Guid?)item.Id)">@item.ToString()</MudSelectItem>
}
</MudSelect>
<MudSwitch Class="mb-1" Label="Загружать версию"
@bind-Value="@Node.Step.LoadConfigurationStep.LoadExactVersion"
@bind-Value:after="SetNeedRenderTask" Color="Color.Primary"/>
<MudTextField Class="mb-1" Label="Версия"
For="@(() => Node.Step.LoadConfigurationStep.Version)"
@bind-Value="@Node.Step.LoadConfigurationStep.Version"/>
}
else
{
<MudSelect Class="mb-1" Label="Файл CF" For="@(() => Node.Step.LoadConfigurationStep.FileId)"
@bind-Value="@Node.Step.LoadConfigurationStep.FileId" Clearable="true">
@foreach (var item in _context.Files.Where(c => c.FileType == FileType.Cf).ToList())
{
<MudSelectItem Value="@((Guid?)item.Id)">@item.ToString()</MudSelectItem>
}
</MudSelect>
}
}
@if (Node.Step.Kind == MaintenanceStepKind.UpdateConfiguration)
{
<MudSelect Class="mb-1" Label="Файл CFU" For="@(() => Node.Step.UpdateConfigurationStep.FileId)"
@bind-Value="@Node.Step.UpdateConfigurationStep.FileId" Clearable="true">
@foreach (var item in _context.Files.Where(c => c.FileType == FileType.Cfu).ToList())
{
<MudSelectItem Value="@((Guid?)item.Id)">@item.ToString()</MudSelectItem>
}
</MudSelect>
}
@if (Node.Step.Kind == MaintenanceStepKind.LoadExtension)
{
<MudTextField Class="mb-1" Label="Имя расширения" For="@(() => Node.Step.LoadExtensionStep!.ExtensionName)"
@bind-Value="@Node.Step.LoadExtensionStep!.ExtensionName"/>
<MudSwitch Class="mb-1" Label="Из хранилища" @bind-Value="@Node.Step.LoadExtensionStep!.FromConfigRepository"
@bind-Value:after="SetNeedRenderTask" Color="Color.Primary"/>
@if (Node.Step.LoadExtensionStep.FromConfigRepository)
{
<ItemSelector
@bind-Value="@Node.Step.LoadExtensionStep.BaseConfigurationRepositoryId"
Items="@_context!.ConfigRepositories.Where(c => c.CredentialsId != null).ToList()"
Class="mb-"
ItemValueSelector="arg => arg.Id"
Label="Хранилище базовой конфигурации"
ItemNameSelector="arg => arg.ToString()"
For="@(() => Node.Step.LoadExtensionStep.BaseConfigurationRepositoryId)"/>
<MudSelect Class="mb-1" Label="Хранилище"
For="@(() => Node.Step.LoadExtensionStep.ConfigurationRepositoryId)"
@bind-Value="@Node.Step.LoadExtensionStep.ConfigurationRepositoryId" Clearable="true">
@foreach (var item in _context.ConfigRepositories.Where(c => c.CredentialsId != null).ToList())
{
<MudSelectItem Value="@((Guid?)item.Id)">@item.ToString()</MudSelectItem>
}
</MudSelect>
<MudSwitch Class="mb-1" Label="Загружать версию"
@bind-Value="@Node.Step.LoadExtensionStep.LoadExactVersion"
@bind-Value:after="SetNeedRenderTask" Color="Color.Primary"/>
<MudTextField Class="mb-1" Label="Версия"
For="@(() => Node.Step.LoadExtensionStep.Version)"
@bind-Value="@Node.Step.LoadExtensionStep.Version"/>
}
else
{
<MudSelect Class="mb-1" Label="Файл CFE" For="@(() => Node.Step.LoadExtensionStep.FileId)"
@bind-Value="@Node.Step.LoadExtensionStep.FileId" Clearable="true">
@foreach (var item in _context.Files.Where(c => c.FileType == FileType.Cfe).ToList())
{
<MudSelectItem Value="@((Guid?)item.Id)">@item.ToString()</MudSelectItem>
}
</MudSelect>
}
}
@if (Node.Step.Kind == MaintenanceStepKind.CopyInfoBase)
{
<MudSelect Class="mb-1" Label="Учетные данные БД-источника"
For="@(() => Node.Step.CopyInfoBaseStep.SourceCredentialsId)"
@bind-Value="@Node.Step.CopyInfoBaseStep.SourceCredentialsId" Clearable="true">
@foreach (var item in _context.Credentials.Where(c => !c.IsToken).ToList())
{
<MudSelectItem Value="@((Guid?)item.Id)">@item.Name</MudSelectItem>
}
</MudSelect>
<MudSelect Class="mb-1" Label="ИБ-источник" For="@(() => Node.Step.CopyInfoBaseStep.SourceInfoBaseId)"
@bind-Value="@Node.Step.CopyInfoBaseStep.SourceInfoBaseId" Clearable="true">
@foreach (var item in _context.InfoBases.ToList())
{
<MudSelectItem Value="@((Guid?)item.Id)">@item.Name</MudSelectItem>
}
</MudSelect>
<MudSelect Class="mb-1" Label="Учетные данные БД-приемника"
For="@(() => Node.Step.CopyInfoBaseStep.DestinationCredentialsId)"
@bind-Value="@Node.Step.CopyInfoBaseStep.DestinationCredentialsId" Clearable="true">
@foreach (var item in _context.Credentials.Where(c => !c.IsToken).ToList())
{
<MudSelectItem Value="@((Guid?)item.Id)">@item.Name</MudSelectItem>
}
</MudSelect>
<MudSelect Class="mb-1" Label="ИБ-приемник" For="@(() => Node.Step.CopyInfoBaseStep.DestinationInfoBaseId)"
@bind-Value="@Node.Step.CopyInfoBaseStep.DestinationInfoBaseId" Clearable="true">
@foreach (var item in _context.InfoBases.ToList())
{
<MudSelectItem Value="@((Guid?)item.Id)">@item.Name</MudSelectItem>
}
</MudSelect>
}
</MudCardContent>
@foreach (var port in Node.Ports)
{
<PortRenderer @key="port" Port="port"/>
}
</MudCard>
@code
{
private bool _needRender;
private AppDbContext? _context;
[Parameter]
public StepNode Node { get; set; } = null!;
[CascadingParameter]
public StepsDiagram Diagram { get; set; }
protected override async Task OnInitializedAsync()
{
_context = await ContextFactory.CreateDbContextAsync();
}
protected override bool ShouldRender()
{
var result = _needRender;
_needRender = false;
return result;
}
public void Dispose()
{
_context?.Dispose();
}
private void SetNeedRender()
{
_needRender = true;
}
private void SetNeedRenderTask()
{
Diagram.UpdateTask?.Invoke(this, EventArgs.Empty);
SetNeedRender();
}
}