annotate service/wifi/src/wifi-table.ts @ 672:f424809cba8d

npm run build works now, accessing streamed-graph. But, s-g isn't in the output bundle yet. Ignore-this: 2b08220ad8d275f4dd242c3aa1a8647a
author drewp@bigasterisk.com
date Sun, 29 Dec 2019 19:41:48 -0800
parents service/wifi/src/wifi.ts@540dd68af9f2
children 9ae34280218b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
662
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
1 import { html } from 'lit-html';
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
2 import { NamedNode, DataFactory } from 'n3';
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
3 const { literal, quad, namedNode } = DataFactory;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
4 import * as sgmod from 'streamed-graph';
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
5 import { Literal, Term, N3Store } from 'n3';
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
6
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
7 interface DevGroup {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
8 connectedToAp: NamedNode,
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
9 wifiBand: NamedNode,
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
10 devs: Array<Dev>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
11 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
12 interface Dev {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
13 agoMin: number,
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
14 ipAddress: Literal,
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
15 dhcpHostname: string,
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
16 macAddress: Literal,
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
17 packetsPerSec: number,
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
18 bytesPerSec: number
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
19 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
20
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
21 console.log('got', sgmod);
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
22
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
23 const NS: any = {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
24 room: 'http://projects.bigasterisk.com/room/'
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
25 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
26
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
27 // from rdf-uri.html
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
28 const BigastUri = {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
29 // not well defined for uri prefixes that are string prefixes of each other
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
30 compactUri: function (uri: string) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
31 if (uri === undefined) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
32 return uri;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
33 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
34 if (typeof (uri) == "object") { throw new Error("type"); }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
35 if (uri == "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
36 return "a";
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
37 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
38 for (var short of Object.keys(NS as any)) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
39 var prefix = NS[short];
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
40 if (uri.indexOf(prefix) == 0) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
41 return short + ':' + uri.substr(prefix.length);
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
42 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
43 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
44 return uri;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
45 },
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
46 expandUri: function (s: string) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
47 for (var short of Object.keys(NS)) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
48 var prefix = NS[short];
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
49 if (s.indexOf(short + ":") == 0) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
50 return prefix + s.substr(short.length + 1);
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
51 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
52 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
53 return s;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
54 },
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
55 };
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
56
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
57 // workaround for uris that don't have good labels in the graph
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
58 function labelFromUri(uri: NamedNode, prefix: string, tailsToLabels: any, defaultLabel: string) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
59 let label = defaultLabel === undefined ? uri.value : defaultLabel;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
60 Object.entries(tailsToLabels).forEach(([tail, useLabel]) => {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
61 if (uri.equals(namedNode(prefix + tail))) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
62 label = useLabel as string;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
63 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
64 });
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
65 return label
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
66 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
67
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
68 // set out[suffix] = graph.get(subj, predPrefix+suffix) for all suffixes
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
69 function getProperties(store: N3Store, out: any, subject: Term, predPrefix: string, predSuffixes: Array<string>) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
70 predSuffixes.forEach((term) => {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
71 store.forEach((q) => {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
72 out[term] = q.object;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
73 }, subject, namedNode(predPrefix + term), null, null);
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
74
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
75 return out;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
76 });
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
77 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
78
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
79 function graphView(store: N3Store, showGroups: boolean): void {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
80 const grouped: Map<string, DevGroup> = new Map();
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
81 store.forEach((q) => {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
82 const row: any = { uri: q.subject };
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
83
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
84 getProperties(store, row, row.uri, 'room:',
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
85 ['dhcpHostname', 'ipAddress', 'macAddress', 'connectedToAp', 'wifiBand', 'connected', 'bytesPerSec', 'packetsPerSec']);
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
86 if (row.dhcpHostname && row.dhcpHostname.value) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
87 row.dhcpHostname = row.dhcpHostname.value;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
88 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
89 if (!showGroups || row.connectedToAp) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
90 const key = (showGroups ? `${row.connectedToAp.toNT()}-${row.wifiBand.toNT()}` : 'all');
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
91 if (!grouped.has(key)) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
92 grouped.set(key, { connectedToAp: row.connectedToAp, wifiBand: row.wifiBand, devs: [] });
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
93 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
94 grouped.get(key)!.devs.push(row);
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
95 } else {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
96 console.log('lost row', row);
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
97 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
98 if (row.connected) {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
99 const t = new Date(row.connected.value);
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
100 const agoMs = (Date.now() as number) - (t as unknown as number);
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
101 row.agoMin = agoMs / 1000 / 60;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
102 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
103 if (row.bytesPerSec) { row.bytesPerSec = row.bytesPerSec.valueOf() + ' B/s'; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
104 if (row.packetsPerSec) { row.packetsPerSec = row.packetsPerSec.valueOf() + ' p/s'; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
105 }, null, namedNode('rdf:type'), namedNode('room:NetworkedDevice'), null);
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
106 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
107
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
108 const renderDevice = (dev: Dev) => {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
109 const glow = Math.max(0, 1 - dev.agoMin / 60);
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
110 const agoReport = dev.agoMin < 360 ? ` (${Math.ceil(dev.agoMin * 10) / 10} minutes ago)` : '';
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
111 return html`
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
112 <div class="dev" style="background: rgba(185, 5, 138, ${glow});">
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
113 <span class="mac">${dev.macAddress.value}</span>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
114 <span class="ip"><a href="http://${dev.ipAddress.value}/">${dev.ipAddress.value}</a></span>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
115 <span class="packets">${dev.packetsPerSec}</span>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
116 <span class="bytes">${dev.bytesPerSec}</span>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
117 <span class="hostname">${dev.dhcpHostname}</span>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
118 <span class="ago">${agoReport}</span>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
119 <span class="links">
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
120 <a href="https://bigasterisk.com/ntop/lua/host_details.lua?ifid=17&amp;host=${dev.ipAddress.value}&amp;page=flows">[flows]</a>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
121 </span>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
122 </div>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
123 `;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
124 };
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
125
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
126 const renderGroup = (key: string, group: DevGroup) => {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
127 let label;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
128 if (key != 'all') {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
129 label = labelFromUri(group.connectedToAp,
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
130 'http://bigasterisk.com/mac/',
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
131 {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
132 'a0:40:a0:6f:96:d5': "Main router (d5)",
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
133 '8c:3b:ad:c4:8d:ce': "Downstairs satellite (ce)",
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
134 'a0:40:a0:6f:aa:f8': "Upstairs satellite (f8)",
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
135 },
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
136 "unknown");
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
137
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
138 label += labelFromUri(group.wifiBand,
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
139 'http://projects.bigasterisk.com/room/wifiBand/',
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
140 {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
141 '5G': ' 5G',
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
142 '2.4G': ' 2.4G',
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
143 },
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
144 "unknown");
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
145 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
146
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
147 const devs = group.devs;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
148 function padIp(ip: string) { return ip.replace(/(\d+)/g, (m) => ('00' + m).slice(-3)); }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
149 devs.sort((a, b) => { return padIp(a.ipAddress.value) > padIp(b.ipAddress.value) ? 1 : -1; });
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
150 return html`
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
151 <tr>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
152 <th>${label}</th>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
153 <td>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
154 <div>Devices:</div>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
155 ${devs.map((d) => { return renderDevice(d); })}
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
156 </td>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
157 </tr>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
158 `;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
159 /*
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
160 let groups=['?'];
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
161 const out = html`
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
162 <style>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
163
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
164 .report { font-family: sans-serif; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
165 section { margin-left: 1em; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
166 .dev { margin-bottom: 2px; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
167 .ip, .mac, .packets, .bytes {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
168 display: inline-block;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
169 font-family: monospace;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
170 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
171 .packets, .bytes {
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
172 text-align: right;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
173 padding-right: 1em;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
174 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
175 .mac {color: #ccffcc; width: 11em; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
176 .ip {color: #b5b5d4; width: 6em; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
177 .packets {color: #2da1a5; width: 6em; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
178 .bytes {color: #a5912d; width: 9em; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
179 th,td { vertical-align: top; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
180 th { background: #333; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
181 td { background: #252525; }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
182
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
183 </style>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
184 <div class="report">
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
185 report
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
186 <table>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
187 ${groups.map((row) => { return renderGroup(row[0], row[1]); })}
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
188 </table>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
189 </div>
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
190 `;
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
191 return out;*/
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
192 }
540dd68af9f2 start ts config files, but this doesn't share the streamed-graph code properly yet
drewp@bigasterisk.com
parents:
diff changeset
193 export { graphView }