From 58437b8cc3badde046e270ed8ee04208ed7ea6a0 Mon Sep 17 00:00:00 2001 From: kiddin9 <48883331+kiddin9@users.noreply.github.com> Date: Thu, 23 Apr 2026 20:36:51 +0800 Subject: [PATCH] Add files via upload --- .../luci-static/resources/tools/github.js | 51 +++++++++++++++++++ .../resources/view/status/include/19_cpu.js | 45 ++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 .github/diy/packages/luci-base/htdocs/luci-static/resources/tools/github.js create mode 100644 .github/diy/packages/luci-mod-status/htdocs/luci-static/resources/view/status/include/19_cpu.js diff --git a/.github/diy/packages/luci-base/htdocs/luci-static/resources/tools/github.js b/.github/diy/packages/luci-base/htdocs/luci-static/resources/tools/github.js new file mode 100644 index 00000000..490b62c2 --- /dev/null +++ b/.github/diy/packages/luci-base/htdocs/luci-static/resources/tools/github.js @@ -0,0 +1,51 @@ +'use strict'; + +return L.Class.extend({ + desc: function(description, username, project) { + var luci_project = 'luci-app-' + project; + var title = _('if you have any problem, please click to view the project on GitHub : ') + project; + var luci_title = _('if you have any problem, please click to view the luci ui project on GitHub : ') + luci_project; + var package_label = 'package-' + project.replace(/-/g, '_') + '-default'; + var luci_label = 'luci-' + project.replace(/-/g, '_') + '-default'; + + return "" + + "" + + "" + + "" + + "" + + "
" + _(description) + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + project + "" + + "" + project + "" + + "" + + "" + + "" + luci_project + "" + + "" + luci_project + "" + + "" + + "
" + + "
"; + }, + + luci_desc: function(description, username, project) { + var luci_label = 'luci-' + project.replace(/-/g, '_') + '-default'; + project = 'luci-app-' + project; + var luci_title = _('if you have any problem, please click to view the luci ui project on GitHub : ') + project; + + return "" + + "" + + "" + + "" + + "" + + "
" + _(description) + "" + + "" + + "" + project + "" + + "" + project + "" + + "" + + "
"; + } +}); \ No newline at end of file diff --git a/.github/diy/packages/luci-mod-status/htdocs/luci-static/resources/view/status/include/19_cpu.js b/.github/diy/packages/luci-mod-status/htdocs/luci-static/resources/view/status/include/19_cpu.js new file mode 100644 index 00000000..1f036c22 --- /dev/null +++ b/.github/diy/packages/luci-mod-status/htdocs/luci-static/resources/view/status/include/19_cpu.js @@ -0,0 +1,45 @@ +'use strict'; +'require rpc'; + +var callCPUFreeInfo = rpc.declare({ + object: 'luci', + method: 'getCPUUsage' +}); + +function progressbar(value, max) { + var vn = parseInt(value) || 0, + mn = parseInt(max) || 100, + pc = Math.floor((100 / mn) * vn); + + return E('div', { + 'class': 'cbi-progressbar', + 'title': '%s%% / %s%%'.format(vn, mn, pc) + }, E('div', { 'style': 'width:%.2f%%'.format(pc) })); +} + +return L.Class.extend({ + title: _('CPU'), + + load: function() { + return L.resolveDefault(callCPUFreeInfo(), {}); + }, + + render: function(info) { + var fields = [ + _('Used'), (info.cpuusage) ? info.cpuusage : 0, 100 + ]; + + var table = E('table', { 'class': 'table cpu' }); + + for (var i = 0; i < fields.length; i += 3) { + table.appendChild(E('tr', { 'class': 'tr' }, [ + E('td', { 'class': 'td left', 'width': '33%' }, [ fields[i] ]), + E('td', { 'class': 'td left' }, [ + (fields[i + 1] != null) ? progressbar(fields[i + 1], fields[i + 2], true) : '?' + ]) + ])); + } + + return table; + } +});