annotate src/render/graph_view.ts @ 106:2468f2227d22

make src/layout/ and src/render/ separation
author drewp@bigasterisk.com
date Sun, 13 Mar 2022 22:00:30 -0700
parents src/graph_view.ts@26c55d5d5202
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
2 import { DataFactory, Literal, NamedNode, Quad, Store, Term } from "n3";
96
4d19759d0d9a factor NodeDisplay
drewp@bigasterisk.com
parents: 94
diff changeset
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
58676ebdce0f sort and dedup imports
drewp@bigasterisk.com
parents: 71
diff changeset
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
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
28 this._addLabelsForAllTerms(this.graph, labels);
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
29
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
30 if (this.view.graph) {
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
31 this._addLabelsForAllTerms(this.view.graph, labels);
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
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
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
36 _addLabelsForAllTerms(graph: Store, labels: SuffixLabels) {
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
37 console.log("_addLabelsForAllTerms");
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
38
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
39 graph.forEach(
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
40 (q: Quad) => {
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
41 if (q.subject.termType === "NamedNode") {
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
42 labels.planDisplayForNode(q.subject);
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
43 }
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
44 if (q.predicate.termType === "NamedNode") {
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
45 labels.planDisplayForNode(q.predicate);
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
46 }
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
47 if (q.object.termType === "NamedNode") {
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
48 labels.planDisplayForNode(q.object);
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
49 }
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
50 if (q.object.termType === "Literal" && q.object.datatype) {
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
51 labels.planDisplayForNode(q.object.datatype);
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
52 }
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
53 },
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 null,
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
57 null
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 }
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
60
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
61 _subjPredObjsBlock(subj: NamedNode) {
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
62 const columns = predsForSubj(this.graph, subj);
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
63 return html`
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
64 <div class="subject">
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
65 ${this.nodeDisplay.render(subj)}
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
66 <!-- todo: special section for uri/type-and-icon/label/comment -->
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
67 <div>
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
68 ${columns.map((p) => {
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
69 return this._predObjsBlock(subj, p);
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
70 })}
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
71 </div>
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
72 </div>
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
73 `;
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
74 }
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
75
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
76 _objCell(obj: Term) {
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
77 return html`
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
78 <div class="object">
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
79 ${this.nodeDisplay.render(obj)}
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
80 <!-- indicate what source or graph said this stmt -->
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
81 </div>
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
82 `;
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
83 }
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
84
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
85 _predObjsBlock(subj: NamedNode, pred: NamedNode) {
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
86 const objsSet = new Set<Term>();
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
87 this.graph.forEach(
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
88 (q: Quad) => {
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
89 objsSet.add(q.object);
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
90 },
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
91 subj,
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
92 pred,
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
93 null,
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
94 null
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 const objs = Array.from(objsSet.values());
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
97 objs.sort();
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
98 return html`
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
99 <div class="predicate">
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
100 ${this.nodeDisplay.render(pred)}
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
101 <div>${objs.map(this._objCell.bind(this))}</div>
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
102 </div>
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
103 `;
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
104 }
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
105
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
106 _drawObj(obj: Term): TemplateResult {
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
107 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
108 }
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
109
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
110 _drawColumnHead(pred: NamedNode): TemplateResult {
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
111 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
112 }
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
113
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
114 _thead(layout: MultiSubjsTypeBlockLayout): TemplateResult {
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
115 return html`
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
116 <thead>
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
117 <tr>
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
118 <th></th>
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
119 ${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
120 </tr>
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 `;
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
123 }
49
c16a331f42e5 rewrap; stylesheet
drewp@bigasterisk.com
parents: 40
diff changeset
124
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
125 _msbCell(layout: MultiSubjsTypeBlockLayout, subj: NamedNode) {
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
126 return (pred: NamedNode): TemplateResult => {
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
127 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
128 if (!objs || !objs.size) {
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
129 return html` <td></td> `;
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
130 }
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
131 const objsList = Array.from(objs);
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
132 objsList.sort();
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
133 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
134 };
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
135 }
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
136
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
137 _instanceRow(layout: MultiSubjsTypeBlockLayout) {
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
138 return (subj: NamedNode): TemplateResult => {
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
139 return html`
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
140 <tr>
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
141 <td>${this.nodeDisplay.render(subj)}</td>
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
142 ${layout.preds.map(this._msbCell(layout, subj))}
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
143 </tr>
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
144 `;
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
145 };
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
146 }
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
147
97
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
148 _multiSubjsTypeBlock(byType: TypeToSubjs, table: TableDesc) {
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
149 const layout = new MultiSubjsTypeBlockLayout(this.graph, byType, table);
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
150
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
151 let typeNames = [html`${this.nodeDisplay.render(table.primary)}`];
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
152 if (table.joins) {
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
153 typeNames.push(html` joined with [`);
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
154 for (let j of table.joins) {
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
155 typeNames.push(html`${this.nodeDisplay.render(j)}`);
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
156 }
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
157 typeNames.push(html`]`);
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
158 }
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
159
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
160 return html`
97
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
161 <div>[icon] Resources of type ${typeNames}</div>
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
162 <div class="typeBlockScroll">
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
163 <table class="typeBlock">
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
164 ${this._thead(layout)} ${layout.subjs.map(this._instanceRow(layout))}
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
165 </table>
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
166 </div>
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
167 `;
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
168 }
49
c16a331f42e5 rewrap; stylesheet
drewp@bigasterisk.com
parents: 40
diff changeset
169
93
955cde1550c3 start the View work: parse view document
drewp@bigasterisk.com
parents: 88
diff changeset
170 async makeTemplate(): Promise<TemplateResult> {
955cde1550c3 start the View work: parse view document
drewp@bigasterisk.com
parents: 88
diff changeset
171 await this.view.ready;
94
a5f53d397526 view: pick types to show at top-level
drewp@bigasterisk.com
parents: 93
diff changeset
172 const { byType, typesPresent, untypedSubjs } = groupByRdfType(this.graph);
93
955cde1550c3 start the View work: parse view document
drewp@bigasterisk.com
parents: 88
diff changeset
173 let viewTitle = html` (no view)`;
955cde1550c3 start the View work: parse view document
drewp@bigasterisk.com
parents: 88
diff changeset
174 if (this.view.url) {
97
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
175 viewTitle = html` using view
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
176 <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
177 }
97
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
178 const tables = this.view.toplevelTables(typesPresent);
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
179 return html`
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
180 <section>
93
955cde1550c3 start the View work: parse view document
drewp@bigasterisk.com
parents: 88
diff changeset
181 <h2>
955cde1550c3 start the View work: parse view document
drewp@bigasterisk.com
parents: 88
diff changeset
182 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
183 </h2>
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
184 <div>
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
185 <!-- todo: graphs and provenance.
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
186 These statements are all in the
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
187 <span data-bind="html: $root.createCurie(graphUri())">...</span> graph.-->
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
188 </div>
97
26c55d5d5202 WIP on views & joins
drewp@bigasterisk.com
parents: 96
diff changeset
189 ${tables.map((t: TableDesc) => this._multiSubjsTypeBlock(byType, t))}
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
190 <div class="spoGrid">
88
ac7ad087d474 graph view rewrites and fixes for the multi-subject table
drewp@bigasterisk.com
parents: 84
diff changeset
191 ${untypedSubjs.map(this._subjPredObjsBlock.bind(this))}
84
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
192 </div>
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
193 </section>
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 }
067d66a45a51 enable more code. factor out setGraphView
drewp@bigasterisk.com
parents: 79
diff changeset
196 }