ngx-relationship-visualiser 1.1.4 → 2.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.
Files changed (26) hide show
  1. package/README.md +60 -65
  2. package/esm2022/ngx-relationship-visualiser.mjs +1 -1
  3. package/esm2022/projects/ngx-relationship-visualiser-lib/lib/db/graphDatabase.mjs +1 -1
  4. package/esm2022/projects/ngx-relationship-visualiser-lib/lib/models/data.interface.mjs +1 -1
  5. package/esm2022/projects/ngx-relationship-visualiser-lib/lib/models/font-awesome-icons.mjs +209 -0
  6. package/esm2022/projects/ngx-relationship-visualiser-lib/lib/ngx-relationship-visualiser.module.mjs +30 -5
  7. package/esm2022/projects/ngx-relationship-visualiser-lib/lib/visualiser/context-menus/context-menus.component.mjs +120 -0
  8. package/esm2022/projects/ngx-relationship-visualiser-lib/lib/visualiser/modals/abstract-modal-form-handler.mjs +121 -0
  9. package/esm2022/projects/ngx-relationship-visualiser-lib/lib/visualiser/modals/modals.component.mjs +223 -0
  10. package/esm2022/projects/ngx-relationship-visualiser-lib/lib/visualiser/services/dagre-layout.service.mjs +17 -18
  11. package/esm2022/projects/ngx-relationship-visualiser-lib/lib/visualiser/services/visualiser-graph.service.mjs +473 -45
  12. package/esm2022/projects/ngx-relationship-visualiser-lib/lib/visualiser/visualiser-graph/visualiser-graph.component.mjs +461 -12
  13. package/esm2022/public_api.mjs +1 -1
  14. package/fesm2022/ngx-relationship-visualiser.mjs +1630 -76
  15. package/fesm2022/ngx-relationship-visualiser.mjs.map +1 -1
  16. package/package.json +13 -13
  17. package/projects/ngx-relationship-visualiser-lib/lib/models/data.interface.d.ts +6 -0
  18. package/projects/ngx-relationship-visualiser-lib/lib/models/font-awesome-icons.d.ts +6 -0
  19. package/projects/ngx-relationship-visualiser-lib/lib/ngx-relationship-visualiser.module.d.ts +8 -2
  20. package/projects/ngx-relationship-visualiser-lib/lib/visualiser/context-menus/context-menus.component.d.ts +39 -0
  21. package/projects/ngx-relationship-visualiser-lib/lib/visualiser/modals/abstract-modal-form-handler.d.ts +25 -0
  22. package/projects/ngx-relationship-visualiser-lib/lib/visualiser/modals/modals.component.d.ts +68 -0
  23. package/projects/ngx-relationship-visualiser-lib/lib/visualiser/services/dagre-layout.service.d.ts +27 -6
  24. package/projects/ngx-relationship-visualiser-lib/lib/visualiser/services/visualiser-graph.service.d.ts +17 -2
  25. package/projects/ngx-relationship-visualiser-lib/lib/visualiser/visualiser-graph/visualiser-graph.component.d.ts +53 -7
  26. package/ngx-relationship-visualiser-1.1.4.tgz +0 -0
@@ -1,12 +1,465 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, EventEmitter, Component, ViewChild, Output, Input, NgModule } from '@angular/core';
2
+ import { EventEmitter, Output, ViewChild, Component, Injectable, Input, NgModule } from '@angular/core';
3
3
  import { BrowserModule } from '@angular/platform-browser';
4
+ import * as i2$1 from '@angular/forms';
5
+ import { Validators, FormArray, ReactiveFormsModule, FormsModule } from '@angular/forms';
6
+ import * as i1 from 'ngx-bootstrap/modal';
7
+ import { ModalModule } from 'ngx-bootstrap/modal';
8
+ import * as i2 from '@kreash/ngx-contextmenu';
9
+ import { ContextMenuModule } from '@kreash/ngx-contextmenu';
10
+ import Dexie from 'dexie';
11
+ import * as i4 from '@angular/common';
12
+ import * as i5 from '@ng-select/ng-select';
13
+ import { NgSelectModule } from '@ng-select/ng-select';
4
14
  import Swal from 'sweetalert2';
5
15
  import * as d3 from 'd3';
6
- import { ReplaySubject } from 'rxjs';
7
- import Dexie from 'dexie';
16
+ import { Subject, ReplaySubject } from 'rxjs';
8
17
  import * as dagre from '@dagrejs/dagre';
9
- import * as i4 from '@angular/common';
18
+
19
+ class ContextMenusComponent {
20
+ editNodeContextMenu;
21
+ findCreateNodesContextMenu;
22
+ createEditLinkContextMenu;
23
+ editLinkLabelContextMenu;
24
+ editNodeContextMenuEvent = new EventEmitter();
25
+ findCreateNodesContextMenuEvent = new EventEmitter();
26
+ createLinkContextMenuEvent = new EventEmitter();
27
+ editLinkLabelContextMenuEvent = new EventEmitter();
28
+ editLinksContextMenuEvent = new EventEmitter();
29
+ currentMatchingLink = null;
30
+ currentItem = null;
31
+ editNode() {
32
+ this.editNodeContextMenuEvent.emit(true);
33
+ }
34
+ findNodes() {
35
+ this.findCreateNodesContextMenuEvent.emit('findNodes');
36
+ }
37
+ createNode() {
38
+ this.findCreateNodesContextMenuEvent.emit('createNode');
39
+ }
40
+ createLink() {
41
+ if (!this.currentItem) {
42
+ console.error('Selected graph data is required to create a link.');
43
+ return;
44
+ }
45
+ const payload = {
46
+ open: true,
47
+ data: this.currentItem.selectedNodes
48
+ };
49
+ this.createLinkContextMenuEvent.emit(payload);
50
+ }
51
+ editLinkLabel() {
52
+ this.editLinkLabelContextMenuEvent.emit(true);
53
+ }
54
+ editLinks() {
55
+ if (this.currentMatchingLink) {
56
+ this.editLinksContextMenuEvent.emit({
57
+ open: true,
58
+ data: this.currentMatchingLink
59
+ });
60
+ }
61
+ else {
62
+ console.warn("No matching link to edit.");
63
+ }
64
+ }
65
+ linksExist = (item) => {
66
+ this.currentItem = item;
67
+ const matchingLink = this.checkLinkBetweenSelectedNodes(item);
68
+ if (matchingLink) {
69
+ this.currentMatchingLink = matchingLink;
70
+ return true;
71
+ }
72
+ else {
73
+ this.currentMatchingLink = null;
74
+ return false;
75
+ }
76
+ };
77
+ linksDoNotExist = (item) => {
78
+ this.currentItem = item;
79
+ const matchingLink = this.checkLinkBetweenSelectedNodes(item);
80
+ if (!matchingLink) {
81
+ return true;
82
+ }
83
+ else {
84
+ return false;
85
+ }
86
+ };
87
+ checkLinkBetweenSelectedNodes(payload) {
88
+ if (!payload || !payload.selectedNodes) {
89
+ console.warn("Payload or selectedNodes is undefined.");
90
+ return null;
91
+ }
92
+ const selectedNodes = payload.selectedNodes;
93
+ const links = payload.graphData.links;
94
+ const sourceId = selectedNodes[0].id;
95
+ const targetId = selectedNodes[1].id;
96
+ // Check for a link in both directions (source -> target or target -> source)
97
+ const matchingLink = links.find((link) => (link.source === sourceId && link.target === targetId) ||
98
+ (link.source === targetId && link.target === sourceId));
99
+ if (matchingLink) {
100
+ return matchingLink;
101
+ }
102
+ else {
103
+ return null;
104
+ }
105
+ }
106
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ContextMenusComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
107
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: ContextMenusComponent, selector: "app-context-menus", outputs: { editNodeContextMenuEvent: "editNodeContextMenuEvent", findCreateNodesContextMenuEvent: "findCreateNodesContextMenuEvent", createLinkContextMenuEvent: "createLinkContextMenuEvent", editLinkLabelContextMenuEvent: "editLinkLabelContextMenuEvent", editLinksContextMenuEvent: "editLinksContextMenuEvent" }, viewQueries: [{ propertyName: "editNodeContextMenu", first: true, predicate: ["editNodeContextMenu"], descendants: true }, { propertyName: "findCreateNodesContextMenu", first: true, predicate: ["findCreateNodesContextMenu"], descendants: true }, { propertyName: "createEditLinkContextMenu", first: true, predicate: ["createEditLinkContextMenu"], descendants: true }, { propertyName: "editLinkLabelContextMenu", first: true, predicate: ["editLinkLabelContextMenu"], descendants: true }], ngImport: i0, template: "<context-menu #editNodeContextMenu>\n <ng-template contextMenuItem let-item (execute)=\"editNode()\">\n Edit Node...\n </ng-template>\n</context-menu>\n\n<context-menu #findCreateNodesContextMenu>\n <ng-template contextMenuItem let-item (execute)=\"findNodes()\">\n Search Nodes...\n </ng-template>\n <ng-template contextMenuItem let-item (execute)=\"createNode()\">\n Create Node...\n </ng-template>\n</context-menu>\n\n<context-menu #createEditLinkContextMenu>\n <ng-template [visible]=\"linksDoNotExist\" contextMenuItem let-item (execute)=\"createLink()\">\n Create Link...\n </ng-template>\n <ng-template [visible]=\"linksExist\" (execute)=\"editLinks()\" contextMenuItem let-item>\n Edit Links...\n </ng-template>\n</context-menu>\n\n<context-menu #editLinkLabelContextMenu>\n <ng-template contextMenuItem let-item (execute)=\"editLinkLabel()\">\n Edit Link label...\n </ng-template>\n</context-menu>", dependencies: [{ kind: "component", type: i2.ContextMenuComponent, selector: "context-menu", inputs: ["menuClass", "autoFocus", "useBootstrap4", "disabled"], outputs: ["close", "open"] }, { kind: "directive", type: i2.ContextMenuItemDirective, selector: "[contextMenuItem]", inputs: ["subMenu", "divider", "enabled", "passive", "visible"], outputs: ["execute"] }] });
108
+ }
109
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ContextMenusComponent, decorators: [{
110
+ type: Component,
111
+ args: [{ selector: 'app-context-menus', template: "<context-menu #editNodeContextMenu>\n <ng-template contextMenuItem let-item (execute)=\"editNode()\">\n Edit Node...\n </ng-template>\n</context-menu>\n\n<context-menu #findCreateNodesContextMenu>\n <ng-template contextMenuItem let-item (execute)=\"findNodes()\">\n Search Nodes...\n </ng-template>\n <ng-template contextMenuItem let-item (execute)=\"createNode()\">\n Create Node...\n </ng-template>\n</context-menu>\n\n<context-menu #createEditLinkContextMenu>\n <ng-template [visible]=\"linksDoNotExist\" contextMenuItem let-item (execute)=\"createLink()\">\n Create Link...\n </ng-template>\n <ng-template [visible]=\"linksExist\" (execute)=\"editLinks()\" contextMenuItem let-item>\n Edit Links...\n </ng-template>\n</context-menu>\n\n<context-menu #editLinkLabelContextMenu>\n <ng-template contextMenuItem let-item (execute)=\"editLinkLabel()\">\n Edit Link label...\n </ng-template>\n</context-menu>" }]
112
+ }], propDecorators: { editNodeContextMenu: [{
113
+ type: ViewChild,
114
+ args: ['editNodeContextMenu']
115
+ }], findCreateNodesContextMenu: [{
116
+ type: ViewChild,
117
+ args: ['findCreateNodesContextMenu']
118
+ }], createEditLinkContextMenu: [{
119
+ type: ViewChild,
120
+ args: ['createEditLinkContextMenu']
121
+ }], editLinkLabelContextMenu: [{
122
+ type: ViewChild,
123
+ args: ['editLinkLabelContextMenu']
124
+ }], editNodeContextMenuEvent: [{
125
+ type: Output
126
+ }], findCreateNodesContextMenuEvent: [{
127
+ type: Output
128
+ }], createLinkContextMenuEvent: [{
129
+ type: Output
130
+ }], editLinkLabelContextMenuEvent: [{
131
+ type: Output
132
+ }], editLinksContextMenuEvent: [{
133
+ type: Output
134
+ }] } });
135
+
136
+ var fontAwesomeIcons = [
137
+ { id: 1, name: 'Address book', icon: '\uf2b9' },
138
+ { id: 2, name: 'Address card', icon: '\uf2bb' },
139
+ { id: 3, name: 'Anchor', icon: '\uf13d' },
140
+ { id: 4, name: 'Apple Whole', icon: '\uf5d1' },
141
+ { id: 5, name: 'Atom', icon: '\uf5d2' },
142
+ { id: 6, name: 'Award', icon: '\uf559' },
143
+ { id: 7, name: 'Baby', icon: '\uf77c' },
144
+ { id: 8, name: 'Bacon', icon: '\uf7e5' },
145
+ { id: 9, name: 'Balance Scale', icon: '\uf24e' },
146
+ { id: 10, name: 'Bank', icon: '\uf19c' },
147
+ { id: 11, name: 'Battery Full', icon: '\uf240' },
148
+ { id: 12, name: 'Beer', icon: '\uf0fc' },
149
+ { id: 13, name: 'Bell', icon: '\uf0f3' },
150
+ { id: 14, name: 'Bell slash', icon: '\uf1f6' },
151
+ { id: 15, name: 'Bicycle', icon: '\uf206' },
152
+ { id: 16, name: 'Binoculars', icon: '\uf1e5' },
153
+ { id: 17, name: 'Birthday Cake', icon: '\uf1fd' },
154
+ { id: 18, name: 'Blender', icon: '\uf517' },
155
+ { id: 19, name: 'Bolt', icon: '\uf0e7' },
156
+ { id: 20, name: 'Bomb', icon: '\uf1e2' },
157
+ { id: 21, name: 'Bone', icon: '\uf5d7' },
158
+ { id: 22, name: 'Book', icon: '\uf02d' },
159
+ { id: 23, name: 'Bookmark', icon: '\uf02e' },
160
+ { id: 24, name: 'Bowling Ball', icon: '\uf436' },
161
+ { id: 25, name: 'Box', icon: '\uf466' },
162
+ { id: 26, name: 'Brain', icon: '\uf5dc' },
163
+ { id: 27, name: 'Bread Slice', icon: '\uf7ec' },
164
+ { id: 28, name: 'Briefcase', icon: '\uf0b1' },
165
+ { id: 29, name: 'Bug', icon: '\uf188' },
166
+ { id: 30, name: 'Building', icon: '\uf1ad' },
167
+ { id: 31, name: 'Bus', icon: '\uf207' },
168
+ { id: 32, name: 'Calculator', icon: '\uf1ec' },
169
+ { id: 33, name: 'Calendar', icon: '\uf133' },
170
+ { id: 34, name: 'Calendar check', icon: '\uf274' },
171
+ { id: 35, name: 'Calendar days', icon: '\uf073' },
172
+ { id: 36, name: 'Calendar minus', icon: '\uf272' },
173
+ { id: 37, name: 'Calendar plus', icon: '\uf271' },
174
+ { id: 38, name: 'Calendar xmark', icon: '\uf273' },
175
+ { id: 39, name: 'Camera', icon: '\uf030' },
176
+ { id: 40, name: 'Candy Cane', icon: '\uf786' },
177
+ { id: 41, name: 'Car', icon: '\uf1b9' },
178
+ { id: 42, name: 'Cat', icon: '\uf6be' },
179
+ { id: 43, name: 'Chair', icon: '\uf6c0' },
180
+ { id: 44, name: 'Charging Station', icon: '\uf5e7' },
181
+ { id: 45, name: 'Chart bar', icon: '\uf080' },
182
+ { id: 46, name: 'Chess', icon: '\uf439' },
183
+ { id: 47, name: 'Chess bishop', icon: '\uf43a' },
184
+ { id: 48, name: 'Chess king', icon: '\uf43f' },
185
+ { id: 49, name: 'Chess knight', icon: '\uf441' },
186
+ { id: 50, name: 'Chess pawn', icon: '\uf443' },
187
+ { id: 51, name: 'Chess queen', icon: '\uf445' },
188
+ { id: 52, name: 'Chess rook', icon: '\uf447' },
189
+ { id: 53, name: 'Church', icon: '\uf51d' },
190
+ { id: 54, name: 'Circle', icon: '\uf111' },
191
+ { id: 55, name: 'Circle check', icon: '\uf058' },
192
+ { id: 56, name: 'Circle dot', icon: '\uf192' },
193
+ { id: 57, name: 'Circle down', icon: '\uf358' },
194
+ { id: 58, name: 'Circle left', icon: '\uf359' },
195
+ { id: 59, name: 'Circle pause', icon: '\uf28b' },
196
+ { id: 60, name: 'Circle play', icon: '\uf144' },
197
+ { id: 61, name: 'Circle question', icon: '\uf059' },
198
+ { id: 62, name: 'Circle right', icon: '\uf35a' },
199
+ { id: 63, name: 'Circle stop', icon: '\uf28d' },
200
+ { id: 64, name: 'Circle up', icon: '\uf35b' },
201
+ { id: 65, name: 'Circle user', icon: '\uf2bd' },
202
+ { id: 66, name: 'Circle xmark', icon: '\uf057' },
203
+ { id: 67, name: 'Clipboard', icon: '\uf328' },
204
+ { id: 68, name: 'Clock', icon: '\uf017' },
205
+ { id: 69, name: 'Clone', icon: '\uf24d' },
206
+ { id: 70, name: 'Closed captioning', icon: '\uf20a' },
207
+ { id: 71, name: 'Cloud', icon: '\uf0c2' },
208
+ { id: 72, name: 'Cloud download', icon: '\uf0ed' },
209
+ { id: 73, name: 'Cloud upload', icon: '\uf0ee' },
210
+ { id: 74, name: 'Comment', icon: '\uf075' },
211
+ { id: 75, name: 'Comment dots', icon: '\uf4ad' },
212
+ { id: 76, name: 'Comments', icon: '\uf086' },
213
+ { id: 77, name: 'Compass', icon: '\uf14e' },
214
+ { id: 78, name: 'Copyright', icon: '\uf1f9' },
215
+ { id: 79, name: 'Copy', icon: '\uf0c5' },
216
+ { id: 80, name: 'Credit card', icon: '\uf09d' },
217
+ { id: 81, name: 'Envelope', icon: '\uf0e0' },
218
+ { id: 82, name: 'Envelope open', icon: '\uf2b6' },
219
+ { id: 83, name: 'Eye', icon: '\uf06e' },
220
+ { id: 84, name: 'Eye slash', icon: '\uf070' },
221
+ { id: 85, name: 'Face angry', icon: '\uf556' },
222
+ { id: 86, name: 'Face dizzy', icon: '\uf567' },
223
+ { id: 87, name: 'Face flushed', icon: '\uf579' },
224
+ { id: 88, name: 'Face frown', icon: '\uf119' },
225
+ { id: 89, name: 'Face frown open', icon: '\uf57a' },
226
+ { id: 90, name: 'Face grimace', icon: '\uf57f' },
227
+ { id: 91, name: 'Face grin', icon: '\uf580' },
228
+ { id: 92, name: 'Face grin beam', icon: '\uf582' },
229
+ { id: 93, name: 'Face grin beam sweat', icon: '\uf583' },
230
+ { id: 94, name: 'Face grin hearts', icon: '\uf584' },
231
+ { id: 95, name: 'Face grin squint', icon: '\uf585' },
232
+ { id: 96, name: 'Face grin squint tears', icon: '\uf586' },
233
+ { id: 97, name: 'Face grin stars', icon: '\uf587' },
234
+ { id: 98, name: 'Face grin tongue', icon: '\uf589' },
235
+ { id: 99, name: 'Face grin tongue squint', icon: '\uf58a' },
236
+ { id: 100, name: 'Face grin tongue wink', icon: '\uf58b' },
237
+ { id: 101, name: 'Face grin wide', icon: '\uf581' },
238
+ { id: 102, name: 'Face grin wink', icon: '\uf58c' },
239
+ { id: 103, name: 'Face kiss', icon: '\uf596' },
240
+ { id: 104, name: 'Face kiss beam', icon: '\uf597' },
241
+ { id: 105, name: 'Face kiss wink heart', icon: '\uf598' },
242
+ { id: 106, name: 'Face laugh', icon: '\uf599' },
243
+ { id: 107, name: 'Face laugh beam', icon: '\uf59a' },
244
+ { id: 108, name: 'Face laugh squint', icon: '\uf59b' },
245
+ { id: 109, name: 'Face laugh wink', icon: '\uf59c' },
246
+ { id: 110, name: 'Face meh', icon: '\uf11a' },
247
+ { id: 111, name: 'Face meh blank', icon: '\uf5a4' },
248
+ { id: 112, name: 'Face rolling eyes', icon: '\uf5a5' },
249
+ { id: 113, name: 'Face sad cry', icon: '\uf5b3' },
250
+ { id: 114, name: 'Face sad tear', icon: '\uf5b4' },
251
+ { id: 115, name: 'Face smile', icon: '\uf118' },
252
+ { id: 116, name: 'Face smile beam', icon: '\uf5b8' },
253
+ { id: 117, name: 'Face smile wink', icon: '\uf4da' },
254
+ { id: 118, name: 'Face surprise', icon: '\uf5c2' },
255
+ { id: 119, name: 'Face tired', icon: '\uf5c8' },
256
+ { id: 120, name: 'File', icon: '\uf15b' },
257
+ { id: 121, name: 'File audio', icon: '\uf1c7' },
258
+ { id: 122, name: 'File code', icon: '\uf1c9' },
259
+ { id: 123, name: 'File excel', icon: '\uf1c3' },
260
+ { id: 124, name: 'File image', icon: '\uf1c5' },
261
+ { id: 125, name: 'File lines', icon: '\uf15c' },
262
+ { id: 126, name: 'File pdf', icon: '\uf1c1' },
263
+ { id: 127, name: 'File powerpoint', icon: '\uf1c4' },
264
+ { id: 128, name: 'File video', icon: '\uf1c8' },
265
+ { id: 129, name: 'File word', icon: '\uf1c2' },
266
+ { id: 130, name: 'File zipper', icon: '\uf1c6' },
267
+ { id: 131, name: 'Flag', icon: '\uf024' },
268
+ { id: 132, name: 'Flask', icon: '\uf0c3' },
269
+ { id: 133, name: 'Floppy disk', icon: '\uf0c7' },
270
+ { id: 134, name: 'Folder', icon: '\uf07b' },
271
+ { id: 135, name: 'Folder closed', icon: '\uf07b' },
272
+ { id: 136, name: 'Folder open', icon: '\uf07c' },
273
+ { id: 137, name: 'Font awesome', icon: '\uf2b4' },
274
+ { id: 138, name: 'Futbol', icon: '\uf1e3' },
275
+ { id: 139, name: 'Gem', icon: '\uf3a5' },
276
+ { id: 140, name: 'Hand', icon: '\uf256' },
277
+ { id: 141, name: 'Hand back fist', icon: '\uf255' },
278
+ { id: 142, name: 'Hand lizard', icon: '\uf258' },
279
+ { id: 143, name: 'Hand peace', icon: '\uf25b' },
280
+ { id: 144, name: 'Hand point down', icon: '\uf0a7' },
281
+ { id: 145, name: 'Hand point left', icon: '\uf0a5' },
282
+ { id: 146, name: 'Hand point right', icon: '\uf0a4' },
283
+ { id: 147, name: 'Hand point up', icon: '\uf0a6' },
284
+ { id: 148, name: 'Hand pointer', icon: '\uf25a' },
285
+ { id: 149, name: 'Hand rock', icon: '\uf255' },
286
+ { id: 150, name: 'Hand scissors', icon: '\uf257' },
287
+ { id: 151, name: 'Handshake', icon: '\uf2b5' },
288
+ { id: 152, name: 'Hard drive', icon: '\uf0a0' },
289
+ { id: 153, name: 'Heart', icon: '\uf004' },
290
+ { id: 154, name: 'Hospital', icon: '\uf0f8' },
291
+ { id: 155, name: 'Hourglass', icon: '\uf254' },
292
+ { id: 156, name: 'Hourglass half', icon: '\uf252' },
293
+ { id: 157, name: 'Id badge', icon: '\uf2c1' },
294
+ { id: 158, name: 'Id card', icon: '\uf2c2' },
295
+ { id: 159, name: 'Image', icon: '\uf03e' },
296
+ { id: 160, name: 'Images', icon: '\uf302' },
297
+ { id: 161, name: 'Keyboard', icon: '\uf11c' },
298
+ { id: 162, name: 'Lemon', icon: '\uf094' },
299
+ { id: 163, name: 'Life ring', icon: '\uf1cd' },
300
+ { id: 164, name: 'Lightbulb', icon: '\uf0eb' },
301
+ { id: 165, name: 'Map', icon: '\uf279' },
302
+ { id: 166, name: 'Message', icon: '\uf27a' },
303
+ { id: 167, name: 'Money bill 1', icon: '\uf3d1' },
304
+ { id: 168, name: 'Moon', icon: '\uf186' },
305
+ { id: 169, name: 'Music', icon: '\uf001' },
306
+ { id: 170, name: 'Newspaper', icon: '\uf1ea' },
307
+ { id: 171, name: 'Note sticky', icon: '\uf249' },
308
+ { id: 172, name: 'Object group', icon: '\uf247' },
309
+ { id: 173, name: 'Object ungroup', icon: '\uf248' },
310
+ { id: 174, name: 'Paper plane', icon: '\uf1d8' },
311
+ { id: 175, name: 'Paste', icon: '\uf0ea' },
312
+ { id: 176, name: 'Pen to square', icon: '\uf044' },
313
+ { id: 177, name: 'Phone', icon: '\uf095' },
314
+ { id: 178, name: 'Phone flip', icon: '\uf879' },
315
+ { id: 179, name: 'Phone slash', icon: '\uf3dd' },
316
+ { id: 180, name: 'Procedures', icon: '\uf487' },
317
+ { id: 181, name: 'Rectangle list', icon: '\uf022' },
318
+ { id: 182, name: 'Rectangle xmark', icon: '\uf410' },
319
+ { id: 183, name: 'Registered', icon: '\uf25d' },
320
+ { id: 184, name: 'Share from square', icon: '\uf14d' },
321
+ { id: 185, name: 'Snowflake', icon: '\uf2dc' },
322
+ { id: 186, name: 'Square', icon: '\uf0c8' },
323
+ { id: 187, name: 'Square caret down', icon: '\uf150' },
324
+ { id: 188, name: 'Square caret left', icon: '\uf191' },
325
+ { id: 189, name: 'Square caret right', icon: '\uf152' },
326
+ { id: 190, name: 'Square caret up', icon: '\uf151' },
327
+ { id: 191, name: 'Square check', icon: '\uf14a' },
328
+ { id: 192, name: 'Square full', icon: '\uf45c' },
329
+ { id: 193, name: 'Square minus', icon: '\uf146' },
330
+ { id: 194, name: 'Square plus', icon: '\uf0fe' },
331
+ { id: 195, name: 'Star', icon: '\uf005' },
332
+ { id: 196, name: 'Star half', icon: '\uf089' },
333
+ { id: 197, name: 'Star half stroke', icon: '\uf5c0' },
334
+ { id: 198, name: 'Sun', icon: '\uf185' },
335
+ { id: 199, name: 'Thumbs down', icon: '\uf165' },
336
+ { id: 200, name: 'Thumbs up', icon: '\uf164' },
337
+ { id: 201, name: 'Trash can', icon: '\uf2ed' },
338
+ { id: 202, name: 'User', icon: '\uf007' },
339
+ { id: 203, name: 'Window maximize', icon: '\uf2d0' },
340
+ { id: 204, name: 'Window minimize', icon: '\uf2d1' },
341
+ { id: 205, name: 'Window restore', icon: '\uf2d2' },
342
+ { id: 206, name: 'Yin Yang', icon: '\uf6ad' },
343
+ ];
344
+
345
+ class AbstractModalFormHandler {
346
+ fb;
347
+ createLinkForm;
348
+ createNodeForm;
349
+ fontAwesomeIcons = fontAwesomeIcons;
350
+ constructor(fb) {
351
+ this.fb = fb;
352
+ this.createLinkForm = this.fb.group({
353
+ lineStyle: ['Dotted', Validators.required],
354
+ sourceArrow: [false],
355
+ targetArrow: [false],
356
+ label: this.fb.array([], Validators.required),
357
+ });
358
+ this.createNodeForm = this.fb.group({
359
+ id: '',
360
+ label: this.fb.array([], [Validators.required, this.minLengthArray(1)]),
361
+ imageUrl: [''],
362
+ icon: [''],
363
+ fx: [null],
364
+ fy: [null],
365
+ additionalIcon: [''],
366
+ iconType: ['select'],
367
+ }, { validators: this.iconOrImageValidator });
368
+ }
369
+ get labelArray() {
370
+ return this.createLinkForm.get('label');
371
+ }
372
+ get nodeLabelArray() {
373
+ return this.createNodeForm.get('label');
374
+ }
375
+ addLabel() {
376
+ const labelGroup = this.fb.group({
377
+ label: ['', Validators.required],
378
+ linkIcon: [false],
379
+ });
380
+ this.labelArray.push(labelGroup);
381
+ }
382
+ addNodeLabel() {
383
+ const labelGroup = this.fb.group({
384
+ label: ['', Validators.required],
385
+ });
386
+ this.nodeLabelArray.push(labelGroup);
387
+ }
388
+ removeLabel(index) {
389
+ if (this.labelArray.length > 1) {
390
+ this.labelArray.removeAt(index);
391
+ }
392
+ }
393
+ removeNodeLabel(index) {
394
+ if (this.nodeLabelArray.length > 1) {
395
+ this.nodeLabelArray.removeAt(index);
396
+ }
397
+ }
398
+ resetLinksForm() {
399
+ this.createLinkForm.reset({
400
+ lineStyle: 'Dotted',
401
+ sourceArrow: false,
402
+ targetArrow: false,
403
+ label: this.fb.array([]),
404
+ });
405
+ this.labelArray.clear();
406
+ }
407
+ resetNodeForm() {
408
+ this.createNodeForm.reset({
409
+ label: this.fb.array([]),
410
+ imageUrl: '',
411
+ icon: '',
412
+ additionalIcon: '',
413
+ iconType: 'select',
414
+ });
415
+ this.nodeLabelArray.clear();
416
+ }
417
+ populateEditLinkForm(data) {
418
+ this.createLinkForm.patchValue({
419
+ lineStyle: data.lineStyle || 'Dotted',
420
+ sourceArrow: data.sourceArrow,
421
+ targetArrow: data.targetArrow
422
+ });
423
+ if (data.relationships && Array.isArray(data.relationships)) {
424
+ data.relationships.forEach((relationship) => {
425
+ const labelGroup = this.fb.group({
426
+ labelIndex: [relationship.labelIndex, Validators.required],
427
+ label: [relationship.label, Validators.required],
428
+ linkIcon: [relationship.linkIcon]
429
+ });
430
+ this.labelArray.push(labelGroup);
431
+ });
432
+ }
433
+ }
434
+ populateEditNodeForm(data) {
435
+ this.createNodeForm.patchValue({
436
+ id: data.id,
437
+ imageUrl: data.imageUrl,
438
+ icon: data.icon,
439
+ fx: data.fx,
440
+ fy: data.fy,
441
+ additionalIcon: data.additionalIcon,
442
+ iconType: data.imageUrl ? 'url' : 'select'
443
+ });
444
+ this.createNodeForm.setControl('label', this.fb.array(data.label.map(label => this.fb.group({ label: [label, Validators.required] }))));
445
+ }
446
+ iconOrImageValidator(control) {
447
+ const imageUrl = control.get('imageUrl').value;
448
+ const icon = control.get('icon').value;
449
+ if ((imageUrl && icon) || (!imageUrl && !icon)) {
450
+ return { 'iconOrImage': true };
451
+ }
452
+ return null;
453
+ }
454
+ minLengthArray(min) {
455
+ return (control) => {
456
+ if (control instanceof FormArray) {
457
+ return control.length >= min ? null : { minLengthArray: true };
458
+ }
459
+ return null;
460
+ };
461
+ }
462
+ }
10
463
 
