⛅ Sync 2026-10-11 13:16:00

This commit is contained in:
github-actions[bot] committed 2026-10-11 13:16:00 +08:00
1 parent 705dadd362
commit e6d1b4e2d7
105 files changed
+26511 -50

No files matched your search

@@ -94,6 +94,23 @@ function isServiceEnabled() {
return ((sections[0] || {}).enabled === '1');
}
function updateStatus(data, targetEl) {
var el = targetEl || document.getElementById('honk_status');
if (!el) return;
if (data && data.running) {
var mem = data.memory ? ' (' + _('Memory Usage') + ': ' + data.memory + ')' : '';
dom.content(el, [
E('span', { 'style': 'color: var(--success, #22c55e); font-weight: bold;' }, _('HONK') + ' ' + _('RUNNING')),
' ',
E('span', { 'style': 'color: var(--text-muted, #888); font-size: 0.9em;' }, mem)
]);
} else {
dom.content(el, [
E('span', { 'style': 'color: var(--danger, #ef4444); font-weight: bold;' }, _('HONK') + ' ' + _('NOT RUNNING'))
]);
}
}
function waitForHonkState(wantRunning, attempts) {
attempts = attempts || 10;
@@ -104,15 +121,23 @@ function waitForHonkState(wantRunning, attempts) {
callHonkStatus().then(function(st) {
var running = !!(st && st.running);
if (running === wantRunning || ++tries >= attempts)
resolve({ running: running });
else
if (running === wantRunning || ++tries >= attempts) {
updateStatus(st);
if (poll && typeof(poll.start) === 'function')
poll.start();
resolve({ running: running, memory: st ? st.memory : null });
} else {
setTimeout(step, 1200);
}
}).catch(function() {
if (++tries >= attempts)
if (++tries >= attempts) {
updateStatus({ running: false });
if (poll && typeof(poll.start) === 'function')
poll.start();
resolve({ running: null });
else
} else {
setTimeout(step, 1200);
}
});
}
@@ -137,6 +162,25 @@ function switchDashboardAndWait(type) {
});
}
function applyChangesAndWait(mode) {
return new Promise(function(resolve) {
var timer = null;
var onApplied = function() {
if (timer) clearTimeout(timer);
document.removeEventListener('uci-applied', onApplied);
resolve();
};
var holdoff = (window.L && L.env && +L.env.apply_holdoff) || 4;
var timeout = (window.L && L.env && +L.env.apply_timeout) || 5;
timer = setTimeout(onApplied, (holdoff + timeout) * 1000);
document.addEventListener('uci-applied', onApplied);
ui.changes.apply(mode == '0');
});
}
var DOWNLOAD_MAX_TICKS = 900;
var DOWNLOAD_STALE_TICKS = 90;
var activeDownloadCancel = null;
@@ -621,6 +665,7 @@ function createConfigFileView(filePath, mapTitle, mapDesc, fieldTitle, successMs
return { skipped: true };
return needRestart ? waitForHonkState(true) : callHonkStatus().then(function(st) {
updateStatus(st);
return { running: !!(st && st.running) };
});
}).then(function(st) {
@@ -750,30 +795,18 @@ function renderStatusHeader() {
])
]);
function updateStatus(data) {
if (!statusEl) return;
if (data && data.running) {
var mem = data.memory ? ' (' + _('Memory Usage') + ': ' + data.memory + ')' : '';
dom.content(statusEl, [
E('span', { 'style': 'color: var(--success, #22c55e); font-weight: bold;' }, _('HONK') + ' ' + _('RUNNING')),
' ',
E('span', { 'style': 'color: var(--text-muted, #888); font-size: 0.9em;' }, mem)
]);
} else {
dom.content(statusEl, [
E('span', { 'style': 'color: var(--danger, #ef4444); font-weight: bold;' }, _('HONK') + ' ' + _('NOT RUNNING'))
]);
}
}
callHonkStatus().then(updateStatus);
callHonkStatus().then(function(st) {
updateStatus(st, statusEl);
});
var pollStatusFn = function() {
if (!document.body.contains(statusEl)) {
poll.remove(pollStatusFn);
return Promise.resolve();
}
return callHonkStatus().then(updateStatus).catch(function() { });
return callHonkStatus().then(function(st) {
updateStatus(st, statusEl);
}).catch(function() { });
};
poll.add(pollStatusFn, 5);
@@ -809,5 +842,7 @@ return baseclass.extend({
waitForHonkState: waitForHonkState,
switchDashboardAndWait: switchDashboardAndWait,
isServiceEnabled: isServiceEnabled,
showNotification: showNotification
showNotification: showNotification,
updateStatus: updateStatus,
applyChangesAndWait: applyChangesAndWait
});
@@ -62,30 +62,23 @@ return view.extend({
return this.handleSave(ev).then(function() {
var newDash = uci.get('honk', sid, 'dashboard') || 'none';
var enabled = honk.isServiceEnabled();
if (newDash !== oldDash) {
return honk.switchDashboardAndWait(newDash).then(function(res) {
if (res && res.pending)
honk.showNotification(null, E('p', _('Saved, but the panel files are not installed yet — download the panel first.')), 'warning');
else if (res.running === false)
throw new Error(_('HONK did not come back up; check the logs'));
});
}
var pre = (newDash !== oldDash) ? honk.switchDashboardAndWait(newDash).then(function(res) {
if (res && res.pending)
honk.showNotification(null, E('p', _('Saved, but the panel files are not installed yet — download the panel first.')), 'warning');
else if (res.running === false)
throw new Error(_('HONK did not come back up; check the logs'));
}) : Promise.resolve();
return honk.callHonkReload().then(function(resp) {
if (!resp || resp.success === false)
throw new Error((resp && resp.message) || _('Service did not accept the request'));
if (!honk.isServiceEnabled())
return;
return honk.waitForHonkState(true).then(function(st) {
if (st.running === false)
throw new Error(_('HONK did not come back up; check the logs'));
});
return pre.then(function() {
return honk.applyChangesAndWait(mode);
}).then(function() {
return honk.waitForHonkState(enabled);
}).then(function(st) {
if (enabled && st && st.running === false)
throw new Error(_('HONK did not come back up; check the logs'));
});
}).then(function() {
return ui.changes.apply(mode == '0');
}).catch(function(err) {
honk.showNotification(null, E('p', _('Failed to apply configuration:') + ' ' + (err.message || err)), 'error');
});