From ac361b3165ac1c4e1110caff3ad306476092bde9 Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Sun, 9 Nov 2025 10:17:24 -0600 Subject: [PATCH] add troubleshoot button to classic schedules (#2615) * add troubleshoot button to classic schedules * move troubleshoot button --- CHANGELOG.md | 2 + ErsatzTV/Pages/ScheduleItemsEditor.razor | 1 - ErsatzTV/Pages/Schedules.razor | 19 ++++++- ErsatzTV/Shared/ScheduleItemsDialog.razor | 66 +++++++++++++++++++++++ 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 ErsatzTV/Shared/ScheduleItemsDialog.razor diff --git a/CHANGELOG.md b/CHANGELOG.md index afe5d7722..11201cad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - There are two requirements for AviSynth Scripts to work: - FFmpeg needs to be compiled with AviSynth support (not currently available in Docker) - AviSynth itself needs to be installed +- Add `Troubleshoot` button to classic schedule list + - This generates JSON representing the entire schedule which can be shared when requested for troubleshooting ### Fixed - Fix HLS Direct playback with Jellyfin 10.11 diff --git a/ErsatzTV/Pages/ScheduleItemsEditor.razor b/ErsatzTV/Pages/ScheduleItemsEditor.razor index 1b21f096e..7e05c74d6 100644 --- a/ErsatzTV/Pages/ScheduleItemsEditor.razor +++ b/ErsatzTV/Pages/ScheduleItemsEditor.razor @@ -1134,5 +1134,4 @@ } private string SelectedRowClassFunc(ProgramScheduleItemEditViewModel element, int rowNumber) => _selectedItem != null && _selectedItem == element ? "selected" : string.Empty; - } diff --git a/ErsatzTV/Pages/Schedules.razor b/ErsatzTV/Pages/Schedules.razor index a189b1f27..bbb5668e6 100644 --- a/ErsatzTV/Pages/Schedules.razor +++ b/ErsatzTV/Pages/Schedules.razor @@ -27,7 +27,7 @@ - + @@ -58,6 +58,11 @@ OnClick="@(_ => CopySchedule(context))"> + + + + @@ -213,5 +218,17 @@ _table.ReloadServerData(); } + private async Task Troubleshoot(ProgramScheduleViewModel schedule) + { + Option> maybeResults = await Mediator.Send(new GetProgramScheduleItems(schedule.Id), _cts.Token); + foreach (IEnumerable results in maybeResults) + { + var parameters = new DialogParameters { { "Schedule", schedule }, { "Items", results } }; + var options = new DialogOptions { CloseButton = true, CloseOnEscapeKey = true, MaxWidth = MaxWidth.Medium, FullWidth = true }; + IDialogReference dialog = await Dialog.ShowAsync(schedule.Name, parameters, options); + DialogResult _ = await dialog.Result; + } + } + private string SelectedRowClassFunc(ProgramScheduleViewModel element, int rowNumber) => _selectedSchedule != null && _selectedSchedule == element ? "selected" : string.Empty; } diff --git a/ErsatzTV/Shared/ScheduleItemsDialog.razor b/ErsatzTV/Shared/ScheduleItemsDialog.razor new file mode 100644 index 000000000..e897a400a --- /dev/null +++ b/ErsatzTV/Shared/ScheduleItemsDialog.razor @@ -0,0 +1,66 @@ +@using System.Text.Json +@using System.Text.Json.Serialization +@using ErsatzTV.Application.ProgramSchedules +@inject IJSRuntime JsRuntime + +
+ + +
+
+                    @_info
+                
+
+
+ + + Copy + + Close + +
+
+ +@code { + + [CascadingParameter] + IMudDialogInstance MudDialog { get; set; } + + [Parameter] + public ProgramScheduleViewModel Schedule { get; set; } + + [Parameter] + public IEnumerable Items { get; set; } + + private string _info; + private ElementReference _infoView; + + protected override Task OnParametersSetAsync() + { + try + { + _info = JsonSerializer.Serialize( + new + { + Schedule, + Items + }, + new JsonSerializerOptions + { + Converters = { new JsonStringEnumConverter() }, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + WriteIndented = true + }); + } + catch (Exception ex) + { + _info = ex.ToString(); + } + + return Task.CompletedTask; + } + + private async Task CopyToClipboard(ElementReference view) => await JsRuntime.InvokeVoidAsync("clipboardCopy.copyText", view); + + private void Close() => MudDialog.Close(DialogResult.Ok(true)); +}