@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.
Files changed (28) hide show
  1. package/README.md +24 -0
  2. package/esm2020/lib/cadmus-graph-ui-ex.module.mjs +132 -0
  3. package/esm2020/lib/components/graph-walker/graph-walker.component.mjs +119 -0
  4. package/esm2020/lib/components/linked-literal-filter/linked-literal-filter.component.mjs +141 -0
  5. package/esm2020/lib/components/linked-node-filter/linked-node-filter.component.mjs +178 -0
  6. package/esm2020/lib/components/triple-filter/triple-filter.component.mjs +219 -0
  7. package/esm2020/lib/graph-walker.mjs +725 -0
  8. package/esm2020/lib/pipes/graph-node-label.pipe.mjs +29 -0
  9. package/esm2020/lib/services/graph-node-lookup.service.mjs +42 -0
  10. package/esm2020/lib/services/graph.service.mjs +343 -0
  11. package/esm2020/myrmidon-cadmus-graph-ui-ex.mjs +5 -0
  12. package/esm2020/public-api.mjs +13 -0
  13. package/fesm2015/myrmidon-cadmus-graph-ui-ex.mjs +1884 -0
  14. package/fesm2015/myrmidon-cadmus-graph-ui-ex.mjs.map +1 -0
  15. package/fesm2020/myrmidon-cadmus-graph-ui-ex.mjs +1876 -0
  16. package/fesm2020/myrmidon-cadmus-graph-ui-ex.mjs.map +1 -0
  17. package/index.d.ts +5 -0
  18. package/lib/cadmus-graph-ui-ex.module.d.ts +31 -0
  19. package/lib/components/graph-walker/graph-walker.component.d.ts +57 -0
  20. package/lib/components/linked-literal-filter/linked-literal-filter.component.d.ts +58 -0
  21. package/lib/components/linked-node-filter/linked-node-filter.component.d.ts +62 -0
  22. package/lib/components/triple-filter/triple-filter.component.d.ts +68 -0
  23. package/lib/graph-walker.d.ts +251 -0
  24. package/lib/pipes/graph-node-label.pipe.d.ts +13 -0
  25. package/lib/services/graph-node-lookup.service.d.ts +20 -0
  26. package/lib/services/graph.service.d.ts +200 -0
  27. package/package.json +43 -0
  28. package/public-api.d.ts +9 -0
