180 lines
6.4 KiB
Plaintext
180 lines
6.4 KiB
Plaintext
@inject LayoutManagerState State
|
|
@inject NavigationManager Navigation
|
|
@inject IDialogService DialogService
|
|
@inject ISnackbar Snackbar
|
|
@implements IDisposable
|
|
|
|
<!-- Toolbar -->
|
|
<MudContainer MaxWidth="MaxWidth.ExtraExtraLarge" Class="mt-4">
|
|
<MudPaper Class="pa-4 mb-4" MinHeight="80px">
|
|
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Spacing="3">
|
|
<MudText Typo="Typo.h5">Layout Manager</MudText>
|
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
|
<!-- Search Box -->
|
|
<MudTextField Value="searchText"
|
|
Placeholder="Search layouts..."
|
|
Variant="Variant.Outlined"
|
|
Adornment="Adornment.Start"
|
|
AdornmentIcon="@Icons.Material.Filled.Search"
|
|
Margin="Margin.Dense"
|
|
Style="min-width: 250px;"
|
|
Immediate="false"
|
|
T="string"
|
|
ValueChanged="TextSearchChanged"
|
|
Clearable="true" />
|
|
|
|
<!-- Import Button -->
|
|
<MudButton StartIcon="@Icons.Material.Filled.FileDownload"
|
|
Variant="Variant.Filled"
|
|
Color="Color.Primary"
|
|
OnClick="OpenImportDialog">
|
|
Import
|
|
</MudButton>
|
|
|
|
<!-- Add Layout Button -->
|
|
<MudButton StartIcon="@Icons.Material.Filled.Add"
|
|
Variant="Variant.Filled"
|
|
Color="Color.Success"
|
|
OnClick="OpenCreateLayoutDialog">
|
|
Add Layout
|
|
</MudButton>
|
|
</MudStack>
|
|
</MudStack>
|
|
</MudPaper>
|
|
|
|
<!-- Loading State -->
|
|
@if (State.IsLoading)
|
|
{
|
|
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="mb-4" />
|
|
}
|
|
|
|
<!-- Main Content -->
|
|
@if (State.IsLoading)
|
|
{
|
|
<MudPaper Class="pa-16 text-center">
|
|
<MudProgressCircular Indeterminate="true" Size="Size.Large" />
|
|
<MudText Typo="Typo.body1" Align="Align.Center" Class="mt-4">
|
|
Loading layouts...
|
|
</MudText>
|
|
</MudPaper>
|
|
}
|
|
else
|
|
{
|
|
<MudGrid Spacing="3">
|
|
<!-- Left Panel: Tree -->
|
|
<MudItem xs="12" md="4">
|
|
<MudPaper Elevation="2" Class="pa-4" Style="height: calc(100vh - 200px); overflow-y: auto;">
|
|
<LayoutTreePanel State="@State" />
|
|
</MudPaper>
|
|
</MudItem>
|
|
|
|
<!-- Right Panel: Preview -->
|
|
<MudItem xs="12" md="8">
|
|
<MudPaper Elevation="2" Class="pa-4" Style="height: calc(100vh - 200px); overflow-y: auto;">
|
|
@if (State.SelectedLevel != null)
|
|
{
|
|
<LayoutPreviewPanel State="@State"
|
|
OnEdit="NavigateToEditor"
|
|
OnStation="NavigateToStation"
|
|
OnExport="ExportLayout" />
|
|
}
|
|
else
|
|
{
|
|
<MudStack AlignItems="AlignItems.Center" Justify="Justify.Center" Style="height: 100%;">
|
|
<MudIcon Icon="@Icons.Material.Filled.Layers" Size="Size.Large" Color="Color.Secondary" Style="font-size: 100px;" />
|
|
<MudText Typo="Typo.h6" Color="Color.Secondary" Align="Align.Center" Class="mt-4">
|
|
Select a layout level to view preview
|
|
</MudText>
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary" Align="Align.Center">
|
|
Choose a level from the tree on the left
|
|
</MudText>
|
|
</MudStack>
|
|
}
|
|
</MudPaper>
|
|
</MudItem>
|
|
</MudGrid>
|
|
}
|
|
</MudContainer>
|
|
|
|
@code {
|
|
private string? searchText;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
State.OnStateChanged += StateHasChanged;
|
|
await State.LoadLayoutsAsync();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
State.OnStateChanged -= StateHasChanged;
|
|
}
|
|
|
|
private async Task TextSearchChanged(string text)
|
|
{
|
|
searchText = text;
|
|
await State.LoadLayoutsAsync(searchText);
|
|
}
|
|
|
|
private async Task OpenCreateLayoutDialog()
|
|
{
|
|
var dialog = await DialogService.ShowAsync<CreateLayoutDialog>("Create New Layout");
|
|
var result = await dialog.Result;
|
|
|
|
if (result != null && !result.Canceled)
|
|
{
|
|
Snackbar.Add("Layout created successfully", Severity.Success);
|
|
}
|
|
}
|
|
|
|
private async Task OpenImportDialog()
|
|
{
|
|
var dialog = await DialogService.ShowAsync<ImportLayoutDialog>("Import VDMA LIF");
|
|
var result = await dialog.Result;
|
|
|
|
if (result != null && !result.Canceled)
|
|
{
|
|
Snackbar.Add("Layout imported successfully", Severity.Success);
|
|
}
|
|
}
|
|
|
|
private void NavigateToEditor()
|
|
{
|
|
if (State.SelectedLevel != null)
|
|
{
|
|
Navigation.NavigateTo($"/layout-editor/{State.SelectedLevel.Id}");
|
|
}
|
|
}
|
|
|
|
private void NavigateToStation()
|
|
{
|
|
if (State.SelectedLevel != null)
|
|
{
|
|
Navigation.NavigateTo($"/station-manager/{State.SelectedLevel.Id}");
|
|
}
|
|
}
|
|
|
|
private async Task ExportLayout()
|
|
{
|
|
if (State.SelectedLayout == null || State.SelectedVersion == null)
|
|
{
|
|
Snackbar.Add("No layout selected", Severity.Warning);
|
|
return;
|
|
}
|
|
|
|
var dialog = await DialogService.ShowAsync<ExportLayoutDialog>("Export Layout", new DialogParameters
|
|
{
|
|
["LayoutId"] = State.SelectedLayout.Id,
|
|
["Version"] = State.SelectedVersion.Version
|
|
});
|
|
|
|
var result = await dialog.Result;
|
|
|
|
if (result != null && !result.Canceled)
|
|
{
|
|
Snackbar.Add("Layout exported successfully", Severity.Success);
|
|
}
|
|
}
|
|
}
|
|
|