mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-02 20:33:56 +08:00
136 lines
3.9 KiB
JavaScript
136 lines
3.9 KiB
JavaScript
'use strict';
|
|
'require baseclass';
|
|
'require rpc';
|
|
'require uci';
|
|
|
|
var callGetUnixtime = rpc.declare({
|
|
object: 'luci',
|
|
method: 'getUnixtime',
|
|
expect: { result: 0 }
|
|
});
|
|
|
|
var callLuciVersion = rpc.declare({
|
|
object: 'luci',
|
|
method: 'getVersion'
|
|
});
|
|
|
|
var callSystemBoard = rpc.declare({
|
|
object: 'system',
|
|
method: 'board'
|
|
});
|
|
|
|
var callSystemInfo = rpc.declare({
|
|
object: 'system',
|
|
method: 'info'
|
|
});
|
|
|
|
var callCPUBench = rpc.declare({
|
|
object: 'luci',
|
|
method: 'getCPUBench'
|
|
});
|
|
|
|
var callCPUInfo = rpc.declare({
|
|
object: 'luci',
|
|
method: 'getCPUInfo'
|
|
});
|
|
|
|
var callCPUUsage = rpc.declare({
|
|
object: 'luci',
|
|
method: 'getTempInfo'
|
|
});
|
|
|
|
return baseclass.extend({
|
|
title: _('System'),
|
|
disableCache: true,
|
|
|
|
load: function() {
|
|
return Promise.all([
|
|
L.resolveDefault(callSystemBoard(), {}),
|
|
L.resolveDefault(callSystemInfo(), {}),
|
|
L.resolveDefault(callCPUBench(), {}),
|
|
L.resolveDefault(callCPUInfo(), {}),
|
|
L.resolveDefault(callCPUUsage(), {}),
|
|
L.resolveDefault(callLuciVersion(), { revision: _('unknown version'), branch: 'LuCI' }),
|
|
L.resolveDefault(callGetUnixtime(), 0),
|
|
uci.load('system')
|
|
]);
|
|
},
|
|
|
|
render: function(data) {
|
|
var boardinfo = data[0],
|
|
systeminfo = data[1],
|
|
cpubench = data[2],
|
|
cpuinfo = data[3],
|
|
cpuusage = data[4],
|
|
luciversion = data[5],
|
|
unixtime = data[6];
|
|
|
|
luciversion = luciversion.branch;
|
|
|
|
var datestr = null;
|
|
|
|
if (unixtime) {
|
|
var date = new Date(unixtime * 1000),
|
|
zn = uci.get('system', '@system[0]', 'zonename')?.replaceAll(' ', '_') || 'UTC',
|
|
ts = uci.get('system', '@system[0]', 'clock_timestyle') || 0,
|
|
hc = uci.get('system', '@system[0]', 'clock_hourcycle') || 0;
|
|
|
|
datestr = new Intl.DateTimeFormat(undefined, {
|
|
dateStyle: 'medium',
|
|
timeStyle: (ts == 0) ? 'long' : 'full',
|
|
hourCycle: (hc == 0) ? undefined : hc,
|
|
timeZone: zn
|
|
}).format(date);
|
|
}
|
|
|
|
var fields = [
|
|
_('Hostname'), boardinfo.hostname,
|
|
_('Architecture'), (cpuinfo.cpuinfo || boardinfo.system) + ' ' + cpubench.cpubench,
|
|
_('Target Platform'), (L.isObject(boardinfo.release) ? boardinfo.release.target : ''),
|
|
_('Firmware Version'), (L.isObject(boardinfo.release) ? boardinfo.release.description + ' / ' : '') + (luciversion || ''),
|
|
_('Kernel Version'), boardinfo.kernel,
|
|
_('Local Time'), datestr,
|
|
_('Uptime'), systeminfo.uptime ? '%t'.format(systeminfo.uptime) : null,
|
|
_('Load Average'), Array.isArray(systeminfo.load) ? '%.2f, %.2f, %.2f'.format(
|
|
systeminfo.load[0] / 65535.0,
|
|
systeminfo.load[1] / 65535.0,
|
|
systeminfo.load[2] / 65535.0
|
|
) : null
|
|
];
|
|
|
|
if (cpuusage.tempinfo) {
|
|
fields.splice(6, 0, _('Temperature'));
|
|
fields.splice(7, 0, cpuusage.tempinfo);
|
|
}
|
|
|
|
if (boardinfo.model != "Default string Default string") {
|
|
fields.splice(2, 0, _('Model'));
|
|
fields.splice(3, 0, boardinfo.model);
|
|
}
|
|
|
|
var table = E('table', { 'class': 'table' });
|
|
|
|
for (var i = 0; i < fields.length; i += 2) {
|
|
table.appendChild(E('tr', { 'class': 'tr' }, [
|
|
E('td', { 'class': 'td left', 'width': '33%' }, [ fields[i] ]),
|
|
E('td', { 'class': 'td left' }, [ (fields[i + 1] != null) ? fields[i + 1] : '?' ])
|
|
]));
|
|
}
|
|
|
|
if (uci.get('system', '@system[0]', 'links') !== '0') {
|
|
table.appendChild(E('tr', { 'class': 'tr' }, [
|
|
E('td', { 'class': 'td', 'colspan': 2, 'style': 'padding: 10px 12px;' }, [
|
|
E('div', { 'style': 'display: flex; justify-content: space-around; align-items: center; text-align: center;' }, [
|
|
E('a', { 'href': 'https://openwrt.ai/', 'target': '_blank' }, [ '固件下载与定制' ]),
|
|
E('a', { 'href': 'https://openwrt.ai/fadian/', 'target': '_blank', 'style': 'color: orangered;' }, [ '赞助' ]),
|
|
E('a', { 'href': 'https://github.com/kiddin9/Kwrt', 'target': '_blank' }, [ '源码与反馈' ]),
|
|
E('a', { 'href': 'https://t.me/opkwrt', 'target': '_blank' }, [ 'TG交流' ])
|
|
])
|
|
])
|
|
]));
|
|
}
|
|
|
|
return table;
|
|
}
|
|
});
|