@@ -0,0 +1,1876 @@
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) => n.data?.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
+ const selectedId = this._selectedNode$.value?.id;
380
+ // remove all the nodes whose origin ID matches,
381
+ // collecting their IDs
382
+ const removedIds = new Set();
383
+ this.removeDescendantNodes(originId, nodes, removedIds);
384
+ // remove all the affected edges
385
+ for (let i = edges.length - 1; i > -1; i--) {
386
+ const endIds = this.getEdgeEndIds(edges[i].id);
387
+ if (endIds?.length &&
388
+ (removedIds.has(endIds[0]) || removedIds.has(endIds[1]))) {
389
+ edges.splice(i, 1);
390
+ }
391
+ }
392
+ // if the removed node was the selected one, select the root origin
393
+ if (selectedId && removedIds.has(selectedId)) {
394
+ this.selectNode(this._rootNode.id);
395
+ }
396
+ }
397
+ /**
398
+ * Build a new graph node representing a property.
399
+ *
400
+ * @param sourceId The source node ID.
401
+ * @param group The triple group emitting this node.
402
+ * @returns A new graph node.
403
+ */
404
+ buildPropertyNode(sourceId, group) {
405
+ const nid = this.getNodeNumericId(sourceId);
406
+ const data = {
407
+ originId: sourceId,
408
+ uri: group.predicateUri,
409
+ customColor: '#FF5619',
410
+ outFilter: {
411
+ pageNumber: 1,
412
+ pageSize: this.pageSize,
413
+ otherNodeId: nid,
414
+ predicateId: group.predicateId,
415
+ },
416
+ inFilter: {
417
+ pageNumber: 1,
418
+ pageSize: this.pageSize,
419
+ otherNodeId: nid,
420
+ predicateId: group.predicateId,
421
+ },
422
+ litFilter: {
423
+ pageNumber: 1,
424
+ pageSize: this.pageSize,
425
+ predicateId: group.predicateId,
426
+ },
427
+ };
428
+ return {
429
+ id: this.buildPropertyId(group.predicateId, nid),
430
+ label: group.count.toString(),
431
+ data: data,
432
+ };
433
+ }
434
+ /**
435
+ * Expand the specified node, by loading its property groups.
436
+ *
437
+ * @param node The node to expand.
438
+ * @param outFilter The properties to update for the output filter.
439
+ * @param inFilter The properties to update for the input filter.
440
+ */
441
+ expandNode(node, outFilter, inFilter) {
442
+ // prepare filters
443
+ const nid = this.getNodeNumericId(node.id);
444
+ // outbound: node=S
445
+ const outf = outFilter
446
+ ? Object.assign(node.data.outFilter, outFilter, {
447
+ subjectId: nid,
448
+ })
449
+ : {
450
+ pageNumber: 1,
451
+ pageSize: this.pageSize,
452
+ subjectId: nid,
453
+ };
454
+ // inbound: node=O
455
+ const inf = inFilter
456
+ ? Object.assign(node.data.inFilter, inFilter, {
457
+ objectId: nid,
458
+ })
459
+ : {
460
+ pageNumber: 1,
461
+ pageSize: this.pageSize,
462
+ objectId: nid,
463
+ };
464
+ // load
465
+ this.toggleLoading(true);
466
+ const nodes = [...this._nodes$.value];
467
+ const edges = [...this._edges$.value];
468
+ forkJoin({
469
+ outs: this._graphService.getTripleGroups(outf),
470
+ ins: this._graphService.getTripleGroups(inf),
471
+ }).subscribe({
472
+ next: (result) => {
473
+ node.data.expanded = true;
474
+ // update origin's filters
475
+ node.data.outFilter = outf;
476
+ node.data.inFilter = inf;
477
+ // remove previous children
478
+ this.removeChildren(node.id, nodes, edges);
479
+ // add outbound children
480
+ node.data.outTotal = result.outs.total;
481
+ for (let i = 0; i < result.outs.items.length; i++) {
482
+ const group = result.outs.items[i];
483
+ const prop = this.buildPropertyNode(node.id, group);
484
+ // when expanding a node (e.g. N17) into props, the prop's ID is
485
+ // P + predicate ID + N + origin node ID (e.g. P30N17).
486
+ // This prop node can then be expanded, too, thus producing
487
+ // a node with ID = N + node ID. When this in turn gets expanded,
488
+ // it will produce also the prop node it comes from, which
489
+ // must not be re-inserted in the graph. This node in the new
490
+ // expansion context will get ID from the source node, which
491
+ // is different from the node at the other end of the prop node:
492
+ // this was e.g. N17, while the new node is e.g. N18. So, the
493
+ // prop previously identified as P30N17 would now be identified
494
+ // as P30N18, thus producing a duplicate. To avoid this, we
495
+ // calculate an alias ID from the origin's origin: for N18,
496
+ // its origin being P30N17, this will be N17. This produces an
497
+ // alias P30N17, which being already present will avoid duplicates.
498
+ const aliasId = `P${group.predicateId}N${this.getNodeNumericId(node.data.originId)}`;
499
+ if (!nodes.some((n) => n.id === prop.id || n.id === aliasId)) {
500
+ nodes.push(prop);
501
+ // edge from origin node to object property
502
+ const edge = {
503
+ id: this.buildEdgeId(node.id, prop.id),
504
+ label: group.predicateUri,
505
+ source: node.id,
506
+ target: prop.id,
507
+ data: {
508
+ originId: node.id,
509
+ },
510
+ };
511
+ this.addEdgeIfAbsent(edge, edges);
512
+ }
513
+ }
514
+ // add inbound children
515
+ node.data.inTotal = result.ins.total;
516
+ for (let i = 0; i < result.ins.items.length; i++) {
517
+ const g = result.ins.items[i];
518
+ // subject property
519
+ const p = this.buildPropertyNode(node.id, g);
520
+ // edge from object property to origin node
521
+ const edge = {
522
+ id: this.buildEdgeId(p.id, node.id),
523
+ label: g.predicateUri,
524
+ source: p.id,
525
+ target: node.id,
526
+ data: {
527
+ originId: node.id,
528
+ },
529
+ };
530
+ // do not add an edge having the same source P and target N,
531
+ // whatever the P's source node
532
+ const r = new RegExp('^EP' + g.predicateId + 'N[0-9]+_' + node.id + '$');
533
+ if (!edges.some((e) => r.test(e.id))) {
534
+ if (!nodes.some((n) => n.id === p.id)) {
535
+ nodes.push(p);
536
+ }
537
+ this.addEdgeIfAbsent(edge, edges);
538
+ }
539
+ }
540
+ // update
541
+ this._nodes$.next(nodes);
542
+ this._edges$.next(edges);
543
+ },
544
+ error: (error) => {
545
+ node.data.error = 'Error loading properties';
546
+ this._nodes$.next(nodes);
547
+ this.setError(error);
548
+ },
549
+ complete: () => {
550
+ this.toggleLoading(false);
551
+ },
552
+ });
553
+ }
554
+ /**
555
+ * Expand the selected node, by loading its property groups.
556
+ *
557
+ * @param outFilter The properties to update for the output filter.
558
+ * @param inFilter The properties to update for the input filter.
559
+ */
560
+ expandSelectedNode(outFilter, inFilter) {
561
+ if (!this._selectedNode$.value ||
562
+ !this._selectedNode$.value.id.startsWith('N')) {
563
+ return;
564
+ }
565
+ const node = this._selectedNode$.value;
566
+ this.expandNode(node, outFilter, inFilter);
567
+ }
568
+ buildLiteralLabel(triple) {
569
+ let value = triple.objectLiteral || '';
570
+ if (this.maxLiteralLen && value.length > this.maxLiteralLen) {
571
+ value = value.substring(0, this.maxLiteralLen) + '\u2026';
572
+ }
573
+ return value;
574
+ }
575
+ buildNonLiteralNode(sourceId, node) {
576
+ const nid = this.getNodeNumericId(sourceId);
577
+ const data = {
578
+ originId: sourceId,
579
+ customColor: '#80ff95',
580
+ uri: node.uri,
581
+ sourceType: node.sourceType,
582
+ isClass: node.isClass,
583
+ sid: node.sid,
584
+ tag: node.tag,
585
+ outFilter: {
586
+ pageNumber: 0,
587
+ pageSize: this.pageSize,
588
+ subjectId: nid,
589
+ },
590
+ inFilter: {
591
+ pageNumber: 0,
592
+ pageSize: this.pageSize,
593
+ objectId: nid,
594
+ },
595
+ };
596
+ return {
597
+ id: this.buildNodeId(node.id),
598
+ label: node.label,
599
+ data: data,
600
+ };
601
+ }
602
+ buildLiteralNode(sourceId, triple) {
603
+ const data = {
604
+ originId: sourceId,
605
+ customColor: '#ebe2e0',
606
+ value: triple.objectLiteral || '',
607
+ type: triple.literalType,
608
+ language: triple.literalLanguage,
609
+ number: triple.literalNumber,
610
+ };
611
+ return {
612
+ id: this.buildLiteralId(triple.id),
613
+ label: this.buildLiteralLabel(triple),
614
+ data: data,
615
+ };
616
+ }
617
+ /**
618
+ * Expand the currently selected properties group node, by loading its
619
+ * outbound nodes, inbound nodes, and literal nodes.
620
+ *
621
+ * @param node The property group node to expand.
622
+ * @param outFilter The properties to update for the outbound nodes filter.
623
+ * @param inFilter The properties to update for the inbound nodes filter.
624
+ * @param litFilter The properties to update for the literal nodes filter.
625
+ */
626
+ expandProperty(node, outFilter, inFilter, litFilter) {
627
+ // prepare filters
628
+ const nid = this.getNodeNumericId(node.id);
629
+ const data = node.data;
630
+ const outf = Object.assign(data.outFilter, outFilter || {}, { isObject: true });
631
+ const inf = Object.assign(data.inFilter, inFilter || {}, {
632
+ isObject: false,
633
+ });
634
+ const litf = Object.assign(data.litFilter, litFilter || {}, { subjectId: nid, predicateId: this.getPredicateNumericId(node.id) });
635
+ // load
636
+ this.toggleLoading(true);
637
+ const nodes = [...this._nodes$.value];
638
+ const edges = [...this._edges$.value];
639
+ forkJoin({
640
+ outs: this._graphService.getLinkedNodes(outf),
641
+ ins: this._graphService.getLinkedNodes(inf),
642
+ lits: this._graphService.getLinkedLiterals(litf),
643
+ }).subscribe({
644
+ next: (result) => {
645
+ node.data.expanded = true;
646
+ // update origin's filters
647
+ node.data.outFilter = outf;
648
+ node.data.inFilter = inf;
649
+ node.data.litFilter = litf;
650
+ // remove previous children
651
+ this.removeChildren(node.id, nodes, edges);
652
+ // add outbound children
653
+ node.data.outTotal = result.outs.total;
654
+ for (let i = 0; i < result.outs.items.length; i++) {
655
+ const child = result.outs.items[i];
656
+ const obj = this.buildNonLiteralNode(node.id, child);
657
+ if (!nodes.some((n) => n.id === obj.id)) {
658
+ nodes.push(obj);
659
+ }
660
+ // edge from property to non literal object node
661
+ const edge = {
662
+ id: this.buildEdgeId(node.id, obj.id),
663
+ label: '',
664
+ source: node.id,
665
+ target: obj.id,
666
+ data: {
667
+ originId: node.id,
668
+ },
669
+ };
670
+ this.addEdgeIfAbsent(edge, edges);
671
+ }
672
+ // add inbound children
673
+ node.data.inTotal = result.ins.total;
674
+ for (let i = 0; i < result.ins.items.length; i++) {
675
+ const child = result.ins.items[i];
676
+ const subj = this.buildNonLiteralNode(node.id, child);
677
+ if (!nodes.some((n) => n.id === subj.id)) {
678
+ nodes.push(subj);
679
+ }
680
+ // edge from subject node to property
681
+ const edge = {
682
+ id: this.buildEdgeId(subj.id, node.id),
683
+ label: '',
684
+ source: subj.id,
685
+ target: node.id,
686
+ data: {
687
+ originId: node.id,
688
+ },
689
+ };
690
+ this.addEdgeIfAbsent(edge, edges);
691
+ }
692
+ // add literal children
693
+ node.data.litTotal = result.lits.total;
694
+ for (let i = 0; i < result.lits.items.length; i++) {
695
+ const triple = result.lits.items[i];
696
+ const lit = this.buildLiteralNode(node.id, triple);
697
+ if (!nodes.some((n) => n.id === lit.id)) {
698
+ nodes.push(lit);
699
+ }
700
+ // edge from property to literal
701
+ const edge = {
702
+ id: this.buildEdgeId(node.id, lit.id),
703
+ label: lit.data.literalType || '',
704
+ source: node.id,
705
+ target: lit.id,
706
+ data: {
707
+ originId: node.id,
708
+ },
709
+ };
710
+ this.addEdgeIfAbsent(edge, edges);
711
+ }
712
+ // update
713
+ this._nodes$.next(nodes);
714
+ this._edges$.next(edges);
715
+ },
716
+ error: (error) => {
717
+ node.data.error = 'Error loading nodes';
718
+ this._nodes$.next(nodes);
719
+ this.setError(error);
720
+ },
721
+ complete: () => {
722
+ this.toggleLoading(false);
723
+ },
724
+ });
725
+ }
726
+ /**
727
+ * Expand the currently selected properties group node, by loading its
728
+ * outbound nodes, inbound nodes, and literal nodes. If there is no
729
+ * selection, or the selected node is not a properties group node, nothing
730
+ * is done.
731
+ *
732
+ * @param outFilter The properties to update for the outbound nodes filter.
733
+ * @param inFilter The properties to update for the inbound nodes filter.
734
+ * @param litFilter The properties to update for the literal nodes filter.
735
+ */
736
+ expandSelectedProperty(outFilter, inFilter, litFilter) {
737
+ if (!this._selectedNode$.value ||
738
+ !this._selectedNode$.value.id.startsWith('P')) {
739
+ return;
740
+ }
741
+ const node = this._selectedNode$.value;
742
+ this.expandProperty(node, outFilter, inFilter, litFilter);
743
+ }
744
+ /**
745
+ * Toggle the specified node by expanding or collapsing it.
746
+ *
747
+ * @param node The node to toggle.
748
+ */
749
+ toggleNode(node) {
750
+ if (node.data.expanded) {
751
+ const nodes = [...this._nodes$.value];
752
+ const edges = [...this._edges$.value];
753
+ this.removeChildren(node.id, nodes, edges);
754
+ node.data.expanded = undefined;
755
+ this._nodes$.next(nodes);
756
+ this._edges$.next(edges);
757
+ }
758
+ else {
759
+ if (node.id.startsWith('N')) {
760
+ this.expandNode(node);
761
+ }
762
+ else if (node.id.startsWith('P')) {
763
+ this.expandProperty(node);
764
+ }
765
+ }
766
+ }
767
+ }
768
+
769
+ //#region Models
770
+ var NodeSourceType;
771
+ (function (NodeSourceType) {
772
+ NodeSourceType[NodeSourceType["User"] = 0] = "User";
773
+ NodeSourceType[NodeSourceType["Item"] = 1] = "Item";
774
+ NodeSourceType[NodeSourceType["Part"] = 2] = "Part";
775
+ NodeSourceType[NodeSourceType["Thesaurus"] = 3] = "Thesaurus";
776
+ NodeSourceType[NodeSourceType["Implicit"] = 4] = "Implicit";
777
+ })(NodeSourceType || (NodeSourceType = {}));
778
+ //#endregion
779
+ /**
780
+ * Cadmus semantic graph service.
781
+ */
782
+ class GraphService {
783
+ constructor(_http, _error, _env) {
784
+ this._http = _http;
785
+ this._error = _error;
786
+ this._env = _env;
787
+ }
788
+ /**
789
+ * Get the specified page of graph nodes.
790
+ *
791
+ * @param filter The nodes filter.
792
+ * @returns A page of nodes.
793
+ */
794
+ getNodes(filter) {
795
+ const url = this._env.get('apiUrl') + 'graph/nodes';
796
+ let httpParams = new HttpParams();
797
+ httpParams = httpParams.set('pageNumber', filter.pageNumber.toString());
798
+ httpParams = httpParams.set('pageSize', filter.pageSize.toString());
799
+ if (filter.uid) {
800
+ httpParams = httpParams.set('uid', filter.uid);
801
+ }
802
+ if (filter.isClass !== null && filter.isClass !== undefined) {
803
+ httpParams = httpParams.set('isClass', filter.isClass ? 'true' : 'false');
804
+ }
805
+ if (filter.tag) {
806
+ httpParams = httpParams.set('tag', filter.tag);
807
+ }
808
+ if (filter.label) {
809
+ httpParams = httpParams.set('label', filter.label);
810
+ }
811
+ if (filter.sourceType !== null && filter.sourceType !== undefined) {
812
+ httpParams = httpParams.set('sourceType', filter.sourceType.toString());
813
+ }
814
+ if (filter.sid) {
815
+ httpParams = httpParams.set('sid', filter.sid);
816
+ }
817
+ if (filter.isSidPrefix) {
818
+ httpParams = httpParams.set('isSidPrefix', 'true');
819
+ }
820
+ if (filter.linkedNodeId) {
821
+ httpParams = httpParams.set('linkedNodeId', filter.linkedNodeId.toString());
822
+ }
823
+ if (filter.linkedNodeRole) {
824
+ httpParams = httpParams.set('linkedNodeRole', filter.linkedNodeRole);
825
+ }
826
+ if (filter.classIds?.length) {
827
+ for (let i = 0; i < filter.classIds.length; i++) {
828
+ httpParams = httpParams.set('classIds', filter.classIds[i]);
829
+ }
830
+ }
831
+ return this._http
832
+ .get(url, {
833
+ params: httpParams,
834
+ })
835
+ .pipe(retry(3), catchError(this._error.handleError));
836
+ }
837
+ /**
838
+ * Get the specified set of nodes.
839
+ *
840
+ * @param ids The nodes IDs.
841
+ * @returns List of nodes/nulls.
842
+ */
843
+ getNodeSet(ids) {
844
+ const url = this._env.get('apiUrl') + 'graph/nodes-set/';
845
+ let httpParams = new HttpParams();
846
+ for (let i = 0; i < ids.length; i++) {
847
+ httpParams = httpParams.append('id', ids[i].toString());
848
+ }
849
+ return this._http
850
+ .get(url, {
851
+ params: httpParams,
852
+ })
853
+ .pipe(retry(3), catchError(this._error.handleError));
854
+ }
855
+ /**
856
+ * Get the node with the specified ID.
857
+ *
858
+ * @param id The node's ID.
859
+ * @returns The node.
860
+ */
861
+ getNode(id) {
862
+ const url = this._env.get('apiUrl') + 'graph/nodes/' + id.toString();
863
+ return this._http
864
+ .get(url)
865
+ .pipe(retry(3), catchError(this._error.handleError));
866
+ }
867
+ /**
868
+ * Get the node with the specified URI.
869
+ *
870
+ * @param uri The node's URI.
871
+ * @returns The node.
872
+ */
873
+ getNodeByUri(uri) {
874
+ const url = this._env.get('apiUrl') + 'graph/nodes-by-uri';
875
+ let httpParams = new HttpParams();
876
+ httpParams = httpParams.set('uri', uri);
877
+ return this._http
878
+ .get(url, { params: httpParams })
879
+ .pipe(retry(3), catchError(this._error.handleError));
880
+ }
881
+ /**
882
+ * Add or update the specified node. A new node has id=0 and uri set;
883
+ * an existing node has its id.
884
+ *
885
+ * @param node The node to add.
886
+ * @returns The added node.
887
+ */
888
+ addNode(node) {
889
+ const url = this._env.get('apiUrl') + 'graph/nodes/';
890
+ return this._http
891
+ .post(url, node)
892
+ .pipe(catchError(this._error.handleError));
893
+ }
894
+ /**
895
+ * Delete the node with the specified ID.
896
+ *
897
+ * @param id The node's ID.
898
+ */
899
+ deleteNode(id) {
900
+ const url = this._env.get('apiUrl') + 'graph/nodes/' + id.toString();
901
+ return this._http.delete(url).pipe(catchError(this._error.handleError));
902
+ }
903
+ applyTripleFilter(filter, httpParams) {
904
+ httpParams = httpParams.set('pageNumber', filter.pageNumber.toString());
905
+ httpParams = httpParams.set('pageSize', filter.pageSize.toString());
906
+ if (filter.subjectId) {
907
+ httpParams = httpParams.set('subjectId', filter.subjectId.toString());
908
+ }
909
+ if (filter.predicateIds?.length) {
910
+ filter.predicateIds.forEach((p) => {
911
+ httpParams = httpParams.set('predicateIds', p);
912
+ });
913
+ }
914
+ if (filter.notPredicateIds?.length) {
915
+ filter.notPredicateIds.forEach((p) => {
916
+ httpParams = httpParams.set('notPredicateIds', p);
917
+ });
918
+ }
919
+ if (filter.hasLiteralObject !== null &&
920
+ filter.hasLiteralObject !== undefined) {
921
+ httpParams = httpParams.set('hasLiteralObject', filter.hasLiteralObject.toString());
922
+ }
923
+ if (filter.objectId) {
924
+ httpParams = httpParams.set('objectId', filter.objectId.toString());
925
+ }
926
+ if (filter.sid) {
927
+ httpParams = httpParams.set('sid', filter.sid);
928
+ }
929
+ if (filter.isSidPrefix) {
930
+ httpParams = httpParams.set('isSidPrefix', 'true');
931
+ }
932
+ if (filter.tag) {
933
+ httpParams = httpParams.set('tag', filter.tag);
934
+ }
935
+ return httpParams;
936
+ }
937
+ /**
938
+ * Get the specified page of triples.
939
+ *
940
+ * @param filter The filter.
941
+ * @returns The page.
942
+ */
943
+ getTriples(filter) {
944
+ const url = this._env.get('apiUrl') + 'graph/triples';
945
+ const httpParams = this.applyTripleFilter(filter, new HttpParams());
946
+ return this._http
947
+ .get(url, {
948
+ params: httpParams,
949
+ })
950
+ .pipe(retry(3), catchError(this._error.handleError));
951
+ }
952
+ /**
953
+ * Get the triple with the specified ID.
954
+ *
955
+ * @param id The triple's ID.
956
+ * @returns The triple.
957
+ */
958
+ getTriple(id) {
959
+ const url = this._env.get('apiUrl') + 'graph/triples/' + id.toString();
960
+ return this._http
961
+ .get(url)
962
+ .pipe(retry(3), catchError(this._error.handleError));
963
+ }
964
+ /**
965
+ * Add or update the specified triple.
966
+ *
967
+ * @param triple The triple to add.
968
+ * @returns The added triple.
969
+ */
970
+ addTriple(triple) {
971
+ const url = this._env.get('apiUrl') + 'graph/triples';
972
+ return this._http
973
+ .post(url, triple)
974
+ .pipe(catchError(this._error.handleError));
975
+ }
976
+ /**
977
+ * Delete the triple with the specified ID.
978
+ *
979
+ * @param id The triple's ID.
980
+ */
981
+ deleteTriple(id) {
982
+ const url = this._env.get('apiUrl') + 'graph/triples/' + id.toString();
983
+ return this._http.delete(url).pipe(catchError(this._error.handleError));
984
+ }
985
+ applyLiteralFilter(filter, httpParams) {
986
+ if (filter.literalPattern) {
987
+ httpParams = httpParams.set('literalPattern', filter.literalPattern);
988
+ }
989
+ if (filter.literalType) {
990
+ httpParams = httpParams.set('literalType', filter.literalType);
991
+ }
992
+ if (filter.literalLanguage) {
993
+ httpParams = httpParams.set('literalLanguage', filter.literalLanguage);
994
+ }
995
+ if (filter.minLiteralNumber) {
996
+ httpParams = httpParams.set('minLiteralNumber', filter.minLiteralNumber.toString());
997
+ }
998
+ if (filter.maxLiteralNumber) {
999
+ httpParams = httpParams.set('maxLiteralNumber', filter.maxLiteralNumber.toString());
1000
+ }
1001
+ return httpParams;
1002
+ }
1003
+ /**
1004
+ * Get the specified page of triples grouped by their property.
1005
+ *
1006
+ * @param filter The filter.
1007
+ * @returns The page of triples.
1008
+ */
1009
+ getTripleGroups(filter) {
1010
+ const httpParams = this.applyTripleFilter(filter, new HttpParams());
1011
+ const url = this._env.get('apiUrl') + 'graph/walk/triples';
1012
+ return this._http
1013
+ .get(url, {
1014
+ params: httpParams,
1015
+ })
1016
+ .pipe(retry(3), catchError(this._error.handleError));
1017
+ }
1018
+ /**
1019
+ * Get linked nodes.
1020
+ * @param filter The filter.
1021
+ * @returns Observable with data page.
1022
+ */
1023
+ getLinkedNodes(filter) {
1024
+ let httpParams = new HttpParams();
1025
+ httpParams = httpParams.set('pageNumber', filter.pageNumber.toString());
1026
+ httpParams = httpParams.set('pageSize', filter.pageSize.toString());
1027
+ // NodeFilterBase
1028
+ if (filter.uid) {
1029
+ httpParams = httpParams.set('uid', filter.uid);
1030
+ }
1031
+ if (filter.isClass !== null && filter.isClass !== undefined) {
1032
+ httpParams = httpParams.set('isClass', filter.isClass);
1033
+ }
1034
+ if (filter.tag) {
1035
+ httpParams = httpParams.set('tag', filter.tag);
1036
+ }
1037
+ if (filter.label) {
1038
+ httpParams = httpParams.set('label', filter.label);
1039
+ }
1040
+ if (filter.sourceType) {
1041
+ httpParams = httpParams.set('sourceType', +filter.sourceType);
1042
+ }
1043
+ if (filter.sid) {
1044
+ httpParams = httpParams.set('sid', filter.sid);
1045
+ }
1046
+ if (filter.isSidPrefix !== null && filter.isSidPrefix !== undefined) {
1047
+ httpParams = httpParams.set('isSidPrefix', filter.isSidPrefix);
1048
+ }
1049
+ if (filter.classIds?.length) {
1050
+ for (let i = 0; i < filter.classIds.length; i++) {
1051
+ httpParams = httpParams.set('classIds', filter.classIds[i]);
1052
+ }
1053
+ }
1054
+ // LinkedNodeFilter
1055
+ if (filter.otherNodeId) {
1056
+ httpParams = httpParams.set('otherNodeId', filter.otherNodeId);
1057
+ }
1058
+ if (filter.predicateId) {
1059
+ httpParams = httpParams.set('predicateId', filter.predicateId);
1060
+ }
1061
+ if (filter.isObject !== null && filter.isObject !== undefined) {
1062
+ httpParams = httpParams.set('isObject', filter.isObject);
1063
+ }
1064
+ const url = this._env.get('apiUrl') + 'graph/walk/nodes';
1065
+ return this._http
1066
+ .get(url, {
1067
+ params: httpParams,
1068
+ })
1069
+ .pipe(retry(3), catchError(this._error.handleError));
1070
+ }
1071
+ /**
1072
+ * Get linked literals.
1073
+ * @param filter The filter.
1074
+ * @returns Observable with data page.
1075
+ */
1076
+ getLinkedLiterals(filter) {
1077
+ let httpParams = new HttpParams();
1078
+ httpParams = httpParams.set('pageNumber', filter.pageNumber.toString());
1079
+ httpParams = httpParams.set('pageSize', filter.pageSize.toString());
1080
+ // LiteralFilter
1081
+ httpParams = this.applyLiteralFilter(filter, httpParams);
1082
+ // LinkedLiteralFilter
1083
+ if (filter.subjectId) {
1084
+ httpParams = httpParams.set('subjectId', filter.subjectId.toString());
1085
+ }
1086
+ if (filter.predicateId) {
1087
+ httpParams = httpParams.set('predicateId', filter.predicateId.toString());
1088
+ }
1089
+ const url = this._env.get('apiUrl') + 'graph/walk/nodes/literal';
1090
+ return this._http
1091
+ .get(url, {
1092
+ params: httpParams,
1093
+ })
1094
+ .pipe(retry(3), catchError(this._error.handleError));
1095
+ }
1096
+ }
1097
+ 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 });
1098
+ GraphService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphService, providedIn: 'root' });
1099
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphService, decorators: [{
1100
+ type: Injectable,
1101
+ args: [{
1102
+ providedIn: 'root',
1103
+ }]
1104
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.ErrorService }, { type: i2.EnvService }]; } });
1105
+
1106
+ /**
1107
+ * Graph node lookup service.
1108
+ */
1109
+ class GraphNodeLookupService {
1110
+ constructor(_graphService) {
1111
+ this._graphService = _graphService;
1112
+ }
1113
+ lookup(filter, options) {
1114
+ if (!filter.text) {
1115
+ return of([]);
1116
+ }
1117
+ return this._graphService
1118
+ .getNodes({
1119
+ pageNumber: 1,
1120
+ pageSize: filter.limit || 10,
1121
+ label: filter.text,
1122
+ isClass: filter.isClass === undefined || filter.isClass === null
1123
+ ? undefined
1124
+ : filter.isClass
1125
+ ? true
1126
+ : false,
1127
+ tag: filter.tag,
1128
+ })
1129
+ .pipe(map((p) => p.items));
1130
+ }
1131
+ getName(item) {
1132
+ return item?.label;
1133
+ }
1134
+ }
1135
+ GraphNodeLookupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLookupService, deps: [{ token: GraphService }], target: i0.ɵɵFactoryTarget.Injectable });
1136
+ GraphNodeLookupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLookupService, providedIn: 'root' });
1137
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLookupService, decorators: [{
1138
+ type: Injectable,
1139
+ args: [{
1140
+ providedIn: 'root',
1141
+ }]
1142
+ }], ctorParameters: function () { return [{ type: GraphService }]; } });
1143
+
1144
+ /**
1145
+ * Linked literal filter.
1146
+ */
1147
+ class LinkedLiteralFilterComponent {
1148
+ /**
1149
+ * The filter.
1150
+ */
1151
+ get filter() {
1152
+ return this._filter;
1153
+ }
1154
+ set filter(value) {
1155
+ if (this._filter === value) {
1156
+ return;
1157
+ }
1158
+ this._filter = value;
1159
+ this.updateForm(value);
1160
+ }
1161
+ constructor(formBuilder, lookupService, _graphService) {
1162
+ this.lookupService = lookupService;
1163
+ this._graphService = _graphService;
1164
+ this._filter = {
1165
+ pageNumber: 1,
1166
+ pageSize: 10,
1167
+ };
1168
+ this.total = 0;
1169
+ this.filterChange = new EventEmitter();
1170
+ // form
1171
+ this.pageNumber = formBuilder.control(1, { nonNullable: true });
1172
+ this.pageSize = formBuilder.control(10, { nonNullable: true });
1173
+ this.litPattern = formBuilder.control(null);
1174
+ this.litType = formBuilder.control(null);
1175
+ this.litLanguage = formBuilder.control(null);
1176
+ this.minLitNumber = formBuilder.control(null);
1177
+ this.maxLitNumber = formBuilder.control(null);
1178
+ this.subj = formBuilder.control(null);
1179
+ this.pred = formBuilder.control(null);
1180
+ this.form = formBuilder.group({
1181
+ pageNumber: this.pageNumber,
1182
+ pageSize: this.pageSize,
1183
+ litPattern: this.litPattern,
1184
+ litType: this.litType,
1185
+ litLanguage: this.litLanguage,
1186
+ minLitNumber: this.minLitNumber,
1187
+ maxLitNumber: this.maxLitNumber,
1188
+ subj: this.subj,
1189
+ pred: this.pred,
1190
+ });
1191
+ }
1192
+ ngOnInit() { }
1193
+ updateForm(filter) {
1194
+ this.pageNumber.setValue(filter.pageNumber);
1195
+ this.pageSize.setValue(filter.pageSize);
1196
+ this.litPattern.setValue(filter.literalPattern || null);
1197
+ this.litType.setValue(filter.literalType || null);
1198
+ this.litLanguage.setValue(filter.literalLanguage || null);
1199
+ this.minLitNumber.setValue(filter.minLiteralNumber || null);
1200
+ this.maxLitNumber.setValue(filter.maxLiteralNumber || null);
1201
+ // load the referenced triples so we can show them by label
1202
+ forkJoin({
1203
+ s: filter.subjectId
1204
+ ? this._graphService.getNode(filter.subjectId)
1205
+ : from([null]),
1206
+ p: filter.predicateId
1207
+ ? this._graphService.getNode(filter.predicateId)
1208
+ : from([]),
1209
+ }).subscribe((result) => {
1210
+ this.subj.setValue(result.s);
1211
+ this.pred.setValue(result.p);
1212
+ this.form.markAsPristine();
1213
+ });
1214
+ }
1215
+ getFilter() {
1216
+ return {
1217
+ pageNumber: +this.pageNumber.value,
1218
+ pageSize: +this.pageSize.value,
1219
+ literalPattern: this.litPattern.value || undefined,
1220
+ literalType: this.litType.value || undefined,
1221
+ literalLanguage: this.litLanguage.value || undefined,
1222
+ minLiteralNumber: this.minLitNumber.value || undefined,
1223
+ maxLiteralNumber: this.maxLitNumber.value || undefined,
1224
+ subjectId: this.subj.value?.id,
1225
+ predicateId: this.pred.value?.id,
1226
+ };
1227
+ }
1228
+ emitFilterChange() {
1229
+ this.filterChange.emit(this.getFilter());
1230
+ }
1231
+ onSubjectNodeChange(node) {
1232
+ this.subj.setValue(node);
1233
+ }
1234
+ onPredicateNodeChange(node) {
1235
+ this.pred.setValue(node);
1236
+ }
1237
+ onPageChange(page) {
1238
+ this.pageNumber.setValue(page.pageIndex + 1);
1239
+ this.emitFilterChange();
1240
+ }
1241
+ reset() {
1242
+ this.form.reset();
1243
+ this._filter = this.getFilter();
1244
+ this.filterChange.emit(this._filter);
1245
+ }
1246
+ apply() {
1247
+ if (this.form.invalid) {
1248
+ return;
1249
+ }
1250
+ this.emitFilterChange();
1251
+ this.form.markAsPristine();
1252
+ }
1253
+ }
1254
+ 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 });
1255
+ 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"] }] });
1256
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: LinkedLiteralFilterComponent, decorators: [{
1257
+ type: Component,
1258
+ 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" }]
1259
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: GraphNodeLookupService }, { type: GraphService }]; }, propDecorators: { disabled: [{
1260
+ type: Input
1261
+ }], hasPager: [{
1262
+ type: Input
1263
+ }], total: [{
1264
+ type: Input
1265
+ }], filter: [{
1266
+ type: Input
1267
+ }], filterChange: [{
1268
+ type: Output
1269
+ }] } });
1270
+
1271
+ /**
1272
+ * Linked non-literal node filter.
1273
+ */
1274
+ class LinkedNodeFilterComponent {
1275
+ /**
1276
+ * The filter.
1277
+ */
1278
+ get filter() {
1279
+ return this._filter;
1280
+ }
1281
+ set filter(value) {
1282
+ if (this._filter === value) {
1283
+ return;
1284
+ }
1285
+ this._filter = value;
1286
+ this.updateForm(value);
1287
+ }
1288
+ constructor(formBuilder, lookupService, _graphService) {
1289
+ this.lookupService = lookupService;
1290
+ this._graphService = _graphService;
1291
+ this.otherNodeId = 0;
1292
+ this.predicateId = 0;
1293
+ this.isObject = false;
1294
+ this._filter = {
1295
+ pageNumber: 1,
1296
+ pageSize: 10,
1297
+ otherNodeId: 0,
1298
+ predicateId: 0,
1299
+ };
1300
+ this.total = 0;
1301
+ this.filterChange = new EventEmitter();
1302
+ // form
1303
+ this.pageNumber = formBuilder.control(1, { nonNullable: true });
1304
+ this.pageSize = formBuilder.control(10, { nonNullable: true });
1305
+ this.uid = formBuilder.control(null);
1306
+ this.isClass = formBuilder.control(null);
1307
+ this.tag = formBuilder.control(null);
1308
+ this.label = formBuilder.control(null);
1309
+ this.sourceType = formBuilder.control(null);
1310
+ this.sid = formBuilder.control(null);
1311
+ this.isSidPrefix = formBuilder.control(false, { nonNullable: true });
1312
+ this.classes = formBuilder.control([], { nonNullable: true });
1313
+ this.form = formBuilder.group({
1314
+ pageNumber: this.pageNumber,
1315
+ pageSize: this.pageSize,
1316
+ uid: this.uid,
1317
+ isClass: this.isClass,
1318
+ tag: this.tag,
1319
+ label: this.label,
1320
+ sourceType: this.sourceType,
1321
+ sid: this.sid,
1322
+ isSidPrefix: this.isSidPrefix,
1323
+ classes: this.classes,
1324
+ });
1325
+ }
1326
+ ngOnInit() { }
1327
+ updateForm(filter) {
1328
+ this.otherNodeId = filter.otherNodeId;
1329
+ this.predicateId = filter.predicateId;
1330
+ this.isObject = filter.isObject || false;
1331
+ this.pageNumber.setValue(filter.pageNumber);
1332
+ this.pageSize.setValue(filter.pageSize);
1333
+ this.uid.setValue(filter.uid || null);
1334
+ this.isClass.setValue(filter.isClass || null);
1335
+ this.tag.setValue(filter.tag || null);
1336
+ this.label.setValue(filter.label || null);
1337
+ this.sourceType.setValue(filter.sourceType || null);
1338
+ this.sid.setValue(filter.sid || null);
1339
+ this.isSidPrefix.setValue(filter.isSidPrefix || false);
1340
+ // load the referenced class nodes so we can show them by label
1341
+ if (filter.classIds?.length) {
1342
+ this._graphService
1343
+ .getNodeSet(filter.classIds)
1344
+ .pipe(take(1))
1345
+ .subscribe((nodes) => {
1346
+ this.classes.setValue(nodes.filter((n) => n));
1347
+ this.form.markAsPristine();
1348
+ });
1349
+ }
1350
+ else {
1351
+ this.classes.setValue([]);
1352
+ this.form.markAsPristine();
1353
+ }
1354
+ }
1355
+ getFilter() {
1356
+ return {
1357
+ pageNumber: +this.pageNumber.value,
1358
+ pageSize: +this.pageSize.value,
1359
+ uid: this.uid.value || undefined,
1360
+ isClass: this.isClass.value || undefined,
1361
+ tag: this.tag.value || undefined,
1362
+ label: this.label.value || undefined,
1363
+ sourceType: this.sourceType.value || undefined,
1364
+ sid: this.sid.value || undefined,
1365
+ isSidPrefix: this.isSidPrefix.value ? true : undefined,
1366
+ classIds: this.classes.value.length
1367
+ ? this.classes.value.map((n) => n.id)
1368
+ : undefined,
1369
+ otherNodeId: this.otherNodeId,
1370
+ predicateId: this.predicateId,
1371
+ isObject: this.isObject,
1372
+ };
1373
+ }
1374
+ emitFilterChange() {
1375
+ this.filterChange.emit(this.getFilter());
1376
+ }
1377
+ onPageChange(page) {
1378
+ this.pageNumber.setValue(page.pageIndex + 1);
1379
+ this.emitFilterChange();
1380
+ }
1381
+ onClassAdd(node) {
1382
+ if (!node) {
1383
+ return;
1384
+ }
1385
+ const nodes = [...this.classes.value];
1386
+ nodes.push(node);
1387
+ this.classes.setValue(nodes);
1388
+ this.classes.updateValueAndValidity();
1389
+ this.classes.markAsDirty();
1390
+ }
1391
+ onClassRemove(node) {
1392
+ const nodes = [...this.classes.value];
1393
+ const i = nodes.indexOf(node);
1394
+ if (i > -1) {
1395
+ nodes.splice(i, 1);
1396
+ this.classes.setValue(nodes);
1397
+ this.classes.updateValueAndValidity();
1398
+ this.classes.markAsDirty();
1399
+ }
1400
+ }
1401
+ reset() {
1402
+ this.form.reset();
1403
+ this._filter = this.getFilter();
1404
+ this.filterChange.emit(this._filter);
1405
+ }
1406
+ apply() {
1407
+ if (this.form.invalid) {
1408
+ return;
1409
+ }
1410
+ this.emitFilterChange();
1411
+ this.form.markAsPristine();
1412
+ }
1413
+ }
1414
+ 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 });
1415
+ 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"] }] });
1416
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: LinkedNodeFilterComponent, decorators: [{
1417
+ type: Component,
1418
+ 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"] }]
1419
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: GraphNodeLookupService }, { type: GraphService }]; }, propDecorators: { disabled: [{
1420
+ type: Input
1421
+ }], hasPager: [{
1422
+ type: Input
1423
+ }], total: [{
1424
+ type: Input
1425
+ }], filter: [{
1426
+ type: Input
1427
+ }], filterChange: [{
1428
+ type: Output
1429
+ }] } });
1430
+
1431
+ /**
1432
+ * Triples filter.
1433
+ */
1434
+ class TripleFilterComponent {
1435
+ /**
1436
+ * The filter.
1437
+ */
1438
+ get filter() {
1439
+ return this._filter;
1440
+ }
1441
+ set filter(value) {
1442
+ if (this._filter === value) {
1443
+ return;
1444
+ }
1445
+ this._filter = value;
1446
+ this.updateForm(value);
1447
+ }
1448
+ constructor(formBuilder, lookupService, _graphService) {
1449
+ this.lookupService = lookupService;
1450
+ this._graphService = _graphService;
1451
+ this._filter = {
1452
+ pageNumber: 1,
1453
+ pageSize: 10,
1454
+ };
1455
+ this.total = 0;
1456
+ this.filterChange = new EventEmitter();
1457
+ // form
1458
+ this.pageNumber = formBuilder.control(1, { nonNullable: true });
1459
+ this.pageSize = formBuilder.control(10, { nonNullable: true });
1460
+ this.litPattern = formBuilder.control(null);
1461
+ this.litType = formBuilder.control(null);
1462
+ this.litLanguage = formBuilder.control(null);
1463
+ this.minLitNumber = formBuilder.control(null);
1464
+ this.maxLitNumber = formBuilder.control(null);
1465
+ this.subj = formBuilder.control(null);
1466
+ this.preds = formBuilder.control([], { nonNullable: true });
1467
+ this.isNotPred = formBuilder.control(false, { nonNullable: true });
1468
+ this.notPreds = formBuilder.control([], { nonNullable: true });
1469
+ this.hasLiteralObj = formBuilder.control(null);
1470
+ this.obj = formBuilder.control(null);
1471
+ this.sid = formBuilder.control(null);
1472
+ this.isSidPrefix = formBuilder.control(false, { nonNullable: true });
1473
+ this.tag = formBuilder.control(null);
1474
+ this.form = formBuilder.group({
1475
+ pageNumber: this.pageNumber,
1476
+ pageSize: this.pageSize,
1477
+ litPattern: this.litPattern,
1478
+ litType: this.litType,
1479
+ litLanguage: this.litLanguage,
1480
+ minLitNumber: this.minLitNumber,
1481
+ maxLitNumber: this.maxLitNumber,
1482
+ subj: this.subj,
1483
+ preds: this.preds,
1484
+ isNotPred: this.isNotPred,
1485
+ notPreds: this.notPreds,
1486
+ hasLiteralObj: this.hasLiteralObj,
1487
+ obj: this.obj,
1488
+ sid: this.sid,
1489
+ isSidPrefix: this.isSidPrefix,
1490
+ tag: this.tag,
1491
+ });
1492
+ }
1493
+ ngOnInit() { }
1494
+ updateForm(filter) {
1495
+ this.pageNumber.setValue(filter.pageNumber);
1496
+ this.pageSize.setValue(filter.pageSize);
1497
+ this.litPattern.setValue(filter.literalPattern || null);
1498
+ this.litType.setValue(filter.literalType || null);
1499
+ this.litLanguage.setValue(filter.literalLanguage || null);
1500
+ this.minLitNumber.setValue(filter.minLiteralNumber || null);
1501
+ this.maxLitNumber.setValue(filter.maxLiteralNumber || null);
1502
+ this.hasLiteralObj.setValue(filter.hasLiteralObject || null);
1503
+ this.sid.setValue(filter.sid || null);
1504
+ this.isSidPrefix.setValue(filter.isSidPrefix || false);
1505
+ this.tag.setValue(filter.tag || null);
1506
+ // load the referenced nodes so we can show them by label
1507
+ forkJoin({
1508
+ s: filter.subjectId
1509
+ ? this._graphService.getNode(filter.subjectId)
1510
+ : from([null]),
1511
+ p: filter.predicateIds?.length
1512
+ ? this._graphService.getNodeSet(filter.predicateIds)
1513
+ : from([]),
1514
+ o: filter.objectId
1515
+ ? this._graphService.getNode(filter.objectId)
1516
+ : from([null]),
1517
+ }).subscribe((result) => {
1518
+ this.subj.setValue(result.s);
1519
+ this.preds.setValue(result.p.filter((n) => n));
1520
+ this.obj.setValue(result.o);
1521
+ this.form.markAsPristine();
1522
+ });
1523
+ }
1524
+ getFilter() {
1525
+ return {
1526
+ pageNumber: +this.pageNumber.value,
1527
+ pageSize: +this.pageSize.value,
1528
+ literalPattern: this.litPattern.value || undefined,
1529
+ literalType: this.litType.value || undefined,
1530
+ literalLanguage: this.litLanguage.value || undefined,
1531
+ minLiteralNumber: this.minLitNumber.value || undefined,
1532
+ maxLiteralNumber: this.maxLitNumber.value || undefined,
1533
+ subjectId: this.subj.value?.id || undefined,
1534
+ predicateIds: this.preds.value?.length
1535
+ ? this.preds.value.map((n) => n.id)
1536
+ : undefined,
1537
+ notPredicateIds: this.notPreds.value?.length
1538
+ ? this.notPreds.value.map((n) => n.id)
1539
+ : undefined,
1540
+ hasLiteralObject: this.hasLiteralObj.value !== null
1541
+ ? this.hasLiteralObj.value
1542
+ : undefined,
1543
+ objectId: this.obj.value?.id || undefined,
1544
+ sid: this.sid.value || undefined,
1545
+ isSidPrefix: this.isSidPrefix.value,
1546
+ tag: this.tag.value || undefined,
1547
+ };
1548
+ }
1549
+ emitFilterChange() {
1550
+ this.filterChange.emit(this.getFilter());
1551
+ }
1552
+ onPageChange(page) {
1553
+ this.pageNumber.setValue(page.pageIndex + 1);
1554
+ this.emitFilterChange();
1555
+ }
1556
+ onSubjectNodeChange(node) {
1557
+ this.subj.setValue(node);
1558
+ }
1559
+ onObjectNodeChange(node) {
1560
+ this.obj.setValue(node);
1561
+ }
1562
+ onPredicateNodeChange(node) {
1563
+ if (!node) {
1564
+ return;
1565
+ }
1566
+ if (this.isNotPred.value) {
1567
+ const nodes = [...this.notPreds.value];
1568
+ if (nodes.some((n) => n.id === node.id)) {
1569
+ return;
1570
+ }
1571
+ nodes.push(node);
1572
+ this.notPreds.setValue(nodes);
1573
+ this.notPreds.updateValueAndValidity();
1574
+ this.notPreds.markAsDirty();
1575
+ }
1576
+ else {
1577
+ const nodes = [...this.preds.value];
1578
+ if (nodes.some((n) => n.id === node.id)) {
1579
+ return;
1580
+ }
1581
+ nodes.push(node);
1582
+ this.preds.setValue(nodes);
1583
+ this.preds.updateValueAndValidity();
1584
+ this.preds.markAsDirty();
1585
+ }
1586
+ }
1587
+ deleteNotPred(node) {
1588
+ const nodes = [...this.notPreds.value];
1589
+ const i = nodes.indexOf(node);
1590
+ nodes.splice(i, 1);
1591
+ this.notPreds.setValue(nodes);
1592
+ this.notPreds.updateValueAndValidity();
1593
+ this.notPreds.markAsDirty();
1594
+ }
1595
+ deletePred(node) {
1596
+ const nodes = [...this.preds.value];
1597
+ const i = nodes.indexOf(node);
1598
+ nodes.splice(i, 1);
1599
+ this.preds.setValue(nodes);
1600
+ this.preds.updateValueAndValidity();
1601
+ this.preds.markAsDirty();
1602
+ }
1603
+ reset() {
1604
+ this.form.reset();
1605
+ this._filter = this.getFilter();
1606
+ this.filterChange.emit(this._filter);
1607
+ }
1608
+ apply() {
1609
+ if (this.form.invalid) {
1610
+ return;
1611
+ }
1612
+ this.emitFilterChange();
1613
+ this.form.markAsPristine();
1614
+ }
1615
+ }
1616
+ 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 });
1617
+ 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 &nbsp;\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"] }] });
1618
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: TripleFilterComponent, decorators: [{
1619
+ type: Component,
1620
+ 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 &nbsp;\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" }]
1621
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: GraphNodeLookupService }, { type: GraphService }]; }, propDecorators: { disabled: [{
1622
+ type: Input
1623
+ }], hasPager: [{
1624
+ type: Input
1625
+ }], total: [{
1626
+ type: Input
1627
+ }], filter: [{
1628
+ type: Input
1629
+ }], filterChange: [{
1630
+ type: Output
1631
+ }] } });
1632
+
1633
+ /**
1634
+ * Get the extended label for the specified graph node. This returns the label
1635
+ * for N nodes, and the uri + "=" + the label for P nodes. That's because P
1636
+ * nodes label is just the count of the triples group, so the predicate ID is
1637
+ * got from the property node's data uri.
1638
+ */
1639
+ class GraphNodeLabelPipe {
1640
+ transform(value, ...args) {
1641
+ const node = value;
1642
+ if (!node?.id || !node?.label) {
1643
+ return value;
1644
+ }
1645
+ if (node.id.startsWith('P') && node.data.uri) {
1646
+ return `${node.data.uri}=${node.label}`;
1647
+ }
1648
+ return node.label;
1649
+ }
1650
+ }
1651
+ GraphNodeLabelPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLabelPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1652
+ GraphNodeLabelPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLabelPipe, name: "graphNodeLabel" });
1653
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphNodeLabelPipe, decorators: [{
1654
+ type: Pipe,
1655
+ args: [{
1656
+ name: 'graphNodeLabel'
1657
+ }]
1658
+ }] });
1659
+
1660
+ /**
1661
+ * Graph walker component. This starts from a given node, and let users
1662
+ * walk along edges to discover new nodes.
1663
+ */
1664
+ class GraphWalkerComponent {
1665
+ /**
1666
+ * The root origin node ID.
1667
+ */
1668
+ get nodeId() {
1669
+ return this._nodeId;
1670
+ }
1671
+ set nodeId(value) {
1672
+ if (this._nodeId === value) {
1673
+ return;
1674
+ }
1675
+ this._nodeId = value;
1676
+ this.reset(value);
1677
+ }
1678
+ constructor(graphService, _dialog) {
1679
+ this._dialog = _dialog;
1680
+ // ngx-graph actions
1681
+ this.update$ = new Subject();
1682
+ this.center$ = new Subject();
1683
+ this.zoomToFit$ = new Subject();
1684
+ this._walker = new GraphWalker(graphService);
1685
+ this._nodeId = 0;
1686
+ this.nodePick = new EventEmitter();
1687
+ this.nodes$ = this._walker.nodes$;
1688
+ this.edges$ = this._walker.edges$;
1689
+ this.loading$ = this._walker.loading$;
1690
+ this.error$ = this._walker.error$;
1691
+ this.selectedNode$ = this._walker.selectedNode$;
1692
+ this.pOutFilter$ = this._walker.pOutFilter$;
1693
+ this.pInFilter$ = this._walker.pInFilter$;
1694
+ this.pLitFilter$ = this._walker.pLitFilter$;
1695
+ this.nOutFilter$ = this._walker.nOutFilter$;
1696
+ this.nInFilter$ = this._walker.nInFilter$;
1697
+ this.childTotals$ = this._walker.childTotals$;
1698
+ }
1699
+ ngOnInit() {
1700
+ this.update$.subscribe((_) => {
1701
+ this.onReset();
1702
+ });
1703
+ }
1704
+ onNodeSelect(node) {
1705
+ this._walker.selectNode(node.id);
1706
+ }
1707
+ reset(id) {
1708
+ this._walker.reset(id);
1709
+ }
1710
+ onReset() {
1711
+ if (!this._nodeId) {
1712
+ return;
1713
+ }
1714
+ this._dialog
1715
+ .confirm('Reset', 'Reset the whole graph?')
1716
+ .pipe(take$1(1))
1717
+ .subscribe((yes) => {
1718
+ if (yes) {
1719
+ this.reset(this._nodeId);
1720
+ }
1721
+ });
1722
+ }
1723
+ onNodeDblClick(node) {
1724
+ this._walker.toggleNode(node);
1725
+ }
1726
+ onPOutFilterChange(filter) {
1727
+ this._walker.expandSelectedProperty(filter);
1728
+ }
1729
+ onPInFilterChange(filter) {
1730
+ this._walker.expandSelectedProperty(null, filter);
1731
+ }
1732
+ onPLitFilterChange(filter) {
1733
+ this._walker.expandSelectedProperty(null, null, filter);
1734
+ }
1735
+ onNOutFilterChange(filter) {
1736
+ this._walker.expandSelectedNode(filter);
1737
+ }
1738
+ onNInFilterChange(filter) {
1739
+ this._walker.expandSelectedNode(null, filter);
1740
+ }
1741
+ pickSelectedNode() {
1742
+ const node = this._walker.getSelectedNode();
1743
+ if (!node) {
1744
+ return;
1745
+ }
1746
+ this.nodePick.emit(node);
1747
+ }
1748
+ }
1749
+ 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 });
1750
+ 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'\">&#x2b24;</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" }] });
1751
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GraphWalkerComponent, decorators: [{
1752
+ type: Component,
1753
+ 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'\">&#x2b24;</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"] }]
1754
+ }], ctorParameters: function () { return [{ type: GraphService }, { type: i2$1.DialogService }]; }, propDecorators: { nodeId: [{
1755
+ type: Input
1756
+ }], canPick: [{
1757
+ type: Input
1758
+ }], nodePick: [{
1759
+ type: Output
1760
+ }] } });
1761
+
1762
+ class CadmusGraphUiExModule {
1763
+ }
1764
+ CadmusGraphUiExModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: CadmusGraphUiExModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1765
+ CadmusGraphUiExModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.4", ngImport: i0, type: CadmusGraphUiExModule, declarations: [GraphNodeLabelPipe,
1766
+ GraphWalkerComponent,
1767
+ LinkedLiteralFilterComponent,
1768
+ LinkedNodeFilterComponent,
1769
+ TripleFilterComponent], imports: [CommonModule,
1770
+ FormsModule,
1771
+ ReactiveFormsModule,
1772
+ HttpClientModule,
1773
+ // material
1774
+ MatAutocompleteModule,
1775
+ MatButtonModule,
1776
+ MatCheckboxModule,
1777
+ MatChipsModule,
1778
+ MatFormFieldModule,
1779
+ MatIconModule,
1780
+ MatInputModule,
1781
+ MatListModule,
1782
+ MatPaginatorModule,
1783
+ MatProgressBarModule,
1784
+ MatSelectModule,
1785
+ MatTabsModule,
1786
+ MatTooltipModule,
1787
+ // vendor
1788
+ NgxGraphModule,
1789
+ // Cadmus
1790
+ NgToolsModule,
1791
+ NgMatToolsModule,
1792
+ CadmusRefsLookupModule], exports: [GraphNodeLabelPipe,
1793
+ GraphWalkerComponent,
1794
+ LinkedLiteralFilterComponent,
1795
+ LinkedNodeFilterComponent,
1796
+ TripleFilterComponent] });
1797
+ CadmusGraphUiExModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: CadmusGraphUiExModule, imports: [CommonModule,
1798
+ FormsModule,
1799
+ ReactiveFormsModule,
1800
+ HttpClientModule,
1801
+ // material
1802
+ MatAutocompleteModule,
1803
+ MatButtonModule,
1804
+ MatCheckboxModule,
1805
+ MatChipsModule,
1806
+ MatFormFieldModule,
1807
+ MatIconModule,
1808
+ MatInputModule,
1809
+ MatListModule,
1810
+ MatPaginatorModule,
1811
+ MatProgressBarModule,
1812
+ MatSelectModule,
1813
+ MatTabsModule,
1814
+ MatTooltipModule,
1815
+ // vendor
1816
+ NgxGraphModule,
1817
+ // Cadmus
1818
+ NgToolsModule,
1819
+ NgMatToolsModule,
1820
+ CadmusRefsLookupModule] });
1821
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: CadmusGraphUiExModule, decorators: [{
1822
+ type: NgModule,
1823
+ args: [{
1824
+ declarations: [
1825
+ GraphNodeLabelPipe,
1826
+ GraphWalkerComponent,
1827
+ LinkedLiteralFilterComponent,
1828
+ LinkedNodeFilterComponent,
1829
+ TripleFilterComponent,
1830
+ ],
1831
+ imports: [
1832
+ CommonModule,
1833
+ FormsModule,
1834
+ ReactiveFormsModule,
1835
+ HttpClientModule,
1836
+ // material
1837
+ MatAutocompleteModule,
1838
+ MatButtonModule,
1839
+ MatCheckboxModule,
1840
+ MatChipsModule,
1841
+ MatFormFieldModule,
1842
+ MatIconModule,
1843
+ MatInputModule,
1844
+ MatListModule,
1845
+ MatPaginatorModule,
1846
+ MatProgressBarModule,
1847
+ MatSelectModule,
1848
+ MatTabsModule,
1849
+ MatTooltipModule,
1850
+ // vendor
1851
+ NgxGraphModule,
1852
+ // Cadmus
1853
+ NgToolsModule,
1854
+ NgMatToolsModule,
1855
+ CadmusRefsLookupModule
1856
+ ],
1857
+ exports: [
1858
+ GraphNodeLabelPipe,
1859
+ GraphWalkerComponent,
1860
+ LinkedLiteralFilterComponent,
1861
+ LinkedNodeFilterComponent,
1862
+ TripleFilterComponent,
1863
+ ],
1864
+ }]
1865
+ }] });
1866
+
1867
+ /*
1868
+ * Public API Surface of cadmus-graph-ui
1869
+ */
1870
+
1871
+ /**
1872
+ * Generated bundle index. Do not edit.
1873
+ */
1874
+
1875
+ export { CadmusGraphUiExModule, GraphNodeLabelPipe, GraphNodeLookupService, GraphService, GraphWalker, GraphWalkerComponent, LinkedLiteralFilterComponent, LinkedNodeFilterComponent, NodeSourceType, TripleFilterComponent };
1876
+ //# sourceMappingURL=myrmidon-cadmus-graph-ui-ex.mjs.map