Refocus dashboard on device monitoring

This commit is contained in:
chick
2026-07-07 23:33:27 +08:00
parent 2505ee561a
commit 0e746f961c
6 changed files with 247 additions and 91 deletions
+34 -8
View File
@@ -41,21 +41,47 @@ test('client stores simadmin_session from login and sends it on later proxied re
assert.match(calls.at(-1).options.headers.cookie, /simadmin_session=abc123/)
})
test('snapshot summary merges status from device, sim, network, sms and system endpoints', () => {
test('snapshot summary exposes device-monitoring fields from stats, sms, data and hardware endpoints', () => {
const snapshot = summarizeInstanceSnapshot({
device: { data: { model: 'CPE X', imei: '123' } },
sim: { data: { iccid: '8986', operator: 'CMCC' } },
network: { data: { accessTechnology: 'LTE', registration: 'registered' } },
smsStats: { data: { total: 12, unread: 2 } },
data: { data: { enabled: true, connected: true } },
ota: { data: { current_version: '1.2.3' } },
device: { data: { model: 'CPE X', imei: '123', manufacturer: 'Quectel', powered: true, revision: 'RG500QEAAAR13A01' } },
sim: { data: { iccid: '8986', imsi: '460001234', phone_numbers: ['13800138000'], operator: 'CMCC', present: true } },
network: { data: { operator_name: '中国移动', signal_strength: -73, registration_status: 'registered', technology_preference: 'LTE' } },
smsStats: { data: { total: 12, incoming: 9, outgoing: 3, pushed: 8 } },
data: { data: { active: true } },
ota: { data: { current_version: '1.2.3', current_commit: 'abc123', pending_update: false } },
stats: { data: {
cpu_load: [0.2, 0.4, 0.6],
memory: { total: 1024, used: 512, free: 512 },
disk: { total: 2048, used: 1024, free: 1024 },
network_speed: { rx: 1024, tx: 2048 },
system_info: { os: 'OpenWrt', kernel: '6.6.1' },
temperature: { cpu: 47.5, modem: 41 },
uptime: 3600,
} },
})
assert.equal(snapshot.device.model, 'CPE X')
assert.equal(snapshot.device.manufacturer, 'Quectel')
assert.equal(snapshot.device.powered, true)
assert.equal(snapshot.sim.iccid, '8986')
assert.equal(snapshot.sim.present, true)
assert.equal(snapshot.sim.phoneNumber, '13800138000')
assert.equal(snapshot.network.operator, '中国移动')
assert.equal(snapshot.network.signal, -73)
assert.equal(snapshot.network.accessTechnology, 'LTE')
assert.equal(snapshot.sms.total, 12)
assert.equal(snapshot.data.connected, true)
assert.equal(snapshot.sms.incoming, 9)
assert.equal(snapshot.sms.outgoing, 3)
assert.equal(snapshot.sms.pushed, 8)
assert.equal(snapshot.data.active, true)
assert.equal(snapshot.ota.currentVersion, '1.2.3')
assert.equal(snapshot.ota.currentCommit, 'abc123')
assert.equal(snapshot.ota.pendingUpdate, false)
assert.deepEqual(snapshot.system.temperature, { cpu: 47.5, modem: 41 })
assert.deepEqual(snapshot.system.networkSpeed, { rx: 1024, tx: 2048 })
assert.equal(snapshot.system.memory.used, 512)
assert.equal(snapshot.system.disk.free, 1024)
assert.equal(snapshot.system.info.os, 'OpenWrt')
assert.equal(snapshot.system.uptime, 3600)
})
test('config store can add update and delete instances while persisting json', async () => {