aboutsummaryrefslogtreecommitdiff
path: root/src_js/vt.js
diff options
context:
space:
mode:
authorbozo.kopic <bozo@kopic.xyz>2021-07-28 01:43:55 +0200
committerbozo.kopic <bozo@kopic.xyz>2021-07-29 00:01:57 +0200
commit1e874e790c12839695761a654b44fb427149a353 (patch)
tree6942441ac511ec1417b2434b111101fa8d7f7e68 /src_js/vt.js
init
Diffstat (limited to 'src_js/vt.js')
-rw-r--r--src_js/vt.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/src_js/vt.js b/src_js/vt.js
new file mode 100644
index 0000000..1f390ab
--- /dev/null
+++ b/src_js/vt.js
@@ -0,0 +1,65 @@
+import r from '@hat-core/renderer';
+import * as u from '@hat-core/util';
+
+import * as common from './common';
+
+
+export function main() {
+ const entries = r.get('entries');
+
+ return ['div.main',
+ ['table',
+ ['thead',
+ ['tr',
+ ['th.col-id', 'ID'],
+ ['th.col-time', 'Time'],
+ ['th.col-address', 'Address'],
+ ['th.col-source', 'Source'],
+ ['th.col-type', 'Type'],
+ ['th.col-data', 'Data']
+ ]
+ ],
+ ['tbody', entries.map(entry =>
+ ['tr',
+ ['td.col-id', String(entry.entry_id)],
+ ['td.col-time', common.timestampToString(entry.timestamp)],
+ ['td.col-address', String(entry.address)],
+ ['td.col-source', String(entry.source)],
+ ['td.col-type', String(entry.type)],
+ ['td.col-data', data(entry.type, entry.data)]
+ ]
+ )]
+ ]
+ ];
+}
+
+
+function data(type, data) {
+ if (type == 'builtin.status.linux')
+ return builtinStatusLinux(data);
+
+ return JSON.stringify(data);
+}
+
+
+function builtinStatusLinux(data) {
+ const timestamp = u.get('timestamp', data);
+ const uptime = u.get('uptime', data);
+ const thermal = u.get('thermal', data) || [];
+ const disks = u.get('disks', data) || [];
+
+ return ['div.data',
+ ['label', 'Time:'],
+ ['span', common.timestampToString(timestamp)],
+ ['label', 'Uptime:'],
+ ['span', `${uptime}s`],
+ thermal.map(i => [
+ ['label', `Temp - ${i.type}:`],
+ ['span', `${i.temp}°C`]
+ ]),
+ disks.map(i => [
+ ['label', `Disk - ${i.name}:`],
+ ['span', `${i.percent} (${i.used}/${i.size})`]
+ ]),
+ ];
+}