@page "/admin/system/resources"

@using Moonlight.Shared.Components.FileManagerPartials
@using Moonlight.App.Helpers.Files
@using Moonlight.Shared.Components.Navigations
@using Moonlight.App.Helpers
@using Moonlight.App.Services
@using Moonlight.App.Services.Interop

@inject SmartTranslateService SmartTranslateService
@inject ConfigService ConfigService
@inject AlertService AlertService

<OnlyAdmin>
    <AdminSystemNavigation Index="5"/>

    <div class="card card-body mb-6">
        <div class="text-end">
            <WButton CssClasses="btn btn-primary"
                     Text="@(SmartTranslateService.Translate("Reload config"))"
                     WorkingText="@(SmartTranslateService.Translate("Reloading"))"
                     OnClick="ReloadConfig">
            </WButton>
        </div>
    </div>

    <div class="card card-body">
        <FileManager Access="@(new HostFileAccess(PathBuilder.Dir("storage")))">
        </FileManager>
    </div>
</OnlyAdmin>

@code 
{
    private async Task ReloadConfig()
    {
        ConfigService.Reload();

        await AlertService.Success(SmartTranslateService.Translate("Successfully reloaded configuration"));
    }
}