mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-05 18:44:06 +08:00
update 2026-10-11 18:30:33
This commit is contained in:
1 parent
93f2a53ca4
commit
8ccdf8f9f7
156 files changed
+40396
-114
No files matched your search
@@ -10,6 +10,14 @@ if [ "$dash" = "none" ]; then
|
||||
: > /etc/honk/config.d/api.dae
|
||||
fi
|
||||
|
||||
# Drop options of the auto-subscribe feature removed from this package
|
||||
uci -q show honk 2>/dev/null | sed -n 's/^\(.*\)\.subscribe_[a-z_]*=.*$/\1/p' | sort -u | while read -r s; do
|
||||
for opt in subscribe_auto_update subscribe_update_week_time subscribe_update_day_time; do
|
||||
uci -q delete "$s.$opt"
|
||||
done
|
||||
uci -q commit honk
|
||||
done
|
||||
|
||||
# Migrate legacy /etc/honk/dashboard directory
|
||||
if [ -d /etc/honk/dashboard ] && [ ! -d /etc/honk/doona ]; then
|
||||
mv /etc/honk/dashboard /etc/honk/doona
|
||||
|
||||
@@ -94,6 +94,49 @@ 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'))
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
@@ -104,15 +147,23 @@ function waitForHonkState(wantRunning, attempts) {
|
||||
callHonkStatus().then(function(st) {
|
||||
var running = !!(st && st.running);
|
||||
|
||||
if (running === wantRunning || ++tries >= attempts)
|
||||
if (running === wantRunning || ++tries >= attempts) {
|
||||
updateStatus(st);
|
||||
if (poll && typeof(poll.start) === 'function')
|
||||
poll.start();
|
||||
resolve({ running: running });
|
||||
else
|
||||
} 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -621,6 +672,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,33 +802,17 @@ 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);
|
||||
addElementPoll(pollStatusFn, statusEl, 5);
|
||||
|
||||
applyTabVisibility();
|
||||
|
||||
@@ -809,5 +845,7 @@ return baseclass.extend({
|
||||
waitForHonkState: waitForHonkState,
|
||||
switchDashboardAndWait: switchDashboardAndWait,
|
||||
isServiceEnabled: isServiceEnabled,
|
||||
showNotification: showNotification
|
||||
showNotification: showNotification,
|
||||
updateStatus: updateStatus,
|
||||
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,
|
||||
|
||||
@@ -63,29 +63,18 @@ return view.extend({
|
||||
return this.handleSave(ev).then(function() {
|
||||
var newDash = uci.get('honk', sid, 'dashboard') || 'none';
|
||||
|
||||
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'));
|
||||
});
|
||||
// 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() {
|
||||
ui.changes.apply(mode == '0');
|
||||
});
|
||||
}).then(function() {
|
||||
return 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)) {
|
||||
|
||||
Reference in new issue
Block a user