@using System.Text.RegularExpressions @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 @inject HttpClient HttpClient @inject DialogService DialogService @inject AlertDialogService AlertDialogService
@if (StatusDto.IsEnabled) { if (StatusDto.IsReachable) {
Version
Version
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 async Task LoadAsync(LazyLoader _) { StatusDto = (await HttpClient.GetFromJsonAsync("api/admin/ch/status"))!; } private async Task ApplyAsync() { await DialogService.LaunchAsync( parameters => { parameters[nameof(UpdateInstanceModal.Version)] = SelectedVersion; }, onConfigure: model => { model.ShowCloseButton = false; model.ClassName = "sm:max-w-4xl!"; } ); } private async Task AskApplyAsync() { if(string.IsNullOrWhiteSpace(SelectedVersion)) return; 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 (!Regex.IsMatch(SelectedVersion, @"^v\d+(\.\d+)*b?$")) { 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 (SelectedVersion.EndsWith('b')) { 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; } }