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