Mercurial > code > home > repos > homeauto
view service/mqtt_to_rdf/src/index.ts @ 1533:a598d2141587
more mqtt_to_rdf renames. bring in basic LitElement setup for the debug page
Ignore-this: 85e2ab49915e44b08219e537fab21870
darcs-hash:f2d312ec10bb4a33c501a24bd7d11a1f35673f25
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sat, 08 Feb 2020 04:02:22 -0800 |
parents | |
children | e0e623c01a69 |
line wrap: on
line source
// for the web page export { DomBind } from "@polymer/polymer/lib/elements/dom-bind.js"; export { StreamedGraph } from "streamed-graph"; import { LitElement, property, html, customElement } from "lit-element"; import { Literal, N3Store } from "n3"; import { NamedNode, DataFactory } from "n3"; const { namedNode, literal } = DataFactory; import { VersionedGraph } from "streamed-graph"; // import style from "./style.styl"; import { labelFromUri, graphLiteral, graphUriValue } from "./graph_access"; const room = "http://projects.bigasterisk.com/room/"; function asString(x: Literal | undefined): string { if (x && x.value) { return x.value; } return "(unknown)"; } @customElement("mqtt-to-rdf-page") export class MqttToRdfPage extends LitElement { // static get styles() { // return [style]; // } @property({ type: Object }) graph!: VersionedGraph; connectedCallback() { super.connectedCallback(); const sg = this.ownerDocument!.querySelector("streamed-graph"); sg?.addEventListener("graph-changed", ((ev: CustomEvent) => { this.graph = ev.detail!.value as VersionedGraph; }) as EventListener); } static get observers() { return ["onGraphChanged(graph)"]; } render() { return html` <pre> mqtt_to_rdf connected to <mqtt server> messages received <n from stats page> subscribed topics: ari nightlight temp: 72.2 <graph> ... </pre> `; } }