@myrmidon/cadmus-graph-ui-ex 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/esm2020/lib/cadmus-graph-ui-ex.module.mjs +132 -0
- package/esm2020/lib/components/graph-walker/graph-walker.component.mjs +119 -0
- package/esm2020/lib/components/linked-literal-filter/linked-literal-filter.component.mjs +141 -0
- package/esm2020/lib/components/linked-node-filter/linked-node-filter.component.mjs +178 -0
- package/esm2020/lib/components/triple-filter/triple-filter.component.mjs +219 -0
- package/esm2020/lib/graph-walker.mjs +725 -0
- package/esm2020/lib/pipes/graph-node-label.pipe.mjs +29 -0
- package/esm2020/lib/services/graph-node-lookup.service.mjs +42 -0
- package/esm2020/lib/services/graph.service.mjs +343 -0
- package/esm2020/myrmidon-cadmus-graph-ui-ex.mjs +5 -0
- package/esm2020/public-api.mjs +13 -0
- package/fesm2015/myrmidon-cadmus-graph-ui-ex.mjs +1884 -0
- package/fesm2015/myrmidon-cadmus-graph-ui-ex.mjs.map +1 -0
- package/fesm2020/myrmidon-cadmus-graph-ui-ex.mjs +1876 -0
- package/fesm2020/myrmidon-cadmus-graph-ui-ex.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/cadmus-graph-ui-ex.module.d.ts +31 -0
- package/lib/components/graph-walker/graph-walker.component.d.ts +57 -0
- package/lib/components/linked-literal-filter/linked-literal-filter.component.d.ts +58 -0
- package/lib/components/linked-node-filter/linked-node-filter.component.d.ts +62 -0
- package/lib/components/triple-filter/triple-filter.component.d.ts +68 -0
- package/lib/graph-walker.d.ts +251 -0
- package/lib/pipes/graph-node-label.pipe.d.ts +13 -0
- package/lib/services/graph-node-lookup.service.d.ts +20 -0
- package/lib/services/graph.service.d.ts +200 -0
- package/package.json +43 -0
- package/public-api.d.ts +9 -0
|
@@ -0,0 +1,1884 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, EventEmitter, Component, Input, Output, Pipe, NgModule } from '@angular/core';
|
|
3
|
+
import { BehaviorSubject, forkJoin, of, map, from, Subject, take as take$1 } from 'rxjs';
|
|
4
|
+
import { take, retry, catchError } from 'rxjs/operators';
|
|
5
|
+
import * as i1 from '@angular/common/http';
|
|
6
|
+
import { HttpParams, HttpClientModule } from '@angular/common/http';
|
|
7
|
+
import * as i2 from '@myrmidon/ng-tools';
|
|
8
|
+
import { NgToolsModule } from '@myrmidon/ng-tools';
|
|
9
|
+
import * as i2$1 from '@myrmidon/ng-mat-tools';
|
|
10
|
+
import { NgMatToolsModule } from '@myrmidon/ng-mat-tools';
|
|
11
|
+
import * as i4 from '@angular/common';
|
|
12
|
+
import { CommonModule } from '@angular/common';
|
|
13
|
+
import * as i5 from '@angular/material/button';
|
|
14
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
15
|
+
import * as i7 from '@angular/material/icon';
|
|
16
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
17
|
+
import * as i6$1 from '@angular/material/progress-bar';
|
|
18
|
+
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
19
|
+
import * as i7$2 from '@angular/material/tabs';
|
|
20
|
+
import { MatTabsModule } from '@angular/material/tabs';
|
|
21
|
+
import * as i10 from '@angular/material/tooltip';
|
|
22
|
+
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
23
|
+
import * as i9$1 from '@swimlane/ngx-graph';
|
|
24
|
+
import { NgxGraphModule } from '@swimlane/ngx-graph';
|
|
25
|
+
import * as i1$1 from '@angular/forms';
|
|
26
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
27
|
+
import * as i6 from '@angular/material/form-field';
|
|
28
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
29
|
+
import * as i8 from '@angular/material/input';
|
|
30
|
+
import { MatInputModule } from '@angular/material/input';
|
|
31
|
+
import * as i9 from '@angular/material/paginator';
|
|
32
|
+
import { MatPaginatorModule } from '@angular/material/paginator';
|
|
33
|
+
import * as i11 from '@myrmidon/cadmus-refs-lookup';
|
|
34
|
+
import { CadmusRefsLookupModule } from '@myrmidon/cadmus-refs-lookup';
|
|
35
|
+
import * as i5$1 from '@angular/material/core';
|
|
36
|
+
import * as i7$1 from '@angular/material/checkbox';
|
|
37
|
+
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
38
|
+
import * as i8$1 from '@angular/material/chips';
|
|
39
|
+
import { MatChipsModule } from '@angular/material/chips';
|
|
40
|
+
import * as i13 from '@angular/material/select';
|
|
41
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
42
|
+
import * as i10$1 from '@angular/material/list';
|
|
43
|
+
import { MatListModule } from '@angular/material/list';
|
|
44
|
+
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
/**
|
|
48
|
+
* Graph walker.
|
|
49
|
+
* This class encapsulates data used for interactively exploring a graph
|
|
50
|
+
* starting from a designated origin node.
|
|
51
|
+
*/
|
|
52
|
+
class GraphWalker {
|
|
53
|
+
/**
|
|
54
|
+
* The nodes of the walker graph, which can represent nodes, literals,
|
|
55
|
+
* or property groups. You can easily determine the type of each node
|
|
56
|
+
* by looking at the first character of its id (N=node, L=literal,
|
|
57
|
+
* P=property).
|
|
58
|
+
*/
|
|
59
|
+
get nodes$() {
|
|
60
|
+
return this._nodes$.asObservable();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The edges connecting nodes.
|
|
64
|
+
*/
|
|
65
|
+
get edges$() {
|
|
66
|
+
return this._edges$.asObservable();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* True if the walker is loading data.
|
|
70
|
+
*/
|
|
71
|
+
get loading$() {
|
|
72
|
+
return this._loading$.asObservable();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The last error occurred in communicating with the server, if any.
|
|
76
|
+
*/
|
|
77
|
+
get error$() {
|
|
78
|
+
return this._error$.asObservable();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The selected node. Only one node at a time can be selected.
|
|
82
|
+
*/
|
|
83
|
+
get selectedNode$() {
|
|
84
|
+
return this._selectedNode$.asObservable();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The outbound linked nodes filter for the selected P node.
|
|
88
|
+
*/
|
|
89
|
+
get pOutFilter$() {
|
|
90
|
+
return this._pOutFilter$.asObservable();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The inbound linked nodes filter for the selected P node.
|
|
94
|
+
*/
|
|
95
|
+
get pInFilter$() {
|
|
96
|
+
return this._pInFilter$.asObservable();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The literal linked nodes filter for the selected P node.
|
|
100
|
+
*/
|
|
101
|
+
get pLitFilter$() {
|
|
102
|
+
return this._pLitFilter$.asObservable();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The outbound triples filter for the selected N node.
|
|
106
|
+
*/
|
|
107
|
+
get nOutFilter$() {
|
|
108
|
+
return this._nOutFilter$.asObservable();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The inbound triples filter for the selected N node.
|
|
112
|
+
*/
|
|
113
|
+
get nInFilter$() {
|
|
114
|
+
return this._nInFilter$.asObservable();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The total items fetched for each filter of the selected node.
|
|
118
|
+
*/
|
|
119
|
+
get childTotals$() {
|
|
120
|
+
return this._childTotals$.asObservable();
|
|
121
|
+
}
|
|
122
|
+
constructor(_graphService) {
|
|
123
|
+
this._graphService = _graphService;
|
|
124
|
+
this._nodes$ = new BehaviorSubject([]);
|
|
125
|
+
this._edges$ = new BehaviorSubject([]);
|
|
126
|
+
this._loading$ = new BehaviorSubject(false);
|
|
127
|
+
this._error$ = new BehaviorSubject(null);
|
|
128
|
+
this._selectedNode$ = new BehaviorSubject(null);
|
|
129
|
+
this._pOutFilter$ = new BehaviorSubject(null);
|
|
130
|
+
this._pInFilter$ = new BehaviorSubject(null);
|
|
131
|
+
this._pLitFilter$ = new BehaviorSubject(null);
|
|
132
|
+
this._nOutFilter$ = new BehaviorSubject(null);
|
|
133
|
+
this._nInFilter$ = new BehaviorSubject(null);
|
|
134
|
+
this._childTotals$ = new BehaviorSubject({
|
|
135
|
+
nOut: 0,
|
|
136
|
+
nIn: 0,
|
|
137
|
+
pOut: 0,
|
|
138
|
+
pIn: 0,
|
|
139
|
+
pLit: 0,
|
|
140
|
+
});
|
|
141
|
+
// defaults
|
|
142
|
+
this.pageSize = 10;
|
|
143
|
+
this.maxLiteralLen = 30;
|
|
144
|
+
}
|
|
145
|
+
getSelectedNode() {
|
|
146
|
+
return this._selectedNode$.value;
|
|
147
|
+
}
|
|
148
|
+
toggleLoading(on) {
|
|
149
|
+
if (on) {
|
|
150
|
+
this._error$.next(null);
|
|
151
|
+
this._loading$.next(true);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
this._loading$.next(false);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
setError(error) {
|
|
158
|
+
if (error) {
|
|
159
|
+
if (typeof error === 'string') {
|
|
160
|
+
this._error$.next(error);
|
|
161
|
+
console.error(error);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
this._error$.next('Walker error');
|
|
165
|
+
console.error(JSON.stringify(error));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this._error$.next('Walker error');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
buildNodeId(id) {
|
|
173
|
+
return `N${id}`;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get the numeric ID of the data node being the source of the graph node
|
|
177
|
+
* with the specified ID.
|
|
178
|
+
*
|
|
179
|
+
* @param id The graph node ID (...N + its data node numeric ID)
|
|
180
|
+
* @returns The data node numeric ID.
|
|
181
|
+
*/
|
|
182
|
+
getNodeNumericId(id) {
|
|
183
|
+
const i = id.indexOf('N');
|
|
184
|
+
return i === -1 ? 0 : +id.substring(i + 1);
|
|
185
|
+
}
|
|
186
|
+
getPredicateNumericId(id) {
|
|
187
|
+
const i = id.indexOf('P');
|
|
188
|
+
const j = id.indexOf('N');
|
|
189
|
+
return i === -1 ? 0 : +id.substring(i + 1, j);
|
|
190
|
+
}
|
|
191
|
+
buildEdgeId(source, target) {
|
|
192
|
+
return `E${source}_${target}`;
|
|
193
|
+
}
|
|
194
|
+
buildPropertyId(predicateId, nodeId) {
|
|
195
|
+
return `P${predicateId}N${nodeId}`;
|
|
196
|
+
}
|
|
197
|
+
buildLiteralId(tripleId) {
|
|
198
|
+
return `L${tripleId}`;
|
|
199
|
+
}
|
|
200
|
+
scale(n, domainMin, domainMax, rangeMin, rangeMax) {
|
|
201
|
+
// https://stackoverflow.com/questions/5294955/how-to-scale-down-a-range-of-numbers-with-a-known-min-and-max-value
|
|
202
|
+
return (((domainMax - domainMin) * (n - rangeMin)) / (rangeMax - rangeMin) +
|
|
203
|
+
domainMin);
|
|
204
|
+
}
|
|
205
|
+
addEdgeIfAbsent(edge, edges) {
|
|
206
|
+
const id = edge.id;
|
|
207
|
+
if (edges.some((e) => e.id === id)) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const i = id.indexOf('_');
|
|
211
|
+
if (i > -1) {
|
|
212
|
+
const invId = 'E' + id.substring(i + 1) + '_' + id.substring(1, i);
|
|
213
|
+
if (edges.some((e) => e.id === invId)) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
edges.push(edge);
|
|
218
|
+
}
|
|
219
|
+
resetFilters() {
|
|
220
|
+
this._nOutFilter$.next(null);
|
|
221
|
+
this._nInFilter$.next(null);
|
|
222
|
+
this._pOutFilter$.next(null);
|
|
223
|
+
this._pInFilter$.next(null);
|
|
224
|
+
this._pLitFilter$.next(null);
|
|
225
|
+
this._childTotals$.next({
|
|
226
|
+
nOut: 0,
|
|
227
|
+
nIn: 0,
|
|
228
|
+
pOut: 0,
|
|
229
|
+
pIn: 0,
|
|
230
|
+
pLit: 0,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Select the specified node. This also implies updating all the current
|
|
235
|
+
* filters, which depend on the selected node.
|
|
236
|
+
*
|
|
237
|
+
* @param id The node ID or null to deselect the selected node.
|
|
238
|
+
*/
|
|
239
|
+
selectNode(id) {
|
|
240
|
+
const node = id ? this._nodes$.value.find((n) => n.id === id) : null;
|
|
241
|
+
if (!node) {
|
|
242
|
+
this._selectedNode$.next(null);
|
|
243
|
+
this.resetFilters();
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
// deselect
|
|
247
|
+
const old = this._nodes$.value.find((n) => { var _a; return (_a = n.data) === null || _a === void 0 ? void 0 : _a.selected; });
|
|
248
|
+
if (old) {
|
|
249
|
+
old.data.selected = undefined;
|
|
250
|
+
}
|
|
251
|
+
// select
|
|
252
|
+
node.data.selected = true;
|
|
253
|
+
this._selectedNode$.next(node);
|
|
254
|
+
switch (node.id.charAt(0)) {
|
|
255
|
+
case 'N': // non-literal node
|
|
256
|
+
const nd = node.data;
|
|
257
|
+
this._nOutFilter$.next(nd.outFilter);
|
|
258
|
+
this._nInFilter$.next(nd.inFilter);
|
|
259
|
+
this._pOutFilter$.next(null);
|
|
260
|
+
this._pInFilter$.next(null);
|
|
261
|
+
this._pLitFilter$.next(null);
|
|
262
|
+
this._childTotals$.next({
|
|
263
|
+
nOut: nd.outTotal || 0,
|
|
264
|
+
nIn: nd.inTotal || 0,
|
|
265
|
+
pOut: 0,
|
|
266
|
+
pIn: 0,
|
|
267
|
+
pLit: 0,
|
|
268
|
+
});
|
|
269
|
+
break;
|
|
270
|
+
case 'P': // props group
|
|
271
|
+
const pd = node.data;
|
|
272
|
+
this._nOutFilter$.next(null);
|
|
273
|
+
this._nInFilter$.next(null);
|
|
274
|
+
this._pOutFilter$.next(pd.outFilter);
|
|
275
|
+
this._pInFilter$.next(pd.inFilter);
|
|
276
|
+
this._pLitFilter$.next(pd.litFilter);
|
|
277
|
+
this._childTotals$.next({
|
|
278
|
+
nOut: 0,
|
|
279
|
+
nIn: 0,
|
|
280
|
+
pOut: pd.outTotal || 0,
|
|
281
|
+
pIn: pd.inTotal || 0,
|
|
282
|
+
pLit: pd.litTotal || 0,
|
|
283
|
+
});
|
|
284
|
+
break;
|
|
285
|
+
case 'L': // literal node
|
|
286
|
+
this.resetFilters();
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Reset the graph setting its origin to the specified node.
|
|
292
|
+
*
|
|
293
|
+
* @param id The ID of the origin node to start from ("root origin").
|
|
294
|
+
*/
|
|
295
|
+
reset(id) {
|
|
296
|
+
this.toggleLoading(true);
|
|
297
|
+
this._graphService
|
|
298
|
+
.getNode(id)
|
|
299
|
+
.pipe(take(1))
|
|
300
|
+
.subscribe({
|
|
301
|
+
next: (node) => {
|
|
302
|
+
const nodes = [];
|
|
303
|
+
const data = {
|
|
304
|
+
uri: node.uri,
|
|
305
|
+
sourceType: node.sourceType,
|
|
306
|
+
originId: '',
|
|
307
|
+
customColor: '#F89427',
|
|
308
|
+
outFilter: {
|
|
309
|
+
pageNumber: 1,
|
|
310
|
+
pageSize: this.pageSize,
|
|
311
|
+
},
|
|
312
|
+
inFilter: {
|
|
313
|
+
pageNumber: 1,
|
|
314
|
+
pageSize: this.pageSize,
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
const n = {
|
|
318
|
+
id: this.buildNodeId(node.id),
|
|
319
|
+
label: node.label || node.uri,
|
|
320
|
+
data: data,
|
|
321
|
+
};
|
|
322
|
+
nodes.push(n);
|
|
323
|
+
this._rootNode = n;
|
|
324
|
+
this._edges$.next([]);
|
|
325
|
+
this._nodes$.next(nodes);
|
|
326
|
+
this.expandNode(n);
|
|
327
|
+
},
|
|
328
|
+
error: (error) => {
|
|
329
|
+
this.setError(error);
|
|
330
|
+
},
|
|
331
|
+
complete: () => {
|
|
332
|
+
this.toggleLoading(false);
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Get the source and target graph nodes IDs from the specified edge ID.
|
|
338
|
+
*
|
|
339
|
+
* @param edgeId The ID of the edge graph node.
|
|
340
|
+
* @returns IDs of the source and target graph nodes.
|
|
341
|
+
*/
|
|
342
|
+
getEdgeEndIds(edgeId) {
|
|
343
|
+
const m = new RegExp('^E([^_]+)_(.+)$').exec(edgeId);
|
|
344
|
+
return m ? [m[1], m[2]] : null;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Remove all the nodes with the specified origin node ID.
|
|
348
|
+
*
|
|
349
|
+
* @param originId The ID of the origin graph node.
|
|
350
|
+
* @param nodes The nodes array to remove nodes from.
|
|
351
|
+
* @param removedIds The IDs of all the removed nodes.
|
|
352
|
+
*/
|
|
353
|
+
removeDescendantNodes(originId, nodes, removedIds) {
|
|
354
|
+
const ids = new Set();
|
|
355
|
+
for (let i = nodes.length - 1; i > -1; i--) {
|
|
356
|
+
if (nodes[i].data.originId === originId) {
|
|
357
|
+
ids.add(nodes[i].id);
|
|
358
|
+
nodes.splice(i, 1);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// recurse for each removed node
|
|
362
|
+
// (edges never derive from other edges directly)
|
|
363
|
+
ids.forEach((id) => {
|
|
364
|
+
this.removeDescendantNodes(id, nodes, removedIds);
|
|
365
|
+
});
|
|
366
|
+
// update the received IDs set
|
|
367
|
+
ids.forEach((id) => {
|
|
368
|
+
removedIds.add(id);
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Remove all the children graph nodes of the specified origin graph node.
|
|
373
|
+
*
|
|
374
|
+
* @param originId The ID of the origin graph node.
|
|
375
|
+
* @param nodes The nodes array to remove nodes from.
|
|
376
|
+
* @param edges The edges array to remove edges from.
|
|
377
|
+
*/
|
|
378
|
+
removeChildren(originId, nodes, edges) {
|
|
379
|
+
var _a;
|
|
380
|
+
const selectedId = (_a = this._selectedNode$.value) === null || _a === void 0 ? void 0 : _a.id;
|
|
381
|
+
// remove all the nodes whose origin ID matches,
|
|
382
|
+
// collecting their IDs
|
|
383
|
+
const removedIds = new Set();
|
|
384
|
+
this.removeDescendantNodes(originId, nodes, removedIds);
|
|
385
|
+
// remove all the affected edges
|
|
386
|
+
for (let i = edges.length - 1; i > -1; i--) {
|
|
387
|
+
const endIds = this.getEdgeEndIds(edges[i].id);
|
|
388
|
+
if ((endIds === null || endIds === void 0 ? void 0 : endIds.length) &&
|
|
389
|
+
(removedIds.has(endIds[0]) || removedIds.has(endIds[1]))) {
|
|
390
|
+
edges.splice(i, 1);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
// if the removed node was the selected one, select the root origin
|
|
394
|
+
if (selectedId && removedIds.has(selectedId)) {
|
|
395
|
+
this.selectNode(this._rootNode.id);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Build a new graph node representing a property.
|
|
400
|
+
*
|
|
401
|
+
* @param sourceId The source node ID.
|
|
402
|
+
* @param group The triple group emitting this node.
|
|
403
|
+
* @returns A new graph node.
|
|
404
|
+
*/
|
|
405
|
+
buildPropertyNode(sourceId, group) {
|
|
406
|
+
const nid = this.getNodeNumericId(sourceId);
|
|
407
|
+
const data = {
|
|
408
|
+
originId: sourceId,
|
|
409
|
+
uri: group.predicateUri,
|
|
410
|
+
customColor: '#FF5619',
|
|
411
|
+
outFilter: {
|
|
412
|
+
pageNumber: 1,
|
|
413
|
+
pageSize: this.pageSize,
|
|
414
|
+
otherNodeId: nid,
|
|
415
|
+
predicateId: group.predicateId,
|
|
416
|
+
},
|
|
417
|
+
inFilter: {
|
|
418
|
+
pageNumber: 1,
|
|
419
|
+
pageSize: this.pageSize,
|
|
420
|
+
otherNodeId: nid,
|
|
421
|
+
predicateId: group.predicateId,
|
|
422
|
+
},
|
|
423
|
+
litFilter: {
|
|
424
|
+
pageNumber: 1,
|
|
425
|
+
pageSize: this.pageSize,
|
|
426
|
+
predicateId: group.predicateId,
|
|
427
|
+
},
|
|
428
|
+
};
|
|
429
|
+
return {
|
|
430
|
+
id: this.buildPropertyId(group.predicateId, nid),
|
|
431
|
+
label: group.count.toString(),
|
|
432
|
+
data: data,
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Expand the specified node, by loading its property groups.
|
|
437
|
+
*
|
|
438
|
+
* @param node The node to expand.
|
|
439
|
+
* @param outFilter The properties to update for the output filter.
|
|
440
|
+
* @param inFilter The properties to update for the input filter.
|
|
441
|
+
*/
|
|
442
|
+
expandNode(node, outFilter, inFilter) {
|
|
443
|
+
// prepare filters
|
|
444
|
+
const nid = this.getNodeNumericId(node.id);
|
|
445
|
+
// outbound: node=S
|
|
446
|
+
const outf = outFilter
|
|
447
|
+
? Object.assign(node.data.outFilter, outFilter, {
|
|
448
|
+
subjectId: nid,
|
|
449
|
+
})
|
|
450
|
+
: {
|
|
451
|
+
pageNumber: 1,
|
|
452
|
+
pageSize: this.pageSize,
|
|
453
|
+
subjectId: nid,
|
|
454
|
+
};
|
|
455
|
+
// inbound: node=O
|
|
456
|
+
const inf = inFilter
|
|
457
|
+
? Object.assign(node.data.inFilter, inFilter, {
|
|
458
|
+
objectId: nid,
|
|
459
|
+
})
|
|
460
|
+
: {
|
|
461
|
+
pageNumber: 1,
|
|
462
|
+
pageSize: this.pageSize,
|
|
463
|
+
objectId: nid,
|
|
464
|
+
};
|
|
465
|
+
// load
|
|
466
|
+
this.toggleLoading(true);
|
|
467
|
+
const nodes = [...this._nodes$.value];
|
|
468
|
+
const edges = [...this._edges$.value];
|
|
469
|
+
forkJoin({
|
|
470
|
+
outs: this._graphService.getTripleGroups(outf),
|
|
471
|
+
ins: this._graphService.getTripleGroups(inf),
|
|
472
|
+
}).subscribe({
|
|
473
|
+
next: (result) => {
|
|
474
|
+
node.data.expanded = true;
|
|
475
|
+
// update origin's filters
|
|
476
|
+
node.data.outFilter = outf;
|
|
477
|
+
node.data.inFilter = inf;
|
|
478
|
+
// remove previous children
|
|
479
|
+
this.removeChildren(node.id, nodes, edges);
|
|
480
|
+
// add outbound children
|
|
481
|
+
node.data.outTotal = result.outs.total;
|
|
482
|
+
for (let i = 0; i < result.outs.items.length; i++) {
|
|
483
|
+
const group = result.outs.items[i];
|
|
484
|
+
const prop = this.buildPropertyNode(node.id, group);
|
|
485
|
+
// when expanding a node (e.g. N17) into props, the prop's ID is
|
|
486
|
+
// P + predicate ID + N + origin node ID (e.g. P30N17).
|
|
487
|
+
// This prop node can then be expanded, too, thus producing
|
|
488
|
+
// a node with ID = N + node ID. When this in turn gets expanded,
|
|
489
|
+
// it will produce also the prop node it comes from, which
|
|
490
|
+
// must not be re-inserted in the graph. This node in the new
|
|
491
|
+
// expansion context will get ID from the source node, which
|
|
492
|
+
// is different from the node at the other end of the prop node:
|
|
493
|
+
// this was e.g. N17, while the new node is e.g. N18. So, the
|
|
494
|
+
// prop previously identified as P30N17 would now be identified
|
|
495
|
+
// as P30N18, thus producing a duplicate. To avoid this, we
|
|
496
|
+
// calculate an alias ID from the origin's origin: for N18,
|
|
497
|
+
// its origin being P30N17, this will be N17. This produces an
|
|
498
|
+
// alias P30N17, which being already present will avoid duplicates.
|
|
499
|
+
const aliasId = `P${group.predicateId}N${this.getNodeNumericId(node.data.originId)}`;
|
|
500
|
+
if (!nodes.some((n) => n.id === prop.id || n.id === aliasId)) {
|
|
501
|
+
nodes.push(prop);
|
|
502
|
+
// edge from origin node to object property
|
|
503
|
+
const edge = {
|
|
504
|
+
id: this.buildEdgeId(node.id, prop.id),
|
|
505
|
+
label: group.predicateUri,
|
|
506
|
+
source: node.id,
|
|
507
|
+
target: prop.id,
|
|
508
|
+
data: {
|
|
509
|
+
originId: node.id,
|
|
510
|
+
},
|
|
511
|
+
};
|
|
512
|
+
this.addEdgeIfAbsent(edge, edges);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
// add inbound children
|
|
516
|
+
node.data.inTotal = result.ins.total;
|
|
517
|
+
for (let i = 0; i < result.ins.items.length; i++) {
|
|
518
|
+
const g = result.ins.items[i];
|
|
519
|
+
// subject property
|
|
520
|
+
const p = this.buildPropertyNode(node.id, g);
|
|
521
|
+
// edge from object property to origin node
|
|
522
|
+
const edge = {
|
|
523
|
+
id: this.buildEdgeId(p.id, node.id),
|
|
524
|
+
label: g.predicateUri,
|
|
525
|
+
source: p.id,
|
|
526
|
+
target: node.id,
|
|
527
|
+
data: {
|
|
528
|
+
originId: node.id,
|
|
529
|
+
},
|
|
530
|
+
};
|
|
531
|
+
// do not add an edge having the same source P and target N,
|
|
532
|
+
// whatever the P's source node
|
|
533
|
+
const r = new RegExp('^EP' + g.predicateId + 'N[0-9]+_' + node.id + '$');
|
|
534
|
+
if (!edges.some((e) => r.test(e.id))) {
|
|
535
|
+
if (!nodes.some((n) => n.id === p.id)) {
|
|
536
|
+
nodes.push(p);
|
|
537
|
+
}
|
|
538
|
+
this.addEdgeIfAbsent(edge, edges);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
// update
|
|
542
|
+
this._nodes$.next(nodes);
|
|
543
|
+
this._edges$.next(edges);
|
|
544
|
+
},
|
|
545
|
+
error: (error) => {
|
|
546
|
+
node.data.error = 'Error loading properties';
|
|
547
|
+
this._nodes$.next(nodes);
|
|
548
|
+
this.setError(error);
|
|
549
|
+
},
|
|
550
|
+
complete: () => {
|
|
551
|
+
this.toggleLoading(false);
|
|
552
|
+
},
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Expand the selected node, by loading its property groups.
|
|
557
|
+
*
|
|
558
|
+
* @param outFilter The properties to update for the output filter.
|
|
559
|
+
* @param inFilter The properties to update for the input filter.
|
|
560
|
+
*/
|
|
561
|
+
expandSelectedNode(outFilter, inFilter) {
|
|
562
|
+
if (!this._selectedNode$.value ||
|
|
563
|
+
!this._selectedNode$.value.id.startsWith('N')) {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
const node = this._selectedNode$.value;
|
|
567
|
+
this.expandNode(node, outFilter, inFilter);
|
|
568
|
+
}
|
|
569
|
+
buildLiteralLabel(triple) {
|
|
570
|
+
let value = triple.objectLiteral || '';
|
|
571
|
+
if (this.maxLiteralLen && value.length > this.maxLiteralLen) {
|
|
572
|
+
value = value.substring(0, this.maxLiteralLen) + '\u2026';
|
|
573
|
+
}
|
|
574
|
+
return value;
|
|
575
|
+
}
|
|
576
|
+
buildNonLiteralNode(sourceId, node) {
|
|
577
|
+
const nid = this.getNodeNumericId(sourceId);
|
|
578
|
+
const data = {
|
|
579
|
+
originId: sourceId,
|
|
580
|
+
customColor: '#80ff95',
|
|
581
|
+
uri: node.uri,
|
|
582
|
+
sourceType: node.sourceType,
|
|
583
|
+
isClass: node.isClass,
|
|
584
|
+
sid: node.sid,
|
|
585
|
+
tag: node.tag,
|
|
586
|
+
outFilter: {
|
|
587
|
+
pageNumber: 0,
|
|
588
|
+
pageSize: this.pageSize,
|
|
589
|
+
subjectId: nid,
|
|
590
|
+
},
|
|
591
|
+
inFilter: {
|
|
592
|
+
pageNumber: 0,
|
|
593
|
+
pageSize: this.pageSize,
|
|
594
|
+
objectId: nid,
|
|
595
|
+
},
|
|
596
|
+
};
|
|
597
|
+
return {
|
|
598
|
+
id: this.buildNodeId(node.id),
|
|
599
|
+
label: node.label,
|
|
600
|
+
data: data,
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
buildLiteralNode(sourceId, triple) {
|
|
604
|
+
const data = {
|
|
605
|
+
originId: sourceId,
|
|
606
|
+
customColor: '#ebe2e0',
|
|
607
|
+
value: triple.objectLiteral || '',
|
|
608
|
+
type: triple.literalType,
|
|
609
|
+
language: triple.literalLanguage,
|
|
610
|
+
number: triple.literalNumber,
|
|
611
|
+
};
|
|
612
|
+
return {
|
|
613
|
+
id: this.buildLiteralId(triple.id),
|
|
614
|
+
label: this.buildLiteralLabel(triple),
|
|
615
|
+
data: data,
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Expand the currently selected properties group node, by loading its
|
|
620
|
+
* outbound nodes, inbound nodes, and literal nodes.
|
|
621
|
+
*
|
|
622
|
+
* @param node The property group node to expand.
|
|
623
|
+
* @param outFilter The properties to update for the outbound nodes filter.
|
|
624
|
+
* @param inFilter The properties to update for the inbound nodes filter.
|
|
625
|
+
* @param litFilter The properties to update for the literal nodes filter.
|
|
626
|
+
*/
|
|
627
|
+
expandProperty(node, outFilter, inFilter, litFilter) {
|
|
628
|
+
// prepare filters
|
|
629
|
+
const nid = this.getNodeNumericId(node.id);
|
|
630
|
+
const data = node.data;
|
|
631
|
+
const outf = Object.assign(data.outFilter, outFilter || {}, { isObject: true });
|
|
632
|
+
const inf = Object.assign(data.inFilter, inFilter || {}, {
|
|
633
|
+
isObject: false,
|
|
634
|
+
});
|
|
635
|
+
const litf = Object.assign(data.litFilter, litFilter || {}, { subjectId: nid, predicateId: this.getPredicateNumericId(node.id) });
|
|
636
|
+
// load
|
|
637
|
+
this.toggleLoading(true);
|
|
638
|
+
const nodes = [...this._nodes$.value];
|
|
639
|
+
const edges = [...this._edges$.value];
|
|
640
|
+
forkJoin({
|
|
641
|
+
outs: this._graphService.getLinkedNodes(outf),
|
|
642
|
+
ins: this._graphService.getLinkedNodes(inf),
|
|
643
|
+
lits: this._graphService.getLinkedLiterals(litf),
|
|
644
|
+
}).subscribe({
|
|
645
|
+
next: (result) => {
|
|
646
|
+
node.data.expanded = true;
|
|
647
|
+
// update origin's filters
|
|
648
|
+
node.data.outFilter = outf;
|
|
649
|
+
node.data.inFilter = inf;
|
|
650
|
+
node.data.litFilter = litf;
|
|
651
|
+
// remove previous children
|
|
652
|
+
this.removeChildren(node.id, nodes, edges);
|
|
653
|
+
// add outbound children
|
|
654
|
+
node.data.outTotal = result.outs.total;
|
|
655
|
+
for (let i = 0; i < result.outs.items.length; i++) {
|
|
656
|
+
const child = result.outs.items[i];
|
|
657
|
+
const obj = this.buildNonLiteralNode(node.id, child);
|
|
658
|
+
if (!nodes.some((n) => n.id === obj.id)) {
|
|
659
|
+
nodes.push(obj);
|
|
660
|
+
}
|
|
661
|
+
// edge from property to non literal object node
|
|
662
|
+
const edge = {
|
|
663
|
+
id: this.buildEdgeId(node.id, obj.id),
|
|
664
|
+
label: '',
|
|
665
|
+
source: node.id,
|
|
666
|
+
target: obj.id,
|
|
667
|
+
data: {
|
|
668
|
+
originId: node.id,
|
|
669
|
+
},
|
|
670
|
+
};
|
|
671
|
+
this.addEdgeIfAbsent(edge, edges);
|
|
672
|
+
}
|
|
673
|
+
// add inbound children
|
|
674
|
+
node.data.inTotal = result.ins.total;
|
|
675
|
+
for (let i = 0; i < result.ins.items.length; i++) {
|
|
676
|
+
const child = result.ins.items[i];
|
|
677
|
+
const subj = this.buildNonLiteralNode(node.id, child);
|
|
678
|
+
if (!nodes.some((n) => n.id === subj.id)) {
|
|
679
|
+
nodes.push(subj);
|
|
680
|
+
}
|
|
681
|
+
// edge from subject node to property
|
|
682
|
+
const edge = {
|
|
683
|
+
id: this.buildEdgeId(subj.id, node.id),
|
|
684
|
+
label: '',
|
|
685
|
+
source: subj.id,
|
|
686
|
+
target: node.id,
|
|
687
|
+
data: {
|
|
688
|
+
originId: node.id,
|
|
689
|
+
},
|
|
690
|
+
};
|
|
691
|
+
this.addEdgeIfAbsent(edge, edges);
|
|
692
|
+
}
|
|
693
|
+
// add literal children
|
|
694
|
+
node.data.litTotal = result.lits.total;
|
|
695
|
+
for (let i = 0; i < result.lits.items.length; i++) {
|
|
696
|
+
const triple = result.lits.items[i];
|
|
697
|
+
const lit = this.buildLiteralNode(node.id, triple);
|
|
698
|
+
if (!nodes.some((n) => n.id === lit.id)) {
|
|
699
|
+
nodes.push(lit);
|
|
700
|
+
}
|
|
701
|
+
// edge from property to literal
|
|
702
|
+
const edge = {
|
|
703
|
+
id: this.buildEdgeId(node.id, lit.id),
|
|
704
|
+
label: lit.data.literalType || '',
|
|
705
|
+
source: node.id,
|
|
706
|
+
target: lit.id,
|
|
707
|
+
data: {
|
|
708
|
+
originId: node.id,
|
|
709
|
+
},
|
|
710
|
+
};
|
|
711
|
+
this.addEdgeIfAbsent(edge, edges);
|
|
712
|
+
}
|
|
713
|
+
// update
|
|
714
|
+
this._nodes$.next(nodes);
|
|
715
|
+
this._edges$.next(edges);
|
|
716
|
+
},
|
|
717
|
+
error: (error) => {
|
|
718
|
+
node.data.error = 'Error loading nodes';
|
|
719
|
+
this._nodes$.next(nodes);
|
|
720
|
+
this.setError(error);
|
|
721
|
+
},
|
|
722
|
+
complete: () => {
|
|
723
|
+
this.toggleLoading(false);
|
|
724
|
+
},
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Expand the currently selected properties group node, by loading its
|
|
729
|
+
* outbound nodes, inbound nodes, and literal nodes. If there is no
|
|
730
|
+
* selection, or the selected node is not a properties group node, nothing
|
|
731
|
+
* is done.
|
|
732
|
+
*
|
|
733
|
+
* @param outFilter The properties to update for the outbound nodes filter.
|
|
734
|
+
* @param inFilter The properties to update for the inbound nodes filter.
|
|
735
|
+
* @param litFilter The properties to update for the literal nodes filter.
|
|
736
|
+
*/
|
|
737
|
+
expandSelectedProperty(outFilter, inFilter, litFilter) {
|
|
738
|
+
if (!this._selectedNode$.value ||
|
|
739
|
+
!this._selectedNode$.value.id.startsWith('P')) {
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
const node = this._selectedNode$.value;
|
|
743
|
+
this.expandProperty(node, outFilter, inFilter, litFilter);
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Toggle the specified node by expanding or collapsing it.
|
|
747
|
+
*
|
|
748
|
+
* @param node The node to toggle.
|
|
749
|
+
*/
|
|
750
|
+
toggleNode(node) {
|
|
751
|
+
if (node.data.expanded) {
|
|
752
|
+
const nodes = [...this._nodes$.value];
|
|
753
|
+
const edges = [...this._edges$.value];
|
|
754
|
+
this.removeChildren(node.id, nodes, edges);
|
|
755
|
+
node.data.expanded = undefined;
|
|
756
|
+
this._nodes$.next(nodes);
|
|
757
|
+
this._edges$.next(edges);
|
|
758
|
+
}
|
|
759
|
+
else {
|
|
760
|
+
if (node.id.startsWith('N')) {
|
|
761
|
+
this.expandNode(node);
|
|
762
|
+
}
|
|
763
|
+
else if (node.id.startsWith('P')) {
|
|
764
|
+
this.expandProperty(node);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
//#region Models
|
|
771
|
+
var NodeSourceType;
|
|
772
|
+
(function (NodeSourceType) {
|
|
773
|
+
NodeSourceType[NodeSourceType["User"] = 0] = "User";
|
|
774
|
+
NodeSourceType[NodeSourceType["Item"] = 1] = "Item";
|
|
775
|
+
NodeSourceType[NodeSourceType["Part"] = 2] = "Part";
|
|
776
|
+
NodeSourceType[NodeSourceType["Thesaurus"] = 3] = "Thesaurus";
|
|
777
|
+
NodeSourceType[NodeSourceType["Implicit"] = 4] = "Implicit";
|
|
778
|
+
})(NodeSourceType || (NodeSourceType = {}));
|
|
779
|
+
//#endregion
|
|
780
|
+
/**
|
|
781
|
+
* Cadmus semantic graph service.
|
|
782
|
+
*/
|
|
783
|
+
class GraphService {
|
|
784
|
+
constructor(_http, _error, _env) {
|
|
785
|
+
this._http = _http;
|
|
786
|
+
this._error = _error;
|
|
787
|
+
this._env = _env;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Get the specified page of graph nodes.
|
|
791
|
+
*
|
|
792
|
+
* @param filter The nodes filter.
|
|
793
|
+
* @returns A page of nodes.
|
|
794
|
+
*/
|
|
795
|
+
getNodes(filter) {
|
|
796
|
+
var _a;
|
|
797
|
+
const url = this._env.get('apiUrl') + 'graph/nodes';
|
|
798
|
+
let httpParams = new HttpParams();
|
|
799
|
+
httpParams = httpParams.set('pageNumber', filter.pageNumber.toString());
|
|
800
|
+
httpParams = httpParams.set('pageSize', filter.pageSize.toString());
|
|
801
|
+
if (filter.uid) {
|
|
802
|
+
httpParams = httpParams.set('uid', filter.uid);
|
|
803
|
+
}
|
|
804
|
+
if (filter.isClass !== null && filter.isClass !== undefined) {
|
|
805
|
+
httpParams = httpParams.set('isClass', filter.isClass ? 'true' : 'false');
|
|
806
|
+
}
|
|
807
|
+
if (filter.tag) {
|
|
808
|
+
httpParams = httpParams.set('tag', filter.tag);
|
|
809
|
+
}
|
|
810
|
+
if (filter.label) {
|
|
811
|
+
httpParams = httpParams.set('label', filter.label);
|
|
812
|
+
}
|
|
813
|
+
if (filter.sourceType !== null && filter.sourceType !== undefined) {
|
|
814
|
+
httpParams = httpParams.set('sourceType', filter.sourceType.toString());
|
|
815
|
+
}
|
|
816
|
+
if (filter.sid) {
|
|
817
|
+
httpParams = httpParams.set('sid', filter.sid);
|
|
818
|
+
}
|
|
819
|
+
if (filter.isSidPrefix) {
|
|
820
|
+
httpParams = httpParams.set('isSidPrefix', 'true');
|
|
821
|
+
}
|
|
822
|
+
if (filter.linkedNodeId) {
|
|
823
|
+
httpParams = httpParams.set('linkedNodeId', filter.linkedNodeId.toString());
|
|
824
|
+
}
|
|
825
|
+
if (filter.linkedNodeRole) {
|
|
826
|
+
httpParams = httpParams.set('linkedNodeRole', filter.linkedNodeRole);
|
|
827
|
+
}
|
|
828
|
+
if ((_a = filter.classIds) === null || _a === void 0 ? void 0 : _a.length) {
|
|
829
|
+
for (let i = 0; i < filter.classIds.length; i++) {
|
|
830
|
+
httpParams = httpParams.set('classIds', filter.classIds[i]);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
return this._http
|
|
834
|
+
.get(url, {
|
|
835
|
+
params: httpParams,
|
|
836
|
+
})
|
|
837
|
+
.pipe(retry(3), catchError(this._error.handleError));
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Get the specified set of nodes.
|
|
841
|
+
*
|
|
842
|
+
* @param ids The nodes IDs.
|
|
843
|
+
* @returns List of nodes/nulls.
|
|
844
|
+
*/
|
|
845
|
+
getNodeSet(ids) {
|
|
846
|
+
const url = this._env.get('apiUrl') + 'graph/nodes-set/';
|
|
847
|
+
let httpParams = new HttpParams();
|
|
848
|
+
for (let i = 0; i < ids.length; i++) {
|
|
849
|
+
httpParams = httpParams.append('id', ids[i].toString());
|
|
850
|
+
}
|
|
851
|
+
return this._http
|
|
852
|
+
.get(url, {
|
|
853
|
+
params: httpParams,
|
|
854
|
+
})
|
|
855
|
+
.pipe(retry(3), catchError(this._error.handleError));
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Get the node with the specified ID.
|
|
859
|
+
*
|
|
860
|
+
* @param id The node's ID.
|
|
861
|
+
* @returns The node.
|
|
862
|
+
*/
|
|
863
|
+
getNode(id) {
|
|
864
|
+
const url = this._env.get('apiUrl') + 'graph/nodes/' + id.toString();
|
|
865
|
+
return this._http
|
|
866
|
+
.get(url)
|
|
867
|
+
.pipe(retry(3), catchError(this._error.handleError));
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* Get the node with the specified URI.
|
|
871
|
+
*
|
|
872
|
+
* @param uri The node's URI.
|
|
873
|
+
* @returns The node.
|
|
874
|
+
*/
|
|
875
|
+
getNodeByUri(uri) {
|
|
876
|
+
const url = this._env.get('apiUrl') + 'graph/nodes-by-uri';
|
|
877
|
+
let httpParams = new HttpParams();
|
|
878
|
+
httpParams = httpParams.set('uri', uri);
|
|
879
|
+
return this._http
|
|
880
|
+
.get(url, { params: httpParams })
|
|
881
|
+
.pipe(retry(3), catchError(this._error.handleError));
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Add or update the specified node. A new node has id=0 and uri set;
|
|
885
|
+
* an existing node has its id.
|
|
886
|
+
*
|
|
887
|
+
* @param node The node to add.
|
|
888
|
+
* @returns The added node.
|
|
889
|
+
*/
|
|
890
|
+
addNode(node) {
|
|
891
|
+
const url = this._env.get('apiUrl') + 'graph/nodes/';
|
|
892
|
+
return this._http
|
|
893
|
+
.post(url, node)
|
|
894
|
+
.pipe(catchError(this._error.handleError));
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Delete the node with the specified ID.
|
|
898
|
+
*
|
|
899
|
+
* @param id The node's ID.
|
|
900
|
+
*/
|
|
901
|
+
deleteNode(id) {
|
|
902
|
+
const url = this._env.get('apiUrl') + 'graph/nodes/' + id.toString();
|
|
903
|
+
return this._http.delete(url).pipe(catchError(this._error.handleError));
|
|
904
|
+
}
|
|
905
|
+
applyTripleFilter(filter, httpParams) {
|
|
906
|
+
var _a, _b;
|
|
907
|
+
httpParams = httpParams.set('pageNumber', filter.pageNumber.toString());
|
|
908
|
+
httpParams = httpParams.set('pageSize', filter.pageSize.toString());
|
|
909
|
+
if (filter.subjectId) {
|
|
910
|
+
httpParams = httpParams.set('subjectId', filter.subjectId.toString());
|
|
911
|
+
}
|
|
912
|
+
if ((_a = filter.predicateIds) === null || _a === void 0 ? void 0 : _a.length) {
|
|
913
|
+
filter.predicateIds.forEach((p) => {
|
|
914
|
+
httpParams = httpParams.set('predicateIds', p);
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
if ((_b = filter.notPredicateIds) === null || _b === void 0 ? void 0 : _b.length) {
|
|
918
|
+
filter.notPredicateIds.forEach((p) => {
|
|
919
|
+
httpParams = httpParams.set('notPredicateIds', p);
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
if (filter.hasLiteralObject !== null &&
|
|
923
|
+
filter.hasLiteralObject !== undefined) {
|
|
924
|
+
httpParams = httpParams.set('hasLiteralObject', filter.hasLiteralObject.toString());
|
|
925
|
+
}
|
|
926
|
+
if (filter.objectId) {
|
|
927
|
+
httpParams = httpParams.set('objectId', filter.objectId.toString());
|
|
928
|
+
}
|
|
929
|
+
if (filter.sid) {
|
|
930
|
+
httpParams = httpParams.set('sid', filter.sid);
|
|
931
|
+
}
|
|
932
|
+
if (filter.isSidPrefix) {
|
|
933
|
+
httpParams = httpParams.set('isSidPrefix', 'true');
|
|
934
|
+
}
|
|
935
|
+
if (filter.tag) {
|
|
936
|
+
httpParams = httpParams.set('tag', filter.tag);
|
|
937
|
+
}
|
|
938
|
+
return httpParams;
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Get the specified page of triples.
|
|
942
|
+
*
|
|
943
|
+
* @param filter The filter.
|
|
944
|
+
* @returns The page.
|
|
945
|
+
*/
|
|
946
|
+
getTriples(filter) {
|
|
947
|
+
const url = this._env.get('apiUrl') + 'graph/triples';
|
|
948
|
+
const httpParams = this.applyTripleFilter(filter, new HttpParams());
|
|
949
|
+
return this._http
|
|
950
|
+
.get(url, {
|
|
951
|
+
params: httpParams,
|
|
952
|
+
})
|
|
953
|
+
.pipe(retry(3), catchError(this._error.handleError));
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Get the triple with the specified ID.
|
|
957
|
+
*
|
|
958
|
+
* @param id The triple's ID.
|
|
959
|
+
* @returns The triple.
|
|
960
|
+
*/
|
|
961
|
+
getTriple(id) {
|
|
962
|
+
const url = this._env.get('apiUrl') + 'graph/triples/' + id.toString();
|
|
963
|
+
return this._http
|
|
964
|
+
.get(url)
|
|
965
|
+
.pipe(retry(3), catchError(this._error.handleError));
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Add or update the specified triple.
|
|
969
|
+
*
|
|
970
|
+
* @param triple The triple to add.
|
|
971
|
+
* @returns The added triple.
|
|
972
|
+
*/
|
|
973
|
+
addTriple(triple) {
|
|
974
|
+
const url = this._env.get('apiUrl') + 'graph/triples';
|
|
975
|
+
return this._http
|
|
976
|
+
.post(url, triple)
|
|
977
|
+
.pipe(catchError(this._error.handleError));
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Delete the triple with the specified ID.
|
|
981
|
+
*
|
|
982
|
+
* @param id The triple's ID.
|
|
983
|
+
*/
|
|
984
|
+
deleteTriple(id) {
|
|
985
|
+
const url = this._env.get('apiUrl') + 'graph/triples/' + id.toString();
|
|
986
|
+
return this._http.delete(url).pipe(catchError(this._error.handleError));
|
|
987
|
+
}
|
|
988
|
+
applyLiteralFilter(filter, httpParams) {
|
|
989
|
+
if (filter.literalPattern) {
|
|
990
|
+
httpParams = httpParams.set('literalPattern', filter.literalPattern);
|
|
991
|
+
}
|
|
992
|
+
if (filter.literalType) {
|
|
993
|
+
httpParams = httpParams.set('literalType', filter.literalType);
|
|
994
|
+
}
|
|
995
|
+
if (filter.literalLanguage) {
|
|
996
|
+
httpParams = httpParams.set('literalLanguage', filter.literalLanguage);
|
|
997
|
+
}
|
|
998
|
+
if (filter.minLiteralNumber) {
|
|
999
|
+
httpParams = httpParams.set('minLiteralNumber', filter.minLiteralNumber.toString());
|
|
1000
|
+
}
|
|
1001
|
+
if (filter.maxLiteralNumber) {
|
|
1002
|
+
httpParams = httpParams.set('maxLiteralNumber', filter.maxLiteralNumber.toString());
|
|
1003
|
+
}
|
|
1004
|
+
return httpParams;
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Get the specified page of triples grouped by their property.
|
|
1008
|
+
*
|
|
1009
|
+
* @param filter The filter.
|
|
1010
|
+
* @returns The page of triples.
|
|
1011
|
+
*/
|
|
1012
|
+
getTripleGroups(filter) {
|
|
1013
|
+
const httpParams = this.applyTripleFilter(filter, new HttpParams());
|
|
1014
|
+
const url = this._env.get('apiUrl') + 'graph/walk/triples';
|
|
1015
|
+
return this._http
|
|
1016
|
+
.get(url, {
|
|
1017
|
+
params: httpParams,
|
|
1018
|
+
})
|
|
1019
|
+
.pipe(retry(3), catchError(this._error.handleError));
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Get linked nodes.
|
|
1023
|
+
* @param filter The filter.
|
|
1024
|
+
* @returns Observable with data page.
|
|
1025
|
+
*/
|
|
1026
|
+
getLinkedNodes(filter) {
|
|
1027
|
+
var _a;
|
|
1028
|
+
let httpParams = new HttpParams();
|
|
1029
|
+
httpParams = httpParams.set('pageNumber', filter.pageNumber.toString());
|
|
1030
|
+
httpParams = httpParams.set('pageSize', filter.pageSize.toString());
|
|
1031
|
+
// NodeFilterBase
|
|
1032
|
+
if (filter.uid) {
|
|
1033
|
+
httpParams = httpParams.set('uid', filter.uid);
|
|
1034
|
+
}
|
|
1035
|
+
if (filter.isClass !== null && filter.isClass !== undefined) {
|
|
1036
|
+
httpParams = httpParams.set('isClass', filter.isClass);
|
|
1037
|
+
}
|
|
1038
|
+
if (filter.tag) {
|
|
1039
|
+
httpParams = httpParams.set('tag', filter.tag);
|
|
1040
|
+
}
|
|
1041
|
+
if (filter.label) {
|
|
1042
|
+
httpParams = httpParams.set('label', filter.label);
|
|
1043
|
+
}
|
|
1044
|
+
if (filter.sourceType) {
|
|
1045
|
+
httpParams = httpParams.set('sourceType', +filter.sourceType);
|
|
1046
|
+
}
|
|
1047
|
+
if (filter.sid) {
|
|
1048
|
+
httpParams = httpParams.set('sid', filter.sid);
|
|
1049
|
+
}
|
|
1050
|
+
if (filter.isSidPrefix !== null && filter.isSidPrefix !== undefined) {
|
|
1051
|
+
httpParams = httpParams.set('isSidPrefix', filter.isSidPrefix);
|
|
1052
|
+
}
|
|
1053
|
+
if ((_a = filter.classIds) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1054
|
+
for (let i = 0; i < filter.classIds.length; i++) {
|
|
1055
|
+
httpParams = httpParams.set('classIds', filter.classIds[i]);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
// LinkedNodeFilter
|
|
1059
|
+
if (filter.otherNodeId) {
|
|
1060
|
+
httpParams = httpParams.set('otherNodeId', filter.otherNodeId);
|
|
1061
|
+
}
|
|
1062
|
+
if (filter.predicateId) {
|
|
1063
|
+
httpParams = httpParams.set('predicateId', filter.predicateId);
|
|
1064
|
+
}
|
|
1065
|
+
if (filter.isObject !== null && filter.isObject !== undefined) {
|
|
1066
|
+
httpParams = httpParams.set('isObject', filter.isObject);
|
|
1067
|
+
}
|
|
1068
|
+
const url = this._env.get('apiUrl') + 'graph/walk/nodes';
|
|
1069
|
+
return this._http
|
|
1070
|
+
.get(url, {
|
|
1071
|
+
params: httpParams,
|
|
1072
|
+
})
|
|
1073
|
+
.pipe(retry(3), catchError(this._error.handleError));
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Get linked literals.
|
|
1077
|
+
* @param filter The filter.
|
|
1078
|
+
* @returns Observable with data page.
|
|
1079
|
+
*/
|
|
1080
|
+
getLinkedLiterals(filter) {
|
|
1081
|
+
let httpParams = new HttpParams();
|
|
1082
|
+
httpParams = httpParams.set('pageNumber', filter.pageNumber.toString());
|
|
1083
|
+
httpParams = httpParams.set('pageSize', filter.pageSize.toString());
|
|
1084
|
+
// LiteralFilter
|
|
1085
|
+
httpParams = this.applyLiteralFilter(filter, httpParams);
|
|
1086
|
+
// LinkedLiteralFilter
|
|
1087
|
+
if (filter.subjectId) {
|
|
1088
|
+
httpParams = httpParams.set('subjectId', filter.subjectId.toString());
|
|
1089
|
+
}
|
|
1090
|
+
if (filter.predicateId) {
|
|
1091
|
+
httpParams = httpParams.set('predicateId', filter.predicateId.toString());
|
|
1092
|
+
}
|
|
1093
|
+
const url = this._env.get('apiUrl') + 'graph/walk/nodes/literal';
|
|
1094
|
+
return this._http
|
|
1095
|
+
.get(url, {
|
|
1096
|
+
params: httpParams,
|
|
1097
|
+
})
|
|
1098
|
+
.pipe(retry(3), catchError(this._error.handleError));
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
GraphService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphService, deps: [{ token: i1.HttpClient }, { token: i2.ErrorService }, { token: i2.EnvService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1102
|
+
GraphService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphService, providedIn: 'root' });
|
|
1103
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphService, decorators: [{
|
|
1104
|
+
type: Injectable,
|
|
1105
|
+
args: [{
|
|
1106
|
+
providedIn: 'root',
|
|
1107
|
+
}]
|
|
1108
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.ErrorService }, { type: i2.EnvService }]; } });
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* Graph node lookup service.
|
|
1112
|
+
*/
|
|
1113
|
+
class GraphNodeLookupService {
|
|
1114
|
+
constructor(_graphService) {
|
|
1115
|
+
this._graphService = _graphService;
|
|
1116
|
+
}
|
|
1117
|
+
lookup(filter, options) {
|
|
1118
|
+
if (!filter.text) {
|
|
1119
|
+
return of([]);
|
|
1120
|
+
}
|
|
1121
|
+
return this._graphService
|
|
1122
|
+
.getNodes({
|
|
1123
|
+
pageNumber: 1,
|
|
1124
|
+
pageSize: filter.limit || 10,
|
|
1125
|
+
label: filter.text,
|
|
1126
|
+
isClass: filter.isClass === undefined || filter.isClass === null
|
|
1127
|
+
? undefined
|
|
1128
|
+
: filter.isClass
|
|
1129
|
+
? true
|
|
1130
|
+
: false,
|
|
1131
|
+
tag: filter.tag,
|
|
1132
|
+
})
|
|
1133
|
+
.pipe(map((p) => p.items));
|
|
1134
|
+
}
|
|
1135
|
+
getName(item) {
|
|
1136
|
+
return item === null || item === void 0 ? void 0 : item.label;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
GraphNodeLookupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLookupService, deps: [{ token: GraphService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1140
|
+
GraphNodeLookupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLookupService, providedIn: 'root' });
|
|
1141
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLookupService, decorators: [{
|
|
1142
|
+
type: Injectable,
|
|
1143
|
+
args: [{
|
|
1144
|
+
providedIn: 'root',
|
|
1145
|
+
}]
|
|
1146
|
+
}], ctorParameters: function () { return [{ type: GraphService }]; } });
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* Linked literal filter.
|
|
1150
|
+
*/
|
|
1151
|
+
class LinkedLiteralFilterComponent {
|
|
1152
|
+
/**
|
|
1153
|
+
* The filter.
|
|
1154
|
+
*/
|
|
1155
|
+
get filter() {
|
|
1156
|
+
return this._filter;
|
|
1157
|
+
}
|
|
1158
|
+
set filter(value) {
|
|
1159
|
+
if (this._filter === value) {
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
this._filter = value;
|
|
1163
|
+
this.updateForm(value);
|
|
1164
|
+
}
|
|
1165
|
+
constructor(formBuilder, lookupService, _graphService) {
|
|
1166
|
+
this.lookupService = lookupService;
|
|
1167
|
+
this._graphService = _graphService;
|
|
1168
|
+
this._filter = {
|
|
1169
|
+
pageNumber: 1,
|
|
1170
|
+
pageSize: 10,
|
|
1171
|
+
};
|
|
1172
|
+
this.total = 0;
|
|
1173
|
+
this.filterChange = new EventEmitter();
|
|
1174
|
+
// form
|
|
1175
|
+
this.pageNumber = formBuilder.control(1, { nonNullable: true });
|
|
1176
|
+
this.pageSize = formBuilder.control(10, { nonNullable: true });
|
|
1177
|
+
this.litPattern = formBuilder.control(null);
|
|
1178
|
+
this.litType = formBuilder.control(null);
|
|
1179
|
+
this.litLanguage = formBuilder.control(null);
|
|
1180
|
+
this.minLitNumber = formBuilder.control(null);
|
|
1181
|
+
this.maxLitNumber = formBuilder.control(null);
|
|
1182
|
+
this.subj = formBuilder.control(null);
|
|
1183
|
+
this.pred = formBuilder.control(null);
|
|
1184
|
+
this.form = formBuilder.group({
|
|
1185
|
+
pageNumber: this.pageNumber,
|
|
1186
|
+
pageSize: this.pageSize,
|
|
1187
|
+
litPattern: this.litPattern,
|
|
1188
|
+
litType: this.litType,
|
|
1189
|
+
litLanguage: this.litLanguage,
|
|
1190
|
+
minLitNumber: this.minLitNumber,
|
|
1191
|
+
maxLitNumber: this.maxLitNumber,
|
|
1192
|
+
subj: this.subj,
|
|
1193
|
+
pred: this.pred,
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
ngOnInit() { }
|
|
1197
|
+
updateForm(filter) {
|
|
1198
|
+
this.pageNumber.setValue(filter.pageNumber);
|
|
1199
|
+
this.pageSize.setValue(filter.pageSize);
|
|
1200
|
+
this.litPattern.setValue(filter.literalPattern || null);
|
|
1201
|
+
this.litType.setValue(filter.literalType || null);
|
|
1202
|
+
this.litLanguage.setValue(filter.literalLanguage || null);
|
|
1203
|
+
this.minLitNumber.setValue(filter.minLiteralNumber || null);
|
|
1204
|
+
this.maxLitNumber.setValue(filter.maxLiteralNumber || null);
|
|
1205
|
+
// load the referenced triples so we can show them by label
|
|
1206
|
+
forkJoin({
|
|
1207
|
+
s: filter.subjectId
|
|
1208
|
+
? this._graphService.getNode(filter.subjectId)
|
|
1209
|
+
: from([null]),
|
|
1210
|
+
p: filter.predicateId
|
|
1211
|
+
? this._graphService.getNode(filter.predicateId)
|
|
1212
|
+
: from([]),
|
|
1213
|
+
}).subscribe((result) => {
|
|
1214
|
+
this.subj.setValue(result.s);
|
|
1215
|
+
this.pred.setValue(result.p);
|
|
1216
|
+
this.form.markAsPristine();
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
getFilter() {
|
|
1220
|
+
var _a, _b;
|
|
1221
|
+
return {
|
|
1222
|
+
pageNumber: +this.pageNumber.value,
|
|
1223
|
+
pageSize: +this.pageSize.value,
|
|
1224
|
+
literalPattern: this.litPattern.value || undefined,
|
|
1225
|
+
literalType: this.litType.value || undefined,
|
|
1226
|
+
literalLanguage: this.litLanguage.value || undefined,
|
|
1227
|
+
minLiteralNumber: this.minLitNumber.value || undefined,
|
|
1228
|
+
maxLiteralNumber: this.maxLitNumber.value || undefined,
|
|
1229
|
+
subjectId: (_a = this.subj.value) === null || _a === void 0 ? void 0 : _a.id,
|
|
1230
|
+
predicateId: (_b = this.pred.value) === null || _b === void 0 ? void 0 : _b.id,
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
emitFilterChange() {
|
|
1234
|
+
this.filterChange.emit(this.getFilter());
|
|
1235
|
+
}
|
|
1236
|
+
onSubjectNodeChange(node) {
|
|
1237
|
+
this.subj.setValue(node);
|
|
1238
|
+
}
|
|
1239
|
+
onPredicateNodeChange(node) {
|
|
1240
|
+
this.pred.setValue(node);
|
|
1241
|
+
}
|
|
1242
|
+
onPageChange(page) {
|
|
1243
|
+
this.pageNumber.setValue(page.pageIndex + 1);
|
|
1244
|
+
this.emitFilterChange();
|
|
1245
|
+
}
|
|
1246
|
+
reset() {
|
|
1247
|
+
this.form.reset();
|
|
1248
|
+
this._filter = this.getFilter();
|
|
1249
|
+
this.filterChange.emit(this._filter);
|
|
1250
|
+
}
|
|
1251
|
+
apply() {
|
|
1252
|
+
if (this.form.invalid) {
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
this.emitFilterChange();
|
|
1256
|
+
this.form.markAsPristine();
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
LinkedLiteralFilterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: LinkedLiteralFilterComponent, deps: [{ token: i1$1.FormBuilder }, { token: GraphNodeLookupService }, { token: GraphService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1260
|
+
LinkedLiteralFilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: LinkedLiteralFilterComponent, selector: "cadmus-linked-literal-filter", inputs: { disabled: "disabled", hasPager: "hasPager", total: "total", filter: "filter" }, outputs: { filterChange: "filterChange" }, ngImport: i0, template: "<form [formGroup]=\"form\" (submit)=\"apply()\" ng-disabled=\"disabled\">\r\n <!-- paginator -->\r\n <mat-paginator\r\n *ngIf=\"hasPager\"\r\n [length]=\"total\"\r\n [pageSize]=\"pageSize.value || 10\"\r\n [pageSizeOptions]=\"[5, 10, 20]\"\r\n (page)=\"onPageChange($event)\"\r\n aria-label=\"Select page\"\r\n >\r\n </mat-paginator>\r\n\r\n <!-- subject ID -->\r\n <div>\r\n <cadmus-ref-lookup\r\n label=\"subject\"\r\n [service]=\"lookupService\"\r\n (itemChange)=\"onSubjectNodeChange($event)\"\r\n ></cadmus-ref-lookup>\r\n </div>\r\n\r\n <!-- predicate ID -->\r\n <div>\r\n <cadmus-ref-lookup\r\n label=\"predicate\"\r\n [service]=\"lookupService\"\r\n [baseFilter]=\"{ tag: 'property' }\"\r\n (itemChange)=\"onPredicateNodeChange($event)\"\r\n ></cadmus-ref-lookup>\r\n </div>\r\n\r\n <!-- LITERAL -->\r\n <!-- litPattern -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litPattern\" placeholder=\"pattern\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- litType -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litType\" placeholder=\"type\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- litLanguage-->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litLanguage\" placeholder=\"language\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- minLitNumber, maxLitNumber -->\r\n <div>\r\n <mat-form-field style=\"width: 5em\">\r\n <input\r\n matInput\r\n type=\"number\"\r\n [formControl]=\"minLitNumber\"\r\n placeholder=\"min.\"\r\n />\r\n </mat-form-field>\r\n -\r\n <mat-form-field style=\"width: 5em\">\r\n <input\r\n matInput\r\n type=\"number\"\r\n [formControl]=\"maxLitNumber\"\r\n placeholder=\"max.\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n <div\r\n class=\"btn-group\"\r\n role=\"group\"\r\n aria-label=\"toolbar\"\r\n style=\"margin-bottom: 10px\"\r\n >\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n (click)=\"reset()\"\r\n color=\"warn\"\r\n matTooltip=\"Reset filters\"\r\n [disabled]=\"disabled\"\r\n >\r\n <mat-icon>clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-icon-button\r\n color=\"primary\"\r\n [disabled]=\"disabled\"\r\n matTooltip=\"Apply filters\"\r\n >\r\n <mat-icon>check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i6.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "component", type: i7.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i9.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }, { kind: "directive", type: i10.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i11.RefLookupComponent, selector: "cadmus-ref-lookup", inputs: ["label", "limit", "baseFilter", "service", "item", "required", "hasMore", "linkTemplate", "optDialog", "options"], outputs: ["itemChange", "moreRequest"] }] });
|
|
1261
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: LinkedLiteralFilterComponent, decorators: [{
|
|
1262
|
+
type: Component,
|
|
1263
|
+
args: [{ selector: 'cadmus-linked-literal-filter', template: "<form [formGroup]=\"form\" (submit)=\"apply()\" ng-disabled=\"disabled\">\r\n <!-- paginator -->\r\n <mat-paginator\r\n *ngIf=\"hasPager\"\r\n [length]=\"total\"\r\n [pageSize]=\"pageSize.value || 10\"\r\n [pageSizeOptions]=\"[5, 10, 20]\"\r\n (page)=\"onPageChange($event)\"\r\n aria-label=\"Select page\"\r\n >\r\n </mat-paginator>\r\n\r\n <!-- subject ID -->\r\n <div>\r\n <cadmus-ref-lookup\r\n label=\"subject\"\r\n [service]=\"lookupService\"\r\n (itemChange)=\"onSubjectNodeChange($event)\"\r\n ></cadmus-ref-lookup>\r\n </div>\r\n\r\n <!-- predicate ID -->\r\n <div>\r\n <cadmus-ref-lookup\r\n label=\"predicate\"\r\n [service]=\"lookupService\"\r\n [baseFilter]=\"{ tag: 'property' }\"\r\n (itemChange)=\"onPredicateNodeChange($event)\"\r\n ></cadmus-ref-lookup>\r\n </div>\r\n\r\n <!-- LITERAL -->\r\n <!-- litPattern -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litPattern\" placeholder=\"pattern\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- litType -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litType\" placeholder=\"type\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- litLanguage-->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litLanguage\" placeholder=\"language\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- minLitNumber, maxLitNumber -->\r\n <div>\r\n <mat-form-field style=\"width: 5em\">\r\n <input\r\n matInput\r\n type=\"number\"\r\n [formControl]=\"minLitNumber\"\r\n placeholder=\"min.\"\r\n />\r\n </mat-form-field>\r\n -\r\n <mat-form-field style=\"width: 5em\">\r\n <input\r\n matInput\r\n type=\"number\"\r\n [formControl]=\"maxLitNumber\"\r\n placeholder=\"max.\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n <div\r\n class=\"btn-group\"\r\n role=\"group\"\r\n aria-label=\"toolbar\"\r\n style=\"margin-bottom: 10px\"\r\n >\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n (click)=\"reset()\"\r\n color=\"warn\"\r\n matTooltip=\"Reset filters\"\r\n [disabled]=\"disabled\"\r\n >\r\n <mat-icon>clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-icon-button\r\n color=\"primary\"\r\n [disabled]=\"disabled\"\r\n matTooltip=\"Apply filters\"\r\n >\r\n <mat-icon>check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\n" }]
|
|
1264
|
+
}], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: GraphNodeLookupService }, { type: GraphService }]; }, propDecorators: { disabled: [{
|
|
1265
|
+
type: Input
|
|
1266
|
+
}], hasPager: [{
|
|
1267
|
+
type: Input
|
|
1268
|
+
}], total: [{
|
|
1269
|
+
type: Input
|
|
1270
|
+
}], filter: [{
|
|
1271
|
+
type: Input
|
|
1272
|
+
}], filterChange: [{
|
|
1273
|
+
type: Output
|
|
1274
|
+
}] } });
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* Linked non-literal node filter.
|
|
1278
|
+
*/
|
|
1279
|
+
class LinkedNodeFilterComponent {
|
|
1280
|
+
/**
|
|
1281
|
+
* The filter.
|
|
1282
|
+
*/
|
|
1283
|
+
get filter() {
|
|
1284
|
+
return this._filter;
|
|
1285
|
+
}
|
|
1286
|
+
set filter(value) {
|
|
1287
|
+
if (this._filter === value) {
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
this._filter = value;
|
|
1291
|
+
this.updateForm(value);
|
|
1292
|
+
}
|
|
1293
|
+
constructor(formBuilder, lookupService, _graphService) {
|
|
1294
|
+
this.lookupService = lookupService;
|
|
1295
|
+
this._graphService = _graphService;
|
|
1296
|
+
this.otherNodeId = 0;
|
|
1297
|
+
this.predicateId = 0;
|
|
1298
|
+
this.isObject = false;
|
|
1299
|
+
this._filter = {
|
|
1300
|
+
pageNumber: 1,
|
|
1301
|
+
pageSize: 10,
|
|
1302
|
+
otherNodeId: 0,
|
|
1303
|
+
predicateId: 0,
|
|
1304
|
+
};
|
|
1305
|
+
this.total = 0;
|
|
1306
|
+
this.filterChange = new EventEmitter();
|
|
1307
|
+
// form
|
|
1308
|
+
this.pageNumber = formBuilder.control(1, { nonNullable: true });
|
|
1309
|
+
this.pageSize = formBuilder.control(10, { nonNullable: true });
|
|
1310
|
+
this.uid = formBuilder.control(null);
|
|
1311
|
+
this.isClass = formBuilder.control(null);
|
|
1312
|
+
this.tag = formBuilder.control(null);
|
|
1313
|
+
this.label = formBuilder.control(null);
|
|
1314
|
+
this.sourceType = formBuilder.control(null);
|
|
1315
|
+
this.sid = formBuilder.control(null);
|
|
1316
|
+
this.isSidPrefix = formBuilder.control(false, { nonNullable: true });
|
|
1317
|
+
this.classes = formBuilder.control([], { nonNullable: true });
|
|
1318
|
+
this.form = formBuilder.group({
|
|
1319
|
+
pageNumber: this.pageNumber,
|
|
1320
|
+
pageSize: this.pageSize,
|
|
1321
|
+
uid: this.uid,
|
|
1322
|
+
isClass: this.isClass,
|
|
1323
|
+
tag: this.tag,
|
|
1324
|
+
label: this.label,
|
|
1325
|
+
sourceType: this.sourceType,
|
|
1326
|
+
sid: this.sid,
|
|
1327
|
+
isSidPrefix: this.isSidPrefix,
|
|
1328
|
+
classes: this.classes,
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
ngOnInit() { }
|
|
1332
|
+
updateForm(filter) {
|
|
1333
|
+
var _a;
|
|
1334
|
+
this.otherNodeId = filter.otherNodeId;
|
|
1335
|
+
this.predicateId = filter.predicateId;
|
|
1336
|
+
this.isObject = filter.isObject || false;
|
|
1337
|
+
this.pageNumber.setValue(filter.pageNumber);
|
|
1338
|
+
this.pageSize.setValue(filter.pageSize);
|
|
1339
|
+
this.uid.setValue(filter.uid || null);
|
|
1340
|
+
this.isClass.setValue(filter.isClass || null);
|
|
1341
|
+
this.tag.setValue(filter.tag || null);
|
|
1342
|
+
this.label.setValue(filter.label || null);
|
|
1343
|
+
this.sourceType.setValue(filter.sourceType || null);
|
|
1344
|
+
this.sid.setValue(filter.sid || null);
|
|
1345
|
+
this.isSidPrefix.setValue(filter.isSidPrefix || false);
|
|
1346
|
+
// load the referenced class nodes so we can show them by label
|
|
1347
|
+
if ((_a = filter.classIds) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1348
|
+
this._graphService
|
|
1349
|
+
.getNodeSet(filter.classIds)
|
|
1350
|
+
.pipe(take(1))
|
|
1351
|
+
.subscribe((nodes) => {
|
|
1352
|
+
this.classes.setValue(nodes.filter((n) => n));
|
|
1353
|
+
this.form.markAsPristine();
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
else {
|
|
1357
|
+
this.classes.setValue([]);
|
|
1358
|
+
this.form.markAsPristine();
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
getFilter() {
|
|
1362
|
+
return {
|
|
1363
|
+
pageNumber: +this.pageNumber.value,
|
|
1364
|
+
pageSize: +this.pageSize.value,
|
|
1365
|
+
uid: this.uid.value || undefined,
|
|
1366
|
+
isClass: this.isClass.value || undefined,
|
|
1367
|
+
tag: this.tag.value || undefined,
|
|
1368
|
+
label: this.label.value || undefined,
|
|
1369
|
+
sourceType: this.sourceType.value || undefined,
|
|
1370
|
+
sid: this.sid.value || undefined,
|
|
1371
|
+
isSidPrefix: this.isSidPrefix.value ? true : undefined,
|
|
1372
|
+
classIds: this.classes.value.length
|
|
1373
|
+
? this.classes.value.map((n) => n.id)
|
|
1374
|
+
: undefined,
|
|
1375
|
+
otherNodeId: this.otherNodeId,
|
|
1376
|
+
predicateId: this.predicateId,
|
|
1377
|
+
isObject: this.isObject,
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
emitFilterChange() {
|
|
1381
|
+
this.filterChange.emit(this.getFilter());
|
|
1382
|
+
}
|
|
1383
|
+
onPageChange(page) {
|
|
1384
|
+
this.pageNumber.setValue(page.pageIndex + 1);
|
|
1385
|
+
this.emitFilterChange();
|
|
1386
|
+
}
|
|
1387
|
+
onClassAdd(node) {
|
|
1388
|
+
if (!node) {
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
const nodes = [...this.classes.value];
|
|
1392
|
+
nodes.push(node);
|
|
1393
|
+
this.classes.setValue(nodes);
|
|
1394
|
+
this.classes.updateValueAndValidity();
|
|
1395
|
+
this.classes.markAsDirty();
|
|
1396
|
+
}
|
|
1397
|
+
onClassRemove(node) {
|
|
1398
|
+
const nodes = [...this.classes.value];
|
|
1399
|
+
const i = nodes.indexOf(node);
|
|
1400
|
+
if (i > -1) {
|
|
1401
|
+
nodes.splice(i, 1);
|
|
1402
|
+
this.classes.setValue(nodes);
|
|
1403
|
+
this.classes.updateValueAndValidity();
|
|
1404
|
+
this.classes.markAsDirty();
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
reset() {
|
|
1408
|
+
this.form.reset();
|
|
1409
|
+
this._filter = this.getFilter();
|
|
1410
|
+
this.filterChange.emit(this._filter);
|
|
1411
|
+
}
|
|
1412
|
+
apply() {
|
|
1413
|
+
if (this.form.invalid) {
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
this.emitFilterChange();
|
|
1417
|
+
this.form.markAsPristine();
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
LinkedNodeFilterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: LinkedNodeFilterComponent, deps: [{ token: i1$1.FormBuilder }, { token: GraphNodeLookupService }, { token: GraphService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1421
|
+
LinkedNodeFilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: LinkedNodeFilterComponent, selector: "cadmus-linked-node-filter", inputs: { disabled: "disabled", hasPager: "hasPager", total: "total", filter: "filter" }, outputs: { filterChange: "filterChange" }, ngImport: i0, template: "<form [formGroup]=\"form\" (submit)=\"apply()\" ng-disabled=\"disabled\">\r\n <!-- paginator -->\r\n <mat-paginator\r\n *ngIf=\"hasPager\"\r\n [length]=\"total\"\r\n [pageSize]=\"pageSize.value || 10\"\r\n [pageSizeOptions]=\"[5, 10, 20]\"\r\n (page)=\"onPageChange($event)\"\r\n aria-label=\"Select page\"\r\n >\r\n </mat-paginator>\r\n\r\n <!-- label -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"label\" placeholder=\"label\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- uid -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"uid\" placeholder=\"UID\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- isClass -->\r\n <div>\r\n <mat-form-field>\r\n <mat-select [formControl]=\"isClass\" placeholder=\"class\">\r\n <mat-option [value]=\"0\">(any)</mat-option>\r\n <mat-option [value]=\"1\">not-class</mat-option>\r\n <mat-option [value]=\"2\">class</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n <!-- tag -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"tag\" placeholder=\"tag\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- sourceType -->\r\n <div>\r\n <mat-form-field>\r\n <mat-select [formControl]=\"sourceType\" placeholder=\"source type\">\r\n <mat-option [value]=\"null\">(any)</mat-option>\r\n <mat-option [value]=\"0\">user</mat-option>\r\n <mat-option [value]=\"1\">item</mat-option>\r\n <mat-option [value]=\"2\">part</mat-option>\r\n <mat-option [value]=\"3\">thesaurus</mat-option>\r\n <mat-option [value]=\"4\">implicit</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n <div>\r\n <!-- sid -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"sid\" placeholder=\"SID\" />\r\n </mat-form-field>\r\n\r\n <!-- isSidPrefix -->\r\n <mat-checkbox [formControl]=\"isSidPrefix\">prefix</mat-checkbox>\r\n </div>\r\n </div>\r\n <!-- classes -->\r\n <div>\r\n <fieldset>\r\n <legend>classes</legend>\r\n <cadmus-ref-lookup\r\n label=\"class\"\r\n [service]=\"lookupService\"\r\n [baseFilter]=\"{ isClass: true }\"\r\n (itemChange)=\"onClassAdd($event)\"\r\n ></cadmus-ref-lookup>\r\n\r\n <mat-chip-listbox *ngIf=\"classes.value?.length\">\r\n <mat-chip-option\r\n *ngFor=\"let node of classes.value\"\r\n [removable]=\"true\"\r\n (removed)=\"onClassRemove(node)\"\r\n matTooltip=\"{{ node.uri }}\"\r\n >{{ node.label }}\r\n <button type=\"button\" matChipRemove>\r\n <mat-icon>cancel</mat-icon>\r\n </button>\r\n </mat-chip-option>\r\n </mat-chip-listbox>\r\n </fieldset>\r\n </div>\r\n\r\n <div\r\n class=\"btn-group\"\r\n role=\"group\"\r\n aria-label=\"toolbar\"\r\n style=\"margin-bottom: 10px\"\r\n >\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n (click)=\"reset()\"\r\n color=\"warn\"\r\n matTooltip=\"Reset filters\"\r\n [disabled]=\"disabled\"\r\n >\r\n <mat-icon>clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-icon-button\r\n color=\"primary\"\r\n [disabled]=\"disabled\"\r\n matTooltip=\"Apply filters\"\r\n >\r\n <mat-icon>check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\n", styles: ["fieldset{border:1px solid silver;border-radius:4px;padding:4px}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i5$1.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i7$1.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "component", type: i8$1.MatChipListbox, selector: "mat-chip-listbox", inputs: ["tabIndex", "multiple", "aria-orientation", "selectable", "compareWith", "required", "value"], outputs: ["change"] }, { kind: "component", type: i8$1.MatChipOption, selector: "mat-basic-chip-option, mat-chip-option", inputs: ["color", "disabled", "disableRipple", "tabIndex", "selectable", "selected"], outputs: ["selectionChange"] }, { kind: "directive", type: i8$1.MatChipRemove, selector: "[matChipRemove]" }, { kind: "component", type: i6.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "component", type: i7.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i9.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }, { kind: "component", type: i13.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "directive", type: i10.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i11.RefLookupComponent, selector: "cadmus-ref-lookup", inputs: ["label", "limit", "baseFilter", "service", "item", "required", "hasMore", "linkTemplate", "optDialog", "options"], outputs: ["itemChange", "moreRequest"] }] });
|
|
1422
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: LinkedNodeFilterComponent, decorators: [{
|
|
1423
|
+
type: Component,
|
|
1424
|
+
args: [{ selector: 'cadmus-linked-node-filter', template: "<form [formGroup]=\"form\" (submit)=\"apply()\" ng-disabled=\"disabled\">\r\n <!-- paginator -->\r\n <mat-paginator\r\n *ngIf=\"hasPager\"\r\n [length]=\"total\"\r\n [pageSize]=\"pageSize.value || 10\"\r\n [pageSizeOptions]=\"[5, 10, 20]\"\r\n (page)=\"onPageChange($event)\"\r\n aria-label=\"Select page\"\r\n >\r\n </mat-paginator>\r\n\r\n <!-- label -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"label\" placeholder=\"label\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- uid -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"uid\" placeholder=\"UID\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- isClass -->\r\n <div>\r\n <mat-form-field>\r\n <mat-select [formControl]=\"isClass\" placeholder=\"class\">\r\n <mat-option [value]=\"0\">(any)</mat-option>\r\n <mat-option [value]=\"1\">not-class</mat-option>\r\n <mat-option [value]=\"2\">class</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n <!-- tag -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"tag\" placeholder=\"tag\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- sourceType -->\r\n <div>\r\n <mat-form-field>\r\n <mat-select [formControl]=\"sourceType\" placeholder=\"source type\">\r\n <mat-option [value]=\"null\">(any)</mat-option>\r\n <mat-option [value]=\"0\">user</mat-option>\r\n <mat-option [value]=\"1\">item</mat-option>\r\n <mat-option [value]=\"2\">part</mat-option>\r\n <mat-option [value]=\"3\">thesaurus</mat-option>\r\n <mat-option [value]=\"4\">implicit</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n <div>\r\n <!-- sid -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"sid\" placeholder=\"SID\" />\r\n </mat-form-field>\r\n\r\n <!-- isSidPrefix -->\r\n <mat-checkbox [formControl]=\"isSidPrefix\">prefix</mat-checkbox>\r\n </div>\r\n </div>\r\n <!-- classes -->\r\n <div>\r\n <fieldset>\r\n <legend>classes</legend>\r\n <cadmus-ref-lookup\r\n label=\"class\"\r\n [service]=\"lookupService\"\r\n [baseFilter]=\"{ isClass: true }\"\r\n (itemChange)=\"onClassAdd($event)\"\r\n ></cadmus-ref-lookup>\r\n\r\n <mat-chip-listbox *ngIf=\"classes.value?.length\">\r\n <mat-chip-option\r\n *ngFor=\"let node of classes.value\"\r\n [removable]=\"true\"\r\n (removed)=\"onClassRemove(node)\"\r\n matTooltip=\"{{ node.uri }}\"\r\n >{{ node.label }}\r\n <button type=\"button\" matChipRemove>\r\n <mat-icon>cancel</mat-icon>\r\n </button>\r\n </mat-chip-option>\r\n </mat-chip-listbox>\r\n </fieldset>\r\n </div>\r\n\r\n <div\r\n class=\"btn-group\"\r\n role=\"group\"\r\n aria-label=\"toolbar\"\r\n style=\"margin-bottom: 10px\"\r\n >\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n (click)=\"reset()\"\r\n color=\"warn\"\r\n matTooltip=\"Reset filters\"\r\n [disabled]=\"disabled\"\r\n >\r\n <mat-icon>clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-icon-button\r\n color=\"primary\"\r\n [disabled]=\"disabled\"\r\n matTooltip=\"Apply filters\"\r\n >\r\n <mat-icon>check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\n", styles: ["fieldset{border:1px solid silver;border-radius:4px;padding:4px}\n"] }]
|
|
1425
|
+
}], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: GraphNodeLookupService }, { type: GraphService }]; }, propDecorators: { disabled: [{
|
|
1426
|
+
type: Input
|
|
1427
|
+
}], hasPager: [{
|
|
1428
|
+
type: Input
|
|
1429
|
+
}], total: [{
|
|
1430
|
+
type: Input
|
|
1431
|
+
}], filter: [{
|
|
1432
|
+
type: Input
|
|
1433
|
+
}], filterChange: [{
|
|
1434
|
+
type: Output
|
|
1435
|
+
}] } });
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* Triples filter.
|
|
1439
|
+
*/
|
|
1440
|
+
class TripleFilterComponent {
|
|
1441
|
+
/**
|
|
1442
|
+
* The filter.
|
|
1443
|
+
*/
|
|
1444
|
+
get filter() {
|
|
1445
|
+
return this._filter;
|
|
1446
|
+
}
|
|
1447
|
+
set filter(value) {
|
|
1448
|
+
if (this._filter === value) {
|
|
1449
|
+
return;
|
|
1450
|
+
}
|
|
1451
|
+
this._filter = value;
|
|
1452
|
+
this.updateForm(value);
|
|
1453
|
+
}
|
|
1454
|
+
constructor(formBuilder, lookupService, _graphService) {
|
|
1455
|
+
this.lookupService = lookupService;
|
|
1456
|
+
this._graphService = _graphService;
|
|
1457
|
+
this._filter = {
|
|
1458
|
+
pageNumber: 1,
|
|
1459
|
+
pageSize: 10,
|
|
1460
|
+
};
|
|
1461
|
+
this.total = 0;
|
|
1462
|
+
this.filterChange = new EventEmitter();
|
|
1463
|
+
// form
|
|
1464
|
+
this.pageNumber = formBuilder.control(1, { nonNullable: true });
|
|
1465
|
+
this.pageSize = formBuilder.control(10, { nonNullable: true });
|
|
1466
|
+
this.litPattern = formBuilder.control(null);
|
|
1467
|
+
this.litType = formBuilder.control(null);
|
|
1468
|
+
this.litLanguage = formBuilder.control(null);
|
|
1469
|
+
this.minLitNumber = formBuilder.control(null);
|
|
1470
|
+
this.maxLitNumber = formBuilder.control(null);
|
|
1471
|
+
this.subj = formBuilder.control(null);
|
|
1472
|
+
this.preds = formBuilder.control([], { nonNullable: true });
|
|
1473
|
+
this.isNotPred = formBuilder.control(false, { nonNullable: true });
|
|
1474
|
+
this.notPreds = formBuilder.control([], { nonNullable: true });
|
|
1475
|
+
this.hasLiteralObj = formBuilder.control(null);
|
|
1476
|
+
this.obj = formBuilder.control(null);
|
|
1477
|
+
this.sid = formBuilder.control(null);
|
|
1478
|
+
this.isSidPrefix = formBuilder.control(false, { nonNullable: true });
|
|
1479
|
+
this.tag = formBuilder.control(null);
|
|
1480
|
+
this.form = formBuilder.group({
|
|
1481
|
+
pageNumber: this.pageNumber,
|
|
1482
|
+
pageSize: this.pageSize,
|
|
1483
|
+
litPattern: this.litPattern,
|
|
1484
|
+
litType: this.litType,
|
|
1485
|
+
litLanguage: this.litLanguage,
|
|
1486
|
+
minLitNumber: this.minLitNumber,
|
|
1487
|
+
maxLitNumber: this.maxLitNumber,
|
|
1488
|
+
subj: this.subj,
|
|
1489
|
+
preds: this.preds,
|
|
1490
|
+
isNotPred: this.isNotPred,
|
|
1491
|
+
notPreds: this.notPreds,
|
|
1492
|
+
hasLiteralObj: this.hasLiteralObj,
|
|
1493
|
+
obj: this.obj,
|
|
1494
|
+
sid: this.sid,
|
|
1495
|
+
isSidPrefix: this.isSidPrefix,
|
|
1496
|
+
tag: this.tag,
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
ngOnInit() { }
|
|
1500
|
+
updateForm(filter) {
|
|
1501
|
+
var _a;
|
|
1502
|
+
this.pageNumber.setValue(filter.pageNumber);
|
|
1503
|
+
this.pageSize.setValue(filter.pageSize);
|
|
1504
|
+
this.litPattern.setValue(filter.literalPattern || null);
|
|
1505
|
+
this.litType.setValue(filter.literalType || null);
|
|
1506
|
+
this.litLanguage.setValue(filter.literalLanguage || null);
|
|
1507
|
+
this.minLitNumber.setValue(filter.minLiteralNumber || null);
|
|
1508
|
+
this.maxLitNumber.setValue(filter.maxLiteralNumber || null);
|
|
1509
|
+
this.hasLiteralObj.setValue(filter.hasLiteralObject || null);
|
|
1510
|
+
this.sid.setValue(filter.sid || null);
|
|
1511
|
+
this.isSidPrefix.setValue(filter.isSidPrefix || false);
|
|
1512
|
+
this.tag.setValue(filter.tag || null);
|
|
1513
|
+
// load the referenced nodes so we can show them by label
|
|
1514
|
+
forkJoin({
|
|
1515
|
+
s: filter.subjectId
|
|
1516
|
+
? this._graphService.getNode(filter.subjectId)
|
|
1517
|
+
: from([null]),
|
|
1518
|
+
p: ((_a = filter.predicateIds) === null || _a === void 0 ? void 0 : _a.length)
|
|
1519
|
+
? this._graphService.getNodeSet(filter.predicateIds)
|
|
1520
|
+
: from([]),
|
|
1521
|
+
o: filter.objectId
|
|
1522
|
+
? this._graphService.getNode(filter.objectId)
|
|
1523
|
+
: from([null]),
|
|
1524
|
+
}).subscribe((result) => {
|
|
1525
|
+
this.subj.setValue(result.s);
|
|
1526
|
+
this.preds.setValue(result.p.filter((n) => n));
|
|
1527
|
+
this.obj.setValue(result.o);
|
|
1528
|
+
this.form.markAsPristine();
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
getFilter() {
|
|
1532
|
+
var _a, _b, _c, _d;
|
|
1533
|
+
return {
|
|
1534
|
+
pageNumber: +this.pageNumber.value,
|
|
1535
|
+
pageSize: +this.pageSize.value,
|
|
1536
|
+
literalPattern: this.litPattern.value || undefined,
|
|
1537
|
+
literalType: this.litType.value || undefined,
|
|
1538
|
+
literalLanguage: this.litLanguage.value || undefined,
|
|
1539
|
+
minLiteralNumber: this.minLitNumber.value || undefined,
|
|
1540
|
+
maxLiteralNumber: this.maxLitNumber.value || undefined,
|
|
1541
|
+
subjectId: ((_a = this.subj.value) === null || _a === void 0 ? void 0 : _a.id) || undefined,
|
|
1542
|
+
predicateIds: ((_b = this.preds.value) === null || _b === void 0 ? void 0 : _b.length)
|
|
1543
|
+
? this.preds.value.map((n) => n.id)
|
|
1544
|
+
: undefined,
|
|
1545
|
+
notPredicateIds: ((_c = this.notPreds.value) === null || _c === void 0 ? void 0 : _c.length)
|
|
1546
|
+
? this.notPreds.value.map((n) => n.id)
|
|
1547
|
+
: undefined,
|
|
1548
|
+
hasLiteralObject: this.hasLiteralObj.value !== null
|
|
1549
|
+
? this.hasLiteralObj.value
|
|
1550
|
+
: undefined,
|
|
1551
|
+
objectId: ((_d = this.obj.value) === null || _d === void 0 ? void 0 : _d.id) || undefined,
|
|
1552
|
+
sid: this.sid.value || undefined,
|
|
1553
|
+
isSidPrefix: this.isSidPrefix.value,
|
|
1554
|
+
tag: this.tag.value || undefined,
|
|
1555
|
+
};
|
|
1556
|
+
}
|
|
1557
|
+
emitFilterChange() {
|
|
1558
|
+
this.filterChange.emit(this.getFilter());
|
|
1559
|
+
}
|
|
1560
|
+
onPageChange(page) {
|
|
1561
|
+
this.pageNumber.setValue(page.pageIndex + 1);
|
|
1562
|
+
this.emitFilterChange();
|
|
1563
|
+
}
|
|
1564
|
+
onSubjectNodeChange(node) {
|
|
1565
|
+
this.subj.setValue(node);
|
|
1566
|
+
}
|
|
1567
|
+
onObjectNodeChange(node) {
|
|
1568
|
+
this.obj.setValue(node);
|
|
1569
|
+
}
|
|
1570
|
+
onPredicateNodeChange(node) {
|
|
1571
|
+
if (!node) {
|
|
1572
|
+
return;
|
|
1573
|
+
}
|
|
1574
|
+
if (this.isNotPred.value) {
|
|
1575
|
+
const nodes = [...this.notPreds.value];
|
|
1576
|
+
if (nodes.some((n) => n.id === node.id)) {
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
nodes.push(node);
|
|
1580
|
+
this.notPreds.setValue(nodes);
|
|
1581
|
+
this.notPreds.updateValueAndValidity();
|
|
1582
|
+
this.notPreds.markAsDirty();
|
|
1583
|
+
}
|
|
1584
|
+
else {
|
|
1585
|
+
const nodes = [...this.preds.value];
|
|
1586
|
+
if (nodes.some((n) => n.id === node.id)) {
|
|
1587
|
+
return;
|
|
1588
|
+
}
|
|
1589
|
+
nodes.push(node);
|
|
1590
|
+
this.preds.setValue(nodes);
|
|
1591
|
+
this.preds.updateValueAndValidity();
|
|
1592
|
+
this.preds.markAsDirty();
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
deleteNotPred(node) {
|
|
1596
|
+
const nodes = [...this.notPreds.value];
|
|
1597
|
+
const i = nodes.indexOf(node);
|
|
1598
|
+
nodes.splice(i, 1);
|
|
1599
|
+
this.notPreds.setValue(nodes);
|
|
1600
|
+
this.notPreds.updateValueAndValidity();
|
|
1601
|
+
this.notPreds.markAsDirty();
|
|
1602
|
+
}
|
|
1603
|
+
deletePred(node) {
|
|
1604
|
+
const nodes = [...this.preds.value];
|
|
1605
|
+
const i = nodes.indexOf(node);
|
|
1606
|
+
nodes.splice(i, 1);
|
|
1607
|
+
this.preds.setValue(nodes);
|
|
1608
|
+
this.preds.updateValueAndValidity();
|
|
1609
|
+
this.preds.markAsDirty();
|
|
1610
|
+
}
|
|
1611
|
+
reset() {
|
|
1612
|
+
this.form.reset();
|
|
1613
|
+
this._filter = this.getFilter();
|
|
1614
|
+
this.filterChange.emit(this._filter);
|
|
1615
|
+
}
|
|
1616
|
+
apply() {
|
|
1617
|
+
if (this.form.invalid) {
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
this.emitFilterChange();
|
|
1621
|
+
this.form.markAsPristine();
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
TripleFilterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: TripleFilterComponent, deps: [{ token: i1$1.FormBuilder }, { token: GraphNodeLookupService }, { token: GraphService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1625
|
+
TripleFilterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: TripleFilterComponent, selector: "cadmus-triple-filter", inputs: { disabled: "disabled", hasPager: "hasPager", total: "total", filter: "filter" }, outputs: { filterChange: "filterChange" }, ngImport: i0, template: "<form [formGroup]=\"form\" (submit)=\"apply()\" ng-disabled=\"disabled\">\r\n <!-- paginator -->\r\n <mat-paginator\r\n *ngIf=\"hasPager\"\r\n [length]=\"total\"\r\n [pageSize]=\"pageSize.value || 10\"\r\n [pageSizeOptions]=\"[5, 10, 20]\"\r\n (page)=\"onPageChange($event)\"\r\n aria-label=\"Select page\"\r\n >\r\n </mat-paginator>\r\n <mat-tab-group>\r\n <!-- TRIPLE -->\r\n <mat-tab label=\"triple\">\r\n <!-- subject ID -->\r\n <div>\r\n <cadmus-ref-lookup\r\n label=\"subject\"\r\n [service]=\"lookupService\"\r\n (itemChange)=\"onSubjectNodeChange($event)\"\r\n ></cadmus-ref-lookup>\r\n </div>\r\n <!-- predicate IDs -->\r\n <div>\r\n <cadmus-ref-lookup\r\n label=\"predicate\"\r\n [service]=\"lookupService\"\r\n [baseFilter]=\"{ tag: 'property' }\"\r\n (itemChange)=\"onPredicateNodeChange($event)\"\r\n ></cadmus-ref-lookup>\r\n <mat-checkbox [formControl]=\"isNotPred\">not</mat-checkbox>\r\n <!-- notPreds -->\r\n <div *ngIf=\"isNotPred?.value\">\r\n <mat-list dense>\r\n <mat-list-item *ngFor=\"let n of notPreds.value\">\r\n <span>{{ n.label }}</span>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"warn\"\r\n (click)=\"deleteNotPred(n)\"\r\n >\r\n <mat-icon>clear</mat-icon>\r\n </button>\r\n </mat-list-item>\r\n </mat-list>\r\n </div>\r\n <!-- preds -->\r\n <div *ngIf=\"!isNotPred?.value\">\r\n <mat-list dense>\r\n <mat-list-item *ngFor=\"let n of preds.value\">\r\n <span>{{ n.label }}</span>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"warn\"\r\n (click)=\"deletePred(n)\"\r\n >\r\n <mat-icon>clear</mat-icon>\r\n </button>\r\n </mat-list-item>\r\n </mat-list>\r\n </div>\r\n </div>\r\n <!-- object ID -->\r\n <div>\r\n <cadmus-ref-lookup\r\n label=\"object\"\r\n [service]=\"lookupService\"\r\n (itemChange)=\"onObjectNodeChange($event)\"\r\n ></cadmus-ref-lookup>\r\n </div>\r\n <!-- sid -->\r\n <div>\r\n <mat-form-field>\r\n <input\r\n matInput\r\n [formControl]=\"sid\"\r\n placeholder=\"sid\"\r\n maxlength=\"500\"\r\n />\r\n </mat-form-field>\r\n \r\n <mat-checkbox [formControl]=\"isSidPrefix\">prefix</mat-checkbox>\r\n </div>\r\n <!-- tag -->\r\n <div>\r\n <mat-form-field>\r\n <input\r\n matInput\r\n [formControl]=\"tag\"\r\n placeholder=\"tag\"\r\n maxlength=\"50\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n </mat-tab>\r\n <!-- LITERAL -->\r\n <mat-tab label=\"literal\">\r\n <!-- litPattern -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litPattern\" placeholder=\"pattern\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- litType -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litType\" placeholder=\"type\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- litLanguage-->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litLanguage\" placeholder=\"language\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- minLitNumber, maxLitNumber -->\r\n <div>\r\n <mat-form-field style=\"width: 4em\">\r\n <input\r\n matInput\r\n type=\"number\"\r\n [formControl]=\"minLitNumber\"\r\n placeholder=\"min.\"\r\n />\r\n </mat-form-field>\r\n -\r\n <mat-form-field style=\"width: 4em\">\r\n <input\r\n matInput\r\n type=\"number\"\r\n [formControl]=\"maxLitNumber\"\r\n placeholder=\"max.\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n </mat-tab>\r\n </mat-tab-group>\r\n <div\r\n class=\"btn-group\"\r\n role=\"group\"\r\n aria-label=\"toolbar\"\r\n style=\"margin-bottom: 10px\"\r\n >\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n (click)=\"reset()\"\r\n color=\"warn\"\r\n matTooltip=\"Reset filters\"\r\n [disabled]=\"disabled\"\r\n >\r\n <mat-icon>clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-icon-button\r\n color=\"primary\"\r\n [disabled]=\"disabled\"\r\n matTooltip=\"Apply filters\"\r\n >\r\n <mat-icon>check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i7$1.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "component", type: i6.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "component", type: i7.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i10$1.MatList, selector: "mat-list", exportAs: ["matList"] }, { kind: "component", type: i10$1.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["activated"], exportAs: ["matListItem"] }, { kind: "component", type: i9.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }, { kind: "component", type: i7$2.MatTab, selector: "mat-tab", inputs: ["disabled"], exportAs: ["matTab"] }, { kind: "component", type: i7$2.MatTabGroup, selector: "mat-tab-group", inputs: ["color", "disableRipple", "fitInkBarToContent", "mat-stretch-tabs"], exportAs: ["matTabGroup"] }, { kind: "directive", type: i10.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i11.RefLookupComponent, selector: "cadmus-ref-lookup", inputs: ["label", "limit", "baseFilter", "service", "item", "required", "hasMore", "linkTemplate", "optDialog", "options"], outputs: ["itemChange", "moreRequest"] }] });
|
|
1626
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: TripleFilterComponent, decorators: [{
|
|
1627
|
+
type: Component,
|
|
1628
|
+
args: [{ selector: 'cadmus-triple-filter', template: "<form [formGroup]=\"form\" (submit)=\"apply()\" ng-disabled=\"disabled\">\r\n <!-- paginator -->\r\n <mat-paginator\r\n *ngIf=\"hasPager\"\r\n [length]=\"total\"\r\n [pageSize]=\"pageSize.value || 10\"\r\n [pageSizeOptions]=\"[5, 10, 20]\"\r\n (page)=\"onPageChange($event)\"\r\n aria-label=\"Select page\"\r\n >\r\n </mat-paginator>\r\n <mat-tab-group>\r\n <!-- TRIPLE -->\r\n <mat-tab label=\"triple\">\r\n <!-- subject ID -->\r\n <div>\r\n <cadmus-ref-lookup\r\n label=\"subject\"\r\n [service]=\"lookupService\"\r\n (itemChange)=\"onSubjectNodeChange($event)\"\r\n ></cadmus-ref-lookup>\r\n </div>\r\n <!-- predicate IDs -->\r\n <div>\r\n <cadmus-ref-lookup\r\n label=\"predicate\"\r\n [service]=\"lookupService\"\r\n [baseFilter]=\"{ tag: 'property' }\"\r\n (itemChange)=\"onPredicateNodeChange($event)\"\r\n ></cadmus-ref-lookup>\r\n <mat-checkbox [formControl]=\"isNotPred\">not</mat-checkbox>\r\n <!-- notPreds -->\r\n <div *ngIf=\"isNotPred?.value\">\r\n <mat-list dense>\r\n <mat-list-item *ngFor=\"let n of notPreds.value\">\r\n <span>{{ n.label }}</span>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"warn\"\r\n (click)=\"deleteNotPred(n)\"\r\n >\r\n <mat-icon>clear</mat-icon>\r\n </button>\r\n </mat-list-item>\r\n </mat-list>\r\n </div>\r\n <!-- preds -->\r\n <div *ngIf=\"!isNotPred?.value\">\r\n <mat-list dense>\r\n <mat-list-item *ngFor=\"let n of preds.value\">\r\n <span>{{ n.label }}</span>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n color=\"warn\"\r\n (click)=\"deletePred(n)\"\r\n >\r\n <mat-icon>clear</mat-icon>\r\n </button>\r\n </mat-list-item>\r\n </mat-list>\r\n </div>\r\n </div>\r\n <!-- object ID -->\r\n <div>\r\n <cadmus-ref-lookup\r\n label=\"object\"\r\n [service]=\"lookupService\"\r\n (itemChange)=\"onObjectNodeChange($event)\"\r\n ></cadmus-ref-lookup>\r\n </div>\r\n <!-- sid -->\r\n <div>\r\n <mat-form-field>\r\n <input\r\n matInput\r\n [formControl]=\"sid\"\r\n placeholder=\"sid\"\r\n maxlength=\"500\"\r\n />\r\n </mat-form-field>\r\n \r\n <mat-checkbox [formControl]=\"isSidPrefix\">prefix</mat-checkbox>\r\n </div>\r\n <!-- tag -->\r\n <div>\r\n <mat-form-field>\r\n <input\r\n matInput\r\n [formControl]=\"tag\"\r\n placeholder=\"tag\"\r\n maxlength=\"50\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n </mat-tab>\r\n <!-- LITERAL -->\r\n <mat-tab label=\"literal\">\r\n <!-- litPattern -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litPattern\" placeholder=\"pattern\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- litType -->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litType\" placeholder=\"type\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- litLanguage-->\r\n <div>\r\n <mat-form-field>\r\n <input matInput [formControl]=\"litLanguage\" placeholder=\"language\" />\r\n </mat-form-field>\r\n </div>\r\n <!-- minLitNumber, maxLitNumber -->\r\n <div>\r\n <mat-form-field style=\"width: 4em\">\r\n <input\r\n matInput\r\n type=\"number\"\r\n [formControl]=\"minLitNumber\"\r\n placeholder=\"min.\"\r\n />\r\n </mat-form-field>\r\n -\r\n <mat-form-field style=\"width: 4em\">\r\n <input\r\n matInput\r\n type=\"number\"\r\n [formControl]=\"maxLitNumber\"\r\n placeholder=\"max.\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n </mat-tab>\r\n </mat-tab-group>\r\n <div\r\n class=\"btn-group\"\r\n role=\"group\"\r\n aria-label=\"toolbar\"\r\n style=\"margin-bottom: 10px\"\r\n >\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n (click)=\"reset()\"\r\n color=\"warn\"\r\n matTooltip=\"Reset filters\"\r\n [disabled]=\"disabled\"\r\n >\r\n <mat-icon>clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-icon-button\r\n color=\"primary\"\r\n [disabled]=\"disabled\"\r\n matTooltip=\"Apply filters\"\r\n >\r\n <mat-icon>check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\n" }]
|
|
1629
|
+
}], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: GraphNodeLookupService }, { type: GraphService }]; }, propDecorators: { disabled: [{
|
|
1630
|
+
type: Input
|
|
1631
|
+
}], hasPager: [{
|
|
1632
|
+
type: Input
|
|
1633
|
+
}], total: [{
|
|
1634
|
+
type: Input
|
|
1635
|
+
}], filter: [{
|
|
1636
|
+
type: Input
|
|
1637
|
+
}], filterChange: [{
|
|
1638
|
+
type: Output
|
|
1639
|
+
}] } });
|
|
1640
|
+
|
|
1641
|
+
/**
|
|
1642
|
+
* Get the extended label for the specified graph node. This returns the label
|
|
1643
|
+
* for N nodes, and the uri + "=" + the label for P nodes. That's because P
|
|
1644
|
+
* nodes label is just the count of the triples group, so the predicate ID is
|
|
1645
|
+
* got from the property node's data uri.
|
|
1646
|
+
*/
|
|
1647
|
+
class GraphNodeLabelPipe {
|
|
1648
|
+
transform(value, ...args) {
|
|
1649
|
+
const node = value;
|
|
1650
|
+
if (!(node === null || node === void 0 ? void 0 : node.id) || !(node === null || node === void 0 ? void 0 : node.label)) {
|
|
1651
|
+
return value;
|
|
1652
|
+
}
|
|
1653
|
+
if (node.id.startsWith('P') && node.data.uri) {
|
|
1654
|
+
return `${node.data.uri}=${node.label}`;
|
|
1655
|
+
}
|
|
1656
|
+
return node.label;
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
GraphNodeLabelPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLabelPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1660
|
+
GraphNodeLabelPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLabelPipe, name: "graphNodeLabel" });
|
|
1661
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLabelPipe, decorators: [{
|
|
1662
|
+
type: Pipe,
|
|
1663
|
+
args: [{
|
|
1664
|
+
name: 'graphNodeLabel'
|
|
1665
|
+
}]
|
|
1666
|
+
}] });
|
|
1667
|
+
|
|
1668
|
+
/**
|
|
1669
|
+
* Graph walker component. This starts from a given node, and let users
|
|
1670
|
+
* walk along edges to discover new nodes.
|
|
1671
|
+
*/
|
|
1672
|
+
class GraphWalkerComponent {
|
|
1673
|
+
/**
|
|
1674
|
+
* The root origin node ID.
|
|
1675
|
+
*/
|
|
1676
|
+
get nodeId() {
|
|
1677
|
+
return this._nodeId;
|
|
1678
|
+
}
|
|
1679
|
+
set nodeId(value) {
|
|
1680
|
+
if (this._nodeId === value) {
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
this._nodeId = value;
|
|
1684
|
+
this.reset(value);
|
|
1685
|
+
}
|
|
1686
|
+
constructor(graphService, _dialog) {
|
|
1687
|
+
this._dialog = _dialog;
|
|
1688
|
+
// ngx-graph actions
|
|
1689
|
+
this.update$ = new Subject();
|
|
1690
|
+
this.center$ = new Subject();
|
|
1691
|
+
this.zoomToFit$ = new Subject();
|
|
1692
|
+
this._walker = new GraphWalker(graphService);
|
|
1693
|
+
this._nodeId = 0;
|
|
1694
|
+
this.nodePick = new EventEmitter();
|
|
1695
|
+
this.nodes$ = this._walker.nodes$;
|
|
1696
|
+
this.edges$ = this._walker.edges$;
|
|
1697
|
+
this.loading$ = this._walker.loading$;
|
|
1698
|
+
this.error$ = this._walker.error$;
|
|
1699
|
+
this.selectedNode$ = this._walker.selectedNode$;
|
|
1700
|
+
this.pOutFilter$ = this._walker.pOutFilter$;
|
|
1701
|
+
this.pInFilter$ = this._walker.pInFilter$;
|
|
1702
|
+
this.pLitFilter$ = this._walker.pLitFilter$;
|
|
1703
|
+
this.nOutFilter$ = this._walker.nOutFilter$;
|
|
1704
|
+
this.nInFilter$ = this._walker.nInFilter$;
|
|
1705
|
+
this.childTotals$ = this._walker.childTotals$;
|
|
1706
|
+
}
|
|
1707
|
+
ngOnInit() {
|
|
1708
|
+
this.update$.subscribe((_) => {
|
|
1709
|
+
this.onReset();
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
onNodeSelect(node) {
|
|
1713
|
+
this._walker.selectNode(node.id);
|
|
1714
|
+
}
|
|
1715
|
+
reset(id) {
|
|
1716
|
+
this._walker.reset(id);
|
|
1717
|
+
}
|
|
1718
|
+
onReset() {
|
|
1719
|
+
if (!this._nodeId) {
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
this._dialog
|
|
1723
|
+
.confirm('Reset', 'Reset the whole graph?')
|
|
1724
|
+
.pipe(take$1(1))
|
|
1725
|
+
.subscribe((yes) => {
|
|
1726
|
+
if (yes) {
|
|
1727
|
+
this.reset(this._nodeId);
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
onNodeDblClick(node) {
|
|
1732
|
+
this._walker.toggleNode(node);
|
|
1733
|
+
}
|
|
1734
|
+
onPOutFilterChange(filter) {
|
|
1735
|
+
this._walker.expandSelectedProperty(filter);
|
|
1736
|
+
}
|
|
1737
|
+
onPInFilterChange(filter) {
|
|
1738
|
+
this._walker.expandSelectedProperty(null, filter);
|
|
1739
|
+
}
|
|
1740
|
+
onPLitFilterChange(filter) {
|
|
1741
|
+
this._walker.expandSelectedProperty(null, null, filter);
|
|
1742
|
+
}
|
|
1743
|
+
onNOutFilterChange(filter) {
|
|
1744
|
+
this._walker.expandSelectedNode(filter);
|
|
1745
|
+
}
|
|
1746
|
+
onNInFilterChange(filter) {
|
|
1747
|
+
this._walker.expandSelectedNode(null, filter);
|
|
1748
|
+
}
|
|
1749
|
+
pickSelectedNode() {
|
|
1750
|
+
const node = this._walker.getSelectedNode();
|
|
1751
|
+
if (!node) {
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
this.nodePick.emit(node);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
GraphWalkerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphWalkerComponent, deps: [{ token: GraphService }, { token: i2$1.DialogService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1758
|
+
GraphWalkerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GraphWalkerComponent, selector: "cadmus-graph-walker", inputs: { nodeId: "nodeId", canPick: "canPick" }, outputs: { nodePick: "nodePick" }, ngImport: i0, template: "<div id=\"container\">\r\n <!-- graph -->\r\n <div id=\"graph\">\r\n <ngx-graph\r\n class=\"chart-container\"\r\n [showMiniMap]=\"true\"\r\n [links]=\"(edges$ | async) || []\"\r\n [nodes]=\"(nodes$ | async) || []\"\r\n [update$]=\"update$\"\r\n [center$]=\"center$\"\r\n [zoomToFit$]=\"zoomToFit$\"\r\n layout=\"colaForceDirected\"\r\n (select)=\"onNodeSelect($event)\"\r\n >\r\n <ng-template #defsTemplate>\r\n <svg:marker\r\n id=\"arrow\"\r\n viewBox=\"0 -5 10 10\"\r\n refX=\"8\"\r\n refY=\"0\"\r\n markerWidth=\"4\"\r\n markerHeight=\"4\"\r\n orient=\"auto\"\r\n >\r\n <svg:path d=\"M0,-5L10,0L0,5\" class=\"arrow-head\" />\r\n </svg:marker>\r\n </ng-template>\r\n\r\n <!-- cluster template -->\r\n <ng-template #clusterTemplate let-cluster>\r\n <svg:g class=\"node cluster\">\r\n <svg:rect\r\n rx=\"5\"\r\n ry=\"5\"\r\n [attr.width]=\"cluster.dimension.width\"\r\n [attr.height]=\"cluster.dimension.height\"\r\n [attr.fill]=\"cluster.data.color\"\r\n />\r\n </svg:g>\r\n </ng-template>\r\n\r\n <!-- node template -->\r\n <ng-template #nodeTemplate let-node>\r\n <svg:g class=\"node\" (dblclick)=\"onNodeDblClick(node)\">\r\n <svg:rect\r\n [class.selected]=\"node.data?.selected\"\r\n [attr.width]=\"node.dimension.width\"\r\n [attr.height]=\"node.dimension.height\"\r\n [attr.fill]=\"node.data.customColor || node.data.color\"\r\n />\r\n <svg:text\r\n alignment-baseline=\"central\"\r\n [attr.x]=\"10\"\r\n [attr.y]=\"node.dimension.height / 2\"\r\n >\r\n {{ node.label }}\r\n </svg:text>\r\n </svg:g>\r\n </ng-template>\r\n\r\n <!-- link template -->\r\n <ng-template #linkTemplate let-link>\r\n <svg:g class=\"edge\">\r\n <svg:path\r\n class=\"line\"\r\n stroke-width=\"2\"\r\n marker-end=\"url(#arrow)\"\r\n ></svg:path>\r\n <svg:text class=\"edge-label\" text-anchor=\"middle\">\r\n <textPath\r\n class=\"text-path\"\r\n [attr.href]=\"'#' + link.id\"\r\n [style.dominant-baseline]=\"link.dominantBaseline\"\r\n startOffset=\"50%\"\r\n >\r\n {{ link.label }}\r\n </textPath>\r\n </svg:text>\r\n </svg:g>\r\n </ng-template>\r\n </ngx-graph>\r\n </div>\r\n\r\n <!-- tools -->\r\n <div id=\"tools\">\r\n <div id=\"bar\">\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Center\"\r\n (click)=\"center$.next(true)\"\r\n >\r\n <mat-icon>filter_center_focus</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Zoom to fit\"\r\n (click)=\"zoomToFit$.next(true)\"\r\n >\r\n <mat-icon>fit_screen</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n color=\"warn\"\r\n mat-icon-button\r\n matTooltip=\"Reset\"\r\n (click)=\"update$.next(true)\"\r\n >\r\n <mat-icon>restart_alt</mat-icon>\r\n </button>\r\n <span *ngIf=\"nodes$ | async as nodes\" class=\"muted\"\r\n >N:{{ nodes.length }} E:{{ (edges$ | async)?.length }}</span\r\n >\r\n <button\r\n *ngIf=\"canPick\"\r\n type=\"button\"\r\n color=\"primary\"\r\n mat-icon-button\r\n matTooltip=\"Pick the selected node\"\r\n [disabled]=\"!(selectedNode$ | async)\"\r\n (click)=\"pickSelectedNode()\"\r\n >\r\n <mat-icon>check_circle</mat-icon>\r\n </button>\r\n </div>\r\n <!-- progress -->\r\n <div id=\"progress\">\r\n <mat-progress-bar\r\n mode=\"indeterminate\"\r\n *ngIf=\"loading$ | async\"\r\n ></mat-progress-bar>\r\n </div>\r\n <div id=\"filters\">\r\n <div id=\"filter-head\" *ngIf=\"selectedNode$ | async as node\">\r\n <span [style.color]=\"node.data.color || 'black'\">⬤</span>\r\n <span style=\"margin-left: 6px\" matTooltip=\"{{ node.data.uri }}\">{{\r\n node | graphNodeLabel\r\n }}</span>\r\n <span class=\"muted\" style=\"margin-left: 8px; font-size: 90%\">{{\r\n node.id\r\n }}</span>\r\n </div>\r\n <mat-tab-group>\r\n <!-- N-outs -->\r\n <mat-tab *ngIf=\"nOutFilter$ | async as nOutFilter\">\r\n <ng-template mat-tab-label>\r\n N<mat-icon>logout</mat-icon>\r\n </ng-template>\r\n <cadmus-triple-filter\r\n [filter]=\"nOutFilter\"\r\n (filterChange)=\"onNOutFilterChange($event)\"\r\n ></cadmus-triple-filter>\r\n </mat-tab>\r\n <!-- N-ins -->\r\n <mat-tab *ngIf=\"nInFilter$ | async as nInFilter\">\r\n <ng-template mat-tab-label> N<mat-icon>login</mat-icon> </ng-template>\r\n <cadmus-triple-filter\r\n [filter]=\"nInFilter\"\r\n (filterChange)=\"onNInFilterChange($event)\"\r\n ></cadmus-triple-filter>\r\n </mat-tab>\r\n <!-- P-outs -->\r\n <mat-tab *ngIf=\"pOutFilter$ | async as pOutFilter\">\r\n <ng-template mat-tab-label>\r\n P<mat-icon>logout</mat-icon>\r\n </ng-template>\r\n <cadmus-linked-node-filter\r\n [filter]=\"pOutFilter\"\r\n (filterChange)=\"onPOutFilterChange($event)\"\r\n ></cadmus-linked-node-filter>\r\n </mat-tab>\r\n <!-- P-ins -->\r\n <mat-tab *ngIf=\"pInFilter$ | async as pInFilter\">\r\n <ng-template mat-tab-label> P<mat-icon>login</mat-icon> </ng-template>\r\n <cadmus-linked-node-filter\r\n [filter]=\"pInFilter\"\r\n (filterChange)=\"onPInFilterChange($event)\"\r\n ></cadmus-linked-node-filter>\r\n </mat-tab>\r\n <!-- P-lit -->\r\n <mat-tab *ngIf=\"pLitFilter$ | async as pLitFilter\">\r\n <ng-template mat-tab-label>\r\n P<mat-icon>exit_to_app</mat-icon>\r\n </ng-template>\r\n <cadmus-linked-literal-filter\r\n [filter]=\"pLitFilter\"\r\n (filterChange)=\"onPLitFilterChange($event)\"\r\n ></cadmus-linked-literal-filter>\r\n </mat-tab>\r\n </mat-tab-group>\r\n </div>\r\n </div>\r\n</div>\r\n", styles: ["div#filter-head{border:1px solid #f8f1ae;border-radius:4px;padding:4px;margin-bottom:4px;background-color:#f8f1ae;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.muted{color:silver}.selected{stroke-width:2px;stroke:#e7d211}#container{width:100%;max-width:100%;height:100%;max-height:100%;display:grid;grid-template-rows:1fr;grid-template-columns:auto 1fr;grid-template-areas:\"tools graph\";gap:8px}#graph{grid-area:graph}#tools{grid-area:tools;padding:8px;border:1px solid silver;height:100%;max-height:100%;min-width:300px;background-color:#fdfdfd}#tools #bar{display:flex;align-items:center;flex-wrap:wrap}@media only screen and (max-width: 959px){#container{grid-template-rows:auto 1fr;grid-template-columns:1fr;grid-template-areas:\"tools\" \"graph\"}}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i7.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i6$1.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "directive", type: i7$2.MatTabLabel, selector: "[mat-tab-label], [matTabLabel]" }, { kind: "component", type: i7$2.MatTab, selector: "mat-tab", inputs: ["disabled"], exportAs: ["matTab"] }, { kind: "component", type: i7$2.MatTabGroup, selector: "mat-tab-group", inputs: ["color", "disableRipple", "fitInkBarToContent", "mat-stretch-tabs"], exportAs: ["matTabGroup"] }, { kind: "directive", type: i10.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i9$1.GraphComponent, selector: "ngx-graph", inputs: ["nodes", "clusters", "links", "activeEntries", "curve", "draggingEnabled", "nodeHeight", "nodeMaxHeight", "nodeMinHeight", "nodeWidth", "nodeMinWidth", "nodeMaxWidth", "panningEnabled", "panningAxis", "enableZoom", "zoomSpeed", "minZoomLevel", "maxZoomLevel", "autoZoom", "panOnZoom", "animate", "autoCenter", "update$", "center$", "zoomToFit$", "panToNode$", "layout", "layoutSettings", "enableTrackpadSupport", "showMiniMap", "miniMapMaxWidth", "miniMapMaxHeight", "miniMapPosition", "view", "scheme", "customColors", "animations", "groupResultsBy", "zoomLevel", "panOffsetX", "panOffsetY"], outputs: ["select", "activate", "deactivate", "zoomChange", "clickHandler"] }, { kind: "component", type: LinkedLiteralFilterComponent, selector: "cadmus-linked-literal-filter", inputs: ["disabled", "hasPager", "total", "filter"], outputs: ["filterChange"] }, { kind: "component", type: LinkedNodeFilterComponent, selector: "cadmus-linked-node-filter", inputs: ["disabled", "hasPager", "total", "filter"], outputs: ["filterChange"] }, { kind: "component", type: TripleFilterComponent, selector: "cadmus-triple-filter", inputs: ["disabled", "hasPager", "total", "filter"], outputs: ["filterChange"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: GraphNodeLabelPipe, name: "graphNodeLabel" }] });
|
|
1759
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphWalkerComponent, decorators: [{
|
|
1760
|
+
type: Component,
|
|
1761
|
+
args: [{ selector: 'cadmus-graph-walker', template: "<div id=\"container\">\r\n <!-- graph -->\r\n <div id=\"graph\">\r\n <ngx-graph\r\n class=\"chart-container\"\r\n [showMiniMap]=\"true\"\r\n [links]=\"(edges$ | async) || []\"\r\n [nodes]=\"(nodes$ | async) || []\"\r\n [update$]=\"update$\"\r\n [center$]=\"center$\"\r\n [zoomToFit$]=\"zoomToFit$\"\r\n layout=\"colaForceDirected\"\r\n (select)=\"onNodeSelect($event)\"\r\n >\r\n <ng-template #defsTemplate>\r\n <svg:marker\r\n id=\"arrow\"\r\n viewBox=\"0 -5 10 10\"\r\n refX=\"8\"\r\n refY=\"0\"\r\n markerWidth=\"4\"\r\n markerHeight=\"4\"\r\n orient=\"auto\"\r\n >\r\n <svg:path d=\"M0,-5L10,0L0,5\" class=\"arrow-head\" />\r\n </svg:marker>\r\n </ng-template>\r\n\r\n <!-- cluster template -->\r\n <ng-template #clusterTemplate let-cluster>\r\n <svg:g class=\"node cluster\">\r\n <svg:rect\r\n rx=\"5\"\r\n ry=\"5\"\r\n [attr.width]=\"cluster.dimension.width\"\r\n [attr.height]=\"cluster.dimension.height\"\r\n [attr.fill]=\"cluster.data.color\"\r\n />\r\n </svg:g>\r\n </ng-template>\r\n\r\n <!-- node template -->\r\n <ng-template #nodeTemplate let-node>\r\n <svg:g class=\"node\" (dblclick)=\"onNodeDblClick(node)\">\r\n <svg:rect\r\n [class.selected]=\"node.data?.selected\"\r\n [attr.width]=\"node.dimension.width\"\r\n [attr.height]=\"node.dimension.height\"\r\n [attr.fill]=\"node.data.customColor || node.data.color\"\r\n />\r\n <svg:text\r\n alignment-baseline=\"central\"\r\n [attr.x]=\"10\"\r\n [attr.y]=\"node.dimension.height / 2\"\r\n >\r\n {{ node.label }}\r\n </svg:text>\r\n </svg:g>\r\n </ng-template>\r\n\r\n <!-- link template -->\r\n <ng-template #linkTemplate let-link>\r\n <svg:g class=\"edge\">\r\n <svg:path\r\n class=\"line\"\r\n stroke-width=\"2\"\r\n marker-end=\"url(#arrow)\"\r\n ></svg:path>\r\n <svg:text class=\"edge-label\" text-anchor=\"middle\">\r\n <textPath\r\n class=\"text-path\"\r\n [attr.href]=\"'#' + link.id\"\r\n [style.dominant-baseline]=\"link.dominantBaseline\"\r\n startOffset=\"50%\"\r\n >\r\n {{ link.label }}\r\n </textPath>\r\n </svg:text>\r\n </svg:g>\r\n </ng-template>\r\n </ngx-graph>\r\n </div>\r\n\r\n <!-- tools -->\r\n <div id=\"tools\">\r\n <div id=\"bar\">\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Center\"\r\n (click)=\"center$.next(true)\"\r\n >\r\n <mat-icon>filter_center_focus</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Zoom to fit\"\r\n (click)=\"zoomToFit$.next(true)\"\r\n >\r\n <mat-icon>fit_screen</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n color=\"warn\"\r\n mat-icon-button\r\n matTooltip=\"Reset\"\r\n (click)=\"update$.next(true)\"\r\n >\r\n <mat-icon>restart_alt</mat-icon>\r\n </button>\r\n <span *ngIf=\"nodes$ | async as nodes\" class=\"muted\"\r\n >N:{{ nodes.length }} E:{{ (edges$ | async)?.length }}</span\r\n >\r\n <button\r\n *ngIf=\"canPick\"\r\n type=\"button\"\r\n color=\"primary\"\r\n mat-icon-button\r\n matTooltip=\"Pick the selected node\"\r\n [disabled]=\"!(selectedNode$ | async)\"\r\n (click)=\"pickSelectedNode()\"\r\n >\r\n <mat-icon>check_circle</mat-icon>\r\n </button>\r\n </div>\r\n <!-- progress -->\r\n <div id=\"progress\">\r\n <mat-progress-bar\r\n mode=\"indeterminate\"\r\n *ngIf=\"loading$ | async\"\r\n ></mat-progress-bar>\r\n </div>\r\n <div id=\"filters\">\r\n <div id=\"filter-head\" *ngIf=\"selectedNode$ | async as node\">\r\n <span [style.color]=\"node.data.color || 'black'\">⬤</span>\r\n <span style=\"margin-left: 6px\" matTooltip=\"{{ node.data.uri }}\">{{\r\n node | graphNodeLabel\r\n }}</span>\r\n <span class=\"muted\" style=\"margin-left: 8px; font-size: 90%\">{{\r\n node.id\r\n }}</span>\r\n </div>\r\n <mat-tab-group>\r\n <!-- N-outs -->\r\n <mat-tab *ngIf=\"nOutFilter$ | async as nOutFilter\">\r\n <ng-template mat-tab-label>\r\n N<mat-icon>logout</mat-icon>\r\n </ng-template>\r\n <cadmus-triple-filter\r\n [filter]=\"nOutFilter\"\r\n (filterChange)=\"onNOutFilterChange($event)\"\r\n ></cadmus-triple-filter>\r\n </mat-tab>\r\n <!-- N-ins -->\r\n <mat-tab *ngIf=\"nInFilter$ | async as nInFilter\">\r\n <ng-template mat-tab-label> N<mat-icon>login</mat-icon> </ng-template>\r\n <cadmus-triple-filter\r\n [filter]=\"nInFilter\"\r\n (filterChange)=\"onNInFilterChange($event)\"\r\n ></cadmus-triple-filter>\r\n </mat-tab>\r\n <!-- P-outs -->\r\n <mat-tab *ngIf=\"pOutFilter$ | async as pOutFilter\">\r\n <ng-template mat-tab-label>\r\n P<mat-icon>logout</mat-icon>\r\n </ng-template>\r\n <cadmus-linked-node-filter\r\n [filter]=\"pOutFilter\"\r\n (filterChange)=\"onPOutFilterChange($event)\"\r\n ></cadmus-linked-node-filter>\r\n </mat-tab>\r\n <!-- P-ins -->\r\n <mat-tab *ngIf=\"pInFilter$ | async as pInFilter\">\r\n <ng-template mat-tab-label> P<mat-icon>login</mat-icon> </ng-template>\r\n <cadmus-linked-node-filter\r\n [filter]=\"pInFilter\"\r\n (filterChange)=\"onPInFilterChange($event)\"\r\n ></cadmus-linked-node-filter>\r\n </mat-tab>\r\n <!-- P-lit -->\r\n <mat-tab *ngIf=\"pLitFilter$ | async as pLitFilter\">\r\n <ng-template mat-tab-label>\r\n P<mat-icon>exit_to_app</mat-icon>\r\n </ng-template>\r\n <cadmus-linked-literal-filter\r\n [filter]=\"pLitFilter\"\r\n (filterChange)=\"onPLitFilterChange($event)\"\r\n ></cadmus-linked-literal-filter>\r\n </mat-tab>\r\n </mat-tab-group>\r\n </div>\r\n </div>\r\n</div>\r\n", styles: ["div#filter-head{border:1px solid #f8f1ae;border-radius:4px;padding:4px;margin-bottom:4px;background-color:#f8f1ae;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.muted{color:silver}.selected{stroke-width:2px;stroke:#e7d211}#container{width:100%;max-width:100%;height:100%;max-height:100%;display:grid;grid-template-rows:1fr;grid-template-columns:auto 1fr;grid-template-areas:\"tools graph\";gap:8px}#graph{grid-area:graph}#tools{grid-area:tools;padding:8px;border:1px solid silver;height:100%;max-height:100%;min-width:300px;background-color:#fdfdfd}#tools #bar{display:flex;align-items:center;flex-wrap:wrap}@media only screen and (max-width: 959px){#container{grid-template-rows:auto 1fr;grid-template-columns:1fr;grid-template-areas:\"tools\" \"graph\"}}\n"] }]
|
|
1762
|
+
}], ctorParameters: function () { return [{ type: GraphService }, { type: i2$1.DialogService }]; }, propDecorators: { nodeId: [{
|
|
1763
|
+
type: Input
|
|
1764
|
+
}], canPick: [{
|
|
1765
|
+
type: Input
|
|
1766
|
+
}], nodePick: [{
|
|
1767
|
+
type: Output
|
|
1768
|
+
}] } });
|
|
1769
|
+
|
|
1770
|
+
class CadmusGraphUiExModule {
|
|
1771
|
+
}
|
|
1772
|
+
CadmusGraphUiExModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: CadmusGraphUiExModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1773
|
+
CadmusGraphUiExModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.4", ngImport: i0, type: CadmusGraphUiExModule, declarations: [GraphNodeLabelPipe,
|
|
1774
|
+
GraphWalkerComponent,
|
|
1775
|
+
LinkedLiteralFilterComponent,
|
|
1776
|
+
LinkedNodeFilterComponent,
|
|
1777
|
+
TripleFilterComponent], imports: [CommonModule,
|
|
1778
|
+
FormsModule,
|
|
1779
|
+
ReactiveFormsModule,
|
|
1780
|
+
HttpClientModule,
|
|
1781
|
+
// material
|
|
1782
|
+
MatAutocompleteModule,
|
|
1783
|
+
MatButtonModule,
|
|
1784
|
+
MatCheckboxModule,
|
|
1785
|
+
MatChipsModule,
|
|
1786
|
+
MatFormFieldModule,
|
|
1787
|
+
MatIconModule,
|
|
1788
|
+
MatInputModule,
|
|
1789
|
+
MatListModule,
|
|
1790
|
+
MatPaginatorModule,
|
|
1791
|
+
MatProgressBarModule,
|
|
1792
|
+
MatSelectModule,
|
|
1793
|
+
MatTabsModule,
|
|
1794
|
+
MatTooltipModule,
|
|
1795
|
+
// vendor
|
|
1796
|
+
NgxGraphModule,
|
|
1797
|
+
// Cadmus
|
|
1798
|
+
NgToolsModule,
|
|
1799
|
+
NgMatToolsModule,
|
|
1800
|
+
CadmusRefsLookupModule], exports: [GraphNodeLabelPipe,
|
|
1801
|
+
GraphWalkerComponent,
|
|
1802
|
+
LinkedLiteralFilterComponent,
|
|
1803
|
+
LinkedNodeFilterComponent,
|
|
1804
|
+
TripleFilterComponent] });
|
|
1805
|
+
CadmusGraphUiExModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: CadmusGraphUiExModule, imports: [CommonModule,
|
|
1806
|
+
FormsModule,
|
|
1807
|
+
ReactiveFormsModule,
|
|
1808
|
+
HttpClientModule,
|
|
1809
|
+
// material
|
|
1810
|
+
MatAutocompleteModule,
|
|
1811
|
+
MatButtonModule,
|
|
1812
|
+
MatCheckboxModule,
|
|
1813
|
+
MatChipsModule,
|
|
1814
|
+
MatFormFieldModule,
|
|
1815
|
+
MatIconModule,
|
|
1816
|
+
MatInputModule,
|
|
1817
|
+
MatListModule,
|
|
1818
|
+
MatPaginatorModule,
|
|
1819
|
+
MatProgressBarModule,
|
|
1820
|
+
MatSelectModule,
|
|
1821
|
+
MatTabsModule,
|
|
1822
|
+
MatTooltipModule,
|
|
1823
|
+
// vendor
|
|
1824
|
+
NgxGraphModule,
|
|
1825
|
+
// Cadmus
|
|
1826
|
+
NgToolsModule,
|
|
1827
|
+
NgMatToolsModule,
|
|
1828
|
+
CadmusRefsLookupModule] });
|
|
1829
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: CadmusGraphUiExModule, decorators: [{
|
|
1830
|
+
type: NgModule,
|
|
1831
|
+
args: [{
|
|
1832
|
+
declarations: [
|
|
1833
|
+
GraphNodeLabelPipe,
|
|
1834
|
+
GraphWalkerComponent,
|
|
1835
|
+
LinkedLiteralFilterComponent,
|
|
1836
|
+
LinkedNodeFilterComponent,
|
|
1837
|
+
TripleFilterComponent,
|
|
1838
|
+
],
|
|
1839
|
+
imports: [
|
|
1840
|
+
CommonModule,
|
|
1841
|
+
FormsModule,
|
|
1842
|
+
ReactiveFormsModule,
|
|
1843
|
+
HttpClientModule,
|
|
1844
|
+
// material
|
|
1845
|
+
MatAutocompleteModule,
|
|
1846
|
+
MatButtonModule,
|
|
1847
|
+
MatCheckboxModule,
|
|
1848
|
+
MatChipsModule,
|
|
1849
|
+
MatFormFieldModule,
|
|
1850
|
+
MatIconModule,
|
|
1851
|
+
MatInputModule,
|
|
1852
|
+
MatListModule,
|
|
1853
|
+
MatPaginatorModule,
|
|
1854
|
+
MatProgressBarModule,
|
|
1855
|
+
MatSelectModule,
|
|
1856
|
+
MatTabsModule,
|
|
1857
|
+
MatTooltipModule,
|
|
1858
|
+
// vendor
|
|
1859
|
+
NgxGraphModule,
|
|
1860
|
+
// Cadmus
|
|
1861
|
+
NgToolsModule,
|
|
1862
|
+
NgMatToolsModule,
|
|
1863
|
+
CadmusRefsLookupModule
|
|
1864
|
+
],
|
|
1865
|
+
exports: [
|
|
1866
|
+
GraphNodeLabelPipe,
|
|
1867
|
+
GraphWalkerComponent,
|
|
1868
|
+
LinkedLiteralFilterComponent,
|
|
1869
|
+
LinkedNodeFilterComponent,
|
|
1870
|
+
TripleFilterComponent,
|
|
1871
|
+
],
|
|
1872
|
+
}]
|
|
1873
|
+
}] });
|
|
1874
|
+
|
|
1875
|
+
/*
|
|
1876
|
+
* Public API Surface of cadmus-graph-ui
|
|
1877
|
+
*/
|
|
1878
|
+
|
|
1879
|
+
/**
|
|
1880
|
+
* Generated bundle index. Do not edit.
|
|
1881
|
+
*/
|
|
1882
|
+
|
|
1883
|
+
export { CadmusGraphUiExModule, GraphNodeLabelPipe, GraphNodeLookupService, GraphService, GraphWalker, GraphWalkerComponent, LinkedLiteralFilterComponent, LinkedNodeFilterComponent, NodeSourceType, TripleFilterComponent };
|
|
1884
|
+
//# sourceMappingURL=myrmidon-cadmus-graph-ui-ex.mjs.map
|