@myrmidon/cadmus-graph-ui-ex 10.2.0 → 11.0.0

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