Mercurial > code > home > repos > light9
annotate web/RdfdbSyncedGraph.ts @ 2376:4556eebe5d73
topdir reorgs; let pdm have its src/ dir; separate vite area from light9/
author | drewp@bigasterisk.com |
---|---|
date | Sun, 12 May 2024 19:02:10 -0700 |
parents | light9/web/RdfdbSyncedGraph.ts@06bf6dae8e64 |
children | f2b3cfcc23d3 |
rev | line source |
---|---|
2074
1a96f8647126
big graph & autodep porting to make collector display labels from a syncedgraph
drewp@bigasterisk.com
parents:
1905
diff
changeset
|
1 import debug from "debug"; |
2268 | 2 import { LitElement, css, html } from "lit"; |
2074
1a96f8647126
big graph & autodep porting to make collector display labels from a syncedgraph
drewp@bigasterisk.com
parents:
1905
diff
changeset
|
3 import { customElement, property } from "lit/decorators.js"; |
1a96f8647126
big graph & autodep porting to make collector display labels from a syncedgraph
drewp@bigasterisk.com
parents:
1905
diff
changeset
|
4 import { SyncedGraph } from "./SyncedGraph"; |
1a96f8647126
big graph & autodep porting to make collector display labels from a syncedgraph
drewp@bigasterisk.com
parents:
1905
diff
changeset
|
5 |
1a96f8647126
big graph & autodep porting to make collector display labels from a syncedgraph
drewp@bigasterisk.com
parents:
1905
diff
changeset
|
6 const log = debug("syncedgraph-el"); |
1a96f8647126
big graph & autodep porting to make collector display labels from a syncedgraph
drewp@bigasterisk.com
parents:
1905
diff
changeset
|
7 |
2268 | 8 // Contains a SyncedGraph. Displays as little status box. |
9 // Put one element on your page and use getTopGraph everywhere. | |
2075 | 10 @customElement("rdfdb-synced-graph") |
11 export class RdfdbSyncedGraph extends LitElement { | |
12 @property() graph: SyncedGraph; | |
13 @property() status: string; | |
14 @property() testGraph = false; | |
15 static styles = [ | |
16 css` | |
17 :host { | |
18 display: inline-block; | |
19 border: 1px solid gray; | |
20 min-width: 22em; | |
21 background: #05335a; | |
22 color: #4fc1d4; | |
23 } | |
24 `, | |
25 ]; | |
26 render() { | |
27 return html`graph: ${this.status}`; | |
28 } | |
2074
1a96f8647126
big graph & autodep porting to make collector display labels from a syncedgraph
drewp@bigasterisk.com
parents:
1905
diff
changeset
|
29 |
2075 | 30 constructor() { |
31 super(); | |
32 this.status = "startup"; | |
2087 | 33 const prefixes = new Map<string, string>([ |
34 ["", "http://light9.bigasterisk.com/"], | |
35 ["dev", "http://light9.bigasterisk.com/device/"], | |
2270
b51c74da9d35
more cleanup- mixed up with other commits
drewp@bigasterisk.com
parents:
2268
diff
changeset
|
36 ["effect", "http://light9.bigasterisk.com/effect/"], |
2087 | 37 ["rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"], |
38 ["rdfs", "http://www.w3.org/2000/01/rdf-schema#"], | |
39 ["xsd", "http://www.w3.org/2001/XMLSchema#"], | |
40 ]); | |
2075 | 41 this.graph = new SyncedGraph( |
2372
06bf6dae8e64
reorg tools into light9/web/ and a single vite instance
drewp@bigasterisk.com
parents:
2270
diff
changeset
|
42 this.testGraph ? "unused" : "/service/rdfdb/syncedGraph", |
2087 | 43 prefixes, |
2075 | 44 (s: string) => { |
45 this.status = s; | |
2268 | 46 } |
2075 | 47 ); |
48 setTopGraph(this.graph); | |
49 } | |
50 } | |
51 | |
2268 | 52 // todo: consider if this has anything to contribute: |
53 // https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/context.md | |
54 let setTopGraph: (sg: SyncedGraph) => void; | |
55 (window as any).topSyncedGraph = new Promise<SyncedGraph>((res, rej) => { | |
56 setTopGraph = res; | |
57 }); | |
58 | |
2075 | 59 export async function getTopGraph(): Promise<SyncedGraph> { |
2074
1a96f8647126
big graph & autodep porting to make collector display labels from a syncedgraph
drewp@bigasterisk.com
parents:
1905
diff
changeset
|
60 const s = (window as any).topSyncedGraph; |
1a96f8647126
big graph & autodep porting to make collector display labels from a syncedgraph
drewp@bigasterisk.com
parents:
1905
diff
changeset
|
61 return await s; |
1a96f8647126
big graph & autodep porting to make collector display labels from a syncedgraph
drewp@bigasterisk.com
parents:
1905
diff
changeset
|
62 } |