🍕 Sync 2026-10-11 13:22:55

This commit is contained in:
github-actions[bot] committed 2026-10-11 13:22:55 +08:00
1 parent e6d1b4e2d7
commit fca7e71908
5 files changed
+39 -49

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-honk
PKG_VERSION:=1.1.4
PKG_RELEASE:=20
PKG_RELEASE:=21
LUCI_TITLE:=LuCI support for honk
LUCI_PKGARCH:=all
@@ -111,6 +111,32 @@ function updateStatus(data, targetEl) {
}
}
// Register a poll function operating on `el` and unregister it once `el` is gone.
// poll.add() runs the first tick synchronously when it starts the polling loop, which
// normally happens while the view is still being rendered, i.e. before `el` has been
// attached to the document. Tolerate that single early tick and only give up on the
// element once it is still missing on a later tick.
function addElementPoll(fn, el, interval, onDetach) {
var missing = 0;
var pollFn = function() {
if (document.body.contains(el)) {
missing = 0;
} else if (++missing > 1) {
poll.remove(pollFn);
if (typeof onDetach === 'function')
onDetach();
return Promise.resolve();
}
return fn();
};
poll.add(pollFn, interval);
return pollFn;
}
function waitForHonkState(wantRunning, attempts) {
attempts = attempts || 10;
@@ -125,7 +151,7 @@ function waitForHonkState(wantRunning, attempts) {
updateStatus(st);
if (poll && typeof(poll.start) === 'function')
poll.start();
resolve({ running: running, memory: st ? st.memory : null });
resolve({ running: running });
} else {
setTimeout(step, 1200);
}
@@ -162,25 +188,6 @@ 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;
@@ -800,16 +807,12 @@ function renderStatusHeader() {
});
var pollStatusFn = function() {
if (!document.body.contains(statusEl)) {
poll.remove(pollStatusFn);
return Promise.resolve();
}
return callHonkStatus().then(function(st) {
updateStatus(st, statusEl);
}).catch(function() { });
};
poll.add(pollStatusFn, 5);
addElementPoll(pollStatusFn, statusEl, 5);
applyTabVisibility();
@@ -844,5 +847,5 @@ return baseclass.extend({
isServiceEnabled: isServiceEnabled,
showNotification: showNotification,
updateStatus: updateStatus,
applyChangesAndWait: applyChangesAndWait
addElementPoll: addElementPoll
});
@@ -1,7 +1,6 @@
'use strict';
'require view';
'require ui';
'require poll';
'require uci';
'require honk.common as honk';
'require honk.dashprofiles as dash';
@@ -574,10 +573,6 @@ return view.extend({
loadInfo();
var dashStatusPollFn = function() {
if (!document.body.contains(iframe)) {
poll.remove(dashStatusPollFn);
return Promise.resolve();
}
if (document.hidden) {
return Promise.resolve();
}
@@ -590,7 +585,7 @@ return view.extend({
return Promise.resolve();
};
poll.add(dashStatusPollFn, 5);
honk.addElementPoll(dashStatusPollFn, iframe, 5);
return E('div', { 'class': 'dash-wrap' }, [
style,
@@ -62,7 +62,6 @@ return view.extend({
return this.handleSave(ev).then(function() {
var newDash = uci.get('honk', sid, 'dashboard') || 'none';
var enabled = honk.isServiceEnabled();
var pre = (newDash !== oldDash) ? honk.switchDashboardAndWait(newDash).then(function(res) {
if (res && res.pending)
@@ -71,13 +70,10 @@ return view.extend({
throw new Error(_('HONK did not come back up; check the logs'));
}) : Promise.resolve();
// LuCI reloads the page right after applying, and the status header then
// polls the real service state on its own (see honk.addElementPoll).
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'));
ui.changes.apply(mode == '0');
});
}).catch(function(err) {
honk.showNotification(null, E('p', _('Failed to apply configuration:') + ' ' + (err.message || err)), 'error');
@@ -2,7 +2,6 @@
'require view';
'require ui';
'require uci';
'require poll';
'require honk.common as honk';
return view.extend({
@@ -65,20 +64,17 @@ return view.extend({
var onVisibilityChange;
var logPollFn = function() {
if (!document.body.contains(logTextarea)) {
poll.remove(logPollFn);
if (onVisibilityChange) {
document.removeEventListener('visibilitychange', onVisibilityChange);
}
return Promise.resolve();
}
if (document.hidden) {
return Promise.resolve();
}
return updateLog().catch(function() { });
};
poll.add(logPollFn, 3);
honk.addElementPoll(logPollFn, logTextarea, 3, function() {
if (onVisibilityChange) {
document.removeEventListener('visibilitychange', onVisibilityChange);
}
});
onVisibilityChange = function() {
if (!document.body.contains(logTextarea)) {