11
464
  class DexieService extends Dexie {
12
465
  graphData;
@@ -36,6 +489,220 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
36
489
  }]
37
490
  }], ctorParameters: () => [] });
38
491
 
492
+ class ModalsComponent extends AbstractModalFormHandler {
493
+ modalService;
494
+ dexieService;
495
+ editNodeData;
496
+ editLinksData = null;
497
+ closeModalEvent = new EventEmitter();
498
+ createEditLinkEvent = new EventEmitter();
499
+ createEditNodeEvent = new EventEmitter();
500
+ deleteLinkEvent = new EventEmitter();
501
+ deleteNodeEvent = new EventEmitter();
502
+ editNodeModal;
503
+ createNodeModal;
504
+ createLinkModal;
505
+ editLinksModal;
506
+ modalRef;
507
+ defaultModalConfig = { class: 'modal-xl' };
508
+ fontAwesomeIcons = fontAwesomeIcons;
509
+ sourceLabels = [];
510
+ targetLabels = [];
511
+ sourceImageUrl;
512
+ targetImageUrl;
513
+ sourceIcon;
514
+ targetIcon;
515
+ // virtual scroll
516
+ loading = false;
517
+ iconsBuffer = [];
518
+ numberOfItemsFromEndBeforeFetchingMore = 10;
519
+ bufferSize = 50;
520
+ constructor(modalService, fb, dexieService) {
521
+ super(fb);
522
+ this.modalService = modalService;
523
+ this.dexieService = dexieService;
524
+ }
525
+ ngOnChanges(changes) {
526
+ if (changes.editLinksData && this.editLinksData && !Array.isArray(this.editLinksData)) {
527
+ this.resetLinksForm();
528
+ this.findEditLabelsAndImagesfromIDs();
529
+ this.populateEditLinkForm(this.editLinksData);
530
+ }
531
+ if (changes.editNodeData && this.editNodeData) {
532
+ this.resetNodeForm();
533
+ this.populateEditNodeForm(this.editNodeData);
534
+ }
535
+ }
536
+ openModal(template) {
537
+ if (!template) {
538
+ console.error('Template is required to open a modal.');
539
+ return null;
540
+ }
541
+ if (template === this.editLinksModal &&
542
+ this.editLinksData &&
543
+ !Array.isArray(this.editLinksData)) {
544
+ this.resetLinksForm();
545
+ this.findEditLabelsAndImagesfromIDs();
546
+ this.populateEditLinkForm(this.editLinksData);
547
+ }
548
+ if (template === this.createLinkModal && this.editLinksData) {
549
+ this.resetLinksForm();
550
+ }
551
+ if (template === this.createNodeModal) {
552
+ this.resetNodeForm();
553
+ }
554
+ this.modalRef = this.modalService.show(template, this.defaultModalConfig);
555
+ }
556
+ async findEditLabelsAndImagesfromIDs() {
557
+ const editLinksData = this.editLinksData;
558
+ if (!editLinksData) {
559
+ return;
560
+ }
561
+ if (Array.isArray(editLinksData)) {
562
+ this.reset();
563
+ this.sourceLabels = editLinksData[0].label;
564
+ this.targetLabels = editLinksData[1].label;
565
+ this.sourceImageUrl = editLinksData[0].imageUrl;
566
+ this.targetImageUrl = editLinksData[1].imageUrl;
567
+ this.sourceIcon = editLinksData[0].icon;
568
+ this.targetIcon = editLinksData[1].icon;
569
+ return;
570
+ }
571
+ const linkData = editLinksData;
572
+ if (linkData.dataId && linkData.source && linkData.target) {
573
+ const data = await this.dexieService.getGraphData(linkData.dataId);
574
+ const sourceNode = data.nodes.find(node => node.id === linkData.source);
575
+ const targetNode = data.nodes.find(node => node.id === linkData.target);
576
+ if (sourceNode && targetNode) {
577
+ this.sourceLabels = sourceNode.label;
578
+ this.targetLabels = targetNode.label;
579
+ this.sourceImageUrl = sourceNode.imageUrl;
580
+ this.targetImageUrl = targetNode.imageUrl;
581
+ this.sourceIcon = sourceNode.icon;
582
+ this.targetIcon = targetNode.icon;
583
+ }
584
+ else {
585
+ console.error('Source or target node not found.');
586
+ }
587
+ }
588
+ else {
589
+ this.reset();
590
+ console.warn('editLinksData structure does not match the desired format.');
591
+ }
592
+ }
593
+ reset() {
594
+ this.sourceLabels = [];
595
+ this.targetLabels = [];
596
+ this.sourceImageUrl = '';
597
+ this.targetImageUrl = '';
598
+ this.sourceIcon = '';
599
+ this.targetIcon = '';
600
+ }
601
+ closeModal(modalRef) {
602
+ if (this[modalRef]) {
603
+ this[modalRef].hide();
604
+ }
605
+ }
606
+ createEditLink(source) {
607
+ if (this.createLinkForm.valid) {
608
+ const createLinkData = this.createLinkForm.value;
609
+ this.createEditLinkEvent.emit({ payload: createLinkData, source });
610
+ this.resetLinksForm();
611
+ this.closeModal('modalRef');
612
+ }
613
+ }
614
+ createEditNode(source) {
615
+ if (this.createNodeForm.valid) {
616
+ const createNodeData = this.createNodeForm.value;
617
+ const payload = {
618
+ id: createNodeData.id,
619
+ label: createNodeData.label.map((item) => item.label),
620
+ imageUrl: createNodeData.imageUrl,
621
+ icon: createNodeData.icon,
622
+ fx: createNodeData.fx,
623
+ fy: createNodeData.fy,
624
+ additionalIcon: createNodeData.additionalIcon,
625
+ };
626
+ this.createEditNodeEvent.emit({ payload, source });
627
+ this.resetNodeForm();
628
+ this.closeModal('modalRef');
629
+ }
630
+ }
631
+ deleteNode() {
632
+ this.deleteNodeEvent.emit(true);
633
+ this.resetNodeForm();
634
+ this.closeModal('modalRef');
635
+ }
636
+ deleteLink() {
637
+ const editLinksData = this.editLinksData;
638
+ if (!editLinksData || Array.isArray(editLinksData)) {
639
+ console.error('Link data is required to delete a link.');
640
+ return;
641
+ }
642
+ const linkId = editLinksData.linkId;
643
+ this.deleteLinkEvent.emit(linkId);
644
+ this.resetLinksForm();
645
+ this.closeModal('modalRef');
646
+ }
647
+ clearImageUrl() {
648
+ this.createNodeForm.get('imageUrl').setValue('');
649
+ }
650
+ trackByFn(item) {
651
+ return item.id;
652
+ }
653
+ onScrollToEnd() {
654
+ this.fetchMore();
655
+ }
656
+ onScroll({ end }) {
657
+ if (this.loading || this.fontAwesomeIcons.length <= this.iconsBuffer.length) {
658
+ return;
659
+ }
660
+ if (end + this.numberOfItemsFromEndBeforeFetchingMore >=
661
+ this.iconsBuffer.length) {
662
+ this.fetchMore();
663
+ }
664
+ }
665
+ fetchMore() {
666
+ const len = this.iconsBuffer.length;
667
+ const more = this.fontAwesomeIcons.slice(len, this.bufferSize + len);
668
+ this.loading = true;
669
+ this.loading = false;
670
+ this.iconsBuffer = this.iconsBuffer.concat(more);
671
+ }
672
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ModalsComponent, deps: [{ token: i1.BsModalService }, { token: i2$1.FormBuilder }, { token: DexieService }], target: i0.ɵɵFactoryTarget.Component });
673
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: ModalsComponent, selector: "app-modals", inputs: { editNodeData: "editNodeData", editLinksData: "editLinksData" }, outputs: { closeModalEvent: "closeModalEvent", createEditLinkEvent: "createEditLinkEvent", createEditNodeEvent: "createEditNodeEvent", deleteLinkEvent: "deleteLinkEvent", deleteNodeEvent: "deleteNodeEvent" }, viewQueries: [{ propertyName: "editNodeModal", first: true, predicate: ["editNodeModal"], descendants: true }, { propertyName: "createNodeModal", first: true, predicate: ["createNodeModal"], descendants: true }, { propertyName: "createLinkModal", first: true, predicate: ["createLinkModal"], descendants: true }, { propertyName: "editLinksModal", first: true, predicate: ["editLinksModal"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<!--EDIT NODE MODAL-->\n<ng-template #editNodeModal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title pull-left\">Edit Node</h4>\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModal('modalRef')\">\n <span aria-hidden=\"true\" class=\"visually-hidden\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n <form [formGroup]=\"createNodeForm\">\n <div class=\"form-group\">\n <label for=\"iconType\">Icon Type</label>\n <div>\n <input type=\"radio\" id=\"imageUrl\" formControlName=\"iconType\" value=\"url\"> Image URL\n <input class=\"ml-5\" type=\"radio\" id=\"iconTypeSelect\" formControlName=\"iconType\" value=\"select\"> Choose Icon\n </div>\n </div>\n <div class=\"form-group\" *ngIf=\"createNodeForm.get('iconType').value === 'url'\">\n <label for=\"imageUrl\">Image URL</label>\n <div class=\"input-group\">\n <input type=\"text\" id=\"imageUrl\" formControlName=\"imageUrl\" class=\"form-control\" placeholder=\"Image URL\">\n <button type=\"button\" class=\"btn btn-outline-secondary\" (click)=\"clearImageUrl()\">Clear</button>\n </div>\n </div>\n <div class=\"form-group\" *ngIf=\"createNodeForm.get('iconType').value === 'select'\">\n <label for=\"nodeIcon\">Choose Icon</label>\n <ng-select\n formControlName=\"icon\"\n [items]=\"iconsBuffer\"\n [virtualScroll]=\"true\"\n [loading]=\"loading\"\n bindLabel=\"name\"\n bindValue=\"icon\"\n [editableSearchTerm]=\"true\"\n placeholder=\"Select icon\"\n appendTo=\"body\"\n [trackByFn]=\"trackByFn\"\n (scroll)=\"onScroll($event)\"\n (scrollToEnd)=\"onScrollToEnd()\"\n >\n <ng-template ng-header-tmp>\n <small class=\"form-text text-muted\"\n >Loaded {{ iconsBuffer.length }} of {{ fontAwesomeIcons.length }}</small\n >\n </ng-template>\n <ng-template ng-option-tmp let-item=\"item\">\n <i class=\"fa fa-light\">{{item.icon}}</i>\n <span class=\"ml-3\">{{ item.name }}</span>\n </ng-template>\n </ng-select>\n </div>\n <div *ngIf=\"createNodeForm.errors?.iconOrImage\" class=\"text-danger\">\n Please provide either an Image URL or choose an Icon, but not both.\n </div>\n <div class=\"form-group\">\n <label for=\"label\">Labels</label>\n <div formArrayName=\"label\">\n <div *ngFor=\"let label of nodeLabelArray.controls; let i = index\" [formGroupName]=\"i\"\n class=\"d-flex flex-column align-items-start\">\n <div class=\"d-flex align-items-center w-100\">\n <input formControlName=\"label\" class=\"form-control mb-2\" placeholder=\"Label\" [id]=\"'node-label-' + i\">\n <button type=\"button\" class=\"btn btn-danger ml-2\" (click)=\"removeNodeLabel(i)\" [disabled]=\"nodeLabelArray.length <= 1\">Remove</button>\n </div>\n </div>\n </div>\n <button type=\"button\" class=\"btn btn-secondary mt-2\" (click)=\"addNodeLabel()\">Add Label</button>\n </div>\n <div class=\"form-group\">\n <label for=\"nodeAdditionalIcon\">Additional icon</label>\n <ng-select\n formControlName=\"additionalIcon\"\n [items]=\"iconsBuffer\"\n [virtualScroll]=\"true\"\n [loading]=\"loading\"\n bindLabel=\"name\"\n bindValue=\"icon\"\n [editableSearchTerm]=\"true\"\n placeholder=\"Select icon\"\n appendTo=\"body\"\n [trackByFn]=\"trackByFn\"\n (scroll)=\"onScroll($event)\"\n (scrollToEnd)=\"onScrollToEnd()\"\n >\n <ng-template ng-header-tmp>\n <small class=\"form-text text-muted\"\n >Loaded {{ iconsBuffer.length }} of {{ fontAwesomeIcons.length }}</small\n >\n </ng-template>\n <ng-template ng-option-tmp let-item=\"item\">\n <i class=\"fa fa-light\">{{item.icon}}</i>\n <span class=\"ml-3\">{{ item.name }}</span>\n </ng-template>\n </ng-select>\n </div>\n </form>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"closeModal('modalRef')\">Cancel</button>\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"createEditNode('editNodeModal')\" [disabled]=\"!createNodeForm.valid\">Save Changes</button>\n <button type=\"button\" class=\"btn btn-danger\" (click)=\"deleteNode()\">Delete Node</button>\n </div>\n</ng-template>\n<!-- ./MODAL-->\n\n<!--CREATE NODE MODAL-->\n<ng-template #createNodeModal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title pull-left\">Create Node</h4>\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModal('modalRef')\">\n <span aria-hidden=\"true\" class=\"visually-hidden\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n <form [formGroup]=\"createNodeForm\">\n <div class=\"form-group\">\n <label for=\"iconType\">Icon Type</label>\n <div>\n <input type=\"radio\" id=\"imageUrl\" formControlName=\"iconType\" value=\"url\"> Image URL\n <input class=\"ml-5\" type=\"radio\" id=\"iconTypeSelect\" formControlName=\"iconType\" value=\"select\"> Choose Icon\n </div>\n </div>\n <div class=\"form-group\" *ngIf=\"createNodeForm.get('iconType').value === 'url'\">\n <label for=\"imageUrl\">Image URL</label>\n <div class=\"input-group\">\n <input type=\"text\" id=\"imageUrl\" formControlName=\"imageUrl\" class=\"form-control\" placeholder=\"Image URL\">\n <button type=\"button\" class=\"btn btn-outline-secondary\" (click)=\"clearImageUrl()\">Clear</button>\n </div>\n </div>\n <div class=\"form-group\" *ngIf=\"createNodeForm.get('iconType').value === 'select'\">\n <label for=\"nodeIcon\">Choose Icon</label>\n <ng-select\n formControlName=\"icon\"\n [items]=\"iconsBuffer\"\n [virtualScroll]=\"true\"\n [loading]=\"loading\"\n bindLabel=\"name\"\n bindValue=\"icon\"\n [editableSearchTerm]=\"true\"\n placeholder=\"Select icon\"\n appendTo=\"body\"\n [trackByFn]=\"trackByFn\"\n (scroll)=\"onScroll($event)\"\n (scrollToEnd)=\"onScrollToEnd()\"\n >\n <ng-template ng-header-tmp>\n <small class=\"form-text text-muted\"\n >Loaded {{ iconsBuffer.length }} of {{ fontAwesomeIcons.length }}</small\n >\n </ng-template>\n <ng-template ng-option-tmp let-item=\"item\">\n <i class=\"fa fa-light\">{{item.icon}}</i>\n <span class=\"ml-3\">{{ item.name }}</span>\n </ng-template>\n </ng-select>\n </div>\n <div *ngIf=\"createNodeForm.errors?.iconOrImage\" class=\"text-danger\">\n Please provide either an Image URL or choose an Icon, but not both.\n </div>\n <div class=\"form-group\">\n <label for=\"label\">Labels</label>\n <div formArrayName=\"label\">\n <div *ngFor=\"let label of nodeLabelArray.controls; let i = index\" [formGroupName]=\"i\"\n class=\"d-flex flex-column align-items-start\">\n <div class=\"d-flex align-items-center w-100\">\n <input formControlName=\"label\" class=\"form-control mb-2\" placeholder=\"Label\" [id]=\"'node-label-' + i\">\n <button type=\"button\" class=\"btn btn-danger ml-2\" (click)=\"removeNodeLabel(i)\" [disabled]=\"nodeLabelArray.length <= 1\">Remove</button>\n </div>\n </div>\n </div>\n <button type=\"button\" class=\"btn btn-secondary mt-2\" (click)=\"addNodeLabel()\">Add Label</button>\n </div>\n <div class=\"form-group\">\n <label for=\"nodeAdditionalIcon\">Additional icon</label>\n <ng-select\n formControlName=\"additionalIcon\"\n [items]=\"iconsBuffer\"\n [virtualScroll]=\"true\"\n [loading]=\"loading\"\n bindLabel=\"name\"\n bindValue=\"icon\"\n [editableSearchTerm]=\"true\"\n placeholder=\"Select icon\"\n appendTo=\"body\"\n [trackByFn]=\"trackByFn\"\n (scroll)=\"onScroll($event)\"\n (scrollToEnd)=\"onScrollToEnd()\"\n >\n <ng-template ng-header-tmp>\n <small class=\"form-text text-muted\"\n >Loaded {{ iconsBuffer.length }} of {{ fontAwesomeIcons.length }}</small\n >\n </ng-template>\n <ng-template ng-option-tmp let-item=\"item\">\n <i class=\"fa fa-light\">{{item.icon}}</i>\n <span class=\"ml-3\">{{ item.name }}</span>\n </ng-template>\n </ng-select>\n </div>\n </form>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"closeModal('modalRef')\">Cancel</button>\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"createEditNode('createNodeModal')\" [disabled]=\"!createNodeForm.valid\">Create Node</button>\n </div>\n</ng-template>\n<!-- ./MODAL-->\n\n<!--EDIT LINKS MODAL-->\n<ng-template #editLinksModal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title pull-left\">Edit Links</h4>\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModal('modalRef')\">\n <span aria-hidden=\"true\" class=\"visually-hidden\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n <form [formGroup]=\"createLinkForm\">\n <div class=\"col-sm-12 d-flex flex-column\">\n <div class=\"d-flex mb-3\">\n <div class=\"iconImage\">\n <span><i class=\"fas fa-arrow-left\"></i></span>\n <span class=\"arrow\">\n <input type=\"checkbox\" id=\"sourceArrow\" formControlName=\"sourceArrow\" class=\"form-check-input\">\n <label class=\"d-none form-check-label\" for=\"leftArrow\"></label>\n </span>\n </div>\n <div class=\"iconImage ml-3\">\n <ng-container *ngIf=\"targetImageUrl; else targetIconTemplate\">\n <img class=\"imageUrl\" [src]=\"targetImageUrl\" />\n </ng-container>\n <ng-template #targetIconTemplate>\n <i class=\"fa-solid fa-2x\">{{targetIcon}}</i>\n </ng-template>\n </div>\n <div\n [ngClass]=\"{\n 'link-line-solid': createLinkForm.get('lineStyle').value === 'Solid',\n 'link-line-dotted': createLinkForm.get('lineStyle').value === 'Dotted'\n }\"\n >\n </div>\n <div class=\"iconImage mr-3\">\n <ng-container *ngIf=\"sourceImageUrl; else sourceIconTemplate\">\n <img class=\"imageUrl\" [src]=\"sourceImageUrl\" />\n </ng-container>\n <ng-template #sourceIconTemplate>\n <i class=\"fa-solid fa-2x\">{{sourceIcon}}</i>\n </ng-template>\n </div>\n <div class=\"iconImage\">\n <span><i class=\"fas fa-arrow-right\"></i></span>\n <span class=\"arrow\">\n <input type=\"checkbox\" id=\"targetArrow\" formControlName=\"targetArrow\" class=\"form-check-input\">\n <label class=\"form-check-label\" for=\"rightArrow\"></label>\n </span>\n </div>\n </div>\n <div class=\"d-flex justify-content-between mb-3\">\n <div class=\"text-left d-block font-weight-bold\" style=\"font-size: 12px\">\n <span class=\"d-block\" *ngFor=\"let label of targetLabels\">{{ label }}</span>\n </div>\n <div class=\"text-right d-block font-weight-bold\" style=\"font-size: 12px\">\n <span class=\"d-block\" *ngFor=\"let label of sourceLabels\">{{ label }}</span>\n </div>\n </div>\n <div *ngIf=\"createLinkForm.get('label')?.value?.length\" class=\"labelPosition text-center\">\n <span *ngFor=\"let label of createLinkForm.get('label').value\">\n <span class=\"d-block\">{{ label.label }} <span style=\"color: #856404;\" *ngIf=\"label.linkIcon\"><i class=\"fas fa-link\"></i></span></span>\n </span>\n </div>\n </div>\n <div class=\"form-group\">\n <label for=\"lineStyle\">Line Style</label>\n <select id=\"lineStyle\" formControlName=\"lineStyle\" class=\"form-control\">\n <option value=\"Solid\">Solid</option>\n <option value=\"Dotted\">Dotted</option>\n </select>\n </div>\n\n <div class=\"form-group\">\n <label for=\"label\">Labels</label>\n <div formArrayName=\"label\">\n <div *ngFor=\"let label of labelArray.controls; let i = index\" [formGroupName]=\"i\"\n class=\"d-flex flex-column align-items-start\">\n <div class=\"d-flex align-items-center w-100\">\n <input formControlName=\"label\" class=\"form-control\" placeholder=\"Label\" [id]=\"'label-' + i\">\n <button type=\"button\" class=\"btn btn-danger ml-2\" (click)=\"removeLabel(i)\" [disabled]=\"labelArray.length <= 1\">Remove</button>\n </div>\n <div class=\"form-group form-check\">\n <input type=\"checkbox\" formControlName=\"linkIcon\" class=\"form-check-input\" [id]=\"'linkIcon-' + i\">\n <label [for]=\"'linkIcon-' + i\">Link Icon?</label>\n </div>\n </div>\n </div>\n <button type=\"button\" class=\"btn btn-secondary mt-2\" (click)=\"addLabel()\">Add Label</button>\n </div>\n </form>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"closeModal('modalRef')\">Cancel</button>\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"createEditLink('editLinkModal')\" [disabled]=\"!createLinkForm.valid\">Save Changes</button>\n <button type=\"button\" class=\"btn btn-danger\" (click)=\"deleteLink()\">Delete Link</button>\n </div>\n</ng-template>\n<!-- ./MODAL-->\n\n\n<!--CREATE LINK MODAL-->\n<ng-template #createLinkModal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title pull-left\">Create Link</h4>\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModal('modalRef')\">\n <span aria-hidden=\"true\" class=\"visually-hidden\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n <form [formGroup]=\"createLinkForm\">\n <div class=\"col-sm-12 d-flex flex-column\">\n <div class=\"d-flex mb-3\">\n <div class=\"iconImage\">\n <span><i class=\"fas fa-arrow-left\"></i></span>\n <span class=\"arrow\">\n <input type=\"checkbox\" id=\"sourceArrow\" formControlName=\"sourceArrow\" class=\"form-check-input\">\n <label class=\"d-none form-check-label\" for=\"leftArrow\"></label>\n </span>\n </div>\n <div class=\"iconImage ml-3\">\n <ng-container *ngIf=\"targetImageUrl; else targetIconTemplate\">\n <img class=\"imageUrl\" [src]=\"targetImageUrl\" />\n </ng-container>\n <ng-template #targetIconTemplate>\n <i class=\"fa-solid fa-2x\">{{targetIcon}}</i>\n </ng-template>\n </div>\n <div\n [ngClass]=\"{\n 'link-line-solid': createLinkForm.get('lineStyle').value === 'Solid',\n 'link-line-dotted': createLinkForm.get('lineStyle').value === 'Dotted'\n }\"\n >\n </div>\n <div class=\"iconImage mr-3\">\n <ng-container *ngIf=\"sourceImageUrl; else sourceIconTemplate\">\n <img class=\"imageUrl\" [src]=\"sourceImageUrl\" />\n </ng-container>\n <ng-template #sourceIconTemplate>\n <i class=\"fa-solid fa-2x\">{{sourceIcon}}</i>\n </ng-template>\n </div>\n <div class=\"iconImage\">\n <span><i class=\"fas fa-arrow-right\"></i></span>\n <span class=\"arrow\">\n <input type=\"checkbox\" id=\"targetArrow\" formControlName=\"targetArrow\" class=\"form-check-input\">\n <label class=\"form-check-label\" for=\"rightArrow\"></label>\n </span>\n </div>\n </div>\n <div class=\"d-flex justify-content-between mb-3\">\n <div class=\"text-left d-block font-weight-bold\" style=\"font-size: 12px\">\n <span class=\"d-block\" *ngFor=\"let label of targetLabels\">{{ label }}</span>\n </div>\n <div class=\"text-right d-block font-weight-bold\" style=\"font-size: 12px\">\n <span class=\"d-block\" *ngFor=\"let label of sourceLabels\">{{ label }}</span>\n </div>\n </div>\n <div *ngIf=\"createLinkForm.get('label')?.value?.length\" class=\"labelPosition text-center\">\n <span *ngFor=\"let label of createLinkForm.get('label').value\">\n <span class=\"d-block\">{{ label.label }} <span style=\"color: #856404;\" *ngIf=\"label.linkIcon\"><i class=\"fas fa-link\"></i></span></span>\n </span>\n </div>\n </div>\n <div class=\"form-group\">\n <label for=\"lineStyle\">Line Style</label>\n <select id=\"lineStyle\" formControlName=\"lineStyle\" class=\"form-control\">\n <option value=\"Solid\">Solid</option>\n <option value=\"Dotted\">Dotted</option>\n </select>\n </div>\n\n <div class=\"form-group\">\n <label for=\"label\">Labels</label>\n <div formArrayName=\"label\">\n <div *ngFor=\"let label of labelArray.controls; let i = index\" [formGroupName]=\"i\"\n class=\"d-flex flex-column align-items-start\">\n <div class=\"d-flex align-items-center w-100\">\n <input formControlName=\"label\" class=\"form-control\" placeholder=\"Label\" [id]=\"'label-' + i\">\n <button type=\"button\" class=\"btn btn-danger ml-2\" (click)=\"removeLabel(i)\" [disabled]=\"labelArray.length <= 1\">Remove</button>\n </div>\n <div class=\"form-group form-check\">\n <input type=\"checkbox\" formControlName=\"linkIcon\" class=\"form-check-input\" [id]=\"'linkIcon-' + i\">\n <label [for]=\"'linkIcon-' + i\">Link Icon?</label>\n </div>\n </div>\n </div>\n <button type=\"button\" class=\"btn btn-secondary mt-2\" (click)=\"addLabel()\">Add Label</button>\n </div>\n </form>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"closeModal('modalRef')\">Cancel</button>\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"createEditLink('createLinkModal')\" [disabled]=\"!createLinkForm.valid\">Create Link</button>\n </div>\n</ng-template>\n<!-- ./MODAL-->", styles: [".imageUrl{max-width:30px}.labelPosition{position:relative;top:-55px;margin-right:30px;margin-left:30px}.link-line-solid{width:100%;position:relative;margin:15px;border-top:2px solid #777}.link-line-dotted{width:100%;position:relative;margin:15px;background-image:repeating-linear-gradient(to right,#cacaca,#cacaca 7px,transparent 7px,transparent 15px);height:2px}.iconImage{position:relative;top:4px}.arrow{position:absolute;top:20px;left:20px}\n"], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2$1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i2$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2$1.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i2$1.FormGroupName, selector: "[formGroupName]", inputs: ["formGroupName"] }, { kind: "directive", type: i2$1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "component", type: i5.NgSelectComponent, selector: "ng-select", inputs: ["bindLabel", "bindValue", "markFirst", "placeholder", "notFoundText", "typeToSearchText", "addTagText", "loadingText", "clearAllText", "appearance", "dropdownPosition", "appendTo", "loading", "closeOnSelect", "hideSelected", "selectOnTab", "openOnEnter", "maxSelectedItems", "groupBy", "groupValue", "bufferAmount", "virtualScroll", "selectableGroup", "selectableGroupAsModel", "searchFn", "trackByFn", "clearOnBackspace", "labelForId", "inputAttrs", "tabIndex", "readonly", "searchWhileComposing", "minTermLength", "editableSearchTerm", "keyDownFn", "typeahead", "multiple", "addTag", "searchable", "clearable", "isOpen", "items", "compareWith", "clearSearchOnAdd", "deselectOnClick"], outputs: ["blur", "focus", "change", "open", "close", "search", "clear", "add", "remove", "scroll", "scrollToEnd"] }, { kind: "directive", type: i5.NgOptionTemplateDirective, selector: "[ng-option-tmp]" }, { kind: "directive", type: i5.NgHeaderTemplateDirective, selector: "[ng-header-tmp]" }] });
674
+ }
675
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ModalsComponent, decorators: [{
676
+ type: Component,
677
+ args: [{ selector: 'app-modals', template: "<!--EDIT NODE MODAL-->\n<ng-template #editNodeModal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title pull-left\">Edit Node</h4>\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModal('modalRef')\">\n <span aria-hidden=\"true\" class=\"visually-hidden\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n <form [formGroup]=\"createNodeForm\">\n <div class=\"form-group\">\n <label for=\"iconType\">Icon Type</label>\n <div>\n <input type=\"radio\" id=\"imageUrl\" formControlName=\"iconType\" value=\"url\"> Image URL\n <input class=\"ml-5\" type=\"radio\" id=\"iconTypeSelect\" formControlName=\"iconType\" value=\"select\"> Choose Icon\n </div>\n </div>\n <div class=\"form-group\" *ngIf=\"createNodeForm.get('iconType').value === 'url'\">\n <label for=\"imageUrl\">Image URL</label>\n <div class=\"input-group\">\n <input type=\"text\" id=\"imageUrl\" formControlName=\"imageUrl\" class=\"form-control\" placeholder=\"Image URL\">\n <button type=\"button\" class=\"btn btn-outline-secondary\" (click)=\"clearImageUrl()\">Clear</button>\n </div>\n </div>\n <div class=\"form-group\" *ngIf=\"createNodeForm.get('iconType').value === 'select'\">\n <label for=\"nodeIcon\">Choose Icon</label>\n <ng-select\n formControlName=\"icon\"\n [items]=\"iconsBuffer\"\n [virtualScroll]=\"true\"\n [loading]=\"loading\"\n bindLabel=\"name\"\n bindValue=\"icon\"\n [editableSearchTerm]=\"true\"\n placeholder=\"Select icon\"\n appendTo=\"body\"\n [trackByFn]=\"trackByFn\"\n (scroll)=\"onScroll($event)\"\n (scrollToEnd)=\"onScrollToEnd()\"\n >\n <ng-template ng-header-tmp>\n <small class=\"form-text text-muted\"\n >Loaded {{ iconsBuffer.length }} of {{ fontAwesomeIcons.length }}</small\n >\n </ng-template>\n <ng-template ng-option-tmp let-item=\"item\">\n <i class=\"fa fa-light\">{{item.icon}}</i>\n <span class=\"ml-3\">{{ item.name }}</span>\n </ng-template>\n </ng-select>\n </div>\n <div *ngIf=\"createNodeForm.errors?.iconOrImage\" class=\"text-danger\">\n Please provide either an Image URL or choose an Icon, but not both.\n </div>\n <div class=\"form-group\">\n <label for=\"label\">Labels</label>\n <div formArrayName=\"label\">\n <div *ngFor=\"let label of nodeLabelArray.controls; let i = index\" [formGroupName]=\"i\"\n class=\"d-flex flex-column align-items-start\">\n <div class=\"d-flex align-items-center w-100\">\n <input formControlName=\"label\" class=\"form-control mb-2\" placeholder=\"Label\" [id]=\"'node-label-' + i\">\n <button type=\"button\" class=\"btn btn-danger ml-2\" (click)=\"removeNodeLabel(i)\" [disabled]=\"nodeLabelArray.length <= 1\">Remove</button>\n </div>\n </div>\n </div>\n <button type=\"button\" class=\"btn btn-secondary mt-2\" (click)=\"addNodeLabel()\">Add Label</button>\n </div>\n <div class=\"form-group\">\n <label for=\"nodeAdditionalIcon\">Additional icon</label>\n <ng-select\n formControlName=\"additionalIcon\"\n [items]=\"iconsBuffer\"\n [virtualScroll]=\"true\"\n [loading]=\"loading\"\n bindLabel=\"name\"\n bindValue=\"icon\"\n [editableSearchTerm]=\"true\"\n placeholder=\"Select icon\"\n appendTo=\"body\"\n [trackByFn]=\"trackByFn\"\n (scroll)=\"onScroll($event)\"\n (scrollToEnd)=\"onScrollToEnd()\"\n >\n <ng-template ng-header-tmp>\n <small class=\"form-text text-muted\"\n >Loaded {{ iconsBuffer.length }} of {{ fontAwesomeIcons.length }}</small\n >\n </ng-template>\n <ng-template ng-option-tmp let-item=\"item\">\n <i class=\"fa fa-light\">{{item.icon}}</i>\n <span class=\"ml-3\">{{ item.name }}</span>\n </ng-template>\n </ng-select>\n </div>\n </form>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"closeModal('modalRef')\">Cancel</button>\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"createEditNode('editNodeModal')\" [disabled]=\"!createNodeForm.valid\">Save Changes</button>\n <button type=\"button\" class=\"btn btn-danger\" (click)=\"deleteNode()\">Delete Node</button>\n </div>\n</ng-template>\n<!-- ./MODAL-->\n\n<!--CREATE NODE MODAL-->\n<ng-template #createNodeModal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title pull-left\">Create Node</h4>\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModal('modalRef')\">\n <span aria-hidden=\"true\" class=\"visually-hidden\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n <form [formGroup]=\"createNodeForm\">\n <div class=\"form-group\">\n <label for=\"iconType\">Icon Type</label>\n <div>\n <input type=\"radio\" id=\"imageUrl\" formControlName=\"iconType\" value=\"url\"> Image URL\n <input class=\"ml-5\" type=\"radio\" id=\"iconTypeSelect\" formControlName=\"iconType\" value=\"select\"> Choose Icon\n </div>\n </div>\n <div class=\"form-group\" *ngIf=\"createNodeForm.get('iconType').value === 'url'\">\n <label for=\"imageUrl\">Image URL</label>\n <div class=\"input-group\">\n <input type=\"text\" id=\"imageUrl\" formControlName=\"imageUrl\" class=\"form-control\" placeholder=\"Image URL\">\n <button type=\"button\" class=\"btn btn-outline-secondary\" (click)=\"clearImageUrl()\">Clear</button>\n </div>\n </div>\n <div class=\"form-group\" *ngIf=\"createNodeForm.get('iconType').value === 'select'\">\n <label for=\"nodeIcon\">Choose Icon</label>\n <ng-select\n formControlName=\"icon\"\n [items]=\"iconsBuffer\"\n [virtualScroll]=\"true\"\n [loading]=\"loading\"\n bindLabel=\"name\"\n bindValue=\"icon\"\n [editableSearchTerm]=\"true\"\n placeholder=\"Select icon\"\n appendTo=\"body\"\n [trackByFn]=\"trackByFn\"\n (scroll)=\"onScroll($event)\"\n (scrollToEnd)=\"onScrollToEnd()\"\n >\n <ng-template ng-header-tmp>\n <small class=\"form-text text-muted\"\n >Loaded {{ iconsBuffer.length }} of {{ fontAwesomeIcons.length }}</small\n >\n </ng-template>\n <ng-template ng-option-tmp let-item=\"item\">\n <i class=\"fa fa-light\">{{item.icon}}</i>\n <span class=\"ml-3\">{{ item.name }}</span>\n </ng-template>\n </ng-select>\n </div>\n <div *ngIf=\"createNodeForm.errors?.iconOrImage\" class=\"text-danger\">\n Please provide either an Image URL or choose an Icon, but not both.\n </div>\n <div class=\"form-group\">\n <label for=\"label\">Labels</label>\n <div formArrayName=\"label\">\n <div *ngFor=\"let label of nodeLabelArray.controls; let i = index\" [formGroupName]=\"i\"\n class=\"d-flex flex-column align-items-start\">\n <div class=\"d-flex align-items-center w-100\">\n <input formControlName=\"label\" class=\"form-control mb-2\" placeholder=\"Label\" [id]=\"'node-label-' + i\">\n <button type=\"button\" class=\"btn btn-danger ml-2\" (click)=\"removeNodeLabel(i)\" [disabled]=\"nodeLabelArray.length <= 1\">Remove</button>\n </div>\n </div>\n </div>\n <button type=\"button\" class=\"btn btn-secondary mt-2\" (click)=\"addNodeLabel()\">Add Label</button>\n </div>\n <div class=\"form-group\">\n <label for=\"nodeAdditionalIcon\">Additional icon</label>\n <ng-select\n formControlName=\"additionalIcon\"\n [items]=\"iconsBuffer\"\n [virtualScroll]=\"true\"\n [loading]=\"loading\"\n bindLabel=\"name\"\n bindValue=\"icon\"\n [editableSearchTerm]=\"true\"\n placeholder=\"Select icon\"\n appendTo=\"body\"\n [trackByFn]=\"trackByFn\"\n (scroll)=\"onScroll($event)\"\n (scrollToEnd)=\"onScrollToEnd()\"\n >\n <ng-template ng-header-tmp>\n <small class=\"form-text text-muted\"\n >Loaded {{ iconsBuffer.length }} of {{ fontAwesomeIcons.length }}</small\n >\n </ng-template>\n <ng-template ng-option-tmp let-item=\"item\">\n <i class=\"fa fa-light\">{{item.icon}}</i>\n <span class=\"ml-3\">{{ item.name }}</span>\n </ng-template>\n </ng-select>\n </div>\n </form>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"closeModal('modalRef')\">Cancel</button>\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"createEditNode('createNodeModal')\" [disabled]=\"!createNodeForm.valid\">Create Node</button>\n </div>\n</ng-template>\n<!-- ./MODAL-->\n\n<!--EDIT LINKS MODAL-->\n<ng-template #editLinksModal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title pull-left\">Edit Links</h4>\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModal('modalRef')\">\n <span aria-hidden=\"true\" class=\"visually-hidden\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n <form [formGroup]=\"createLinkForm\">\n <div class=\"col-sm-12 d-flex flex-column\">\n <div class=\"d-flex mb-3\">\n <div class=\"iconImage\">\n <span><i class=\"fas fa-arrow-left\"></i></span>\n <span class=\"arrow\">\n <input type=\"checkbox\" id=\"sourceArrow\" formControlName=\"sourceArrow\" class=\"form-check-input\">\n <label class=\"d-none form-check-label\" for=\"leftArrow\"></label>\n </span>\n </div>\n <div class=\"iconImage ml-3\">\n <ng-container *ngIf=\"targetImageUrl; else targetIconTemplate\">\n <img class=\"imageUrl\" [src]=\"targetImageUrl\" />\n </ng-container>\n <ng-template #targetIconTemplate>\n <i class=\"fa-solid fa-2x\">{{targetIcon}}</i>\n </ng-template>\n </div>\n <div\n [ngClass]=\"{\n 'link-line-solid': createLinkForm.get('lineStyle').value === 'Solid',\n 'link-line-dotted': createLinkForm.get('lineStyle').value === 'Dotted'\n }\"\n >\n </div>\n <div class=\"iconImage mr-3\">\n <ng-container *ngIf=\"sourceImageUrl; else sourceIconTemplate\">\n <img class=\"imageUrl\" [src]=\"sourceImageUrl\" />\n </ng-container>\n <ng-template #sourceIconTemplate>\n <i class=\"fa-solid fa-2x\">{{sourceIcon}}</i>\n </ng-template>\n </div>\n <div class=\"iconImage\">\n <span><i class=\"fas fa-arrow-right\"></i></span>\n <span class=\"arrow\">\n <input type=\"checkbox\" id=\"targetArrow\" formControlName=\"targetArrow\" class=\"form-check-input\">\n <label class=\"form-check-label\" for=\"rightArrow\"></label>\n </span>\n </div>\n </div>\n <div class=\"d-flex justify-content-between mb-3\">\n <div class=\"text-left d-block font-weight-bold\" style=\"font-size: 12px\">\n <span class=\"d-block\" *ngFor=\"let label of targetLabels\">{{ label }}</span>\n </div>\n <div class=\"text-right d-block font-weight-bold\" style=\"font-size: 12px\">\n <span class=\"d-block\" *ngFor=\"let label of sourceLabels\">{{ label }}</span>\n </div>\n </div>\n <div *ngIf=\"createLinkForm.get('label')?.value?.length\" class=\"labelPosition text-center\">\n <span *ngFor=\"let label of createLinkForm.get('label').value\">\n <span class=\"d-block\">{{ label.label }} <span style=\"color: #856404;\" *ngIf=\"label.linkIcon\"><i class=\"fas fa-link\"></i></span></span>\n </span>\n </div>\n </div>\n <div class=\"form-group\">\n <label for=\"lineStyle\">Line Style</label>\n <select id=\"lineStyle\" formControlName=\"lineStyle\" class=\"form-control\">\n <option value=\"Solid\">Solid</option>\n <option value=\"Dotted\">Dotted</option>\n </select>\n </div>\n\n <div class=\"form-group\">\n <label for=\"label\">Labels</label>\n <div formArrayName=\"label\">\n <div *ngFor=\"let label of labelArray.controls; let i = index\" [formGroupName]=\"i\"\n class=\"d-flex flex-column align-items-start\">\n <div class=\"d-flex align-items-center w-100\">\n <input formControlName=\"label\" class=\"form-control\" placeholder=\"Label\" [id]=\"'label-' + i\">\n <button type=\"button\" class=\"btn btn-danger ml-2\" (click)=\"removeLabel(i)\" [disabled]=\"labelArray.length <= 1\">Remove</button>\n </div>\n <div class=\"form-group form-check\">\n <input type=\"checkbox\" formControlName=\"linkIcon\" class=\"form-check-input\" [id]=\"'linkIcon-' + i\">\n <label [for]=\"'linkIcon-' + i\">Link Icon?</label>\n </div>\n </div>\n </div>\n <button type=\"button\" class=\"btn btn-secondary mt-2\" (click)=\"addLabel()\">Add Label</button>\n </div>\n </form>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"closeModal('modalRef')\">Cancel</button>\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"createEditLink('editLinkModal')\" [disabled]=\"!createLinkForm.valid\">Save Changes</button>\n <button type=\"button\" class=\"btn btn-danger\" (click)=\"deleteLink()\">Delete Link</button>\n </div>\n</ng-template>\n<!-- ./MODAL-->\n\n\n<!--CREATE LINK MODAL-->\n<ng-template #createLinkModal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title pull-left\">Create Link</h4>\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModal('modalRef')\">\n <span aria-hidden=\"true\" class=\"visually-hidden\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n <form [formGroup]=\"createLinkForm\">\n <div class=\"col-sm-12 d-flex flex-column\">\n <div class=\"d-flex mb-3\">\n <div class=\"iconImage\">\n <span><i class=\"fas fa-arrow-left\"></i></span>\n <span class=\"arrow\">\n <input type=\"checkbox\" id=\"sourceArrow\" formControlName=\"sourceArrow\" class=\"form-check-input\">\n <label class=\"d-none form-check-label\" for=\"leftArrow\"></label>\n </span>\n </div>\n <div class=\"iconImage ml-3\">\n <ng-container *ngIf=\"targetImageUrl; else targetIconTemplate\">\n <img class=\"imageUrl\" [src]=\"targetImageUrl\" />\n </ng-container>\n <ng-template #targetIconTemplate>\n <i class=\"fa-solid fa-2x\">{{targetIcon}}</i>\n </ng-template>\n </div>\n <div\n [ngClass]=\"{\n 'link-line-solid': createLinkForm.get('lineStyle').value === 'Solid',\n 'link-line-dotted': createLinkForm.get('lineStyle').value === 'Dotted'\n }\"\n >\n </div>\n <div class=\"iconImage mr-3\">\n <ng-container *ngIf=\"sourceImageUrl; else sourceIconTemplate\">\n <img class=\"imageUrl\" [src]=\"sourceImageUrl\" />\n </ng-container>\n <ng-template #sourceIconTemplate>\n <i class=\"fa-solid fa-2x\">{{sourceIcon}}</i>\n </ng-template>\n </div>\n <div class=\"iconImage\">\n <span><i class=\"fas fa-arrow-right\"></i></span>\n <span class=\"arrow\">\n <input type=\"checkbox\" id=\"targetArrow\" formControlName=\"targetArrow\" class=\"form-check-input\">\n <label class=\"form-check-label\" for=\"rightArrow\"></label>\n </span>\n </div>\n </div>\n <div class=\"d-flex justify-content-between mb-3\">\n <div class=\"text-left d-block font-weight-bold\" style=\"font-size: 12px\">\n <span class=\"d-block\" *ngFor=\"let label of targetLabels\">{{ label }}</span>\n </div>\n <div class=\"text-right d-block font-weight-bold\" style=\"font-size: 12px\">\n <span class=\"d-block\" *ngFor=\"let label of sourceLabels\">{{ label }}</span>\n </div>\n </div>\n <div *ngIf=\"createLinkForm.get('label')?.value?.length\" class=\"labelPosition text-center\">\n <span *ngFor=\"let label of createLinkForm.get('label').value\">\n <span class=\"d-block\">{{ label.label }} <span style=\"color: #856404;\" *ngIf=\"label.linkIcon\"><i class=\"fas fa-link\"></i></span></span>\n </span>\n </div>\n </div>\n <div class=\"form-group\">\n <label for=\"lineStyle\">Line Style</label>\n <select id=\"lineStyle\" formControlName=\"lineStyle\" class=\"form-control\">\n <option value=\"Solid\">Solid</option>\n <option value=\"Dotted\">Dotted</option>\n </select>\n </div>\n\n <div class=\"form-group\">\n <label for=\"label\">Labels</label>\n <div formArrayName=\"label\">\n <div *ngFor=\"let label of labelArray.controls; let i = index\" [formGroupName]=\"i\"\n class=\"d-flex flex-column align-items-start\">\n <div class=\"d-flex align-items-center w-100\">\n <input formControlName=\"label\" class=\"form-control\" placeholder=\"Label\" [id]=\"'label-' + i\">\n <button type=\"button\" class=\"btn btn-danger ml-2\" (click)=\"removeLabel(i)\" [disabled]=\"labelArray.length <= 1\">Remove</button>\n </div>\n <div class=\"form-group form-check\">\n <input type=\"checkbox\" formControlName=\"linkIcon\" class=\"form-check-input\" [id]=\"'linkIcon-' + i\">\n <label [for]=\"'linkIcon-' + i\">Link Icon?</label>\n </div>\n </div>\n </div>\n <button type=\"button\" class=\"btn btn-secondary mt-2\" (click)=\"addLabel()\">Add Label</button>\n </div>\n </form>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"closeModal('modalRef')\">Cancel</button>\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"createEditLink('createLinkModal')\" [disabled]=\"!createLinkForm.valid\">Create Link</button>\n </div>\n</ng-template>\n<!-- ./MODAL-->", styles: [".imageUrl{max-width:30px}.labelPosition{position:relative;top:-55px;margin-right:30px;margin-left:30px}.link-line-solid{width:100%;position:relative;margin:15px;border-top:2px solid #777}.link-line-dotted{width:100%;position:relative;margin:15px;background-image:repeating-linear-gradient(to right,#cacaca,#cacaca 7px,transparent 7px,transparent 15px);height:2px}.iconImage{position:relative;top:4px}.arrow{position:absolute;top:20px;left:20px}\n"] }]
678
+ }], ctorParameters: () => [{ type: i1.BsModalService }, { type: i2$1.FormBuilder }, { type: DexieService }], propDecorators: { editNodeData: [{
679
+ type: Input
680
+ }], editLinksData: [{
681
+ type: Input
682
+ }], closeModalEvent: [{
683
+ type: Output
684
+ }], createEditLinkEvent: [{
685
+ type: Output
686
+ }], createEditNodeEvent: [{
687
+ type: Output
688
+ }], deleteLinkEvent: [{
689
+ type: Output
690
+ }], deleteNodeEvent: [{
691
+ type: Output
692
+ }], editNodeModal: [{
693
+ type: ViewChild,
694
+ args: ['editNodeModal']
695
+ }], createNodeModal: [{
696
+ type: ViewChild,
697
+ args: ['createNodeModal']
698
+ }], createLinkModal: [{
699
+ type: ViewChild,
700
+ args: ['createLinkModal']
701
+ }], editLinksModal: [{
702
+ type: ViewChild,
703
+ args: ['editLinksModal']
704
+ }] } });
705
+
39
706
  class VisualiserGraphService {
40
707
  dexieService;
41
708
  constructor(dexieService) {
@@ -50,6 +717,12 @@ class VisualiserGraphService {
50
717
  extent = null;
51
718
  zoom = false;
52
719
  zoomToFit = false;
720
+ resetSearch;
721
+ /** RxJS subject to listen for updates of the selection */
722
+ selectedNodesArray = new Subject();
723
+ dblClickNodePayload = new Subject();
724
+ dblClickLinkPayload = new Subject();
725
+ selectedLinkArray = new Subject();
53
726
  saveGraphData = new ReplaySubject();
54
727
  update(data, element, zoom, zoomToFit) {
55
728
  const svg = d3.select(element);
@@ -60,13 +733,13 @@ class VisualiserGraphService {
60
733
  ticked(link, node, edgepaths) {
61
734
  link.each(function (d, i, n) {
62
735
  // Total difference in x and y from source to target
63
- let diffX = d.target.x - d.source.x;
64
- let diffY = d.target.y - d.source.y;
736
+ const diffX = d.target.x - d.source.x;
737
+ const diffY = d.target.y - d.source.y;
65
738
  // Length of path from center of source node to center of target node
66
- let pathLength = Math.sqrt(diffX * diffX + diffY * diffY);
739
+ const pathLength = Math.sqrt(diffX * diffX + diffY * diffY);
67
740
  // x and y distances from center to outside edge of target node
68
- let offsetX = (diffX * 40) / pathLength;
69
- let offsetY = (diffY * 40) / pathLength;
741
+ const offsetX = (diffX * 40) / pathLength;
742
+ const offsetY = (diffY * 40) / pathLength;
70
743
  d3.select(n[i])
71
744
  .attr('x1', d.source.x + offsetX)
72
745
  .attr('y1', d.source.y + offsetY)
@@ -155,7 +828,7 @@ class VisualiserGraphService {
155
828
  }
156
829
  removeNewItem(nodes) {
157
830
  for (const node of nodes) {
158
- if (node.hasOwnProperty('newItem')) {
831
+ if (Object.prototype.hasOwnProperty.call(node, 'newItem')) {
159
832
  delete node.newItem;
160
833
  }
161
834
  }
@@ -207,8 +880,12 @@ class VisualiserGraphService {
207
880
  this.nodes = nodes || [];
208
881
  this.links = links || [];
209
882
  // Disable the reset btn
210
- let saveBtn = document.getElementById('save_graph');
211
- saveBtn.setAttribute('disabled', 'true');
883
+ const resetBtn = document.getElementById('reset_graph');
884
+ const saveBtn = document.getElementById('save_graph');
885
+ if (resetBtn) {
886
+ resetBtn.setAttribute('disabled', 'true');
887
+ saveBtn.setAttribute('disabled', 'true');
888
+ }
212
889
  // Width/Height of canvas
213
890
  const parentWidth = _d3.select('svg').node().parentNode.clientWidth;
214
891
  const parentHeight = _d3.select('svg').node().parentNode.clientHeight;
@@ -395,6 +1072,275 @@ class VisualiserGraphService {
395
1072
  }
396
1073
  });
397
1074
  // Zoom End
1075
+ // Selection buttons
1076
+ const selectAllNodes = document.getElementById('select_all');
1077
+ const handleSelectAllNodes = () => {
1078
+ const totalSize = nodeEnter.size();
1079
+ const nonSelectedNodes = d3.selectAll('.node-wrapper:not(.selected)');
1080
+ const count = nonSelectedNodes.size();
1081
+ const notSelectedSize = totalSize - count;
1082
+ if (notSelectedSize !== totalSize) {
1083
+ if (selectAllNodes) {
1084
+ selectAllNodes.innerHTML = '<i class="bi bi-grid"></i>';
1085
+ selectAllNodes.style.opacity = '0.65';
1086
+ }
1087
+ _d3.selectAll('.node-wrapper').classed('selected', function (p) {
1088
+ p.previouslySelected = p.selected;
1089
+ return (p.selected = true);
1090
+ });
1091
+ d3.selectAll('.nodeText')
1092
+ .style('fill', (d) => (d.selected ? 'blue' : '#999'))
1093
+ .style('font-weight', (d) => (d.selected ? 700 : 400));
1094
+ }
1095
+ else {
1096
+ if (selectAllNodes) {
1097
+ selectAllNodes.innerHTML = '<i class="bi bi-grid-fill"></i>';
1098
+ selectAllNodes.style.opacity = '1';
1099
+ }
1100
+ _d3.selectAll('.node-wrapper').classed('selected', false);
1101
+ _d3.selectAll('.node-wrapper').classed('selected', function (p) {
1102
+ return (p.selected = p.previouslySelected = false);
1103
+ });
1104
+ _d3
1105
+ .selectAll('.nodeText')
1106
+ .style('font-weight', 400)
1107
+ .style('fill', '#212529');
1108
+ }
1109
+ // reset link style
1110
+ _d3
1111
+ .selectAll('.edgelabel')
1112
+ .style('font-weight', 400)
1113
+ .style('fill', '#212529');
1114
+ };
1115
+ d3.select('#select_all').on('click', handleSelectAllNodes);
1116
+ const handleToggleSelection = () => {
1117
+ const totalSize = nodeEnter.size();
1118
+ const selectedNodes = d3.selectAll('.node-wrapper.selected');
1119
+ const nonSelectedNodes = d3.selectAll('.node-wrapper:not(.selected)');
1120
+ const selectedCount = selectedNodes.size();
1121
+ const nonSelectedCount = nonSelectedNodes.size();
1122
+ if (selectedCount > 0) {
1123
+ // Deselect selected nodes and select non-selected nodes
1124
+ selectedNodes.classed('selected', function (p) {
1125
+ p.previouslySelected = p.selected;
1126
+ return (p.selected = false);
1127
+ });
1128
+ nonSelectedNodes.classed('selected', function (p) {
1129
+ p.previouslySelected = p.selected;
1130
+ return (p.selected = true);
1131
+ });
1132
+ // If there are only two nodes selected we need to update the subject selectedNodesArray so we can create a new link with the correct nodes attached.
1133
+ const selectedSize = svg.selectAll('.selected').size();
1134
+ if (selectedSize <= 2) {
1135
+ // get data from node
1136
+ const localselectedNodesArray = _d3.selectAll('.selected').data();
1137
+ const filterId = localselectedNodesArray.filter((x) => x);
1138
+ this.selectedNodesArray.next(filterId);
1139
+ }
1140
+ // Update styles of node elements
1141
+ _d3
1142
+ .selectAll('.nodeText')
1143
+ .style('fill', (d) => (d.selected ? 'blue' : '#212529'))
1144
+ .style('font-weight', (d) => (d.selected ? 700 : 400));
1145
+ }
1146
+ else if (nonSelectedCount > 0) {
1147
+ // Select all nodes if none are selected
1148
+ _d3.selectAll('.node-wrapper').classed('selected', function (p) {
1149
+ p.previouslySelected = p.selected;
1150
+ return (p.selected = true);
1151
+ });
1152
+ // Update styles of node elements
1153
+ _d3
1154
+ .selectAll('.nodeText')
1155
+ .style('font-weight', 700)
1156
+ .style('fill', 'blue');
1157
+ }
1158
+ // Update the state of another button based on the current selection
1159
+ const updatedSelectedCount = selectedCount > 0 ? totalSize - selectedCount : totalSize;
1160
+ if (updatedSelectedCount === totalSize) {
1161
+ // Update the state of another button if all nodes are selected
1162
+ if (selectAllNodes) {
1163
+ selectAllNodes.innerHTML = '<i class="bi bi-grid"></i>';
1164
+ selectAllNodes.style.opacity = '0.65';
1165
+ }
1166
+ }
1167
+ else {
1168
+ // Update the state of another button if not all nodes are selected
1169
+ if (selectAllNodes) {
1170
+ selectAllNodes.innerHTML = '<i class="bi bi-grid-fill"></i>';
1171
+ selectAllNodes.style.opacity = '1';
1172
+ }
1173
+ }
1174
+ // reset link style
1175
+ _d3
1176
+ .selectAll('.edgelabel')
1177
+ .style('font-weight', 400)
1178
+ .style('fill', '#212529');
1179
+ };
1180
+ d3.select('#toggle_selection').on('click', handleToggleSelection);
1181
+ // search
1182
+ const searchBtn = document.getElementById('searchButton');
1183
+ // Check to see if exists - control bool
1184
+ if (searchBtn) {
1185
+ const searchInput = document.getElementById('searchInput');
1186
+ const clearButton = document.getElementById('clearButton');
1187
+ const handleSearch = (event) => {
1188
+ if (event.key === 'Enter') {
1189
+ event.preventDefault();
1190
+ performSearch();
1191
+ }
1192
+ };
1193
+ let matchingNodes = [];
1194
+ let currentMatchIndex = -1;
1195
+ const showCurrentMatch = () => {
1196
+ // Remove any previously added background circle
1197
+ d3.selectAll('circle.highlight-background').remove();
1198
+ const matchingNode = matchingNodes[currentMatchIndex];
1199
+ // Highlight the matching node
1200
+ const nodeWrapper = d3.selectAll('.node-wrapper').filter(function () {
1201
+ return d3.select(this).attr('id') === matchingNode.id;
1202
+ });
1203
+ // Add a new background circle to the entire <g> node
1204
+ const bbox = nodeWrapper.node().getBBox();
1205
+ const centerX = bbox.x + bbox.width / 2;
1206
+ const centerY = bbox.y + bbox.height / 2;
1207
+ const radius = Math.max(bbox.width + 30, bbox.height) / 2;
1208
+ const backgroundCircle = nodeWrapper
1209
+ .insert('circle', ':first-child')
1210
+ .attr('class', 'highlight-background')
1211
+ .attr('fill', 'yellow')
1212
+ .attr('opacity', '0.3')
1213
+ .attr('cx', centerX)
1214
+ .attr('cy', centerY);
1215
+ // Animate the background circle
1216
+ backgroundCircle
1217
+ .transition()
1218
+ .duration(1000)
1219
+ .attr('r', radius)
1220
+ .transition()
1221
+ .duration(1000)
1222
+ .attr('r', radius / 4)
1223
+ .attr('opacity', '0.5')
1224
+ .transition()
1225
+ .duration(1000)
1226
+ .attr('r', radius)
1227
+ .attr('opacity', '0.3');
1228
+ // Zoom to the matching node
1229
+ const zoomTransform = d3.zoomTransform(svg.node());
1230
+ const { k } = zoomTransform;
1231
+ const { fx, fy } = matchingNode;
1232
+ const newZoomTransform = d3.zoomIdentity
1233
+ .translate(-fx * k + parentWidth / 2, -fy * k + parentHeight / 2)
1234
+ .scale(k);
1235
+ zoomContainer
1236
+ .transition()
1237
+ .duration(750)
1238
+ .call(zoom.transform, newZoomTransform);
1239
+ // Disable/Enable navigation buttons
1240
+ const prevButton = document.getElementById('prevButton');
1241
+ const nextButton = document.getElementById('nextButton');
1242
+ prevButton.disabled = currentMatchIndex === 0;
1243
+ nextButton.disabled = currentMatchIndex === matchingNodes.length - 1;
1244
+ };
1245
+ const performSearch = () => {
1246
+ // Remove any previously added background circle
1247
+ d3.selectAll('circle.highlight-background').remove();
1248
+ const searchTerm = searchInput.value.toLowerCase().trim();
1249
+ if (searchTerm.length >= 3) {
1250
+ // Perform the search
1251
+ matchingNodes = this.nodes.filter((node) => {
1252
+ const label = node.label.map((item) => item.toLowerCase());
1253
+ return (label.some((labelItem) => labelItem.includes(searchTerm)) ||
1254
+ node.label.some((obj) => Object.values(obj).some((value) => String(value).toLowerCase().includes(searchTerm))));
1255
+ });
1256
+ if (matchingNodes.length > 0) {
1257
+ currentMatchIndex = 0;
1258
+ showCurrentMatch();
1259
+ }
1260
+ else {
1261
+ currentMatchIndex = -1;
1262
+ showNoMatches();
1263
+ }
1264
+ }
1265
+ else {
1266
+ // Clear search
1267
+ matchingNodes = [];
1268
+ currentMatchIndex = -1;
1269
+ showNoMatches();
1270
+ }
1271
+ updateClearButton();
1272
+ };
1273
+ const showNoMatches = () => {
1274
+ // Reset zoom level
1275
+ const newZoomTransform = d3.zoomIdentity.translate(0, 0).scale(1);
1276
+ zoomContainer
1277
+ .transition()
1278
+ .duration(750)
1279
+ .call(zoom.transform, newZoomTransform);
1280
+ updateZoomLevel();
1281
+ // Disable navigation buttons
1282
+ const prevButton = document.getElementById('prevButton');
1283
+ const nextButton = document.getElementById('nextButton');
1284
+ prevButton.disabled = true;
1285
+ nextButton.disabled = true;
1286
+ // Show "no matches found" text with fade-in transition
1287
+ const noMatchesText = document.getElementById('noMatchesText');
1288
+ if (searchInput.value !== '') {
1289
+ noMatchesText.classList.add('show');
1290
+ // Fade away after a few seconds
1291
+ setTimeout(() => {
1292
+ // Hide "no matches found" text with fade-out transition
1293
+ noMatchesText.classList.remove('show');
1294
+ }, 3000);
1295
+ }
1296
+ };
1297
+ const navigateNext = () => {
1298
+ if (currentMatchIndex < matchingNodes.length - 1) {
1299
+ currentMatchIndex++;
1300
+ showCurrentMatch();
1301
+ }
1302
+ };
1303
+ const navigatePrevious = () => {
1304
+ if (currentMatchIndex > 0) {
1305
+ currentMatchIndex--;
1306
+ showCurrentMatch();
1307
+ }
1308
+ };
1309
+ const clearSearchInput = () => {
1310
+ searchInput.value = '';
1311
+ searchInput.focus();
1312
+ updateClearButton();
1313
+ matchingNodes = [];
1314
+ currentMatchIndex = -1;
1315
+ // Remove any previously added background circle
1316
+ d3.selectAll('circle.highlight-background').remove();
1317
+ // Disable the nextButton & prevButton
1318
+ const nextButton = document.getElementById('nextButton');
1319
+ nextButton.disabled = true;
1320
+ const prevButton = document.getElementById('prevButton');
1321
+ prevButton.disabled = true;
1322
+ };
1323
+ const updateClearButton = () => {
1324
+ clearButton.disabled = searchInput.value.trim().length === 0;
1325
+ };
1326
+ // We reset the search when we reset the data
1327
+ if (this.resetSearch) {
1328
+ clearSearchInput();
1329
+ this.resetSearch = false;
1330
+ }
1331
+ searchInput.addEventListener('input', updateClearButton);
1332
+ searchBtn.addEventListener('click', performSearch);
1333
+ clearButton.addEventListener('click', clearSearchInput);
1334
+ document
1335
+ .getElementById('searchInput')
1336
+ .addEventListener('keydown', handleSearch);
1337
+ document
1338
+ .getElementById('nextButton')
1339
+ .addEventListener('click', navigateNext);
1340
+ document
1341
+ .getElementById('prevButton')
1342
+ .addEventListener('click', navigatePrevious);
1343
+ }
398
1344
  // For arrows
399
1345
  this.initDefinitions(svg);
400
1346
  const simulation = this.forceSimulation(_d3, {
@@ -402,13 +1348,13 @@ class VisualiserGraphService {
402
1348
  height: +svg.attr('height'),
403
1349
  });
404
1350
  // Brush Start
405
- let gBrushHolder = svg.append('g');
406
- let brush = d3
1351
+ const gBrushHolder = svg.append('g');
1352
+ const brush = d3
407
1353
  .brush()
408
1354
  .on('start', () => {
409
1355
  this.brushing = true;
410
1356
  nodeEnter.each((d) => {
411
- d.previouslySelected = this.shiftKey && d.selected;
1357
+ d.previouslySelected = Boolean(this.shiftKey && d.selected);
412
1358
  });
413
1359
  _d3
414
1360
  .selectAll('.edgelabel')
@@ -428,16 +1374,11 @@ class VisualiserGraphService {
428
1374
  return;
429
1375
  nodeEnter
430
1376
  .classed('selected', (d) => {
431
- return (d.selected =
432
- d.previouslySelected ^
433
- ((d3.event.selection[0][0] <=
434
- d.x * currentZoom.k + currentZoom.x &&
435
- d.x * currentZoom.k + currentZoom.x <
436
- d3.event.selection[1][0] &&
437
- d3.event.selection[0][1] <=
438
- d.y * currentZoom.k + currentZoom.y &&
439
- d.y * currentZoom.k + currentZoom.y <
440
- d3.event.selection[1][1])));
1377
+ const isInSelection = d3.event.selection[0][0] <= d.x * currentZoom.k + currentZoom.x &&
1378
+ d.x * currentZoom.k + currentZoom.x < d3.event.selection[1][0] &&
1379
+ d3.event.selection[0][1] <= d.y * currentZoom.k + currentZoom.y &&
1380
+ d.y * currentZoom.k + currentZoom.y < d3.event.selection[1][1];
1381
+ return (d.selected = Boolean(d.previouslySelected) !== isInSelection);
441
1382
  })
442
1383
  .select('.nodeText')
443
1384
  .classed('selected', (d) => d.selected)
@@ -462,8 +1403,38 @@ class VisualiserGraphService {
462
1403
  })
463
1404
  .style('fill', '#212529')
464
1405
  .style('font-weight', 400);
1406
+ const totalSize = nodeEnter.size();
1407
+ const nonSelectedNodes = d3.selectAll('.node-wrapper:not(.selected)');
1408
+ const count = nonSelectedNodes.size();
1409
+ const notSelectedSize = totalSize - count;
1410
+ if (notSelectedSize === totalSize) {
1411
+ if (selectAllNodes) {
1412
+ selectAllNodes.innerHTML = '<i class="bi bi-grid"></i>';
1413
+ selectAllNodes.style.opacity = '0.65';
1414
+ }
1415
+ }
1416
+ else {
1417
+ if (selectAllNodes) {
1418
+ selectAllNodes.innerHTML = '<i class="bi bi-grid-fill"></i>';
1419
+ selectAllNodes.style.opacity = '1';
1420
+ }
1421
+ }
1422
+ // counts number of selected classes to not exceed 2
1423
+ const selectedSize = nodeEnter.selectAll('.selected').size();
1424
+ if (selectedSize <= 2) {
1425
+ // get data from node
1426
+ const localselectedNodesArray = nodeEnter
1427
+ .selectAll('.selected')
1428
+ .data();
1429
+ const filterId = localselectedNodesArray.filter((x) => x);
1430
+ this.selectedNodesArray.next(filterId);
1431
+ return filterId;
1432
+ }
1433
+ else {
1434
+ this.selectedNodesArray.next([]);
1435
+ }
465
1436
  });
466
- let keyup = () => {
1437
+ const keyup = () => {
467
1438
  this.shiftKey = false;
468
1439
  this.brushMode = false;
469
1440
  if (this.gBrush && !this.brushing) {
@@ -473,7 +1444,7 @@ class VisualiserGraphService {
473
1444
  this.gBrush = null;
474
1445
  }
475
1446
  };
476
- let keydown = () => {
1447
+ const keydown = () => {
477
1448
  // Allows us to turn off default listeners for keyModifiers(shift)
478
1449
  brush.filter(() => d3.event.shiftKey);
479
1450
  brush.keyModifiers(false);
@@ -525,13 +1496,13 @@ class VisualiserGraphService {
525
1496
  return `${source}_${target}${suffix}`;
526
1497
  })
527
1498
  .attr('marker-end', function (d) {
528
- if (d.parentTargetArrow === true) {
1499
+ if (d.parentSourceArrow === true) {
529
1500
  return 'url(#arrowheadSource)';
530
1501
  }
531
1502
  return null;
532
1503
  })
533
1504
  .attr('marker-start', function (d) {
534
- if (d.parentSourceArrow === true) {
1505
+ if (d.parentTargetArrow === true) {
535
1506
  return 'url(#arrowheadTarget)';
536
1507
  }
537
1508
  return null;
@@ -570,6 +1541,10 @@ class VisualiserGraphService {
570
1541
  .attr('dy', function (d) {
571
1542
  return d.dy;
572
1543
  });
1544
+ svg.selectAll('.edgelabel').on('dblclick', () => {
1545
+ const dblClick = d3.select(_d3.event.currentTarget).data();
1546
+ this.dblClickLinkPayload.next(dblClick);
1547
+ });
573
1548
  edgelabelsEnter
574
1549
  .append('textPath')
575
1550
  .attr('xlink:href', function (d, i) {
@@ -592,13 +1567,17 @@ class VisualiserGraphService {
592
1567
  .attr('class', 'fa')
593
1568
  .text(' \uf0c1');
594
1569
  // on normal label link click - highlight labels
595
- svg.selectAll('.edgelabel').on('click', function (d) {
1570
+ svg.selectAll('.edgelabel').on('click', () => {
596
1571
  _d3.event.stopPropagation();
597
1572
  nodeEnter.each(function (d) {
598
1573
  d.selected = false;
599
1574
  d.previouslySelected = false;
600
1575
  });
601
1576
  node.classed('selected', false);
1577
+ if (selectAllNodes) {
1578
+ selectAllNodes.innerHTML = '<i class="bi bi-grid-fill"></i>';
1579
+ selectAllNodes.style.opacity = '1';
1580
+ }
602
1581
  _d3
603
1582
  .selectAll('.nodeText')
604
1583
  .style('fill', '#212529')
@@ -607,7 +1586,23 @@ class VisualiserGraphService {
607
1586
  .selectAll('.edgelabel')
608
1587
  .style('font-weight', 400)
609
1588
  .style('fill', '#212529');
610
- _d3.select(this).style('fill', 'blue').style('font-weight', 700);
1589
+ _d3.select(_d3.event.currentTarget).style('fill', 'blue').style('font-weight', 700);
1590
+ this.selectedNodesArray.next([]);
1591
+ });
1592
+ // on right label link click - hightlight labels and package data for context menu
1593
+ svg.selectAll('.edgelabel').on('contextmenu', () => {
1594
+ this.selectedNodesArray.next([]);
1595
+ _d3
1596
+ .selectAll('.nodeText')
1597
+ .style('fill', '#212529')
1598
+ .style('font-weight', 400);
1599
+ _d3
1600
+ .selectAll('.edgelabel')
1601
+ .style('font-weight', 400)
1602
+ .style('fill', '#212529');
1603
+ _d3.select(_d3.event.currentTarget).style('fill', 'blue').style('font-weight', 700);
1604
+ const localSelectedLinkArray = d3.select(_d3.event.currentTarget).data();
1605
+ this.selectedLinkArray.next(localSelectedLinkArray);
611
1606
  });
612
1607
  const node = zoomContainer.selectAll().data(this.nodes, function (d) {
613
1608
  return d.id;
@@ -619,7 +1614,12 @@ class VisualiserGraphService {
619
1614
  .drag()
620
1615
  .on('start', function dragstarted(d) {
621
1616
  // Enable the save & reset btn
622
- document.getElementById('save_graph').removeAttribute('disabled');
1617
+ if (resetBtn) {
1618
+ document
1619
+ .getElementById('reset_graph')
1620
+ .removeAttribute('disabled');
1621
+ document.getElementById('save_graph').removeAttribute('disabled');
1622
+ }
623
1623
  if (!_d3.event.active)
624
1624
  simulation.alphaTarget(0.9).restart();
625
1625
  if (!d.selected && !this.shiftKey) {
@@ -637,7 +1637,7 @@ class VisualiserGraphService {
637
1637
  .style('font-weight', 400)
638
1638
  .style('fill', '#212529');
639
1639
  }
640
- _d3.select(this).classed('selected', function (p) {
1640
+ _d3.select(this).classed('selected', function () {
641
1641
  d.previouslySelected = d.selected;
642
1642
  return (d.selected = true);
643
1643
  });
@@ -650,7 +1650,7 @@ class VisualiserGraphService {
650
1650
  d.fy = d.y;
651
1651
  });
652
1652
  })
653
- .on('drag', function dragged(d) {
1653
+ .on('drag', function dragged() {
654
1654
  nodeEnter
655
1655
  .filter(function (d) {
656
1656
  return d.selected;
@@ -660,33 +1660,93 @@ class VisualiserGraphService {
660
1660
  d.fy += _d3.event.dy;
661
1661
  });
662
1662
  })
663
- .on('end', function dragended(d) {
1663
+ .on('end', (d) => {
664
1664
  if (!_d3.event.active) {
665
1665
  simulation.alphaTarget(0.3).restart();
666
1666
  }
667
1667
  d.fx = d.x;
668
1668
  d.fy = d.y;
669
1669
  // Subscribes to updated graph positions for save
670
- self.saveGraphData.next(data);
1670
+ this.saveGraphData.next(data);
671
1671
  }))
672
1672
  .attr('class', 'node-wrapper')
673
1673
  .attr('id', function (d) {
674
1674
  return d.id;
675
1675
  });
676
- // no collision - already using this in statement
677
- const self = this;
1676
+ svg.selectAll('.node-wrapper').on('dblclick', () => {
1677
+ const dblClick = d3.select(_d3.event.currentTarget).data();
1678
+ this.dblClickNodePayload.next(dblClick);
1679
+ });
678
1680
  // node click and ctrl + click
679
- svg.selectAll('.node-wrapper').on('click', function (d) {
1681
+ svg.selectAll('.node-wrapper').on('click', (d) => {
680
1682
  // so we don't activate the canvas .click event
681
1683
  _d3.event.stopPropagation();
682
1684
  // setting the select attribute to the object on single select so we can drag them
683
1685
  d.selected = true;
684
- svg.selectAll('.node-wrapper').classed('selected', false);
685
- d3.select(this).classed('selected', true);
686
- nodeEnter.each(function (d) {
687
- d.selected = false;
688
- d.previouslySelected = false;
689
- });
1686
+ if (selectAllNodes) {
1687
+ selectAllNodes.innerHTML = '<i class="bi bi-grid-fill"></i>';
1688
+ selectAllNodes.style.opacity = '1';
1689
+ }
1690
+ // If ctrl key is held on click
1691
+ if (_d3.event.ctrlKey) {
1692
+ // toggle the class on and off when ctrl click is active
1693
+ const clickedNode = d3.select(_d3.event.currentTarget);
1694
+ const isSelected = clickedNode.classed('selected');
1695
+ clickedNode.classed('selected', !isSelected);
1696
+ d.selected = !isSelected;
1697
+ d.previouslySelected = !isSelected;
1698
+ const totalSize = nodeEnter.size();
1699
+ const nonSelectedNodes = d3.selectAll('.node-wrapper:not(.selected)');
1700
+ const count = nonSelectedNodes.size();
1701
+ const notSelectedSize = totalSize - count;
1702
+ if (notSelectedSize === totalSize) {
1703
+ if (selectAllNodes) {
1704
+ selectAllNodes.innerHTML = '<i class="bi bi-grid"></i>';
1705
+ selectAllNodes.style.opacity = '0.65';
1706
+ }
1707
+ }
1708
+ // remove the single click styling on other nodes and labels
1709
+ _d3
1710
+ .selectAll('.edgelabel')
1711
+ .style('fill', '#212529')
1712
+ .style('font-weight', 400);
1713
+ _d3
1714
+ .selectAll('.nodeText')
1715
+ .style('font-weight', 400)
1716
+ .style('fill', '#212529');
1717
+ svg
1718
+ .selectAll('.selected')
1719
+ .selectAll('.nodeText')
1720
+ .style('fill', 'blue')
1721
+ .style('font-weight', 700);
1722
+ // counts number of selected classes to not exceed 2
1723
+ const selectedSize = svg.selectAll('.selected').size();
1724
+ if (selectedSize <= 2) {
1725
+ // As we allow for single click without a ctrl+click to select two nodes, we have to apply d.selected to it
1726
+ _d3
1727
+ .selectAll('.selected')
1728
+ .attr('selected', true)
1729
+ .each(function (d) {
1730
+ if (d) {
1731
+ d.selected = true;
1732
+ }
1733
+ });
1734
+ // get data from node
1735
+ const localselectedNodesArray = _d3.selectAll('.selected').data();
1736
+ const filterId = localselectedNodesArray.filter((x) => x);
1737
+ this.selectedNodesArray.next(filterId);
1738
+ return filterId;
1739
+ }
1740
+ return null;
1741
+ }
1742
+ else {
1743
+ svg.selectAll('.node-wrapper').classed('selected', false);
1744
+ d3.select(_d3.event.currentTarget).classed('selected', true);
1745
+ nodeEnter.each(function (d) {
1746
+ d.selected = false;
1747
+ d.previouslySelected = false;
1748
+ });
1749
+ }
690
1750
  // remove style from selected node before the class is removed
691
1751
  _d3
692
1752
  .selectAll('.selected')
@@ -700,12 +1760,40 @@ class VisualiserGraphService {
700
1760
  .style('font-weight', 400);
701
1761
  // Add style on single left click
702
1762
  _d3
703
- .select(this)
1763
+ .select(_d3.event.currentTarget)
704
1764
  .select('.nodeText')
705
1765
  .style('fill', 'blue')
706
1766
  .style('font-weight', 700);
1767
+ this.selectedNodesArray.next([]);
707
1768
  return null;
708
1769
  });
1770
+ // Right click on a node highlights for context menu
1771
+ svg.selectAll('.node-wrapper').on('contextmenu', () => {
1772
+ // counts number of selected classes to not exceed 2
1773
+ const selectedSize = svg
1774
+ .selectAll('.selected')
1775
+ .selectAll('.nodeText')
1776
+ .size();
1777
+ if (selectedSize !== 2) {
1778
+ // We don't want to remove style if they are obtaining the context menu for just two nodes (create link option)
1779
+ svg.selectAll('.selected').classed('selected', false);
1780
+ this.selectedNodesArray.next([]);
1781
+ _d3
1782
+ .selectAll('.edgelabel')
1783
+ .style('fill', '#212529')
1784
+ .style('font-weight', 400);
1785
+ _d3
1786
+ .selectAll('.nodeText')
1787
+ .style('fill', '#212529')
1788
+ .style('font-weight', 400);
1789
+ // Add style on single right click
1790
+ _d3
1791
+ .select(_d3.event.currentTarget)
1792
+ .select('.nodeText')
1793
+ .style('fill', 'blue')
1794
+ .style('font-weight', 700);
1795
+ }
1796
+ });
709
1797
  //click on canvas to remove selected nodes
710
1798
  _d3.select('svg').on('click', () => {
711
1799
  nodeEnter.each(function (d) {
@@ -723,6 +1811,11 @@ class VisualiserGraphService {
723
1811
  .selectAll('.edgelabel')
724
1812
  .style('fill', '#212529')
725
1813
  .style('font-weight', 400);
1814
+ this.selectedNodesArray.next([]);
1815
+ if (selectAllNodes) {
1816
+ selectAllNodes.innerHTML = '<i class="bi bi-grid-fill"></i>';
1817
+ selectAllNodes.style.opacity = '1';
1818
+ }
726
1819
  });
727
1820
  nodeEnter
728
1821
  .filter(function (d) {
@@ -917,9 +2010,11 @@ class VisualiserGraphService {
917
2010
  }
918
2011
  });
919
2012
  simulation.force('link').links(this.links);
920
- self.saveGraphData.next(data);
2013
+ this.saveGraphData.next(data);
921
2014
  }
922
2015
  resetGraph(initialData, element, zoom, zoomToFit) {
2016
+ // To reset the search when we reset the data
2017
+ this.resetSearch = true;
923
2018
  // Reset the data to its initial state
924
2019
  this.nodes = [];
925
2020
  this.links = [];
@@ -972,12 +2067,12 @@ class DagreNodesOnlyLayout {
972
2067
  renderLayout(graph) {
973
2068
  this.createDagreGraph(graph);
974
2069
  dagre.layout(this.dagreGraph);
975
- for (const dagreNodeId in this.dagreGraph._nodes) {
976
- const dagreNode = this.dagreGraph._nodes[dagreNodeId];
977
- const node = graph.nodes.find((n) => n.id === dagreNode.id);
2070
+ for (const dagreNodeId of this.dagreGraph.nodes()) {
2071
+ const dagreNode = this.dagreGraph.node(dagreNodeId);
2072
+ const node = graph.nodes.find((n) => n.id === dagreNodeId);
978
2073
  if (node.fx === null && node.fy === null) {
979
2074
  // Check if the node has any associated edges
980
- const hasAssociatedEdges = graph.links.some((link) => link.source === dagreNode.id || link.target === dagreNode.id);
2075
+ const hasAssociatedEdges = graph.links.some((link) => link.source === dagreNodeId || link.target === dagreNodeId);
981
2076
  if (hasAssociatedEdges) {
982
2077
  node.fx = dagreNode.x;
983
2078
  node.fy = dagreNode.y;
@@ -994,11 +2089,11 @@ class DagreNodesOnlyLayout {
994
2089
  this.createDagreGraph(graph);
995
2090
  dagre.layout(this.dagreGraph);
996
2091
  let minFy = Infinity;
997
- for (const dagreNodeId in this.dagreGraph._nodes) {
998
- const dagreNode = this.dagreGraph._nodes[dagreNodeId];
999
- const node = graph.nodes.find((n) => n.id === dagreNode.id);
2092
+ for (const dagreNodeId of this.dagreGraph.nodes()) {
2093
+ const dagreNode = this.dagreGraph.node(dagreNodeId);
2094
+ const node = graph.nodes.find((n) => n.id === dagreNodeId);
1000
2095
  // Check if the node has any associated edges
1001
- const hasAssociatedEdges = graph.links.some((link) => link.source === dagreNode.id || link.target === dagreNode.id);
2096
+ const hasAssociatedEdges = graph.links.some((link) => link.source === dagreNodeId || link.target === dagreNodeId);
1002
2097
  if (hasAssociatedEdges) {
1003
2098
  node.fx = dagreNode.x;
1004
2099
  node.fy = dagreNode.y;
@@ -1040,20 +2135,19 @@ class DagreNodesOnlyLayout {
1040
2135
  align: settings.align,
1041
2136
  acyclicer: settings.acyclicer,
1042
2137
  ranker: settings.ranker,
1043
- multigraph: settings.multigraph,
1044
2138
  compound: settings.compound,
1045
2139
  });
1046
2140
  this.dagreNodes = graph.nodes.map((n) => {
1047
- const node = Object.assign({}, n);
1048
- node.width = 20;
1049
- node.height = 20;
1050
- node.x = n.fx;
1051
- node.y = n.fy;
1052
- return node;
2141
+ return {
2142
+ id: n.id,
2143
+ width: 20,
2144
+ height: 20,
2145
+ x: n.fx || 0,
2146
+ y: n.fy || 0,
2147
+ };
1053
2148
  });
1054
2149
  this.dagreEdges = graph.links.map((l) => {
1055
- const newLink = Object.assign({}, l);
1056
- return newLink;
2150
+ return { ...l };
1057
2151
  });
1058
2152
  for (const node of this.dagreNodes) {
1059
2153
  if (!node.width) {
@@ -1088,18 +2182,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
1088
2182
 
1089
2183
  class VisualiserGraphComponent {
1090
2184
  visualiserGraphService;
2185
+ contextMenuService;
1091
2186
  dagreNodesOnlyLayout;
1092
2187
  dexieService;
1093
2188
  graphElement;
2189
+ contextMenu;
1094
2190
  saveGraphDataEvent = new EventEmitter();
2191
+ selectedNodesArray;
2192
+ selectedNodeId;
2193
+ selectedLinkArray;
1095
2194
  saveGraphData;
1096
2195
  width;
2196
+ showSearch = false;
1097
2197
  savedGraphData;
2198
+ dataId;
2199
+ showConfirmation = false;
1098
2200
  buttonBarRightPosition;
2201
+ editLinksData = null;
2202
+ editNodeData = null;
2203
+ readOnly = false;
1099
2204
  zoom = true;
2205
+ controls = true;
1100
2206
  zoomToFit = false;
1101
- constructor(visualiserGraphService, dagreNodesOnlyLayout, dexieService) {
2207
+ modalsComponent;
2208
+ constructor(visualiserGraphService, contextMenuService, dagreNodesOnlyLayout, dexieService) {
1102
2209
  this.visualiserGraphService = visualiserGraphService;
2210
+ this.contextMenuService = contextMenuService;
1103
2211
  this.dagreNodesOnlyLayout = dagreNodesOnlyLayout;
1104
2212
  this.dexieService = dexieService;
1105
2213
  }
@@ -1109,6 +2217,7 @@ class VisualiserGraphComponent {
1109
2217
  return;
1110
2218
  }
1111
2219
  this.savedGraphData = data;
2220
+ this.dataId = data.dataId;
1112
2221
  // Timeout: The input arrives before the svg is rendered, therefore the nativeElement does not exist
1113
2222
  setTimeout(async () => {
1114
2223
  this.dagreNodesOnlyLayout.renderLayout(data);
@@ -1118,8 +2227,8 @@ class VisualiserGraphComponent {
1118
2227
  }, 500);
1119
2228
  }
1120
2229
  ngOnInit() {
1121
- this.updateWidth();
1122
2230
  this.buttonBarRightPosition = '0';
2231
+ this.updateWidth();
1123
2232
  // Initialize with default empty data if no data is provided
1124
2233
  if (!this.savedGraphData) {
1125
2234
  console.warn('No data provided, using empty data set');
@@ -1129,13 +2238,109 @@ class VisualiserGraphComponent {
1129
2238
  links: [],
1130
2239
  };
1131
2240
  }
2241
+ // Subscribe to the link selections in d3
2242
+ this.visualiserGraphService.selectedNodesArray.subscribe((selectedNodesArray) => {
2243
+ this.selectedNodesArray = selectedNodesArray;
2244
+ });
2245
+ // Subscribe to the double-click node payload
2246
+ this.visualiserGraphService.dblClickNodePayload.subscribe((dblClickNodePayload) => {
2247
+ this.selectedNodeId = dblClickNodePayload[0].id;
2248
+ if (!this.readOnly) {
2249
+ this.handleEditNodesEvent(true);
2250
+ }
2251
+ });
2252
+ // Subscribe to the double-click Link payload
2253
+ this.visualiserGraphService.dblClickLinkPayload.subscribe((dblClickLinkPayload) => {
2254
+ this.selectedLinkArray = dblClickLinkPayload;
2255
+ if (!this.readOnly) {
2256
+ this.onEditLinkLabel();
2257
+ }
2258
+ });
2259
+ this.visualiserGraphService.selectedLinkArray.subscribe((selectedLinkArray) => {
2260
+ this.selectedLinkArray = selectedLinkArray;
2261
+ });
2262
+ }
2263
+ toggleSearch() {
2264
+ this.showSearch = !this.showSearch;
2265
+ if (this.showSearch) {
2266
+ setTimeout(() => {
2267
+ const field = document.querySelector('#searchInput');
2268
+ if (field) {
2269
+ field.focus();
2270
+ field.setSelectionRange(0, 0);
2271
+ }
2272
+ else {
2273
+ console.error('Search input not found.');
2274
+ }
2275
+ }, 0);
2276
+ }
1132
2277
  }
1133
- onResize(event) {
2278
+ onResize() {
1134
2279
  this.updateWidth();
1135
2280
  }
1136
2281
  updateWidth() {
1137
2282
  this.width = document.getElementById('pageId').offsetWidth;
1138
2283
  }
2284
+ async visualiserContextMenus(event) {
2285
+ if (this.readOnly) {
2286
+ return;
2287
+ }
2288
+ if (!this.savedGraphData) {
2289
+ console.error('savedGraphData is not set');
2290
+ return;
2291
+ }
2292
+ let contextMenu;
2293
+ let item;
2294
+ const targetEl = event.target;
2295
+ const localName = targetEl.localName;
2296
+ const parentNodeId = targetEl.parentNode.id;
2297
+ const data = targetEl.parentNode.__data__;
2298
+ this.selectedNodeId = targetEl.id || (data && data.id);
2299
+ if (this.selectedNodesArray?.length === 2) {
2300
+ contextMenu = this.contextMenu.createEditLinkContextMenu;
2301
+ item = {
2302
+ graphData: this.savedGraphData,
2303
+ selectedNodes: this.selectedNodesArray
2304
+ };
2305
+ }
2306
+ else {
2307
+ if (localName === 'text' || localName === 'image' || parentNodeId === 'nodeText') {
2308
+ contextMenu = this.contextMenu.editNodeContextMenu;
2309
+ item = this.selectedNodeId;
2310
+ }
2311
+ else if (localName === 'textPath') {
2312
+ contextMenu = this.contextMenu.editLinkLabelContextMenu;
2313
+ item = this.selectedLinkArray;
2314
+ }
2315
+ else if (localName === 'svg') {
2316
+ contextMenu = this.contextMenu.findCreateNodesContextMenu;
2317
+ item = 'item';
2318
+ }
2319
+ }
2320
+ this.contextMenuService.show.next({
2321
+ contextMenu,
2322
+ event,
2323
+ item,
2324
+ });
2325
+ event.stopPropagation();
2326
+ event.preventDefault();
2327
+ // Update context menu items based on data from Dexie
2328
+ const updatedData = await this.dexieService.getGraphData(this.dataId);
2329
+ if (this.selectedNodesArray?.length === 2) {
2330
+ item.graphData = updatedData;
2331
+ }
2332
+ }
2333
+ findCreateNodesEvent(action) {
2334
+ if (action === 'findNodes') {
2335
+ this.toggleSearch();
2336
+ }
2337
+ else if (action === 'createNode') {
2338
+ this.opencreateNodeModal();
2339
+ }
2340
+ }
2341
+ opencreateNodeModal() {
2342
+ this.modalsComponent.openModal(this.modalsComponent.createNodeModal);
2343
+ }
1139
2344
  async onConfirmSave() {
1140
2345
  if (!this.savedGraphData) {
1141
2346
  console.error('savedGraphData is not set');
@@ -1158,50 +2363,399 @@ class VisualiserGraphComponent {
1158
2363
  this.disableButtons(true);
1159
2364
  this.data = this.saveGraphData;
1160
2365
  Swal.fire({
1161
- title: "Saved!",
2366
+ title: "Graph saved!",
1162
2367
  text: "Your graph has been saved.",
1163
2368
  icon: "success"
1164
2369
  });
1165
2370
  }
1166
2371
  });
1167
2372
  }
2373
+ async onCreateEditNode(nodeData) {
2374
+ if (!this.savedGraphData) {
2375
+ console.error('savedGraphData is not set');
2376
+ return;
2377
+ }
2378
+ const data = await this.dexieService.getGraphData(this.dataId);
2379
+ const { payload, source } = nodeData;
2380
+ // Check if the node already exists
2381
+ const existingNodeIndex = data.nodes.findIndex(node => node.id === payload.id);
2382
+ if (existingNodeIndex === -1) {
2383
+ // Generate a unique numeric ID for the new node
2384
+ let newId;
2385
+ do {
2386
+ newId = crypto.getRandomValues(new Uint32Array(1))[0];
2387
+ } while (data.nodes.some(node => node.id === newId.toString()));
2388
+ payload.id = newId.toString();
2389
+ }
2390
+ const isEditing = source === 'editNodeModal';
2391
+ Swal.fire({
2392
+ title: isEditing ? "Editing node" : "Creating node",
2393
+ text: "You won't be able to revert this!",
2394
+ icon: "warning",
2395
+ showCancelButton: true,
2396
+ confirmButtonColor: "#3085d6",
2397
+ cancelButtonColor: "#d33",
2398
+ confirmButtonText: isEditing ? "Update node" : "Create node"
2399
+ }).then((result) => {
2400
+ if (result.isConfirmed) {
2401
+ if (existingNodeIndex !== -1) {
2402
+ // Update the existing node
2403
+ data.nodes[existingNodeIndex] = payload;
2404
+ }
2405
+ else {
2406
+ // Add the new node
2407
+ data.nodes.push(payload);
2408
+ }
2409
+ this.data = data;
2410
+ this.saveGraphDataEvent.emit(data);
2411
+ Swal.fire({
2412
+ title: isEditing ? "Node edited!" : "Node created!",
2413
+ text: `Your node has been ${isEditing ? "edited" : "created"} and graph saved.`,
2414
+ icon: "success"
2415
+ });
2416
+ }
2417
+ });
2418
+ }
2419
+ async onCreateEditLink(linkData) {
2420
+ if (!this.savedGraphData) {
2421
+ console.error('savedGraphData is not set');
2422
+ return;
2423
+ }
2424
+ const { payload, source } = linkData;
2425
+ // Ensure that exactly two nodes are selected
2426
+ if (this.selectedNodesArray.length === 2) {
2427
+ // Make sure that the source is always the smaller ID
2428
+ this.selectedNodesArray = this.selectedNodesArray.sort((a, b) => Number(a.id) - Number(b.id));
2429
+ const sourceNode = this.selectedNodesArray[0];
2430
+ const targetNode = this.selectedNodesArray[1];
2431
+ // Retrieve the saved graph data from Dexie
2432
+ const data = await this.dexieService.getGraphData(this.dataId);
2433
+ // Find the next available labelIndex
2434
+ const allIndexes = data.links.reduce((acc, link) => {
2435
+ return acc.concat(link.relationships.map(rel => rel.labelIndex));
2436
+ }, []);
2437
+ let nextIndex = Math.max(...allIndexes, 0) + 1;
2438
+ // Map over the labels and linkIcon values, assuming each label has a corresponding linkIcon
2439
+ const relationships = payload.label.map((item) => ({
2440
+ labelIndex: item.labelIndex !== undefined ? item.labelIndex : nextIndex++,
2441
+ label: item.label,
2442
+ source: sourceNode.id,
2443
+ target: targetNode.id,
2444
+ linkIcon: item.linkIcon
2445
+ }));
2446
+ const newLink = {
2447
+ source: sourceNode.id,
2448
+ target: targetNode.id,
2449
+ lineStyle: payload.lineStyle,
2450
+ sourceArrow: payload.sourceArrow,
2451
+ targetArrow: payload.targetArrow,
2452
+ linkId: `${sourceNode.id}_${targetNode.id}`,
2453
+ relationships,
2454
+ };
2455
+ const isEditing = source === 'editLinkModal';
2456
+ Swal.fire({
2457
+ title: isEditing ? "Editing link" : "Creating link",
2458
+ text: "You won't be able to revert this!",
2459
+ icon: "warning",
2460
+ showCancelButton: true,
2461
+ confirmButtonColor: "#3085d6",
2462
+ cancelButtonColor: "#d33",
2463
+ confirmButtonText: isEditing ? "Update link" : "Create link",
2464
+ }).then((result) => {
2465
+ if (result.isConfirmed) {
2466
+ const existingLinkIndex = data.links.findIndex(link => link.linkId === `${sourceNode.id}_${targetNode.id}` || link.linkId === `${targetNode.id}_${sourceNode.id}`);
2467
+ if (existingLinkIndex !== -1) {
2468
+ data.links[existingLinkIndex] = newLink;
2469
+ }
2470
+ else {
2471
+ data.links.push(newLink);
2472
+ }
2473
+ this.data = data;
2474
+ this.saveGraphDataEvent.emit(data);
2475
+ Swal.fire({
2476
+ title: isEditing ? "Link updated" : "Link created",
2477
+ text: `Your link has been ${isEditing ? "edited" : "created"} and graph saved.`,
2478
+ icon: "success"
2479
+ });
2480
+ }
2481
+ });
2482
+ }
2483
+ else {
2484
+ console.error('Please select exactly two nodes to create a link.');
2485
+ }
2486
+ }
2487
+ async onDeleteNode() {
2488
+ if (!this.savedGraphData) {
2489
+ console.error('savedGraphData is not set');
2490
+ return;
2491
+ }
2492
+ Swal.fire({
2493
+ title: "Deleting node",
2494
+ text: "Deleting a node will save graph data, are you sure? This will also delete all links associated with this node.",
2495
+ icon: "warning",
2496
+ showCancelButton: true,
2497
+ confirmButtonColor: "#3085d6",
2498
+ cancelButtonColor: "#d33",
2499
+ confirmButtonText: "Delete node"
2500
+ }).then(async (result) => {
2501
+ if (result.isConfirmed) {
2502
+ const data = await this.dexieService.getGraphData(this.dataId);
2503
+ // Remove the node with the matching id
2504
+ data.nodes = data.nodes.filter(node => node.id !== this.selectedNodeId);
2505
+ // Remove links with matching source or target
2506
+ data.links = data.links.filter(link => link.source !== this.selectedNodeId && link.target !== this.selectedNodeId);
2507
+ this.data = data;
2508
+ this.saveGraphDataEvent.emit(data);
2509
+ Swal.fire({
2510
+ title: "Node deleted!",
2511
+ text: "This node has been deleted and graph saved.",
2512
+ icon: "success"
2513
+ });
2514
+ }
2515
+ });
2516
+ }
2517
+ async onDeleteLink(linkId) {
2518
+ if (!this.savedGraphData) {
2519
+ console.error('savedGraphData is not set');
2520
+ return;
2521
+ }
2522
+ Swal.fire({
2523
+ title: "Deleting link",
2524
+ text: "Deleting a link will save graph data, are you sure?",
2525
+ icon: "warning",
2526
+ showCancelButton: true,
2527
+ confirmButtonColor: "#3085d6",
2528
+ cancelButtonColor: "#d33",
2529
+ confirmButtonText: "Delete link"
2530
+ }).then(async (result) => {
2531
+ if (result.isConfirmed) {
2532
+ const data = await this.dexieService.getGraphData(this.dataId);
2533
+ const existingLinkIndex = data.links.findIndex(link => link.linkId === linkId);
2534
+ if (existingLinkIndex !== -1) {
2535
+ data.links.splice(existingLinkIndex, 1);
2536
+ this.data = data;
2537
+ this.saveGraphDataEvent.emit(data);
2538
+ }
2539
+ Swal.fire({
2540
+ title: "Link deleted!",
2541
+ text: "The link has been deleted and graph saved.",
2542
+ icon: "success"
2543
+ });
2544
+ }
2545
+ });
2546
+ }
2547
+ async onEditLinkLabel() {
2548
+ if (!this.savedGraphData) {
2549
+ console.error('savedGraphData is not set');
2550
+ return;
2551
+ }
2552
+ const inputValue = this.selectedLinkArray[0].label;
2553
+ Swal.fire({
2554
+ title: "Editing a link label will save graph data, are you sure?",
2555
+ input: "text",
2556
+ inputValue,
2557
+ text: "You won't be able to revert this!",
2558
+ icon: "warning",
2559
+ showCancelButton: true,
2560
+ confirmButtonColor: "#3085d6",
2561
+ cancelButtonColor: "#d33",
2562
+ confirmButtonText: "Update link label"
2563
+ }).then(async (result) => {
2564
+ if (result.isConfirmed) {
2565
+ // Update the label property with the result
2566
+ this.selectedLinkArray[0].label = result;
2567
+ // Retrieve the saved graph data from Dexie
2568
+ const data = await this.dexieService.getGraphData(this.dataId);
2569
+ // Find the link in the data using source and target IDs
2570
+ const link = data.links.find(link => (link.source === this.selectedLinkArray[0].source.id && link.target === this.selectedLinkArray[0].target.id) ||
2571
+ (link.source === this.selectedLinkArray[0].target.id && link.target === this.selectedLinkArray[0].source.id));
2572
+ if (link) {
2573
+ // Find the relationship with the same labelIndex
2574
+ const relationship = link.relationships.find(rel => rel.labelIndex === this.selectedLinkArray[0].labelIndex);
2575
+ if (relationship) {
2576
+ // Update the label in the matched object
2577
+ relationship.label = result.value;
2578
+ }
2579
+ this.data = data;
2580
+ this.saveGraphDataEvent.emit(data);
2581
+ }
2582
+ else {
2583
+ console.error('Link not found.');
2584
+ }
2585
+ Swal.fire({
2586
+ title: "Link label updated!",
2587
+ text: "Your link label has been updated and graph saved.",
2588
+ icon: "success"
2589
+ });
2590
+ }
2591
+ });
2592
+ }
2593
+ handleEditLinksEvent(event) {
2594
+ if (event.open) {
2595
+ this.editLinksData = { ...event.data, dataId: this.dataId };
2596
+ this.modalsComponent.openModal(this.modalsComponent.editLinksModal);
2597
+ }
2598
+ }
2599
+ handleCreateLinksEvent(event) {
2600
+ if (event.open) {
2601
+ // Make sure that the source is always the smaller ID
2602
+ const sortedData = event.data.sort((a, b) => Number(a.id) - Number(b.id));
2603
+ this.editLinksData = Object.assign(sortedData, { dataId: this.dataId });
2604
+ this.modalsComponent.openModal(this.modalsComponent.createLinkModal);
2605
+ }
2606
+ }
2607
+ async handleEditNodesEvent(event) {
2608
+ if (event) {
2609
+ this.modalsComponent.openModal(this.modalsComponent.editNodeModal);
2610
+ const data = await this.dexieService.getGraphData(this.dataId);
2611
+ this.editNodeData = data.nodes.find(node => node.id === this.selectedNodeId) || null;
2612
+ }
2613
+ }
2614
+ async resetGraph() {
2615
+ if (!this.savedGraphData) {
2616
+ console.error('savedGraphData is not set');
2617
+ return;
2618
+ }
2619
+ const data = await this.dexieService.getGraphData(this.dataId);
2620
+ this.disableButtons(true);
2621
+ this.visualiserGraphService.resetGraph(data, this.graphElement.nativeElement, this.zoom, this.zoomToFit);
2622
+ }
2623
+ async applyLayout() {
2624
+ if (!this.savedGraphData) {
2625
+ console.error('savedGraphData is not set');
2626
+ return;
2627
+ }
2628
+ const data = await this.dexieService.getGraphData(this.dataId);
2629
+ const newDagreLayout = this.dagreNodesOnlyLayout.initRenderLayout(data);
2630
+ this.visualiserGraphService.resetGraph(newDagreLayout, this.graphElement.nativeElement, this.zoom, this.zoomToFit);
2631
+ this.enableButtons();
2632
+ }
1168
2633
  disableButtons(disabled) {
1169
2634
  document.querySelectorAll('#save_graph, #reset_graph').forEach(btn => {
1170
2635
  btn.setAttribute('disabled', String(disabled));
1171
2636
  });
1172
2637
  }
1173
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: VisualiserGraphComponent, deps: [{ token: VisualiserGraphService }, { token: DagreNodesOnlyLayout }, { token: DexieService }], target: i0.ɵɵFactoryTarget.Component });
1174
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: VisualiserGraphComponent, selector: "visualiser-graph", inputs: { zoom: "zoom", zoomToFit: "zoomToFit", data: "data" }, outputs: { saveGraphDataEvent: "saveGraphDataEvent" }, viewQueries: [{ propertyName: "graphElement", first: true, predicate: ["svgId"], descendants: true }], ngImport: i0, template: "<div class=\"page\" id=\"pageId\" (window:resize)=\"onResize($event)\">\n <div class=\"buttonBar\" [style.right]=\"buttonBarRightPosition\">\n <div class=\"d-flex justify-content-end\">\n <div class=\"btn-group\" role=\"group\" aria-label=\"Controls\">\n <button type=\"button\" id=\"save_graph\" class=\"m-3 btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Save data\" (click)=\"onConfirmSave()\">\n <i class=\"bi bi-save\"></i>\n </button>\n </div>\n </div>\n </div>\n <!-- Zoom indicator-->\n <div *ngIf=\"zoom\" class=\"zoomIndicator\">\n <span id=\"zoom_level\"></span>\n </div>\n <svg #svgId [attr.width]=\"width\" height=\"780\"></svg>\n</div>", styles: ["@import\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css\";@import\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/css/bootstrap.min.css\";@import\"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css\";#zoom_level{position:relative;background-color:#000c;color:#fff;padding:5px;border-radius:5px;opacity:0;transition:opacity 1s ease-in-out}.zoomIndicator{position:absolute;left:0;padding:10px}.buttonBar{position:absolute;padding:10px}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2638
+ enableButtons() {
2639
+ const saveBtn = document.getElementById('save_graph');
2640
+ const resetBtn = document.getElementById('reset_graph');
2641
+ saveBtn.removeAttribute('disabled');
2642
+ resetBtn.removeAttribute('disabled');
2643
+ }
2644
+ ngAfterViewInit() {
2645
+ this.registerDragElement();
2646
+ }
2647
+ registerDragElement() {
2648
+ const elmnt = document.getElementById('draggable');
2649
+ let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
2650
+ const dragMouseDown = (e) => {
2651
+ // Prevent any default behavior
2652
+ e.preventDefault();
2653
+ // Get the mouse cursor position at startup
2654
+ pos3 = e.clientX;
2655
+ pos4 = e.clientY;
2656
+ // Set up mouse event listeners
2657
+ document.onmouseup = closeDragElement;
2658
+ document.onmousemove = elementDrag;
2659
+ };
2660
+ const elementDrag = (e) => {
2661
+ this.buttonBarRightPosition = null;
2662
+ // Calculate the new cursor position
2663
+ pos1 = pos3 - e.clientX;
2664
+ pos2 = pos4 - e.clientY;
2665
+ pos3 = e.clientX;
2666
+ pos4 = e.clientY;
2667
+ // Limit the element's movement within the boundaries of the page
2668
+ const maxWidth = this.width - elmnt.offsetWidth;
2669
+ const maxHeight = window.innerHeight - elmnt.offsetHeight;
2670
+ let newLeft = elmnt.offsetLeft - pos1;
2671
+ let newTop = elmnt.offsetTop - pos2;
2672
+ newLeft = Math.max(0, Math.min(newLeft, maxWidth));
2673
+ newTop = Math.max(0, Math.min(newTop, maxHeight));
2674
+ // Set the element's new position
2675
+ elmnt.style.left = `${newLeft}px`;
2676
+ elmnt.style.top = `${newTop}px`;
2677
+ };
2678
+ const closeDragElement = () => {
2679
+ /* stop moving when mouse button is released:*/
2680
+ document.onmouseup = null;
2681
+ document.onmousemove = null;
2682
+ };
2683
+ if (document.getElementById(elmnt.id + 'Handle')) {
2684
+ /* if present, the header is where you move the DIV from:*/
2685
+ document.getElementById(elmnt.id + 'Handle').onmousedown = dragMouseDown;
2686
+ }
2687
+ else {
2688
+ /* otherwise, move the DIV from anywhere inside the DIV:*/
2689
+ elmnt.onmousedown = dragMouseDown;
2690
+ }
2691
+ }
2692
+ openModal(modal) {
2693
+ const modalTemplate = this.modalsComponent[modal];
2694
+ if (modalTemplate) {
2695
+ this.modalsComponent.openModal(modalTemplate);
2696
+ }
2697
+ else {
2698
+ console.error(`Modal template ${modal} is not available.`);
2699
+ }
2700
+ }
2701
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: VisualiserGraphComponent, deps: [{ token: VisualiserGraphService }, { token: i2.ContextMenuService }, { token: DagreNodesOnlyLayout }, { token: DexieService }], target: i0.ɵɵFactoryTarget.Component });
2702
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: VisualiserGraphComponent, selector: "visualiser-graph", inputs: { readOnly: "readOnly", zoom: "zoom", controls: "controls", zoomToFit: "zoomToFit", data: "data" }, outputs: { saveGraphDataEvent: "saveGraphDataEvent" }, viewQueries: [{ propertyName: "graphElement", first: true, predicate: ["svgId"], descendants: true }, { propertyName: "contextMenu", first: true, predicate: ContextMenusComponent, descendants: true }, { propertyName: "modalsComponent", first: true, predicate: ModalsComponent, descendants: true }], ngImport: i0, template: "<div class=\"page\" id=\"pageId\" (window:resize)=\"onResize()\">\n <div id=\"draggable\" class=\"buttonBar\" [style.right]=\"buttonBarRightPosition\">\n <div *ngIf=\"controls\">\n <div class=\"d-flex justify-content-end\">\n <div class=\"btn-group\" role=\"group\" aria-label=\"Controls\">\n <button type=\"button\" id=\"draggableHandle\" class=\"btn btn-light\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Move toolbar\">\n <i class=\"bi bi-grip-vertical\"></i>\n </button>\n\n <button type=\"button\" id=\"dagre_layout\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Dagre layout\" (click)=\"applyLayout()\">\n <i class=\"bi bi-diagram-3\"></i>\n </button>\n <button type=\"button\" id=\"save_graph\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Save data\" (click)=\"onConfirmSave()\">\n <i class=\"bi bi-save\"></i>\n </button>\n <button type=\"button\" id=\"reset_graph\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Reset data\" (click)=\"resetGraph()\">\n <i class=\"bi bi-skip-backward\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Zoom in\" id=\"zoom_in\">\n <i class=\"bi bi-zoom-in\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Zoom out\" id=\"zoom_out\">\n <i class=\"bi bi-zoom-out\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Zoom reset\" id=\"zoom_reset\" disabled=\"true\">\n <i class=\"bi bi-arrow-counterclockwise\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Zoom to fit\" id=\"zoom_to_fit\">\n <i class=\"bi bi-arrows-fullscreen\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Select all\" id=\"select_all\">\n <i class=\"bi bi-grid-fill\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Invert selection\" id=\"toggle_selection\">\n <i class=\"bi bi-ui-checks-grid\"></i>\n </button>\n <button type=\"button\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Toggle search\" id=\"toggle_search\"\n [ngClass]=\"{'searchButtonActive': showSearch, 'searchButtonInactive': !showSearch}\"\n (click)=\"toggleSearch()\">\n <i class=\"bi bi-search\"></i>\n </button>\n </div>\n </div>\n <div class=\"search float-right input-group mt-3 pr-0\" [hidden]=\"!showSearch\">\n <div class=\"input-group-prepend\">\n <button type=\"button\" id=\"prevButton\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Previous\" disabled>\n <i class=\"bi bi-arrow-left-square\"></i>\n </button>\n <button type=\"button\" id=\"nextButton\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Next\" disabled>\n <i class=\"bi bi-arrow-right-square\"></i>\n </button>\n </div>\n <input type=\"text\" id=\"searchInput\" class=\"form-control\" placeholder=\"Search\" aria-label=\"Search\"\n aria-describedby=\"search\" />\n <div class=\"input-group-append\">\n <button class=\"btn btn-outline-secondary\" type=\"button\" id=\"searchButton\" data-toggle=\"tooltip\"\n data-placement=\"top\" title=\"Search\">\n <i class=\"bi bi-search\"></i>\n </button>\n </div>\n <div class=\"input-group-append\">\n <button class=\"btn btn-outline-secondary\" type=\"button\" id=\"clearButton\" data-toggle=\"tooltip\"\n data-placement=\"top\" title=\"Clear\" disabled>\n clear\n </button>\n </div>\n </div>\n </div>\n <div [hidden]=\"!showSearch\" id=\"noMatchesText\" class=\"noMatchesText float-right\">No matches found</div>\n </div>\n <!-- Zoom indicator-->\n <div *ngIf=\"zoom\" class=\"zoomIndicator\">\n <span id=\"zoom_level\"></span>\n </div>\n\n <app-context-menus\n (editNodeContextMenuEvent)=\"handleEditNodesEvent($event)\"\n (findCreateNodesContextMenuEvent)=\"findCreateNodesEvent($event)\"\n (createLinkContextMenuEvent)=\"handleCreateLinksEvent($event)\"\n (editLinkLabelContextMenuEvent)=\"onEditLinkLabel()\"\n (editLinksContextMenuEvent)=\"handleEditLinksEvent($event)\">\n </app-context-menus>\n\n <app-modals\n [editNodeData]=\"editNodeData\"\n [editLinksData]=\"editLinksData\"\n (createEditLinkEvent)=\"onCreateEditLink($event)\"\n (createEditNodeEvent)=\"onCreateEditNode($event)\"\n (deleteLinkEvent)=\"onDeleteLink($event)\"\n (deleteNodeEvent)=\"onDeleteNode()\">\n </app-modals>\n\n <svg #svgId [attr.width]=\"width\" height=\"780\" (contextmenu)=\"visualiserContextMenus($event)\"></svg>\n</div>", styles: ["@import\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css\";@import\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/css/bootstrap.min.css\";@import\"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css\";#zoom_level{position:relative;background-color:#000c;color:#fff;padding:5px;border-radius:5px;opacity:0;transition:opacity 1s ease-in-out}.buttonBar{position:absolute;padding:10px}.zoomIndicator{position:absolute;left:0;padding:10px}.noMatchesText{opacity:0;transition:opacity .5s;color:red}.noMatchesText.show{opacity:1}@keyframes floatInFromTop{0%{opacity:0;transform:translateY(-100%)}to{opacity:1;transform:translateY(0)}}.input-group{animation-name:floatInFromTop;animation-duration:.3s;animation-fill-mode:forwards;position:relative;width:407px}.searchButtonActive{outline:none;-webkit-box-shadow:inset 0px 0px 5px #323232;-moz-box-shadow:inset 0px 0px 5px #323232;box-shadow:inset 0 0 5px #323232}.searchButtonActive:focus,.searchButtonActive:active{outline:none;-webkit-box-shadow:inset 0px 0px 5px #323232;-moz-box-shadow:inset 0px 0px 5px #323232;box-shadow:inset 0 0 5px #323232}.searchButtonInactive{opacity:1;outline:none;box-shadow:none;background-color:#6c757d!important;border-color:#6c757d!important}#draggableHandle{cursor:move}@media (max-width: 768px){.buttonBar{flex-direction:column;align-items:flex-start}.btn-group{flex-direction:column}.btn-group .btn{width:100%;margin-bottom:5px}}\n"], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ContextMenusComponent, selector: "app-context-menus", outputs: ["editNodeContextMenuEvent", "findCreateNodesContextMenuEvent", "createLinkContextMenuEvent", "editLinkLabelContextMenuEvent", "editLinksContextMenuEvent"] }, { kind: "component", type: ModalsComponent, selector: "app-modals", inputs: ["editNodeData", "editLinksData"], outputs: ["closeModalEvent", "createEditLinkEvent", "createEditNodeEvent", "deleteLinkEvent", "deleteNodeEvent"] }] });
1175
2703
  }
1176
2704
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: VisualiserGraphComponent, decorators: [{
1177
2705
  type: Component,
1178
- args: [{ selector: 'visualiser-graph', template: "<div class=\"page\" id=\"pageId\" (window:resize)=\"onResize($event)\">\n <div class=\"buttonBar\" [style.right]=\"buttonBarRightPosition\">\n <div class=\"d-flex justify-content-end\">\n <div class=\"btn-group\" role=\"group\" aria-label=\"Controls\">\n <button type=\"button\" id=\"save_graph\" class=\"m-3 btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Save data\" (click)=\"onConfirmSave()\">\n <i class=\"bi bi-save\"></i>\n </button>\n </div>\n </div>\n </div>\n <!-- Zoom indicator-->\n <div *ngIf=\"zoom\" class=\"zoomIndicator\">\n <span id=\"zoom_level\"></span>\n </div>\n <svg #svgId [attr.width]=\"width\" height=\"780\"></svg>\n</div>", styles: ["@import\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css\";@import\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/css/bootstrap.min.css\";@import\"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css\";#zoom_level{position:relative;background-color:#000c;color:#fff;padding:5px;border-radius:5px;opacity:0;transition:opacity 1s ease-in-out}.zoomIndicator{position:absolute;left:0;padding:10px}.buttonBar{position:absolute;padding:10px}\n"] }]
1179
- }], ctorParameters: () => [{ type: VisualiserGraphService }, { type: DagreNodesOnlyLayout }, { type: DexieService }], propDecorators: { graphElement: [{
2706
+ args: [{ selector: 'visualiser-graph', template: "<div class=\"page\" id=\"pageId\" (window:resize)=\"onResize()\">\n <div id=\"draggable\" class=\"buttonBar\" [style.right]=\"buttonBarRightPosition\">\n <div *ngIf=\"controls\">\n <div class=\"d-flex justify-content-end\">\n <div class=\"btn-group\" role=\"group\" aria-label=\"Controls\">\n <button type=\"button\" id=\"draggableHandle\" class=\"btn btn-light\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Move toolbar\">\n <i class=\"bi bi-grip-vertical\"></i>\n </button>\n\n <button type=\"button\" id=\"dagre_layout\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Dagre layout\" (click)=\"applyLayout()\">\n <i class=\"bi bi-diagram-3\"></i>\n </button>\n <button type=\"button\" id=\"save_graph\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Save data\" (click)=\"onConfirmSave()\">\n <i class=\"bi bi-save\"></i>\n </button>\n <button type=\"button\" id=\"reset_graph\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Reset data\" (click)=\"resetGraph()\">\n <i class=\"bi bi-skip-backward\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Zoom in\" id=\"zoom_in\">\n <i class=\"bi bi-zoom-in\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Zoom out\" id=\"zoom_out\">\n <i class=\"bi bi-zoom-out\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Zoom reset\" id=\"zoom_reset\" disabled=\"true\">\n <i class=\"bi bi-arrow-counterclockwise\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Zoom to fit\" id=\"zoom_to_fit\">\n <i class=\"bi bi-arrows-fullscreen\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Select all\" id=\"select_all\">\n <i class=\"bi bi-grid-fill\"></i>\n </button>\n <button type=\"button\" *ngIf=\"zoom\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Invert selection\" id=\"toggle_selection\">\n <i class=\"bi bi-ui-checks-grid\"></i>\n </button>\n <button type=\"button\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Toggle search\" id=\"toggle_search\"\n [ngClass]=\"{'searchButtonActive': showSearch, 'searchButtonInactive': !showSearch}\"\n (click)=\"toggleSearch()\">\n <i class=\"bi bi-search\"></i>\n </button>\n </div>\n </div>\n <div class=\"search float-right input-group mt-3 pr-0\" [hidden]=\"!showSearch\">\n <div class=\"input-group-prepend\">\n <button type=\"button\" id=\"prevButton\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Previous\" disabled>\n <i class=\"bi bi-arrow-left-square\"></i>\n </button>\n <button type=\"button\" id=\"nextButton\" class=\"btn btn-secondary\" data-toggle=\"tooltip\" data-placement=\"top\"\n title=\"Next\" disabled>\n <i class=\"bi bi-arrow-right-square\"></i>\n </button>\n </div>\n <input type=\"text\" id=\"searchInput\" class=\"form-control\" placeholder=\"Search\" aria-label=\"Search\"\n aria-describedby=\"search\" />\n <div class=\"input-group-append\">\n <button class=\"btn btn-outline-secondary\" type=\"button\" id=\"searchButton\" data-toggle=\"tooltip\"\n data-placement=\"top\" title=\"Search\">\n <i class=\"bi bi-search\"></i>\n </button>\n </div>\n <div class=\"input-group-append\">\n <button class=\"btn btn-outline-secondary\" type=\"button\" id=\"clearButton\" data-toggle=\"tooltip\"\n data-placement=\"top\" title=\"Clear\" disabled>\n clear\n </button>\n </div>\n </div>\n </div>\n <div [hidden]=\"!showSearch\" id=\"noMatchesText\" class=\"noMatchesText float-right\">No matches found</div>\n </div>\n <!-- Zoom indicator-->\n <div *ngIf=\"zoom\" class=\"zoomIndicator\">\n <span id=\"zoom_level\"></span>\n </div>\n\n <app-context-menus\n (editNodeContextMenuEvent)=\"handleEditNodesEvent($event)\"\n (findCreateNodesContextMenuEvent)=\"findCreateNodesEvent($event)\"\n (createLinkContextMenuEvent)=\"handleCreateLinksEvent($event)\"\n (editLinkLabelContextMenuEvent)=\"onEditLinkLabel()\"\n (editLinksContextMenuEvent)=\"handleEditLinksEvent($event)\">\n </app-context-menus>\n\n <app-modals\n [editNodeData]=\"editNodeData\"\n [editLinksData]=\"editLinksData\"\n (createEditLinkEvent)=\"onCreateEditLink($event)\"\n (createEditNodeEvent)=\"onCreateEditNode($event)\"\n (deleteLinkEvent)=\"onDeleteLink($event)\"\n (deleteNodeEvent)=\"onDeleteNode()\">\n </app-modals>\n\n <svg #svgId [attr.width]=\"width\" height=\"780\" (contextmenu)=\"visualiserContextMenus($event)\"></svg>\n</div>", styles: ["@import\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css\";@import\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/css/bootstrap.min.css\";@import\"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css\";#zoom_level{position:relative;background-color:#000c;color:#fff;padding:5px;border-radius:5px;opacity:0;transition:opacity 1s ease-in-out}.buttonBar{position:absolute;padding:10px}.zoomIndicator{position:absolute;left:0;padding:10px}.noMatchesText{opacity:0;transition:opacity .5s;color:red}.noMatchesText.show{opacity:1}@keyframes floatInFromTop{0%{opacity:0;transform:translateY(-100%)}to{opacity:1;transform:translateY(0)}}.input-group{animation-name:floatInFromTop;animation-duration:.3s;animation-fill-mode:forwards;position:relative;width:407px}.searchButtonActive{outline:none;-webkit-box-shadow:inset 0px 0px 5px #323232;-moz-box-shadow:inset 0px 0px 5px #323232;box-shadow:inset 0 0 5px #323232}.searchButtonActive:focus,.searchButtonActive:active{outline:none;-webkit-box-shadow:inset 0px 0px 5px #323232;-moz-box-shadow:inset 0px 0px 5px #323232;box-shadow:inset 0 0 5px #323232}.searchButtonInactive{opacity:1;outline:none;box-shadow:none;background-color:#6c757d!important;border-color:#6c757d!important}#draggableHandle{cursor:move}@media (max-width: 768px){.buttonBar{flex-direction:column;align-items:flex-start}.btn-group{flex-direction:column}.btn-group .btn{width:100%;margin-bottom:5px}}\n"] }]
2707
+ }], ctorParameters: () => [{ type: VisualiserGraphService }, { type: i2.ContextMenuService }, { type: DagreNodesOnlyLayout }, { type: DexieService }], propDecorators: { graphElement: [{
1180
2708
  type: ViewChild,
1181
2709
  args: ['svgId']
2710
+ }], contextMenu: [{
2711
+ type: ViewChild,
2712
+ args: [ContextMenusComponent]
1182
2713
  }], saveGraphDataEvent: [{
1183
2714
  type: Output
2715
+ }], readOnly: [{
2716
+ type: Input
1184
2717
  }], zoom: [{
1185
2718
  type: Input
2719
+ }], controls: [{
2720
+ type: Input
1186
2721
  }], zoomToFit: [{
1187
2722
  type: Input
2723
+ }], modalsComponent: [{
2724
+ type: ViewChild,
2725
+ args: [ModalsComponent]
1188
2726
  }], data: [{
1189
2727
  type: Input
1190
2728
  }] } });
1191
2729
 
1192
2730
  class NgxRelationshipVisualiserModule {
1193
2731
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxRelationshipVisualiserModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1194
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: NgxRelationshipVisualiserModule, declarations: [VisualiserGraphComponent], imports: [BrowserModule], exports: [VisualiserGraphComponent] });
1195
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxRelationshipVisualiserModule, imports: [BrowserModule] });
2732
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: NgxRelationshipVisualiserModule, declarations: [VisualiserGraphComponent,
2733
+ ContextMenusComponent,
2734
+ ModalsComponent], imports: [BrowserModule,
2735
+ ReactiveFormsModule, i1.ModalModule, i2.ContextMenuModule, NgSelectModule,
2736
+ FormsModule], exports: [VisualiserGraphComponent] });
2737
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxRelationshipVisualiserModule, imports: [BrowserModule,
2738
+ ReactiveFormsModule,
2739
+ ModalModule.forRoot(),
2740
+ ContextMenuModule.forRoot({ useBootstrap4: true }),
2741
+ NgSelectModule,
2742
+ FormsModule] });
1196
2743
  }
1197
2744
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxRelationshipVisualiserModule, decorators: [{
1198
2745
  type: NgModule,
1199
2746
  args: [{
1200
2747
  declarations: [
1201
- VisualiserGraphComponent
2748
+ VisualiserGraphComponent,
2749
+ ContextMenusComponent,
2750
+ ModalsComponent
1202
2751
  ],
1203
2752
  imports: [
1204
- BrowserModule
2753
+ BrowserModule,
2754
+ ReactiveFormsModule,
2755
+ ModalModule.forRoot(),
2756
+ ContextMenuModule.forRoot({ useBootstrap4: true }),
2757
+ NgSelectModule,
2758
+ FormsModule
1205
2759
  ],
1206
2760
  exports: [VisualiserGraphComponent]
1207
2761
  }]