Mercurial > code > home > repos > homeauto
annotate service/wifi/src/index.ts @ 1479:ad9ec466ba6d
rm dead code
Ignore-this: bbb203e41c560d563f8721148f9ea1f5
darcs-hash:ec1934a48ca37a51f6fee1951747d531261bf8ff
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Mon, 06 Jan 2020 22:35:16 -0800 |
parents | 2832e5c14c74 |
children | 6723f7ae8f34 |
rev | line source |
---|---|
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
1 // for the web page |
1475
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
2 export { DomBind } from "@polymer/polymer/lib/elements/dom-bind.js"; |
1479 | 3 export { StreamedGraph } from "streamed-graph"; |
1475
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
4 |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
5 import { LitElement, property, html, customElement } from "lit-element"; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
6 |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
7 import { Literal, Term, N3Store, Util } from "n3"; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
8 import { NamedNode, DataFactory } from "n3"; |
1479 | 9 const { literal, namedNode } = DataFactory; |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
10 |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
11 import { VersionedGraph } from "streamed-graph"; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
12 import { style } from "./style"; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
13 |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
14 interface DevGroup { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
15 connectedToAp: NamedNode; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
16 wifiBand: NamedNode; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
17 devs: Array<Dev>; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
18 } |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
19 interface Dev { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
20 agoMin: number | undefined; |
1478
2832e5c14c74
some type notes and cleanups
drewp <drewp@bigasterisk.com>
parents:
1477
diff
changeset
|
21 ipAddress: Literal; // todo no one wants this literal. just make it string. |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
22 dhcpHostname: string; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
23 macAddress: Literal; |
1477
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
24 packetsPerSec: number; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
25 packetsPerSecDisplay: string; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
26 bytesPerSec: number; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
27 bytesPerSecDisplay: string; |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
28 } |
1477
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
29 const room = "http://projects.bigasterisk.com/room/"; |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
30 |
1478
2832e5c14c74
some type notes and cleanups
drewp <drewp@bigasterisk.com>
parents:
1477
diff
changeset
|
31 ////////////////// funcs that could move out ////////////////////////////// |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
32 // workaround for uris that don't have good labels in the graph |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
33 function labelFromUri( |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
34 uri: NamedNode, |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
35 prefix: string, |
1478
2832e5c14c74
some type notes and cleanups
drewp <drewp@bigasterisk.com>
parents:
1477
diff
changeset
|
36 tailsToLabels: {[key: string]: string}, |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
37 defaultLabel: string |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
38 ) { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
39 let label = defaultLabel === undefined ? uri.value : defaultLabel; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
40 Object.entries(tailsToLabels).forEach(([tail, useLabel]) => { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
41 if (uri.equals(namedNode(prefix + tail))) { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
42 label = useLabel as string; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
43 } |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
44 }); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
45 return label; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
46 } |
1477
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
47 function asString(x: Literal | undefined): string { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
48 if (x && x.value) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
49 return x.value; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
50 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
51 return "(unknown)"; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
52 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
53 |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
54 function graphLiteral( |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
55 store: N3Store, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
56 subj: NamedNode, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
57 pred: string, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
58 notFoundResult?: string |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
59 ): Literal { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
60 const keep: Array<Literal> = []; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
61 store.forEach( |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
62 q => { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
63 if (!Util.isLiteral(q.object)) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
64 throw new Error("non literal found"); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
65 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
66 let seen = false; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
67 for (let other of keep) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
68 if (other.equals(q.object)) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
69 seen = true; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
70 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
71 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
72 if (!seen) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
73 keep.push(q.object as Literal); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
74 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
75 }, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
76 subj, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
77 namedNode(pred), |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
78 null, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
79 null |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
80 ); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
81 if (keep.length == 0) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
82 return literal(notFoundResult || "(missing)"); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
83 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
84 if (keep.length == 1) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
85 return keep[0]; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
86 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
87 console.log(`${subj.value} ${pred} had ${keep.length} objects:`, keep); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
88 return keep[0]; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
89 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
90 |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
91 function graphUriValue( |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
92 store: N3Store, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
93 subj: NamedNode, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
94 pred: string |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
95 ): NamedNode | undefined { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
96 const keep: Array<NamedNode> = []; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
97 store.forEach( |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
98 q => { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
99 if (!Util.isNamedNode(q.object)) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
100 throw new Error("non uri found"); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
101 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
102 keep.push(q.object as NamedNode); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
103 }, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
104 subj, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
105 namedNode(pred), |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
106 null, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
107 null |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
108 ); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
109 if (keep.length == 0) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
110 return undefined; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
111 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
112 if (keep.length == 1) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
113 return keep[0]; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
114 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
115 throw new Error("found multiple matches for pred"); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
116 } |
1478
2832e5c14c74
some type notes and cleanups
drewp <drewp@bigasterisk.com>
parents:
1477
diff
changeset
|
117 ////////////////////////////////////////////////////////////////////////////////// |
1475
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
118 |
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
119 @customElement("wifi-display") |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
120 class WifiDisplay extends LitElement { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
121 static get styles() { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
122 return [style]; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
123 } |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
124 |
1478
2832e5c14c74
some type notes and cleanups
drewp <drewp@bigasterisk.com>
parents:
1477
diff
changeset
|
125 @property({ type: Object }) |
1475
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
126 graph!: VersionedGraph; |
1474
f91ba30b4f75
build adjustments. now seems to read streamedgraph correctly.
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
127 |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
128 connectedCallback() { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
129 super.connectedCallback(); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
130 console.log("wifidisplay connected"); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
131 const sg = this.ownerDocument!.querySelector("streamed-graph"); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
132 sg?.addEventListener("graph-changed", ((ev: CustomEvent) => { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
133 this.graph = ev.detail!.value as VersionedGraph; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
134 console.log("wifidisplay got new graph", this.graph); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
135 }) as EventListener); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
136 } |
1475
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
137 |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
138 static get observers() { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
139 return ["onGraphChanged(graph)"]; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
140 } |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
141 |
1477
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
142 @property({ type: Boolean }) |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
143 showGroups = false; |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
144 |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
145 render() { |
1477
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
146 const grouped = this.graphView(this.graph.store!); |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
147 |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
148 return html` |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
149 <div class="report"> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
150 report at graph version ${this.graph.version} grouped: |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
151 ${Array.from(grouped.entries()).length} |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
152 <table> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
153 ${Array.from(grouped.entries()).map((row: [string, DevGroup]) => { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
154 return this.renderGroup(row[0], row[1]); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
155 })} |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
156 </table> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
157 </div> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
158 `; |
1475
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
159 } |
1474
f91ba30b4f75
build adjustments. now seems to read streamedgraph correctly.
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
160 |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
161 renderDevice(dev: Dev) { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
162 let agoReport = ""; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
163 if (dev.agoMin === undefined) { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
164 agoReport = "unknown"; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
165 } else { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
166 const glow = Math.max(0, 1 - dev.agoMin! / 60); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
167 agoReport = |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
168 dev.agoMin! < 360 |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
169 ? ` (${Math.ceil(dev.agoMin! * 10) / 10} minutes ago)` |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
170 : ""; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
171 } |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
172 const glow = ""; //todo |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
173 return html` |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
174 <div class="dev" style="background: rgba(185, 5, 138, ${glow});"> |
1478
2832e5c14c74
some type notes and cleanups
drewp <drewp@bigasterisk.com>
parents:
1477
diff
changeset
|
175 <span class="mac">${dev.macAddress.value}</span> |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
176 <span class="ip" |
1478
2832e5c14c74
some type notes and cleanups
drewp <drewp@bigasterisk.com>
parents:
1477
diff
changeset
|
177 ><a href="http://${dev.ipAddress.value}/" |
2832e5c14c74
some type notes and cleanups
drewp <drewp@bigasterisk.com>
parents:
1477
diff
changeset
|
178 >${dev.ipAddress.value}</a |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
179 ></span |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
180 > |
1477
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
181 <span class="packets">${dev.packetsPerSecDisplay}</span> |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
182 <span class="bytes">${dev.bytesPerSecDisplay}</span> |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
183 <span class="hostname">${dev.dhcpHostname}</span> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
184 <span class="ago">${agoReport}</span> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
185 <span class="links"> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
186 <a |
1478
2832e5c14c74
some type notes and cleanups
drewp <drewp@bigasterisk.com>
parents:
1477
diff
changeset
|
187 href="https://bigasterisk.com/ntop/lua/host_details.lua?ifid=17&host=${dev.ipAddress.value}&page=flows" |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
188 >[flows]</a |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
189 > |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
190 </span> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
191 </div> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
192 `; |
1475
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
193 } |
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
194 |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
195 renderGroup(key: string, group: DevGroup) { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
196 let label; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
197 if (key != "all") { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
198 label = labelFromUri( |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
199 group.connectedToAp, |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
200 "http://bigasterisk.com/mac/", |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
201 { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
202 "a0:40:a0:6f:96:d5": "Main router (d5)", |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
203 "8c:3b:ad:c4:8d:ce": "Downstairs satellite (ce)", |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
204 "a0:40:a0:6f:aa:f8": "Upstairs satellite (f8)", |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
205 }, |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
206 "unknown" |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
207 ); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
208 |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
209 label += labelFromUri( |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
210 group.wifiBand, |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
211 "http://projects.bigasterisk.com/room/wifiBand/", |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
212 { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
213 "5G": " 5G", |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
214 "2.4G": " 2.4G", |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
215 }, |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
216 "unknown" |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
217 ); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
218 } |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
219 |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
220 const devs = group.devs; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
221 function padIp(ip: string) { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
222 return ip.replace(/(\d+)/g, m => ("00" + m).slice(-3)); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
223 } |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
224 devs.sort((a, b) => { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
225 return padIp(a.ipAddress.value) > padIp(b.ipAddress.value) ? 1 : -1; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
226 }); |
1475
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
227 return html` |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
228 <tr> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
229 <th>${label}</th> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
230 <td> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
231 <div>Devices:</div> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
232 ${devs.map(d => { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
233 return this.renderDevice(d); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
234 })} |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
235 </td> |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
236 </tr> |
1475
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
237 `; |
2e598cbcabf4
streamed-graph finally imports and builds. polymer bindings don't work in a <dom-bind> though
drewp <drewp@bigasterisk.com>
parents:
1474
diff
changeset
|
238 } |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
239 |
1477
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
240 addGroupedDev( |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
241 store: N3Store, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
242 grouped: Map<string, DevGroup>, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
243 devUri: NamedNode |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
244 ) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
245 const getAgoMin = (connected: Literal | undefined): number | undefined => { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
246 if (connected) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
247 const t = new Date(connected.value); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
248 const agoMs = Date.now() - t.valueOf(); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
249 return agoMs / 1000 / 60; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
250 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
251 return undefined; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
252 }; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
253 |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
254 const packetsPerSec = parseFloat( |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
255 graphLiteral(store, devUri, room + "packetsPerSec", "0").value |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
256 ); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
257 const bytesPerSec = parseFloat( |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
258 graphLiteral(store, devUri, room + "bytesPerSec", "0").value |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
259 ); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
260 |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
261 const row: Dev = { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
262 agoMin: getAgoMin(graphLiteral(store, devUri, room + "connected")), |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
263 ipAddress: graphLiteral(store, devUri, room + "ipAddress", "(unknown)"), |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
264 dhcpHostname: asString( |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
265 graphLiteral(store, devUri, room + "dhcpHostname") |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
266 ), |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
267 macAddress: graphLiteral(store, devUri, room + "macAddress"), |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
268 packetsPerSec: packetsPerSec, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
269 packetsPerSecDisplay: packetsPerSec + " P/s", |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
270 bytesPerSec: bytesPerSec, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
271 bytesPerSecDisplay: bytesPerSec + " B/s", |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
272 }; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
273 |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
274 const wifiBand = graphUriValue(store, devUri, room + "wifiBand"); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
275 const connectedToAp = graphUriValue(store, devUri, room + "connectedToAp"); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
276 if (!this.showGroups || connectedToAp) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
277 const key = this.showGroups |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
278 ? `${connectedToAp!.value}-${wifiBand!.value}` |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
279 : "all"; |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
280 if (!grouped.has(key)) { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
281 grouped.set(key, { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
282 connectedToAp: connectedToAp!, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
283 wifiBand: wifiBand!, |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
284 devs: [], |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
285 }); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
286 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
287 grouped.get(key)!.devs.push(row); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
288 } else { |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
289 console.log("lost row", row); |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
290 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
291 } |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
292 |
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
293 graphView(store: N3Store): Map<string, DevGroup> { |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
294 const grouped: Map<string, DevGroup> = new Map(); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
295 store.forEach( |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
296 q => { |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
297 const devUri: NamedNode = q.subject as NamedNode; |
1477
383e32841b35
now roughly works. shows updates. only some workarounds.
drewp <drewp@bigasterisk.com>
parents:
1476
diff
changeset
|
298 this.addGroupedDev(store, grouped, devUri); |
1476
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
299 }, |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
300 null, |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
301 namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
302 namedNode(room + "NetworkedDevice"), |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
303 null |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
304 ); |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
305 return grouped; |
817da2dc80fc
kind of running with lit-element and polymer together. lots of data missing from table still
drewp <drewp@bigasterisk.com>
parents:
1475
diff
changeset
|
306 } |
1474
f91ba30b4f75
build adjustments. now seems to read streamedgraph correctly.
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
307 } |