@page "/script-manager"
@attribute [Authorize]
@implements IAsyncDisposable

@using RobotNet.WebApp.Clients
@using RobotNet.WebApp.Scripts.Components.Dashboards

@inject ProcessorHubClient ProcessorHub

<PageTitle>Script Manager</PageTitle>

<div class="w-100 h-100 position-relative overflow-hidden">
    <div class="w-100 h-100 position-absolute top-0 start-0 overflow-x-hidden overflow-y-auto d-flex flex-column">
        <CascadingValue Value="ProcessorHub">
            <ProcessController />
            <div class="flex-grow-1 w-100 position-relative overflow-hidden">
                <div class="w-100 h-100 position-absolute top-0 start-0 overflow-hidden d-flex flex-row">
                    <RobotNet.WebApp.Scripts.Components.Dashboards.Variables />
                    <RobotNet.WebApp.Scripts.Components.Dashboards.Tasks />
                    <RobotNet.WebApp.Scripts.Components.Dashboards.Missions />
                </div>
            </div>
        </CascadingValue>
    </div>
</div>

@code {
    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        await ProcessorHub.StartAsync();
    }

    public async ValueTask DisposeAsync()
    {
        await ProcessorHub.StopAsync();
    }
}