106 lines
4.8 KiB
Plaintext
106 lines
4.8 KiB
Plaintext
@implements IAsyncDisposable
|
||
@inject IJSRuntime JS
|
||
|
||
<MudPaper Elevation="0" Class="pa-2" Style="background:transparent;">
|
||
|
||
<MudStack Row="true" AlignItems="AlignItems.Center" Style="cursor:pointer" @onclick="ToggleExpand">
|
||
<MudText Typo="Typo.subtitle1">STATUS</MudText>
|
||
<MudText Typo="Typo.caption" Style="@($"font-weight:800;letter-spacing:0.5px;margin-left:20px;white-space:nowrap;{WfColor}")">@WfPhaseText</MudText>
|
||
@if (State.Workflow.CompletedCycles > 0)
|
||
{
|
||
<MudText Typo="Typo.caption" Style="color:#5a8a6a;font-weight:700;white-space:nowrap;">@State.Workflow.CompletedCycles ×</MudText>
|
||
}
|
||
<MudSpacer />
|
||
<MudIcon Icon="@(_expanded ? Icons.Material.Filled.ExpandMore : Icons.Material.Filled.ExpandLess)" Size="Size.Small" />
|
||
</MudStack>
|
||
@if (!string.IsNullOrEmpty(State.Workflow.LastError))
|
||
{
|
||
<MudAlert Severity="Severity.Error" Dense="true" Class="mt-1" Style="font-size:0.7rem;">@State.Workflow.LastError</MudAlert>
|
||
}
|
||
|
||
@if (_expanded)
|
||
{
|
||
|
||
@* ── IMR + AMR ── *@
|
||
<ImrAmrStatusPanel />
|
||
|
||
<MudDivider Class="mt-2 mb-1" />
|
||
|
||
@* ── ASRS grid ── *@
|
||
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:4px;">
|
||
@foreach (var row in AsrsRows)
|
||
{
|
||
@foreach (var cell in row.Cells)
|
||
{
|
||
bool on = cell.Val == true && !State.Asrs.IsOffline;
|
||
<MudChip T="string" Size="Size.Small"
|
||
Color="@(on ? Color.Info : Color.Default)"
|
||
Variant="@(on ? Variant.Filled : Variant.Outlined)"
|
||
Style="width:100%;margin:0;justify-content:center;height:25px;font-size:13px;font-weight:700;">@cell.Label</MudChip>
|
||
}
|
||
}
|
||
</div>
|
||
|
||
@* ── Nav ── *@
|
||
<MudStack Row="true" Spacing="1" Class="mt-2">
|
||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Style="flex:1;min-width:0;padding:0 4px;" OnClick='()=>ScrollTo("p-ctrl")'>CTRL</MudButton>
|
||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Style="flex:1;min-width:0;padding:0 4px;" OnClick='()=>ScrollTo("p-ops")'>OPS</MudButton>
|
||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Style="flex:1;min-width:0;padding:0 4px;" OnClick='()=>ScrollTo("p-conveyor")'>CV</MudButton>
|
||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Style="flex:1;min-width:0;padding:0 4px;" OnClick='()=>ScrollTo("p-imr")'>IMR</MudButton>
|
||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Style="flex:1;min-width:0;padding:0 4px;" OnClick='()=>ScrollTo("p-amr")'>AMR</MudButton>
|
||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Style="flex:1;min-width:0;padding:0 4px;" OnClick='()=>ScrollTo("p-dobot")'>Dobot</MudButton>
|
||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Style="flex:1;min-width:0;padding:0 4px;" OnClick='()=>ScrollTo("p-asrs")'>ASRS</MudButton>
|
||
</MudStack>
|
||
}
|
||
</MudPaper>
|
||
|
||
@code {
|
||
[Inject] StateService State { get; set; } = default!;
|
||
|
||
private bool _expanded = true;
|
||
void ToggleExpand() => _expanded = !_expanded;
|
||
|
||
protected override async Task OnInitializedAsync()
|
||
{
|
||
await State.StartAsync();
|
||
State.AsrsChanged += Refresh;
|
||
State.WorkflowChanged += Refresh;
|
||
}
|
||
|
||
public ValueTask DisposeAsync()
|
||
{
|
||
State.AsrsChanged -= Refresh;
|
||
State.WorkflowChanged -= Refresh;
|
||
return ValueTask.CompletedTask;
|
||
}
|
||
|
||
private void Refresh() => InvokeAsync(StateHasChanged);
|
||
|
||
private Task ScrollTo(string id) =>
|
||
JS.InvokeVoidAsync("eval", $"document.getElementById('{id}')?.scrollIntoView({{behavior:'smooth'}})").AsTask();
|
||
|
||
private string WfPhaseText
|
||
{
|
||
get
|
||
{
|
||
var wf = State.Workflow;
|
||
if (!string.IsNullOrEmpty(wf.LastError)) return "ERROR";
|
||
if (wf.IsRunning) return "RUNNING";
|
||
return "IDLE";
|
||
}
|
||
}
|
||
|
||
private string WfColor =>
|
||
!string.IsNullOrEmpty(State.Workflow.LastError) ? "color:#e74c3c;" :
|
||
State.Workflow.IsRunning ? "color:#4a9eff;" : "color:#9CA3AF;";
|
||
|
||
private (string RowLabel, (string Label, bool? Val)[] Cells)[] AsrsRows => new[]
|
||
{
|
||
("L4", new (string, bool?)[] { ("41", State.Asrs.X41), ("42", State.Asrs.X42), ("43", State.Asrs.X43) }),
|
||
("L3", new (string, bool?)[] { ("31", State.Asrs.X31), ("32", State.Asrs.X32), ("33", State.Asrs.X33) }),
|
||
("L2", new (string, bool?)[] { ("21", State.Asrs.X21), ("22", State.Asrs.X22), ("23", State.Asrs.X23) }),
|
||
("L1", new (string, bool?)[] { ("11", State.Asrs.X11), ("12", State.Asrs.X12), ("13", State.Asrs.X13) }),
|
||
};
|
||
|
||
}
|