@inherits FnzComponentBase

@code {
    private FnzBootstrapModal SettingModal;
    private FnzBootstrapModal AdminModal;
    private string AdminPassword;

    [Parameter]
    public EventCallback ReloadData { get; set; } = EventCallback.Empty;
    public void Show() => SettingModal.Show();
}

<FnzBootstrapModal @ref="AdminModal" CssClass="modal-sm">
    <Title>Admin command</Title>
    <Body>
        Command sent.
    </Body>
</FnzBootstrapModal>

<FnzBootstrapModal @ref="SettingModal">
    <Title>Settings</Title>
    <Body>
        <div class="row">
            <div class="col-6">
                <label>Themes</label>
                <div>
                    <ThemeSelector CssClass="form-control"></ThemeSelector>
                </div>
            </div>
            <div class="col-6">
                <label>Data</label>
                <div>
                    <button class="form-control btn btn-danger" type="button" role="tab" @onclick="async ()=>{await ReloadData.InvokeAsync();}">
                        <i class="bi bi-recycle"></i> Reload
                    </button>
                </div>
                <small>Reload front end data</small>
            </div>
        </div>
        <div class="row mt-2">
            <div class="col-12">
                <label class="col-sm-2">Admin</label>
                <div class="row">
                    <div class="w-100">
                        <div class="form-floating">
                            <InputText class="form-control" type="password" @bind-Value="@AdminPassword" placeholder="Password"></InputText>
                            <label>Password</label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-12">
                <div class="w-100 btn-group mt-2">
                    <button class="btn btn-outline-primary" type="button" @onclick="async ()=>{ await ApiClient.ReloadBackEnd(AdminPassword,false); AdminModal.Show(); }">
                        <i class="bi bi-screwdriver"></i> Reload
                    </button>
                    <button class="btn btn-outline-secondary" type="button" @onclick="async ()=>{ await ApiClient.ReloadBackEnd(AdminPassword,null);AdminModal.Show(); }">
                        <i class="bi bi-wrench"></i> Reload Modules
                    </button>
                    <button class="btn btn-outline-danger" type="button" @onclick="async ()=>{ await ApiClient.ReloadBackEnd(AdminPassword,true);AdminModal.Show(); }">
                        <i class="bi bi-tools"></i> Reload Fully
                    </button>
                </div>
            </div>
            <small>Reload back end data</small>
        </div>
    </Body>
</FnzBootstrapModal>
