@using LucideBlazor @using Moonlight.Frontend.UI.Admin.Modals @using Moonlight.Shared.Http.Responses.Admin @using ShadcnBlazor.Cards @using ShadcnBlazor.Emptys @using ShadcnBlazor.Buttons @using ShadcnBlazor.Extras.AlertDialogs @using ShadcnBlazor.Extras.Common @using ShadcnBlazor.Extras.Dialogs @using ShadcnBlazor.Fields @using ShadcnBlazor.Selects @using ShadcnBlazor.Switches @inject HttpClient HttpClient @inject DialogService DialogService @inject AlertDialogService AlertDialogService
@if (StatusDto.IsEnabled) { if (StatusDto.IsReachable) {
Version
Version / Branch Bypass Build Cache
Plugins No Plugins found No plugins found in instance configuration
} else { Container Helper unreachable The container helper is unreachable. No management actions are available } } else { Container Helper is disabled The container helper is disabled on this instance. This might be due to running a multiple container moonlight setup }
@code { private ContainerHelperStatusDto StatusDto; private string SelectedVersion = "v2.1"; private bool NoBuildCache; private VersionDto[] Versions; private async Task LoadAsync(LazyLoader _) { StatusDto = (await HttpClient.GetFromJsonAsync("api/admin/ch/status"))!; var currentVersion = await HttpClient.GetFromJsonAsync("api/admin/versions/instance"); if (currentVersion != null) SelectedVersion = currentVersion.Identifier; Versions = (await HttpClient.GetFromJsonAsync("api/admin/versions"))!; } private async Task ApplyAsync() { await DialogService.LaunchAsync( parameters => { parameters[nameof(UpdateInstanceModal.Version)] = SelectedVersion; parameters[nameof(UpdateInstanceModal.NoBuildCache)] = NoBuildCache; }, onConfigure: model => { model.ShowCloseButton = false; model.ClassName = "sm:max-w-4xl!"; } ); } private async Task AskApplyAsync() { if (string.IsNullOrWhiteSpace(SelectedVersion)) return; var version = Versions.First(x => x.Identifier == SelectedVersion); var shouldContinue = await ConfirmRiskyVersionAsync( "Moonlight Rebuild", "If you continue the moonlight instance will become unavailable during the rebuild process. This will impact users on this instance" ); if (!shouldContinue) return; if (version.IsDevelopment) { shouldContinue = await ConfirmRiskyVersionAsync( "Development Version", "You are about to install development a version. This can break your instance. Continue at your own risk" ); } else { if (version.IsPreRelease) { shouldContinue = await ConfirmRiskyVersionAsync( "Beta / Pre-Release Version", "You are about to install a version marked as pre-release / beta. This can break your instance. Continue at your own risk" ); } else shouldContinue = true; } if (!shouldContinue) return; await ApplyAsync(); } private async Task ConfirmRiskyVersionAsync(string title, string message) { var tcs = new TaskCompletionSource(); var confirmed = false; await AlertDialogService.ConfirmDangerAsync( title, message, () => { confirmed = true; tcs.SetResult(); return Task.CompletedTask; } ); await tcs.Task; return confirmed; } }