@page "/admin/sys/diagnose"

@using Moonlight.Core.UI.Components.Navigations
@using MoonCoreUI.Services
@using Moonlight.Core.Services

@inject FileDownloadService DownloadService
@inject DiagnoseService DiagnoseService

@attribute [RequirePermission(9999)]

<AdminSysNavigation Index="4"/>

<div class="row g-5">
    <div class="col-md-6 col-12">
        <div class="card card-body p-5">
            <p class="fs-6">
                If you encounter a problem with moonlight, find a bug or need help with the configuration,
                you can use the diagnose report to let the moonlight developers know, what you have configured,
                what errors occured, what version of moonlight you are using and many more. These diagnose reports automatically censor
                sensitive data.
                <br/>
                <br/>
                <span class="text-danger fw-bold">
                    Note: Only share these reports with the moonlight developers.
                    Even though we do our best to censor sensitive data it may still contain information
                    you dont want a random person on the internet to know
                </span>
            </p>
        </div>
    </div>
    <div class="col-md-6 col-12">
        <div class="card card-body p-5">
            <WButton OnClick="DownloadReport" Text="Download diagnose report" CssClasses="btn btn-primary"/>
        </div>
    </div>
</div>

@code
{
    private async Task DownloadReport()
    {
        var diagnoseFileBytes = await DiagnoseService.GenerateReport();
        await DownloadService.DownloadBytes("diagnose.zip", diagnoseFileBytes);
    }
}