Mercurial > code > home > repos > streamed-graph
annotate src/render/GraphView.ts @ 107:042bd3361339
renames
author | drewp@bigasterisk.com |
---|---|
date | Sun, 13 Mar 2022 22:02:30 -0700 |
parents | src/render/graph_view.ts@2468f2227d22 |
children | 5e6840229a05 |
rev | line source |
---|---|
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
1 import { html, TemplateResult } from "lit"; |
97 | 2 import { DataFactory, Literal, NamedNode, Quad, Store, Term } from "n3"; |
96 | 3 import { NodeDisplay } from "./NodeDisplay"; |
106
2468f2227d22
make src/layout/ and src/render/ separation
drewp@bigasterisk.com
parents:
97
diff
changeset
|
4 import { SuffixLabels } from "../layout/suffixLabels"; |
2468f2227d22
make src/layout/ and src/render/ separation
drewp@bigasterisk.com
parents:
97
diff
changeset
|
5 import { Layout } from "../layout/Layout"; |
2468f2227d22
make src/layout/ and src/render/ separation
drewp@bigasterisk.com
parents:
97
diff
changeset
|
6 import { TableDesc, ViewConfig } from "../layout/ViewConfig"; |
76 | 7 |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
8 const { namedNode } = DataFactory; |
20
9ec3cbc8791a
build is running, but no tests, and lots of code is disabled
drewp@bigasterisk.com
parents:
15
diff
changeset
|
9 |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
10 // https://github.com/rdfjs/N3.js/issues/265 |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
11 if ((Literal.prototype as any).hashCode === undefined) { |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
12 (Literal.prototype as any).hashCode = () => 0; |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
13 } |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
14 if ((NamedNode.prototype as any).hashCode === undefined) { |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
15 (NamedNode.prototype as any).hashCode = () => 0; |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
16 } |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
17 export class GraphView { |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
18 url: string; |
93
955cde1550c3
start the View work: parse view document
drewp@bigasterisk.com
parents:
88
diff
changeset
|
19 view: View; |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
20 graph: Store; |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
21 nodeDisplay: NodeDisplay; |
93
955cde1550c3
start the View work: parse view document
drewp@bigasterisk.com
parents:
88
diff
changeset
|
22 constructor(url: string, viewUrl: string, graph: Store) { |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
23 this.url = url; |
93
955cde1550c3
start the View work: parse view document
drewp@bigasterisk.com
parents:
88
diff
changeset
|
24 this.view = new View(viewUrl); |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
25 this.graph = graph; |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
26 |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
27 const labels = new SuffixLabels(); |
97 | 28 this._addLabelsForAllTerms(this.graph, labels); |
29 | |
107 | 30 this.view.ready.then(() => { |
97 | 31 this._addLabelsForAllTerms(this.view.graph, labels); |
107 | 32 }); |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
33 this.nodeDisplay = new NodeDisplay(labels); |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
34 } |
8
6fefd287aff9
closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff
changeset
|
35 |
97 | 36 _addLabelsForAllTerms(graph: Store, labels: SuffixLabels) { |
37 graph.forEach( | |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
38 (q: Quad) => { |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
39 if (q.subject.termType === "NamedNode") { |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
40 labels.planDisplayForNode(q.subject); |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
41 } |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
42 if (q.predicate.termType === "NamedNode") { |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
43 labels.planDisplayForNode(q.predicate); |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
44 } |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
45 if (q.object.termType === "NamedNode") { |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
46 labels.planDisplayForNode(q.object); |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
47 } |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
48 if (q.object.termType === "Literal" && q.object.datatype) { |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
49 labels.planDisplayForNode(q.object.datatype); |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
50 } |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
51 }, |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
52 null, |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
53 null, |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
54 null, |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
55 null |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
56 ); |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
57 } |
8
6fefd287aff9
closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff
changeset
|
58 |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
59 _subjPredObjsBlock(subj: NamedNode) { |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
60 const columns = predsForSubj(this.graph, subj); |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
61 return html` |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
62 <div class="subject"> |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
63 ${this.nodeDisplay.render(subj)} |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
64 <!-- todo: special section for uri/type-and-icon/label/comment --> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
65 <div> |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
66 ${columns.map((p) => { |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
67 return this._predObjsBlock(subj, p); |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
68 })} |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
69 </div> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
70 </div> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
71 `; |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
72 } |
8
6fefd287aff9
closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff
changeset
|
73 |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
74 _objCell(obj: Term) { |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
75 return html` |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
76 <div class="object"> |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
77 ${this.nodeDisplay.render(obj)} |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
78 <!-- indicate what source or graph said this stmt --> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
79 </div> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
80 `; |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
81 } |
8
6fefd287aff9
closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff
changeset
|
82 |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
83 _predObjsBlock(subj: NamedNode, pred: NamedNode) { |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
84 const objsSet = new Set<Term>(); |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
85 this.graph.forEach( |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
86 (q: Quad) => { |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
87 objsSet.add(q.object); |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
88 }, |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
89 subj, |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
90 pred, |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
91 null, |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
92 null |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
93 ); |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
94 const objs = Array.from(objsSet.values()); |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
95 objs.sort(); |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
96 return html` |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
97 <div class="predicate"> |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
98 ${this.nodeDisplay.render(pred)} |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
99 <div>${objs.map(this._objCell.bind(this))}</div> |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
100 </div> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
101 `; |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
102 } |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
103 |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
104 _drawObj(obj: Term): TemplateResult { |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
105 return html` <div>${this.nodeDisplay.render(obj)}</div> `; |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
106 } |
8
6fefd287aff9
closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff
changeset
|
107 |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
108 _drawColumnHead(pred: NamedNode): TemplateResult { |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
109 return html` <th>${this.nodeDisplay.render(pred)}</th> `; |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
110 } |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
111 |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
112 _thead(layout: MultiSubjsTypeBlockLayout): TemplateResult { |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
113 return html` |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
114 <thead> |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
115 <tr> |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
116 <th></th> |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
117 ${layout.preds.map(this._drawColumnHead.bind(this))} |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
118 </tr> |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
119 </thead> |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
120 `; |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
121 } |
49 | 122 |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
123 _msbCell(layout: MultiSubjsTypeBlockLayout, subj: NamedNode) { |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
124 return (pred: NamedNode): TemplateResult => { |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
125 const objs = layout.graphCells.get(layout.makeCellKey(subj, pred)); |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
126 if (!objs || !objs.size) { |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
127 return html` <td></td> `; |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
128 } |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
129 const objsList = Array.from(objs); |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
130 objsList.sort(); |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
131 return html` <td>${objsList.map(this._drawObj.bind(this))}</td> `; |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
132 }; |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
133 } |
8
6fefd287aff9
closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff
changeset
|
134 |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
135 _instanceRow(layout: MultiSubjsTypeBlockLayout) { |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
136 return (subj: NamedNode): TemplateResult => { |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
137 return html` |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
138 <tr> |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
139 <td>${this.nodeDisplay.render(subj)}</td> |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
140 ${layout.preds.map(this._msbCell(layout, subj))} |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
141 </tr> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
142 `; |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
143 }; |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
144 } |
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
145 |
97 | 146 _multiSubjsTypeBlock(byType: TypeToSubjs, table: TableDesc) { |
147 const layout = new MultiSubjsTypeBlockLayout(this.graph, byType, table); | |
148 | |
149 let typeNames = [html`${this.nodeDisplay.render(table.primary)}`]; | |
150 if (table.joins) { | |
151 typeNames.push(html` joined with [`); | |
152 for (let j of table.joins) { | |
153 typeNames.push(html`${this.nodeDisplay.render(j)}`); | |
154 } | |
155 typeNames.push(html`]`); | |
156 } | |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
157 |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
158 return html` |
97 | 159 <div>[icon] Resources of type ${typeNames}</div> |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
160 <div class="typeBlockScroll"> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
161 <table class="typeBlock"> |
107 | 162 ${this._thead(layout)} |
163 ${layout.subjs.map(this._instanceRow(layout))} | |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
164 </table> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
165 </div> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
166 `; |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
167 } |
49 | 168 |
93
955cde1550c3
start the View work: parse view document
drewp@bigasterisk.com
parents:
88
diff
changeset
|
169 async makeTemplate(): Promise<TemplateResult> { |
955cde1550c3
start the View work: parse view document
drewp@bigasterisk.com
parents:
88
diff
changeset
|
170 await this.view.ready; |
94 | 171 const { byType, typesPresent, untypedSubjs } = groupByRdfType(this.graph); |
93
955cde1550c3
start the View work: parse view document
drewp@bigasterisk.com
parents:
88
diff
changeset
|
172 let viewTitle = html` (no view)`; |
955cde1550c3
start the View work: parse view document
drewp@bigasterisk.com
parents:
88
diff
changeset
|
173 if (this.view.url) { |
97 | 174 viewTitle = html` using view |
175 <a href="${this.view.url}">${this.view.label()}</a>`; | |
93
955cde1550c3
start the View work: parse view document
drewp@bigasterisk.com
parents:
88
diff
changeset
|
176 } |
97 | 177 const tables = this.view.toplevelTables(typesPresent); |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
178 return html` |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
179 <section> |
93
955cde1550c3
start the View work: parse view document
drewp@bigasterisk.com
parents:
88
diff
changeset
|
180 <h2> |
955cde1550c3
start the View work: parse view document
drewp@bigasterisk.com
parents:
88
diff
changeset
|
181 Current graph (<a href="${this.url}">${this.url}</a>)${viewTitle} |
955cde1550c3
start the View work: parse view document
drewp@bigasterisk.com
parents:
88
diff
changeset
|
182 </h2> |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
183 <div> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
184 <!-- todo: graphs and provenance. |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
185 These statements are all in the |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
186 <span data-bind="html: $root.createCurie(graphUri())">...</span> graph.--> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
187 </div> |
97 | 188 ${tables.map((t: TableDesc) => this._multiSubjsTypeBlock(byType, t))} |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
189 <div class="spoGrid"> |
88
ac7ad087d474
graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents:
84
diff
changeset
|
190 ${untypedSubjs.map(this._subjPredObjsBlock.bind(this))} |
84
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
191 </div> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
192 </section> |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
193 `; |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
194 } |
067d66a45a51
enable more code. factor out setGraphView
drewp@bigasterisk.com
parents:
79
diff
changeset
|
195 } |