Add onboarding weather and template gradients
This commit is contained in:
@@ -77,6 +77,28 @@
|
||||
});
|
||||
}
|
||||
|
||||
function updateDataSourceToggle(form, response) {
|
||||
var toggleButton = document.querySelector('button[form="' + form.id + '"][data-async-data-source-toggle]');
|
||||
if (!toggleButton) {
|
||||
return;
|
||||
}
|
||||
|
||||
var willEnable = toggleButton.getAttribute('data-enabled') !== 'true';
|
||||
toggleButton.setAttribute('data-enabled', willEnable ? 'true' : 'false');
|
||||
toggleButton.className = toggleButton.className.replace(/btn-(danger|success)/g, willEnable ? 'btn-danger' : 'btn-success');
|
||||
toggleButton.innerHTML = '<i class="bi ' + (willEnable ? 'bi-pause-fill' : 'bi-play-fill') + ' me-1" aria-hidden="true"></i>' + (willEnable ? 'Disable' : 'Enable');
|
||||
|
||||
var message = '';
|
||||
try {
|
||||
message = new URL(response.url, window.location.href).searchParams.get('message') || '';
|
||||
} catch (_error) {
|
||||
message = '';
|
||||
}
|
||||
if (typeof showToast === 'function') {
|
||||
showToast(message || (willEnable ? 'Data source enabled.' : 'Data source disabled.'), 'success');
|
||||
}
|
||||
}
|
||||
|
||||
function initDeleteButtons() {
|
||||
document.addEventListener('click', function (event) {
|
||||
var deleteButton = event.target.closest('[data-delete-action-url]');
|
||||
@@ -610,7 +632,7 @@
|
||||
} catch (_error) {
|
||||
actionPath = String(form.action || '');
|
||||
}
|
||||
var shouldReloadAfterSuccess = /^\/announcements\/\d+\/(?:play|stop)$/.test(actionPath) || /^\/data-sources\/(?:api-sources|rss-feeds|weather)\/\d+$/.test(actionPath);
|
||||
var shouldReloadAfterSuccess = /^\/announcements\/\d+\/(?:play|stop)$/.test(actionPath);
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
@@ -641,6 +663,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (/^\/data-sources\/(?:api-sources|rss-feeds|weather)\/\d+$/.test(actionPath)) {
|
||||
updateDataSourceToggle(form, response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (shouldReloadAfterSuccess && response && response.ok) {
|
||||
window.location.reload();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user