Fix buttons all showing Running state when only one action is triggered
This commit is contained in:
@@ -348,14 +348,14 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '';
|
var csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '';
|
||||||
|
|
||||||
function setLoading(btnId, loading) {
|
function setLoading(btnId, loading, spinnerOnly) {
|
||||||
var btn = document.getElementById(btnId);
|
var btn = document.getElementById(btnId);
|
||||||
if (!btn) return;
|
if (!btn) return;
|
||||||
btn.disabled = loading;
|
btn.disabled = loading;
|
||||||
if (loading) {
|
if (loading && !spinnerOnly) {
|
||||||
btn.dataset.originalHtml = btn.innerHTML;
|
btn.dataset.originalHtml = btn.innerHTML;
|
||||||
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-1" role="status"></span>Running...';
|
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-1" role="status"></span>Running...';
|
||||||
} else if (btn.dataset.originalHtml) {
|
} else if (!loading && btn.dataset.originalHtml) {
|
||||||
btn.innerHTML = btn.dataset.originalHtml;
|
btn.innerHTML = btn.dataset.originalHtml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -370,8 +370,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.runGC = function (dryRun) {
|
window.runGC = function (dryRun) {
|
||||||
setLoading('gcRunBtn', true);
|
setLoading(dryRun ? 'gcDryRunBtn' : 'gcRunBtn', true);
|
||||||
setLoading('gcDryRunBtn', true);
|
setLoading(dryRun ? 'gcRunBtn' : 'gcDryRunBtn', true, true);
|
||||||
|
|
||||||
fetch('{{ url_for("ui.system_gc_run") }}', {
|
fetch('{{ url_for("ui.system_gc_run") }}', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -432,9 +432,10 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.runIntegrity = function (dryRun, autoHeal) {
|
window.runIntegrity = function (dryRun, autoHeal) {
|
||||||
setLoading('integrityRunBtn', true);
|
var activeBtn = dryRun ? 'integrityDryRunBtn' : (autoHeal ? 'integrityHealBtn' : 'integrityRunBtn');
|
||||||
setLoading('integrityHealBtn', true);
|
['integrityRunBtn', 'integrityHealBtn', 'integrityDryRunBtn'].forEach(function (id) {
|
||||||
setLoading('integrityDryRunBtn', true);
|
setLoading(id, true, id !== activeBtn);
|
||||||
|
});
|
||||||
|
|
||||||
fetch('{{ url_for("ui.system_integrity_run") }}', {
|
fetch('{{ url_for("ui.system_integrity_run") }}', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
Reference in New Issue
Block a user