annotate src/graph_view.ts @ 13:b9f451791f3a

refactor and update jsonldquads. WIP
author drewp@localhost
date Fri, 06 Dec 2019 20:33:36 -0800
parents 26d3e4860adc
children 7ca4ff2088c3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
1 // from /my/site/homepage/www/rdf/browse/graphView.js
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
2
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
3 /// <reference types="./n3.d.ts">
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
4
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
5 import { html } from 'lit-html';
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
6 import { SuffixLabels } from './suffixLabels';
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
7
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
8 import { NamedNode, N3Store } from 'n3';
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
10 import ns from 'n3/src/IRIs';
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
11 const {rdf} = ns;
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
12
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
13 const groupByRdfType = (graph: N3Store) => {
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
14 const rdfType = new NamedNode(rdf.type);
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
15 const byType: Map<NamedNode, Set<NamedNode>> = new Map(); // type : subjs
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
16 const untyped = new Set(); // subjs
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
17 graph.getQuads({}, (q) => {
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
18 let subjType = null;
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
19 graph.getQuads({
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
20 subject: q.subject,
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
21 predicate: rdfType
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
22 },
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
23 (q2) => { subjType = q2.object; });
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
24 if (subjType) {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
25 subjType = subjType.toString();
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
26 if (!byType.has(subjType)) {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
27 byType.set(subjType, new Set());
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
28 }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
29 byType.get(subjType).add(q.subject.toString());
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
30 } else {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
31 untyped.add(q.subject.toString());
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
32 }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
33
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
34 });
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
35 return { byType: byType, untyped: untyped };
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
36 };
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
37
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
38 const graphView = (graph: N3Store) => {
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
39 const labels = new SuffixLabels();
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
40 graph.getQuads({}, (q) => {
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
41 if (q.subject.interfaceName == "NamedNode") { labels.planDisplayForNode(q.subject); }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
42 if (q.predicate.interfaceName == "NamedNode") { labels.planDisplayForNode(q.predicate); }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
43 if (q.object.interfaceName == "NamedNode") { labels.planDisplayForNode(q.object); }
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
44 if (q.object.interfaceName == "Literal" && q.object.datatype) { labels.planDisplayForNode(new NamedNode(q.object.datatype)); }
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
45 });
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
46
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
47 const rdfNode = (n) => {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
48 if (n.interfaceName == "Literal") {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
49 let dtPart: any = "";
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
50 if (n.datatype) {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
51 dtPart = html`
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
52 ^^<span class="literalType">
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
53 ${rdfNode(new NamedNode(n.datatype))}
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
54 </span>`;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
55 }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
56 return html`<span class="literal">${n.nominalValue}${dtPart}</span>`;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
57 }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
58 if (n.interfaceName == "NamedNode") {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
59 let dn = labels.getLabelForNode(n);
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
60 if (dn.match(/XMLSchema#.*/)) { dn = dn.replace('XMLSchema#', 'xsd:'); }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
61 if (dn.match(/rdf-schema#.*/)) { dn = dn.replace('rdf-schema#', 'rdfs:'); }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
62 return html`<a class="graphUri" href="${n.toString()}">${dn}</a>`;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
63 }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
64
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
65 return html`[${n.interfaceName} ${n.toNT()}]`;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
66 }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
67
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
68 const objBlock = (obj) => {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
69 return html`
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
70 <div class="object">
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
71 ${rdfNode(obj)} <!-- indicate what source or graph said this stmt -->
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
72 </div>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
73 `;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
74 };
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
75
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
76 /// bunch of table rows
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
77 const predBlock = (subj, pred) => {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
78 const objsSet = new Set();
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
79 graph.getQuads({ subject: subj, predicate: pred }, (q) => {
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
80
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
81 if (q.object.length) {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
82 console.log(q.object)
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
83 }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
84 objsSet.add(q.object);
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
85 });
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
86 const objs = Array.from(objsSet.values());
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
87 objs.sort();
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
88 return html`
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
89 <div class="predicate">${rdfNode(pred)}
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
90 <div>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
91 ${objs.map(objBlock)}
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
92 </div>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
93 </div>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
94 `;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
95 };
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
96
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
97 const { byType, untyped } = groupByRdfType(graph);
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
98 const typedSubjs = Array.from(byType.keys());
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
99 typedSubjs.sort();
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
100
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
101 const untypedSubjs = Array.from(untyped.values());
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
102 untypedSubjs.sort();
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
103
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
104 const subjBlock = (subj) => {
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
105 const subjNode = new NamedNode(subj);
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
106 const predsSet = new Set();
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
107 graph.getQuads({ subject: subjNode }, (q) => {
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
108 predsSet.add(q.predicate);
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
109 });
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
110 const preds = Array.from(predsSet.values());
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
111 preds.sort();
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
112 return html`
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
113 <div class="subject">${rdfNode(subjNode)}
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
114 <!-- todo: special section for uri/type-and-icon/label/comment -->
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
115 <div>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
116 ${preds.map((p) => { return predBlock(subjNode, p); })}
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
117 </div>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
118 </div>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
119 `;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
120 };
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
121 const byTypeBlock = (typeUri) => {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
122 const subjs = Array.from(byType.get(typeUri));
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
123 subjs.sort();
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
124
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
125 const graphCells = new Map(); // [subj, pred] : objs
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
126 const preds = new Set();
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
127
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
128 subjs.forEach((subj) => {
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
129 graph.getQuads({ subject: new NamedNode(subj) }, (q) => {
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
130 preds.add(q.predicate.toString());
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
131 const cellKey = subj + '|||' + q.predicate.toString();
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
132 if (!graphCells.has(cellKey)) {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
133 graphCells.set(cellKey, new Set());
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
134 }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
135 graphCells.get(cellKey).add(q.object);
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
136 });
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
137 });
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
138 const predsList = Array.from(preds);
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
139 predsList.splice(predsList.indexOf('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), 1);
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
140 // also pull out label, which should be used on 1st column
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
141 predsList.sort();
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
142
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
143 const thead = () => {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
144 const predColumnHead = (pred) => {
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
145 return html`<th>${rdfNode(new NamedNode(pred))}</th>`;
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
146 };
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
147 return html`
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
148 <thead>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
149 <tr>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
150 <th></th>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
151 ${predsList.map(predColumnHead)}
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
152 </tr>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
153 </thead>`;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
154 };
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
155
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
156 const instanceRow = (subj) => {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
157 const cell = (pred) => {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
158 const objs = graphCells.get(subj + '|||' + pred);
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
159 if (!objs) {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
160 return html`<td></td>`;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
161 }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
162 const objsList = Array.from(objs);
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
163 objsList.sort();
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
164 const draw = (obj) => {
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
165 return html`<div>${rdfNode(obj)}</div>`
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
166 };
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
167 return html`<td>${objsList.map(draw)}</td>`;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
168 };
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
169
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
170 return html`
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
171 <tr>
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
172 <td>${rdfNode(new NamedNode(subj))}</td>
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
173 ${predsList.map(cell)}
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
174 </tr>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
175 `;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
176 };
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
177
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
178 return html`
9
26d3e4860adc working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents: 8
diff changeset
179 <div>[icon] ${rdfNode(new NamedNode(typeUri))} resources</div>
8
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
180 <div class="typeBlockScroll">
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
181 <table class="typeBlock">
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
182 ${thead()}
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
183 ${subjs.map(instanceRow)}
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
184 </table>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
185 </div>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
186 `;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
187 };
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
188
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
189 return html`
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
190 <link rel="stylesheet" href="/rdf/browse/style.css">
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
191
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
192 <section>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
193 <h2>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
194 Current graph (<a href="${graph.events.url}">${graph.events.url}</a>)
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
195 </h2>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
196 <div>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
197 <!-- todo: graphs and provenance.
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
198 These statements are all in the
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
199 <span data-bind="html: $root.createCurie(graphUri())">...</span> graph.-->
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
200 </div>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
201 ${typedSubjs.map(byTypeBlock)}
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
202 <div class="spoGrid">
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
203 ${untypedSubjs.map(subjBlock)}
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
204 </div>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
205 </section>
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
206 `;
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
207 }
6fefd287aff9 closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
diff changeset
208 export { graphView }