From 20daaa780f1d86214484ef4a5fa0e274426f1af1 Mon Sep 17 00:00:00 2001 From: Speng Reb Date: Tue, 2 Jun 2026 00:05:06 +0200 Subject: [PATCH] Remove list of shows in shows tab - we can use the calendar from now on --- templates/channeloptions.pug | 20 +++---- www/js/ui.js | 110 +++++++++-------------------------- 2 files changed, 36 insertions(+), 94 deletions(-) diff --git a/templates/channeloptions.pug b/templates/channeloptions.pug index 2f63f23b..e4bd5236 100644 --- a/templates/channeloptions.pug +++ b/templates/channeloptions.pug @@ -330,18 +330,14 @@ mixin shows button#cs-shows-create.btn.btn-primary Create Show button#cs-shows-update.btn.btn-default(type="button") Update Selected button#cs-shows-clear.btn.btn-default(type="button") Clear Form - table.table.table-striped.table-condensed(style="margin-top:12px") - thead - tr - th Name - th Status - th Next Run - th Est. End - th Timezone - th Recurrence - th Calendar - th Actions - tbody#cs-shows-list + .form-group + .col-sm-9.col-sm-offset-3 + .btn-group(role="group") + button#cs-shows-run.btn.btn-primary(type="button", disabled) Run + button#cs-shows-pause.btn.btn-default(type="button", disabled) Pause + button#cs-shows-resume.btn.btn-success(type="button", disabled) Resume + button#cs-shows-cancel.btn.btn-warning(type="button", disabled) Cancel + button#cs-shows-delete.btn.btn-danger(type="button", disabled) Delete mixin integrations #cs-integrations.tab-pane diff --git a/www/js/ui.js b/www/js/ui.js index 5d9bb9f3..35b2d7de 100644 --- a/www/js/ui.js +++ b/www/js/ui.js @@ -1817,6 +1817,7 @@ var CSTShows = (function () { renderDraftPlaylist(); updateNotesPreview(); setNotesEditorMode('edit'); + updateSelectedShowActions(); } function selectShow(show) { @@ -1849,6 +1850,7 @@ var CSTShows = (function () { updateNotesPreview(); setNotesEditorMode('edit'); resolveDraftTitles(); + updateSelectedShowActions(); } function openShowsEditor() { @@ -2104,96 +2106,21 @@ var CSTShows = (function () { }); } - function render(shows) { - var tbody = $('#cs-shows-list').empty(); - if (!shows.length) { - tbody.append('No shows configured'); - return; - } - - shows.forEach(function (show) { - var row = $(''); - row.append($('').append( - $('').text(show.name).on('click', function () { selectShow(show); }) - )); - row.append($('').text(show.status)); - row.append($('').text(show.next_run_at ? new Date(show.next_run_at).toLocaleString(undefined, { timeZone: show.timezone || 'UTC' }) : 'N/A')); - row.append($('').text(show.estimated_end_at ? new Date(show.estimated_end_at).toLocaleString(undefined, { timeZone: show.timezone || 'UTC' }) : 'N/A')); - row.append($('').text(show.timezone || 'UTC')); - row.append($('').text(show.recurrence || 'none')); - var calendarTd = $(''); - var googleLinks = show && show.calendar_links && show.calendar_links.google - ? show.calendar_links.google - : null; - if (googleLinks && (googleLinks.event_url || googleLinks.calendar_url)) { - if (googleLinks.event_url) { - $('') - .attr('href', googleLinks.event_url) - .attr('target', '_blank') - .attr('rel', 'noopener noreferrer') - .text('Event') - .appendTo(calendarTd); - } - if (googleLinks.calendar_url) { - if (googleLinks.event_url) { - calendarTd.append(' | '); - } - $('') - .attr('href', googleLinks.calendar_url) - .attr('target', '_blank') - .attr('rel', 'noopener noreferrer') - .text('Calendar') - .appendTo(calendarTd); - } - } else { - calendarTd.append($('').text('Not synced')); - } - row.append(calendarTd); - - var actions = $(''); - $('') - .on('click', function () { action(show.id, 'run'); }) - .appendTo(actions); - $('') - .on('click', function () { action(show.id, 'pause'); }) - .appendTo(actions); - $('') - .on('click', function () { action(show.id, 'resume'); }) - .appendTo(actions); - $('') - .on('click', function () { action(show.id, 'cancel'); }) - .appendTo(actions); - $('') - .on('click', function () { - if (!confirm('Delete this show?')) return; - $.ajax({ - url: apiBase() + '/' + show.id, - method: 'DELETE', - data: { _csrf: csrfField() } - }) - .done(load) - .fail(function (xhr) { - alert('Delete failed: ' + ((xhr.responseJSON && xhr.responseJSON.error) || xhr.statusText)); - }); - }) - .appendTo(actions); - row.append(actions); - tbody.append(row); - }); + function updateSelectedShowActions() { + var visible = !!selectedId; + $('#cs-shows-run').toggle(visible).prop('disabled', !visible); + $('#cs-shows-pause').toggle(visible).prop('disabled', !visible); + $('#cs-shows-resume').toggle(visible).prop('disabled', !visible); + $('#cs-shows-cancel').toggle(visible).prop('disabled', !visible); + $('#cs-shows-delete').toggle(visible).prop('disabled', !visible); } function load() { var endpoint = CLIENT.rank >= 2 ? apiBase() : publicApiBase(); $.getJSON(endpoint, function (shows) { cachedShows = Array.isArray(shows) ? shows : []; - if (CLIENT.rank >= 2) { - render(cachedShows); - } renderScheduleCalendar(cachedShows); }).fail(function () { - if (CLIENT.rank >= 2) { - $('#cs-shows-list').html('Failed to load shows'); - } $('#showschedule-grid').html('
Failed to load schedule
'); }); } @@ -2267,6 +2194,24 @@ var CSTShows = (function () { } }); $('#cs-shows-clear').on('click', clearForm); + $('#cs-shows-run').on('click', function () { if (selectedId) action(selectedId, 'run'); }); + $('#cs-shows-pause').on('click', function () { if (selectedId) action(selectedId, 'pause'); }); + $('#cs-shows-resume').on('click', function () { if (selectedId) action(selectedId, 'resume'); }); + $('#cs-shows-cancel').on('click', function () { if (selectedId) action(selectedId, 'cancel'); }); + $('#cs-shows-delete').on('click', function () { + if (!selectedId) return; + if (!confirm('Delete this show?')) return; + $.ajax({ + url: apiBase() + '/' + selectedId, + method: 'DELETE', + data: { _csrf: csrfField() } + }).done(function () { + clearForm(); + load(); + }).fail(function (xhr) { + alert('Delete failed: ' + ((xhr.responseJSON && xhr.responseJSON.error) || xhr.statusText)); + }); + }); $('#cs-shows-color').on('change', function () { $('#cs-shows-color-hex').val(($(this).val() || '').toUpperCase()); }); @@ -2310,6 +2255,7 @@ var CSTShows = (function () { renderDraftPlaylist(); clearForm(); setNotesEditorMode('edit'); + updateSelectedShowActions(); setupScheduleAutoRefresh(); load();