Mercurial > code > home > repos > homeauto
comparison service/mqtt_to_rdf/src/index.ts @ 733:9ca69f2be87b
more mqtt_to_rdf renames. bring in basic LitElement setup for the debug page
Ignore-this: 85e2ab49915e44b08219e537fab21870
author | drewp@bigasterisk.com |
---|---|
date | Sat, 08 Feb 2020 04:02:22 -0800 |
parents | |
children | e0e623c01a69 |
comparison
equal
deleted
inserted
replaced
732:fdddbdaf07b5 | 733:9ca69f2be87b |
---|---|
1 // for the web page | |
2 export { DomBind } from "@polymer/polymer/lib/elements/dom-bind.js"; | |
3 export { StreamedGraph } from "streamed-graph"; | |
4 | |
5 import { LitElement, property, html, customElement } from "lit-element"; | |
6 | |
7 import { Literal, N3Store } from "n3"; | |
8 import { NamedNode, DataFactory } from "n3"; | |
9 const { namedNode, literal } = DataFactory; | |
10 | |
11 import { VersionedGraph } from "streamed-graph"; | |
12 // import style from "./style.styl"; | |
13 import { labelFromUri, graphLiteral, graphUriValue } from "./graph_access"; | |
14 | |
15 const room = "http://projects.bigasterisk.com/room/"; | |
16 | |
17 function asString(x: Literal | undefined): string { | |
18 if (x && x.value) { | |
19 return x.value; | |
20 } | |
21 return "(unknown)"; | |
22 } | |
23 | |
24 @customElement("mqtt-to-rdf-page") | |
25 export class MqttToRdfPage extends LitElement { | |
26 // static get styles() { | |
27 // return [style]; | |
28 // } | |
29 | |
30 @property({ type: Object }) | |
31 graph!: VersionedGraph; | |
32 | |
33 connectedCallback() { | |
34 super.connectedCallback(); | |
35 const sg = this.ownerDocument!.querySelector("streamed-graph"); | |
36 sg?.addEventListener("graph-changed", ((ev: CustomEvent) => { | |
37 this.graph = ev.detail!.value as VersionedGraph; | |
38 }) as EventListener); | |
39 } | |
40 | |
41 static get observers() { | |
42 return ["onGraphChanged(graph)"]; | |
43 } | |
44 | |
45 render() { | |
46 | |
47 return html` | |
48 <pre> | |
49 mqtt_to_rdf | |
50 | |
51 connected to <mqtt server> | |
52 | |
53 messages received <n from stats page> | |
54 | |
55 subscribed topics: | |
56 ari nightlight temp: 72.2 <graph> | |
57 ... | |
58 | |
59 | |
60 </pre> | |
61 `; | |
62 } | |
63 | |
64 } |