view service/mqtt_to_rdf/src/index.ts @ 1571:fd94061db75c

py3 Ignore-this: fd41253efc73d29e56aa5c3b0f2fb34f darcs-hash:92db0f73f9b6da1e661fa2daff21d185adf8e782
author drewp <drewp@bigasterisk.com>
date Thu, 14 May 2020 22:29:44 -0700
parents a598d2141587
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>
    `;
  }

}