🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

@@ -0,0 +1,184 @@
'use strict';
'require dom';
'require form';
'require fs';
'require ui';
'require uci';
'require view';
/*
Copyright 2022-2024 Rafał Wabik - IceG - From eko.one.pl forum
Licensed to the GNU General Public License v3.0.
*/
return view.extend({
handleCommand: function(exec, args) {
var buttons = document.querySelectorAll('.cbi-button');
for (var i = 0; i < buttons.length; i++)
buttons[i].setAttribute('disabled', 'true');
return fs.exec(exec, args).then(function(res) {
var out = document.querySelector('.atcommand-output');
out.style.display = '';
res.stdout = res.stdout?.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm, "") || '';
res.stderr = res.stderr?.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm, "") || '';
if (res.stdout === undefined || res.stderr === undefined || res.stderr.includes('undefined') || res.stdout.includes('undefined')) {
return;
}
else {
dom.content(out, [ res.stdout || '', res.stderr || '' ]);
}
}).catch(function(err) {
if (res.stdout === undefined || res.stderr === undefined || res.stderr.includes('undefined') || res.stdout.includes('undefined')) {
return;
}
else {
ui.addNotification(null, E('p', [ err ]));
}
}).finally(function() {
for (var i = 0; i < buttons.length; i++)
buttons[i].removeAttribute('disabled');
});
},
handleGo: function(ev) {
var port, atcmd = document.getElementById('cmdvalue').value;
var sections = uci.sections('atcommands');
var port = sections[0].set_port;
if ( atcmd.length < 2 )
{
ui.addNotification(null, E('p', _('Please specify the AT command to send')), 'info');
return false;
}
else {
if ( !port )
{
ui.addNotification(null, E('p', _('Please set the port for communication with the modem')), 'info');
return false;
}
else {
return this.handleCommand('sms_tool', [ '-d' , port , 'at' , atcmd ]);
}
}
if ( !port )
{
ui.addNotification(null, E('p', _('Please set the port for communication with the modem')), 'info');
return false;
}
},
handleClear: function(ev) {
var out = document.querySelector('.atcommand-output');
out.style.display = 'none';
var ov = document.getElementById('cmdvalue');
ov.value = '';
document.getElementById('cmdvalue').focus();
},
handleCopy: function(ev) {
var out = document.querySelector('.atcommand-output');
out.style.display = 'none';
var ov = document.getElementById('cmdvalue');
ov.value = '';
var x = document.getElementById('tk').value;
ov.value = x;
},
load: function() {
return Promise.all([
L.resolveDefault(fs.read_direct('/etc/modem/atcommands.user'), null),
uci.load('atcommands')
]);
},
render: function (loadResults) {
var info = _('User interface for handling AT commands using sms-tool. More information about the sms-tool on the %seko.one.pl forum%s.').format('<a href="https://eko.one.pl/?p=openwrt-sms_tool" target="_blank">', '</a>');
return E('div', { 'class': 'cbi-map', 'id': 'map' }, [
E('h2', {}, [ _('AT Commands') ]),
E('div', { 'class': 'cbi-map-descr'}, info),
E('hr'),
E('div', { 'class': 'cbi-section' }, [
E('div', { 'class': 'cbi-section-node' }, [
E('div', { 'class': 'cbi-value' }, [
E('label', { 'class': 'cbi-value-title' }, [ _('User AT commands') ]),
E('div', { 'class': 'cbi-value-field' }, [
E('select', { 'class': 'cbi-input-select', 'id': 'tk', 'style': 'margin:5px 0; width:100%;', 'mousedown': ui.createHandlerFn(this, 'handleCopy')},
(loadResults[0] || "").trim().split("\n").map(function(cmd) {
var fields = cmd.split(/;/);
var name = fields[0];
var code = fields[1];
return E('option', { 'value': code }, name ) })
)
])
]),
E('div', { 'class': 'cbi-value' }, [
E('label', { 'class': 'cbi-value-title' }, [ _('Command to send') ]),
E('div', { 'class': 'cbi-value-field' }, [
E('input', {
'style': 'margin:5px 0; width:100%;',
'type': 'text',
'id': 'cmdvalue',
'data-tooltip': _('Press [Enter] to send the command, press [Delete] to delete the command'),
'keydown': function(ev) {
if (ev.keyCode === 13)
{
var execBtn = document.getElementById('execute');
if (execBtn)
execBtn.click();
}
if (ev.keyCode === 46)
{
var del = document.getElementById('cmdvalue');
if (del)
var ov = document.getElementById('cmdvalue');
ov.value = '';
document.getElementById('cmdvalue').focus();
}
}
}),
])
]),
])
]),
E('hr'),
E('div', { 'class': 'right' }, [
E('button', {
'class': 'cbi-button cbi-button-remove',
'id': 'clr',
'click': ui.createHandlerFn(this, 'handleClear')
}, [ _('Clear form') ]),
'\xa0\xa0\xa0',
E('button', {
'class': 'cbi-button cbi-button-action important',
'id': 'execute',
'click': ui.createHandlerFn(this, 'handleGo')
}, [ _('Send command') ]),
]),
E('p', _('Reply')),
E('pre', { 'class': 'atcommand-output', 'id': 'preout', 'style': 'display:none; border: 1px solid var(--border-color-medium); border-radius: 5px; font-family: monospace' }),
]);
},
handleSaveApply: null,
handleSave: null,
handleReset: null
})
@@ -0,0 +1,52 @@
'use strict';
'require form';
'require fs';
'require view';
'require uci';
'require ui';
'require tools.widgets as widgets'
/*
Copyright 2022-2024 Rafał Wabik - IceG - From eko.one.pl forum
Licensed to the GNU General Public License v3.0.
*/
return view.extend({
load: function() {
return fs.list('/dev').then(function(devs) {
return devs.filter(function(dev) {
return dev.name.match(/^ttyUSB/) || dev.name.match(/^cdc-wdm/) || dev.name.match(/^ttyACM/) || dev.name.match(/^mhi_/) || dev.name.match(/^wwan/);
});
});
},
render: function(devs) {
var m, s, o;
m = new form.Map('atcommands', _('Configuration sms-tool'), _('Configuration panel for sms-tool and gui application.'));
s = m.section(form.TypedSection, 'atcommands', '', _(''));
s.anonymous = true;
o = s.option(form.Value, 'set_port', _('Port for communication with the modem'),
_("Select one of the available ttyUSBX ports."));
devs.sort((a, b) => a.name > b.name);
devs.forEach(dev => o.value('/dev/' + dev.name));
o.placeholder = _('Please select a port');
o.rmempty = false;
o = s.option(form.TextValue, '_tmpl', _('User AT commands'),
_("Each line must have the following format: 'At command description;AT command'. For user convenience, the file is saved to the location <code>/etc/modem/atcommands.user</code>."));
o.rows = 20;
o.cfgvalue = function(section_id) {
return fs.trimmed('/etc/modem/atcommands.user');
};
o.write = function(section_id, formvalue) {
return fs.write('/etc/modem/atcommands.user', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
};
return m.render();
}
});