mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 14:03:56 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
0d155c70be
commit
32600acc60
14258 files changed
+3954570
No files matched your search
@@ -0,0 +1,62 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
'require form';
|
||||
'require fs';
|
||||
'require ui';
|
||||
'require view';
|
||||
|
||||
return view.extend({
|
||||
render() {
|
||||
let m, s, o;
|
||||
|
||||
m = new form.Map('dae', _('Configuration'),
|
||||
_('Here you can edit dae configuration. It will be hot-reloaded automatically after apply.'));
|
||||
|
||||
s = m.section(form.TypedSection);
|
||||
s.anonymous = true;
|
||||
|
||||
s = m.section(form.NamedSection, 'config', 'dae');
|
||||
|
||||
o = s.option(form.TextValue, '_configuration');
|
||||
o.rows = 30;
|
||||
o.monospace = true;
|
||||
o.load = function(section_id) {
|
||||
return fs.read_direct('/etc/dae/config.dae', 'text')
|
||||
.then(function(content) {
|
||||
return content ?? '';
|
||||
}).catch(function(e) {
|
||||
if (e.toString().includes('NotFoundError'))
|
||||
return fs.read_direct('/etc/dae/example.dae', 'text')
|
||||
.then(function(content) {
|
||||
return content ?? '';
|
||||
}).catch(function(e) {
|
||||
return '';
|
||||
});
|
||||
|
||||
ui.addNotification(null, E('p', e.message));
|
||||
return '';
|
||||
});
|
||||
}
|
||||
o.write = function(section_id, value) {
|
||||
return fs.write('/etc/dae/config.dae', value, 384 /* 0600 */)
|
||||
.catch(function(e) {
|
||||
ui.addNotification(null, E('p', e.message));
|
||||
});
|
||||
}
|
||||
o.remove = function(section_id, value) {
|
||||
return fs.write('/etc/dae/config.dae', '')
|
||||
.catch(function(e) {
|
||||
ui.addNotification(null, E('p', e.message));
|
||||
});
|
||||
}
|
||||
|
||||
return m.render();
|
||||
},
|
||||
|
||||
handleSaveApply(ev, mode) {
|
||||
return this.handleSave(ev).then(function() {
|
||||
return L.resolveDefault(fs.exec_direct('/etc/init.d/dae', ['hot_reload']), null);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,94 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
'require dom';
|
||||
'require fs';
|
||||
'require poll';
|
||||
'require view';
|
||||
|
||||
return view.extend({
|
||||
render: function() {
|
||||
/* Thanks to luci-app-aria2 */
|
||||
let css = ' \
|
||||
#log_textarea { \
|
||||
text-align: left; \
|
||||
} \
|
||||
#log_textarea pre { \
|
||||
padding: .5rem; \
|
||||
word-break: break-all; \
|
||||
margin: 0; \
|
||||
} \
|
||||
.description { \
|
||||
background-color: #33ccff; \
|
||||
}';
|
||||
|
||||
let log_textarea = E('div', { 'id': 'log_textarea' },
|
||||
E('img', {
|
||||
'src': L.resource('icons/loading.svg'),
|
||||
'alt': _('Loading...'),
|
||||
'style': 'vertical-align:middle'
|
||||
}, _('Collecting data…'))
|
||||
);
|
||||
|
||||
poll.add(L.bind(function() {
|
||||
return fs.read_direct('/var/log/dae/dae.log', 'text')
|
||||
.then(function(content) {
|
||||
let log = E('pre', { 'wrap': 'pre' }, [
|
||||
content.trim() || _('Log is empty.')
|
||||
]);
|
||||
|
||||
dom.content(log_textarea, log);
|
||||
}).catch(function(e) {
|
||||
let log;
|
||||
|
||||
if (e.toString().includes('NotFoundError'))
|
||||
log = E('pre', { 'wrap': 'pre' }, [
|
||||
_('Log file does not exist.')
|
||||
]);
|
||||
else
|
||||
log = E('pre', { 'wrap': 'pre' }, [
|
||||
_('Unknown error: %s').format(e)
|
||||
]);
|
||||
|
||||
dom.content(log_textarea, log);
|
||||
});
|
||||
}));
|
||||
|
||||
const scrollDownButton = E('button', {
|
||||
'id': 'scrollDownButton',
|
||||
'class': 'cbi-button cbi-button-neutral',
|
||||
}, _('Scroll to tail', 'scroll to bottom (the tail) of the log file')
|
||||
);
|
||||
scrollDownButton.addEventListener('click', () => {
|
||||
scrollUpButton.focus();
|
||||
});
|
||||
|
||||
const scrollUpButton = E('button', {
|
||||
'id' : 'scrollUpButton',
|
||||
'class': 'cbi-button cbi-button-neutral',
|
||||
}, _('Scroll to head', 'scroll to top (the head) of the log file')
|
||||
);
|
||||
scrollUpButton.addEventListener('click', () => {
|
||||
scrollDownButton.focus();
|
||||
});
|
||||
|
||||
return E([
|
||||
E('style', [ css ]),
|
||||
E('h2', {}, [ _('Log') ]),
|
||||
E('div', {'class': 'cbi-map'}, [
|
||||
E('div', {'style': 'padding-bottom: 20px'}, [scrollDownButton]),
|
||||
E('div', {'class': 'cbi-section'}, [
|
||||
log_textarea,
|
||||
E('div', {'style': 'text-align:right'},
|
||||
E('small', {}, _('Refresh every %s seconds.').format(L.env.pollinterval))
|
||||
)
|
||||
]),
|
||||
E('div', {'style': 'padding-bottom: 20px'}, [scrollUpButton])
|
||||
])
|
||||
]);
|
||||
},
|
||||
|
||||
handleSaveApply: null,
|
||||
handleSave: null,
|
||||
handleReset: null
|
||||
});
|
||||
@@ -0,0 +1,81 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
'require form';
|
||||
'require poll';
|
||||
'require rpc';
|
||||
'require uci';
|
||||
'require view';
|
||||
|
||||
const callServiceList = rpc.declare({
|
||||
object: 'service',
|
||||
method: 'list',
|
||||
params: ['name'],
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
function getServiceStatus() {
|
||||
return L.resolveDefault(callServiceList('dae'), {}).then(function(res) {
|
||||
let isRunning = false;
|
||||
try {
|
||||
isRunning = res['dae']['instances']['dae']['running'];
|
||||
} catch (e) { }
|
||||
return isRunning;
|
||||
});
|
||||
}
|
||||
|
||||
function renderStatus(isRunning) {
|
||||
let spanTemp = '<span style="color:%s"><strong>%s %s</strong></span>';
|
||||
let renderHTML;
|
||||
if (isRunning)
|
||||
renderHTML = spanTemp.format('green', _('dae'), _('RUNNING'));
|
||||
else
|
||||
renderHTML = spanTemp.format('red', _('dae'), _('NOT RUNNING'));
|
||||
|
||||
return renderHTML;
|
||||
}
|
||||
|
||||
return view.extend({
|
||||
render() {
|
||||
let m, s, o;
|
||||
|
||||
m = new form.Map('dae', _('dae'),
|
||||
_('eBPF-based Linux high-performance transparent proxy solution.'));
|
||||
|
||||
s = m.section(form.TypedSection);
|
||||
s.anonymous = true;
|
||||
s.render = function() {
|
||||
poll.add(function() {
|
||||
return L.resolveDefault(getServiceStatus()).then(function(res) {
|
||||
let view = document.getElementById('service_status');
|
||||
view.innerHTML = renderStatus(res);
|
||||
});
|
||||
});
|
||||
|
||||
return E('div', { class: 'cbi-section', id: 'status_bar' }, [
|
||||
E('p', { id: 'service_status' }, _('Collecting data…'))
|
||||
]);
|
||||
}
|
||||
|
||||
s = m.section(form.NamedSection, 'config', 'dae');
|
||||
|
||||
o = s.option(form.Flag, 'enabled', _('Enable'));
|
||||
|
||||
o = s.option(form.Value, 'config_file', _('Configration file'));
|
||||
o.default = '/etc/dae/config.dae';
|
||||
o.rmempty = false;
|
||||
o.readonly = true;
|
||||
|
||||
o = s.option(form.Value, 'log_maxbackups', _('Max log backups'),
|
||||
_('The maximum number of old log files to retain.'));
|
||||
o.datatype = 'uinteger';
|
||||
o.placeholder = '1';
|
||||
|
||||
o = s.option(form.Value, 'log_maxsize', _('Max log size'),
|
||||
_('The maximum size in megabytes of the log file before it gets rotated.'));
|
||||
o.datatype = 'uinteger';
|
||||
o.placeholder = '1';
|
||||
|
||||
return m.render();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user