Changeset - fddd07e694ab
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 3 years ago 2022-05-24 06:53:07
drewp@bigasterisk.com
cleanup nested class mess
2 files changed with 12 insertions and 18 deletions:
0 comments (0 inline, 0 general)
light9/collector/web/Light9CollectorUi.ts
Show inline comments
 
@@ -15,14 +15,12 @@ export { Light9CollectorDevice } from ".
 

	
 
debug.enable("*");
 
const log = debug("collector");
 

	
 
@customElement("light9-collector-ui")
 
export class Light9CollectorUi extends GraphAwarePage {
 
  graph?: SyncedGraph;
 
  static styles = [];
 
  render() {
 
    return html`${super.render()}
 
      <h1>Collector <a href="metrics">[metrics]</a></h1>
 

	
 
      <h2>Devices</h2>
 
      <light9-collector-device-list></light9-collector-device-list> `;
 
@@ -34,13 +32,12 @@ export class Light9CollectorDeviceList e
 
  graph!: SyncedGraph;
 
  @property() devices: NamedNode[] = [];
 
  
 
  render() {
 
    return html`
 
      <h2>Devices</h2>
 
      <light9-collector-device uri="http://light9.bigasterisk.com/theater/skyline/device/strip1"></light9-collector-device>
 
      <div style="column-width: 11em">${this.devices.map((d) => html`<light9-collector-device uri="${d.value}"></light9-collector-device>`)}</div>
 
    `;
 
  }
 
  
 
  constructor() {
 
    super();
light9/web/RdfdbSyncedGraph.ts
Show inline comments
 
@@ -15,23 +15,25 @@ export interface GraphChangedDetail {
 
export class GraphChangedEvent extends CustomEvent<GraphChangedDetail> {
 
  constructor(type: string, opts: { detail: GraphChangedDetail; bubbles: boolean; composed: boolean }) {
 
    super(type, opts);
 
  }
 
}
 

	
 
let RdfdbSyncedGraph
 
let setTopGraph: (sg: SyncedGraph) => void;
 
(window as any).topSyncedGraph = new Promise<SyncedGraph>((res, rej) => {
 
  setTopGraph = res;
 
});
 

	
 
(window as any).topSyncedGraph = new Promise((res, rej) => {
 
  // Contains a SyncedGraph,
 
  // displays a little status box,
 
  // and emits 'changed' events with the graph and latest patch when it changes
 
  
 
  RdfdbSyncedGraph=customElement("rdfdb-synced-graph")(class RdfdbSyncedGraph extends LitElement {
 
    /*@property()*/ graph: SyncedGraph;
 
    /*@property()*/ status: string;
 
    /*@property()*/ testGraph = false;
 
@customElement("rdfdb-synced-graph")
 
export class RdfdbSyncedGraph extends LitElement {
 
  @property() graph: SyncedGraph;
 
  @property() status: string;
 
  @property() testGraph = false;
 
    static styles = [
 
      css`
 
        :host {
 
          display: inline-block;
 
          border: 1px solid gray;
 
          min-width: 22em;
 
@@ -63,29 +65,24 @@ let RdfdbSyncedGraph
 
        (s: string) => {
 
          this.status = s;
 
        },
 
        this.onClear.bind(this),
 
        this.onGraphChanged.bind(this)
 
      );
 
      // (window as any).topSyncedGraph = this.graph;
 
      res(this.graph);
 
    setTopGraph(this.graph);
 
    }
 

	
 
    private onGraphChanged(graph: SyncedGraph, patch: Patch) {
 
      this.dispatchEvent(
 
        new GraphChangedEvent("changed", {
 
          detail: { graph, patch },
 
          bubbles: true,
 
          composed: true,
 
        })
 
      );
 
    }
 
  });
 
});
 
}
 

	
 

	
 
async function getTopGraph(): Promise<SyncedGraph> {
 
export async function getTopGraph(): Promise<SyncedGraph> {
 
  const s = (window as any).topSyncedGraph;
 
  return await s;
 
}
 

	
 
export { RdfdbSyncedGraph, getTopGraph };
 
\ No newline at end of file
0 comments (0 inline, 0 general)