fix(netdata-dashboard): correct API module imports in all views
- Changed from 'require netdata-dashboard.api as api' to 'require netdata-dashboard/api as API' - Updated all api. references to API. in realtime.js, system.js, network.js, and processes.js - Resolves "api.getAllData is not a function" and "api.getCpu is not a function" errors The dot notation (netdata-dashboard.api) doesn't work with LuCI's module loader. The correct syntax uses slash (netdata-dashboard/api) and follows the convention of uppercase API for consistency with other modules. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d97fff3b9e
commit
8b0d75a8d9
@ -4,13 +4,13 @@
|
||||
'require poll';
|
||||
'require dom';
|
||||
'require ui';
|
||||
'require netdata-dashboard.api as api';
|
||||
'require netdata-dashboard/api as API';
|
||||
|
||||
return view.extend({
|
||||
title: _('Network'),
|
||||
|
||||
load: function() {
|
||||
return api.getNetwork();
|
||||
return API.getNetwork();
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
@ -46,11 +46,11 @@ return view.extend({
|
||||
E('div', { 'class': 'nd-quick-stat-label' }, 'Interfaces')
|
||||
]),
|
||||
E('div', { 'class': 'nd-quick-stat' }, [
|
||||
E('div', { 'class': 'nd-quick-stat-value good' }, api.formatBytes(totalRx)),
|
||||
E('div', { 'class': 'nd-quick-stat-value good' }, API.formatBytes(totalRx)),
|
||||
E('div', { 'class': 'nd-quick-stat-label' }, 'Total RX')
|
||||
]),
|
||||
E('div', { 'class': 'nd-quick-stat' }, [
|
||||
E('div', { 'class': 'nd-quick-stat-value info' }, api.formatBytes(totalTx)),
|
||||
E('div', { 'class': 'nd-quick-stat-value info' }, API.formatBytes(totalTx)),
|
||||
E('div', { 'class': 'nd-quick-stat-label' }, 'Total TX')
|
||||
]),
|
||||
E('div', { 'class': 'nd-quick-stat' }, [
|
||||
@ -115,8 +115,8 @@ return view.extend({
|
||||
E('td', { 'class': 'mono' }, iface.ip || '-'),
|
||||
E('td', {}, E('span', { 'class': 'nd-status ' + stateClass }, state)),
|
||||
E('td', { 'class': 'mono' }, iface.speed > 0 ? iface.speed + ' Mbps' : '-'),
|
||||
E('td', { 'class': 'mono value' }, api.formatBytes(iface.rx_bytes || 0)),
|
||||
E('td', { 'class': 'mono' }, api.formatBytes(iface.tx_bytes || 0)),
|
||||
E('td', { 'class': 'mono value' }, API.formatBytes(iface.rx_bytes || 0)),
|
||||
E('td', { 'class': 'mono' }, API.formatBytes(iface.tx_bytes || 0)),
|
||||
E('td', { 'class': 'mono' }, (iface.rx_packets || 0).toLocaleString()),
|
||||
E('td', { 'class': 'mono' }, (iface.tx_packets || 0).toLocaleString()),
|
||||
E('td', { 'class': 'mono' }, (iface.rx_errors || 0) + (iface.tx_errors || 0))
|
||||
@ -145,12 +145,12 @@ return view.extend({
|
||||
E('div', { 'class': 'nd-network-stats' }, [
|
||||
E('div', { 'class': 'nd-network-direction' }, [
|
||||
E('div', { 'class': 'nd-network-icon' }, '📥'),
|
||||
E('div', { 'class': 'nd-network-value rx' }, api.formatBytes(iface.rx_bytes || 0)),
|
||||
E('div', { 'class': 'nd-network-value rx' }, API.formatBytes(iface.rx_bytes || 0)),
|
||||
E('div', { 'class': 'nd-network-label' }, 'Received')
|
||||
]),
|
||||
E('div', { 'class': 'nd-network-direction' }, [
|
||||
E('div', { 'class': 'nd-network-icon' }, '📤'),
|
||||
E('div', { 'class': 'nd-network-value tx' }, api.formatBytes(iface.tx_bytes || 0)),
|
||||
E('div', { 'class': 'nd-network-value tx' }, API.formatBytes(iface.tx_bytes || 0)),
|
||||
E('div', { 'class': 'nd-network-label' }, 'Transmitted')
|
||||
])
|
||||
]),
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
'require poll';
|
||||
'require dom';
|
||||
'require ui';
|
||||
'require netdata-dashboard.api as api';
|
||||
'require netdata-dashboard/api as API';
|
||||
|
||||
return view.extend({
|
||||
title: _('Processes'),
|
||||
|
||||
load: function() {
|
||||
return api.getProcesses();
|
||||
return API.getProcesses();
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
@ -86,7 +86,7 @@ return view.extend({
|
||||
E('td', { 'class': 'mono' }, proc.pid),
|
||||
E('td', {}, proc.user || 'root'),
|
||||
E('td', { 'title': proc.cmd }, E('code', { 'style': 'font-size:11px;color:#58a6ff' }, proc.cmd || '-')),
|
||||
E('td', { 'class': 'mono value' }, api.formatKB(proc.vsz || 0)),
|
||||
E('td', { 'class': 'mono value' }, API.formatKB(proc.vsz || 0)),
|
||||
E('td', {}, E('span', { 'class': 'nd-status ' + stateClass }, stateText))
|
||||
]);
|
||||
})
|
||||
@ -149,7 +149,7 @@ return view.extend({
|
||||
E('div', { 'class': 'nd-bar-track' }, [
|
||||
E('div', { 'class': 'nd-bar-fill', 'style': 'width:' + pct + '%;background:' + colors[i % colors.length] })
|
||||
]),
|
||||
E('span', { 'class': 'nd-bar-value' }, api.formatKB(proc.vsz || 0))
|
||||
E('span', { 'class': 'nd-bar-value' }, API.formatKB(proc.vsz || 0))
|
||||
]);
|
||||
})
|
||||
)
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
'require poll';
|
||||
'require dom';
|
||||
'require ui';
|
||||
'require netdata-dashboard.api as api';
|
||||
'require netdata-dashboard/api as API';
|
||||
|
||||
return view.extend({
|
||||
title: _('Netdata Dashboard'),
|
||||
@ -19,7 +19,7 @@ return view.extend({
|
||||
maxHistory: 60,
|
||||
|
||||
load: function() {
|
||||
return api.getAllData();
|
||||
return API.getAllData();
|
||||
},
|
||||
|
||||
addToHistory: function(key, value) {
|
||||
@ -34,7 +34,7 @@ return view.extend({
|
||||
var radius = (size - 20) / 2;
|
||||
var circumference = 2 * Math.PI * radius;
|
||||
var offset = circumference - (percent / 100 * circumference);
|
||||
var statusClass = api.getStatusClass(percent);
|
||||
var statusClass = API.getStatusClass(percent);
|
||||
|
||||
return E('div', { 'class': 'nd-gauge', 'style': 'width:' + size + 'px;height:' + size + 'px' }, [
|
||||
E('link', { 'rel': 'stylesheet', 'href': L.resource('secubox-theme/secubox-theme.css') }),
|
||||
@ -105,11 +105,11 @@ return view.extend({
|
||||
this.addToHistory('network_rx', stats.network_rx || 0);
|
||||
this.addToHistory('network_tx', stats.network_tx || 0);
|
||||
|
||||
var cpuClass = api.getStatusClass(stats.cpu_percent || 0);
|
||||
var memClass = api.getStatusClass(stats.memory_percent || 0);
|
||||
var diskClass = api.getStatusClass(stats.disk_percent || 0);
|
||||
var cpuClass = API.getStatusClass(stats.cpu_percent || 0);
|
||||
var memClass = API.getStatusClass(stats.memory_percent || 0);
|
||||
var diskClass = API.getStatusClass(stats.disk_percent || 0);
|
||||
var temp = stats.temperature || 0;
|
||||
var tempClass = api.getTempClass(temp);
|
||||
var tempClass = API.getTempClass(temp);
|
||||
|
||||
var view = E('div', { 'class': 'netdata-dashboard' }, [
|
||||
// Header
|
||||
@ -158,7 +158,7 @@ return view.extend({
|
||||
E('div', { 'class': 'nd-quick-stat-label' }, 'Connections')
|
||||
]),
|
||||
E('div', { 'class': 'nd-quick-stat' }, [
|
||||
E('div', { 'class': 'nd-quick-stat-value good' }, api.formatUptime(stats.uptime || 0)),
|
||||
E('div', { 'class': 'nd-quick-stat-value good' }, API.formatUptime(stats.uptime || 0)),
|
||||
E('div', { 'class': 'nd-quick-stat-label' }, 'Uptime')
|
||||
])
|
||||
]),
|
||||
@ -190,7 +190,7 @@ return view.extend({
|
||||
E('span', { 'class': 'nd-chart-title-icon' }, '🧠'),
|
||||
'Memory Usage'
|
||||
]),
|
||||
E('div', { 'class': 'nd-chart-value' }, api.formatKB(memory.used || 0) + ' / ' + api.formatKB(memory.total || 0))
|
||||
E('div', { 'class': 'nd-chart-value' }, API.formatKB(memory.used || 0) + ' / ' + API.formatKB(memory.total || 0))
|
||||
]),
|
||||
E('div', { 'class': 'nd-chart-body' }, [
|
||||
E('div', { 'class': 'nd-stacked-bar' }, [
|
||||
@ -201,19 +201,19 @@ return view.extend({
|
||||
E('div', { 'class': 'nd-stacked-legend' }, [
|
||||
E('div', { 'class': 'nd-legend-item' }, [
|
||||
E('span', { 'class': 'nd-legend-dot', 'style': 'background:#f85149' }),
|
||||
'Used: ' + api.formatKB(memory.used || 0)
|
||||
'Used: ' + API.formatKB(memory.used || 0)
|
||||
]),
|
||||
E('div', { 'class': 'nd-legend-item' }, [
|
||||
E('span', { 'class': 'nd-legend-dot', 'style': 'background:#d29922' }),
|
||||
'Buffers: ' + api.formatKB(memory.buffers || 0)
|
||||
'Buffers: ' + API.formatKB(memory.buffers || 0)
|
||||
]),
|
||||
E('div', { 'class': 'nd-legend-item' }, [
|
||||
E('span', { 'class': 'nd-legend-dot', 'style': 'background:#3fb950' }),
|
||||
'Cached: ' + api.formatKB(memory.cached || 0)
|
||||
'Cached: ' + API.formatKB(memory.cached || 0)
|
||||
]),
|
||||
E('div', { 'class': 'nd-legend-item' }, [
|
||||
E('span', { 'class': 'nd-legend-dot', 'style': 'background:#21262d' }),
|
||||
'Free: ' + api.formatKB(memory.free || 0)
|
||||
'Free: ' + API.formatKB(memory.free || 0)
|
||||
])
|
||||
]),
|
||||
E('div', { 'style': 'margin-top:16px;text-align:center' },
|
||||
@ -234,12 +234,12 @@ return view.extend({
|
||||
E('div', { 'class': 'nd-network-stats' }, [
|
||||
E('div', { 'class': 'nd-network-direction' }, [
|
||||
E('div', { 'class': 'nd-network-icon' }, '📥'),
|
||||
E('div', { 'class': 'nd-network-value rx' }, api.formatBytes(stats.network_rx || 0)),
|
||||
E('div', { 'class': 'nd-network-value rx' }, API.formatBytes(stats.network_rx || 0)),
|
||||
E('div', { 'class': 'nd-network-label' }, 'Received')
|
||||
]),
|
||||
E('div', { 'class': 'nd-network-direction' }, [
|
||||
E('div', { 'class': 'nd-network-icon' }, '📤'),
|
||||
E('div', { 'class': 'nd-network-value tx' }, api.formatBytes(stats.network_tx || 0)),
|
||||
E('div', { 'class': 'nd-network-value tx' }, API.formatBytes(stats.network_tx || 0)),
|
||||
E('div', { 'class': 'nd-network-label' }, 'Transmitted')
|
||||
])
|
||||
]),
|
||||
@ -265,7 +265,7 @@ return view.extend({
|
||||
return E('div', { 'class': 'nd-disk-item' }, [
|
||||
E('div', { 'class': 'nd-disk-header' }, [
|
||||
E('span', { 'class': 'nd-disk-mount' }, fs.mount),
|
||||
E('span', { 'class': 'nd-disk-size' }, api.formatKB(fs.used) + ' / ' + api.formatKB(fs.size))
|
||||
E('span', { 'class': 'nd-disk-size' }, API.formatKB(fs.used) + ' / ' + API.formatKB(fs.size))
|
||||
]),
|
||||
E('div', { 'class': 'nd-disk-bar' }, [
|
||||
E('div', { 'class': 'nd-disk-fill ' + diskStatus, 'style': 'width:' + pct + '%' })
|
||||
|
||||
@ -4,17 +4,17 @@
|
||||
'require poll';
|
||||
'require dom';
|
||||
'require ui';
|
||||
'require netdata-dashboard.api as api';
|
||||
'require netdata-dashboard/api as API';
|
||||
|
||||
return view.extend({
|
||||
title: _('System'),
|
||||
|
||||
load: function() {
|
||||
return Promise.all([
|
||||
api.getSystem(),
|
||||
api.getCpu(),
|
||||
api.getMemory(),
|
||||
api.getSensors()
|
||||
API.getSystem(),
|
||||
API.getCpu(),
|
||||
API.getMemory(),
|
||||
API.getSensors()
|
||||
]);
|
||||
},
|
||||
|
||||
@ -167,35 +167,35 @@ return view.extend({
|
||||
E('div', { 'class': 'nd-info-grid' }, [
|
||||
E('div', { 'class': 'nd-info-item' }, [
|
||||
E('div', { 'class': 'nd-info-label' }, 'Total'),
|
||||
E('div', { 'class': 'nd-info-value' }, api.formatKB(memory.total || 0))
|
||||
E('div', { 'class': 'nd-info-value' }, API.formatKB(memory.total || 0))
|
||||
]),
|
||||
E('div', { 'class': 'nd-info-item' }, [
|
||||
E('div', { 'class': 'nd-info-label' }, 'Used'),
|
||||
E('div', { 'class': 'nd-info-value' }, api.formatKB(memory.used || 0))
|
||||
E('div', { 'class': 'nd-info-value' }, API.formatKB(memory.used || 0))
|
||||
]),
|
||||
E('div', { 'class': 'nd-info-item' }, [
|
||||
E('div', { 'class': 'nd-info-label' }, 'Free'),
|
||||
E('div', { 'class': 'nd-info-value' }, api.formatKB(memory.free || 0))
|
||||
E('div', { 'class': 'nd-info-value' }, API.formatKB(memory.free || 0))
|
||||
]),
|
||||
E('div', { 'class': 'nd-info-item' }, [
|
||||
E('div', { 'class': 'nd-info-label' }, 'Available'),
|
||||
E('div', { 'class': 'nd-info-value' }, api.formatKB(memory.available || 0))
|
||||
E('div', { 'class': 'nd-info-value' }, API.formatKB(memory.available || 0))
|
||||
]),
|
||||
E('div', { 'class': 'nd-info-item' }, [
|
||||
E('div', { 'class': 'nd-info-label' }, 'Buffers'),
|
||||
E('div', { 'class': 'nd-info-value' }, api.formatKB(memory.buffers || 0))
|
||||
E('div', { 'class': 'nd-info-value' }, API.formatKB(memory.buffers || 0))
|
||||
]),
|
||||
E('div', { 'class': 'nd-info-item' }, [
|
||||
E('div', { 'class': 'nd-info-label' }, 'Cached'),
|
||||
E('div', { 'class': 'nd-info-value' }, api.formatKB(memory.cached || 0))
|
||||
E('div', { 'class': 'nd-info-value' }, API.formatKB(memory.cached || 0))
|
||||
]),
|
||||
E('div', { 'class': 'nd-info-item' }, [
|
||||
E('div', { 'class': 'nd-info-label' }, 'Swap Total'),
|
||||
E('div', { 'class': 'nd-info-value' }, api.formatKB(memory.swap_total || 0))
|
||||
E('div', { 'class': 'nd-info-value' }, API.formatKB(memory.swap_total || 0))
|
||||
]),
|
||||
E('div', { 'class': 'nd-info-item' }, [
|
||||
E('div', { 'class': 'nd-info-label' }, 'Swap Used'),
|
||||
E('div', { 'class': 'nd-info-value' }, api.formatKB(memory.swap_used || 0))
|
||||
E('div', { 'class': 'nd-info-value' }, API.formatKB(memory.swap_used || 0))
|
||||
])
|
||||
])
|
||||
])
|
||||
@ -212,7 +212,7 @@ return view.extend({
|
||||
E('div', { 'class': 'nd-chart-body' },
|
||||
(sensors.temperatures && sensors.temperatures.length > 0) ?
|
||||
sensors.temperatures.map(function(s) {
|
||||
var tempClass = api.getTempClass(s.temp_c);
|
||||
var tempClass = API.getTempClass(s.temp_c);
|
||||
return E('div', { 'style': 'display:flex;justify-content:space-between;padding:8px 0;border-bottom:1px solid #30363d' }, [
|
||||
E('span', {}, s.sensor),
|
||||
E('span', { 'class': 'nd-temp-value ' + tempClass, 'style': 'font-size:18px' }, s.temp_c + '°C')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user