update 2026-09-26 11:07:27

This commit is contained in:
action committed 2026-09-26 11:07:27 +08:00
1 parent 7b88b273d0
commit 97ae9f68da
4898 files changed
-1712274

No files matched your search

@@ -1,120 +0,0 @@
'use strict';
'require view';
'require ui';
'require poll';
'require fs';
return view.extend({
load: function() {
return fs.read('/etc/taskplan/taskplan.log').catch(function(err) {
console.error('Failed to read log file:', err);
return '';
});
},
handleClearLog: function() {
var self = this;
return fs.write('/etc/taskplan/taskplan.log', '').then(function() {
ui.addNotification(null, E('p', {}, _('Log cleared')));
self.updateLogDisplay();
}).catch(function(err) {
ui.addNotification(null, E('p', { 'class': 'alert-message' }, _('Failed to clear log: ') + err.message));
});
},
handleReverseLog: function() {
this.reverse = !this.reverse;
this.updateLogDisplay();
},
handleDownloadLog: function() {
var self = this;
fs.read('/etc/taskplan/taskplan.log').then(function(content) {
if (content) {
var blob = new Blob([content], { type: 'text/plain' });
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = 'taskplan.log';
a.click();
URL.revokeObjectURL(url);
} else {
ui.addNotification(null, E('p', {}, _('Log is empty')));
}
});
},
updateLogDisplay: function() {
var self = this;
fs.read('/etc/taskplan/taskplan.log').then(function(content) {
var logArea = document.getElementById('log_content');
if (logArea) {
if (self.reverse) {
logArea.value = content.split('\n').reverse().join('\n');
} else {
logArea.value = content;
}
// 如果不是反向模式,自动滚动到底部
if (!self.reverse) {
logArea.scrollTop = logArea.scrollHeight;
}
}
});
},
render: function(logContent) {
this.reverse = false;
return E('div', { 'class': 'view' }, [
E('div', { 'class': 'cbi-map' }, [
// 标题
E('h2', {}, _('Task Plan Log Viewer')),
E('div', { 'class': 'cbi-section', 'style': 'margin-bottom:10px;' }, [
E('div', { 'class': 'cbi-section-actions' }, [
E('button', {
'class': 'btn cbi-button cbi-button-apply',
'click': ui.createHandlerFn(this, 'handleClearLog')
}, [ _('Clear Log') ]),
' ',
E('button', {
'class': 'btn cbi-button cbi-button-edit',
'click': ui.createHandlerFn(this, 'handleReverseLog')
}, [ _('Reverse Order') ])
])
]),
// 日志显示区域
E('div', { 'class': 'cbi-section' }, [
E('textarea', {
'id': 'log_content',
'class': 'cbi-input-textarea',
'style': 'width:100%; height:500px; font-family:monospace; font-size:12px; padding:10px; border-radius:4px;',
'readonly': 'readonly',
'wrap': 'off'
}, logContent || '')
])
])
]);
},
handle: function(ev) {
var self = this;
poll.add(function() {
return fs.read('/etc/taskplan/taskplan.log').then(function(content) {
var logArea = document.getElementById('log_content');
if (logArea) {
if (self.reverse) {
logArea.value = content.split('\n').reverse().join('\n');
} else {
logArea.value = content;
logArea.scrollTop = logArea.scrollHeight;
}
}
});
}, 5);
return this.render.apply(this, arguments);
}
});
@@ -1,110 +0,0 @@
'use strict';
'require view';
'require form';
'require ui';
'require uci';
'require rpc';
var callExec = rpc.declare({
object: 'luci',
method: 'exec',
params: ['command'],
expect: { result: 0 }
});
return view.extend({
load: function() {
return uci.load('taskplan');
},
render: function(data) {
var m = new form.Map('taskplan', _('Scheduled Tasks'),
_('<b>The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts</b></br>') +
_('N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours.'));
var s = m.section(form.TypedSection, 'global');
s.anonymous = true;
var e = s.option(form.TextValue, 'customscript', _('Edit Custom Script'));
e.description = _('Shell commands for [Customscript] task type');
e.rows = 5;
e.default = '#!/bin/bash\n# Add your commands here';
e.optional = false;
e = s.option(form.TextValue, 'customscript2', _('Edit Custom Script2'));
e.description = _('Shell commands for [Customscript2] task type');
e.rows = 5;
e.default = '#!/bin/bash\n# Add your commands here';
e.optional = false;
var ss = m.section(form.TypedSection, 'stime', '');
ss.addremove = true;
ss.anonymous = true;
ss.sortable = true;
ss.template = 'cbi/tblsection';
var remarks = ss.option(form.Value, 'remarks', _('Remarks'));
remarks.optional = false;
var enable = ss.option(form.Flag, 'enable', _('Enable'));
enable.rmempty = false;
enable.default = 1;
var stype = ss.option(form.ListValue, 'stype', _('Scheduled Type'));
stype.value(1, _('Scheduled Reboot'));
stype.value(2, _('Scheduled Poweroff'));
stype.value(3, _('Scheduled ReNetwork'));
stype.value(4, _('Scheduled RestartSamba'));
stype.value(5, _('Scheduled Restartwan'));
stype.value(6, _('Scheduled Closewan'));
stype.value(7, _('Scheduled Clearmem'));
stype.value(8, _('Scheduled Sysfree'));
stype.value(9, _('Scheduled DisReconn'));
stype.value(10, _('Scheduled DisRereboot'));
stype.value(11, _('Scheduled Restartmwan3'));
stype.value(13, _('Scheduled Wifiup'));
stype.value(14, _('Scheduled Wifidown'));
stype.value(12, _('Scheduled Customscript'));
stype.value(15, _('Scheduled Customscript2'));
stype.default = 1;
var month = ss.option(form.Value, 'month', _('Month(0~11)'));
month.rmempty = false;
month.default = '*';
month.datatype = 'string';
var week = ss.option(form.Value, 'week', _('Week Day(0~6)'));
week.rmempty = true;
week.value('*', _('Everyday'));
week.value('0', _('Sunday'));
week.value('1', _('Monday'));
week.value('2', _('Tuesday'));
week.value('3', _('Wednesday'));
week.value('4', _('Thursday'));
week.value('5', _('Friday'));
week.value('6', _('Saturday'));
week.default = '*';
week.datatype = 'string';
var hour = ss.option(form.Value, 'hour', _('Hour(0~23)'));
hour.description = _('1-8 is the continuous time from 1-8 clock; 11,12,16 clock are discontinuous; */3 represents every 3 hours; * every hour.');
hour.rmempty = false;
hour.default = 0;
hour.datatype = 'string';
var minute = ss.option(form.Value, 'minute', _('Minute(0~59)'));
minute.description = _('1-30 is continuous 1-30 minutes; 7,8,9 minutes discontinuous ; */5 means every 5 minutes ; * every minutes.');
minute.rmempty = false;
minute.default = 0;
minute.datatype = 'string';
m.apply_on_parse = true;
m.on_after_apply = function() {
return callExec('/etc/init.d/taskplan start').then(function() {
ui.addNotification(null, E('p', {}, _('Tasks updated')));
});
};
return m.render();
}
});
@@ -1,87 +0,0 @@
'use strict';
'require view';
'require form';
'require ui';
'require uci';
'require rpc';
var callExec = rpc.declare({
object: 'luci',
method: 'exec',
params: ['command'],
expect: { result: 0 }
});
return view.extend({
load: function() {
return uci.load('taskplan');
},
render: function(data) {
var m = new form.Map('taskplan', _('Startup Tasks'),
_('<b>The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts</b></br>') +
_('The task to be executed upon startup, with a startup delay time unit of seconds.'));
var s = m.section(form.TypedSection, 'global');
s.anonymous = true;
var e = s.option(form.TextValue, 'customscript', _('Edit Custom Script'));
e.description = _('Shell commands for Customscript task type');
e.rows = 5;
e.default = '#!/bin/sh\n# Add your commands here';
e.optional = false;
e = s.option(form.TextValue, 'customscript2', _('Edit Custom Script2'));
e.description = _('Shell commands for Customscript2 task type');
e.rows = 5;
e.default = '#!/bin/sh\n# Add your commands here';
e.optional = false;
var ls = m.section(form.TypedSection, 'ltime', '');
ls.addremove = true;
ls.anonymous = true;
ls.sortable = true;
ls.template = 'cbi/tblsection';
var remarks = ls.option(form.Value, 'remarks', _('Remarks'));
remarks.optional = false;
var enable = ls.option(form.Flag, 'enable', _('Enable'));
enable.rmempty = false;
enable.default = 1;
var stype = ls.option(form.ListValue, 'stype', _('Startup Type'));
stype.description = _('Action to perform at system startup');
stype.value(1, _('Scheduled Reboot'));
stype.value(2, _('Scheduled Poweroff'));
stype.value(3, _('Scheduled ReNetwork'));
stype.value(4, _('Scheduled RestartSamba'));
stype.value(5, _('Scheduled Restartwan'));
stype.value(6, _('Scheduled Closewan'));
stype.value(7, _('Scheduled Clearmem'));
stype.value(8, _('Scheduled Sysfree'));
stype.value(9, _('Scheduled DisReconn'));
stype.value(10, _('Scheduled DisRereboot'));
stype.value(11, _('Scheduled Restartmwan3'));
stype.value(13, _('Scheduled Wifiup'));
stype.value(14, _('Scheduled Wifidown'));
stype.value(12, _('Scheduled Customscript'));
stype.value(15, _('Scheduled Customscript2'));
stype.default = 12;
var delay = ls.option(form.Value, 'delay', _('Delayed Start(seconds)'));
delay.description = _('Seconds to wait after boot before execution');
delay.datatype = 'uinteger';
delay.default = 10;
delay.optional = false;
m.apply_on_parse = true;
m.on_after_apply = function() {
return callExec('/etc/init.d/taskplan start').then(function() {
ui.addNotification(null, E('p', {}, _('Tasks updated')));
});
};
return m.render();
}
});