blob: 48d973b335d994e72d6093eb35db8b8fd60daed8 [file] [log] [blame]
Sean Condonf4f54a12018-10-10 23:25:46 +01001/*
Sean Condon91481822019-01-01 13:56:14 +00002 * Copyright 2019-present Open Networking Foundation
Sean Condonf4f54a12018-10-10 23:25:46 +01003 *
4 * Licensed under the Apache License, Version 2.0 (the 'License');
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an 'AS IS' BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Sean Condon0c577f62018-11-18 22:40:05 +000016import {
17 ChangeDetectionStrategy,
18 ChangeDetectorRef,
19 Component,
20 EventEmitter,
21 HostListener,
22 Input,
23 OnChanges,
24 OnInit,
Sean Condon021f0fa2018-12-06 23:31:11 -080025 Output,
26 QueryList,
Sean Condon50855cf2018-12-23 15:37:42 +000027 SimpleChange,
Sean Condon021f0fa2018-12-06 23:31:11 -080028 SimpleChanges,
29 ViewChildren
Sean Condon0c577f62018-11-18 22:40:05 +000030} from '@angular/core';
Sean Condon1ae15802019-03-02 09:07:18 +000031import {
32 LocMeta,
33 LogService,
34 MetaUi,
35 WebSocketService,
36 ZoomUtils
37} from 'gui2-fw-lib';
Sean Condon0c577f62018-11-18 22:40:05 +000038import {
39 Device,
40 ForceDirectedGraph,
Sean Condon50855cf2018-12-23 15:37:42 +000041 Host,
42 HostLabelToggle,
Sean Condon0c577f62018-11-18 22:40:05 +000043 LabelToggle,
44 LayerType,
Sean Condon50855cf2018-12-23 15:37:42 +000045 Link,
46 LinkHighlight,
Sean Condon1ae15802019-03-02 09:07:18 +000047 Location,
Sean Condon50855cf2018-12-23 15:37:42 +000048 ModelEventMemo,
49 ModelEventType,
Sean Condon0c577f62018-11-18 22:40:05 +000050 Region,
51 RegionLink,
Sean Condon50855cf2018-12-23 15:37:42 +000052 SubRegion,
53 UiElement
Sean Condon0c577f62018-11-18 22:40:05 +000054} from './models';
Sean Condon50855cf2018-12-23 15:37:42 +000055import {
56 DeviceNodeSvgComponent,
57 HostNodeSvgComponent,
58 LinkSvgComponent
59} from './visuals';
Sean Condonee545762019-03-09 10:43:58 +000060import {LocationType} from '../backgroundsvg/backgroundsvg.component';
Sean Condon71910542019-02-16 18:16:42 +000061
62interface UpdateMeta {
63 id: string;
64 class: string;
65 memento: MetaUi;
66}
Sean Condonaa4366d2018-11-02 14:29:01 +000067
Sean Condonf4f54a12018-10-10 23:25:46 +010068/**
69 * ONOS GUI -- Topology Forces Graph Layer View.
Sean Condon0c577f62018-11-18 22:40:05 +000070 *
71 * The regionData is set by Topology Service on WebSocket topo2CurrentRegion callback
72 * This drives the whole Force graph
Sean Condonf4f54a12018-10-10 23:25:46 +010073 */
74@Component({
75 selector: '[onos-forcesvg]',
76 templateUrl: './forcesvg.component.html',
Sean Condon0c577f62018-11-18 22:40:05 +000077 styleUrls: ['./forcesvg.component.css'],
78 changeDetection: ChangeDetectionStrategy.OnPush,
Sean Condonf4f54a12018-10-10 23:25:46 +010079})
Sean Condon0c577f62018-11-18 22:40:05 +000080export class ForceSvgComponent implements OnInit, OnChanges {
Sean Condon021f0fa2018-12-06 23:31:11 -080081 @Input() deviceLabelToggle: LabelToggle = LabelToggle.NONE;
82 @Input() hostLabelToggle: HostLabelToggle = HostLabelToggle.NONE;
Sean Condonb2c483c2019-01-16 20:28:55 +000083 @Input() showHosts: boolean = false;
84 @Input() highlightPorts: boolean = true;
85 @Input() onosInstMastership: string = '';
86 @Input() visibleLayer: LayerType = LayerType.LAYER_DEFAULT;
87 @Input() selectedLink: RegionLink = null;
Sean Condon1ae15802019-03-02 09:07:18 +000088 @Input() scale: number = 1;
Sean Condon0c577f62018-11-18 22:40:05 +000089 @Input() regionData: Region = <Region>{devices: [ [], [], [] ], hosts: [ [], [], [] ], links: []};
Sean Condonb2c483c2019-01-16 20:28:55 +000090 @Output() linkSelected = new EventEmitter<RegionLink>();
91 @Output() selectedNodeEvent = new EventEmitter<UiElement>();
Sean Condon021f0fa2018-12-06 23:31:11 -080092 private graph: ForceDirectedGraph;
Sean Condon0c577f62018-11-18 22:40:05 +000093 private _options: { width, height } = { width: 800, height: 600 };
Sean Condonf4f54a12018-10-10 23:25:46 +010094
Sean Condon021f0fa2018-12-06 23:31:11 -080095 // References to the children of this component - these are created in the
96 // template view with the *ngFor and we get them by a query here
Sean Condon0c577f62018-11-18 22:40:05 +000097 @ViewChildren(DeviceNodeSvgComponent) devices: QueryList<DeviceNodeSvgComponent>;
Sean Condon021f0fa2018-12-06 23:31:11 -080098 @ViewChildren(HostNodeSvgComponent) hosts: QueryList<HostNodeSvgComponent>;
Sean Condon50855cf2018-12-23 15:37:42 +000099 @ViewChildren(LinkSvgComponent) links: QueryList<LinkSvgComponent>;
Sean Condonf4f54a12018-10-10 23:25:46 +0100100
Sean Condon0c577f62018-11-18 22:40:05 +0000101 constructor(
102 protected log: LogService,
Sean Condon71910542019-02-16 18:16:42 +0000103 private ref: ChangeDetectorRef,
104 protected wss: WebSocketService
Sean Condon0c577f62018-11-18 22:40:05 +0000105 ) {
106 this.selectedLink = null;
107 this.log.debug('ForceSvgComponent constructed');
108 }
109
110 /**
Sean Condon021f0fa2018-12-06 23:31:11 -0800111 * Utility for extracting a node name from an endpoint string
112 * In some cases - have to remove the port number from the end of a device
113 * name
114 * @param endPtStr The end point name
115 */
116 private static extractNodeName(endPtStr: string): string {
117 const slash: number = endPtStr.indexOf('/');
118 if (slash === -1) {
119 return endPtStr;
120 } else {
121 const afterSlash = endPtStr.substr(slash + 1);
122 if (afterSlash === 'None') {
123 return endPtStr;
124 } else {
125 return endPtStr.substr(0, slash);
126 }
127 }
128 }
129
Sean Condonee545762019-03-09 10:43:58 +0000130 /**
131 * Recursive method to compare 2 objects attribute by attribute and update
132 * the first where a change is detected
133 * @param existingNode 1st object
134 * @param updatedNode 2nd object
135 */
136 private static updateObject(existingNode: Object, updatedNode: Object): number {
137 let changed: number = 0;
138 for (const key of Object.keys(updatedNode)) {
139 const o = updatedNode[key];
140 if (key === 'id') {
141 continue;
142 } else if (o && typeof o === 'object' && o.constructor === Object) {
143 changed += ForceSvgComponent.updateObject(existingNode[key], updatedNode[key]);
144 } else if (existingNode[key] !== updatedNode[key]) {
145 changed++;
146 existingNode[key] = updatedNode[key];
147 }
148 }
149 return changed;
150 }
151
Sean Condon021f0fa2018-12-06 23:31:11 -0800152 @HostListener('window:resize', ['$event'])
153 onResize(event) {
154 this.graph.initSimulation(this.options);
155 this.log.debug('Simulation reinit after resize', event);
156 }
157
158 /**
Sean Condon0c577f62018-11-18 22:40:05 +0000159 * After the component is initialized create the Force simulation
Sean Condon021f0fa2018-12-06 23:31:11 -0800160 * The list of devices, hosts and links will not have been receieved back
161 * from the WebSocket yet as this time - they will be updated later through
162 * ngOnChanges()
Sean Condon0c577f62018-11-18 22:40:05 +0000163 */
164 ngOnInit() {
165 // Receiving an initialized simulated graph from our custom d3 service
Sean Condon50855cf2018-12-23 15:37:42 +0000166 this.graph = new ForceDirectedGraph(this.options, this.log);
Sean Condon0c577f62018-11-18 22:40:05 +0000167
168 /** Binding change detection check on each tick
Sean Condon021f0fa2018-12-06 23:31:11 -0800169 * This along with an onPush change detection strategy should enforce
170 * checking only when relevant! This improves scripting computation
171 * duration in a couple of tests I've made, consistently. Also, it makes
172 * sense to avoid unnecessary checks when we are dealing only with
173 * simulations data binding.
Sean Condon0c577f62018-11-18 22:40:05 +0000174 */
175 this.graph.ticker.subscribe((simulation) => {
176 // this.log.debug("Force simulation has ticked", simulation);
177 this.ref.markForCheck();
178 });
179 this.log.debug('ForceSvgComponent initialized - waiting for nodes and links');
180
Sean Condon0c577f62018-11-18 22:40:05 +0000181 }
182
183 /**
Sean Condon021f0fa2018-12-06 23:31:11 -0800184 * When any one of the inputs get changed by a containing component, this
185 * gets called automatically. In addition this is called manually by
186 * topology.service when a response is received from the WebSocket from the
187 * server
Sean Condon0c577f62018-11-18 22:40:05 +0000188 *
189 * The Devices, Hosts and SubRegions are all added to the Node list for the simulation
190 * The Links are added to the Link list of the simulation.
191 * Before they are added the Links are associated with Nodes based on their endPt
192 *
193 * @param changes - a list of changed @Input(s)
194 */
195 ngOnChanges(changes: SimpleChanges) {
196 if (changes['regionData']) {
197 const devices: Device[] =
198 changes['regionData'].currentValue.devices[this.visibleLayerIdx()];
199 const hosts: Host[] =
200 changes['regionData'].currentValue.hosts[this.visibleLayerIdx()];
201 const subRegions: SubRegion[] = changes['regionData'].currentValue.subRegion;
202 this.graph.nodes = [];
203 if (devices) {
204 this.graph.nodes = devices;
205 }
206 if (hosts) {
207 this.graph.nodes = this.graph.nodes.concat(hosts);
208 }
209 if (subRegions) {
210 this.graph.nodes = this.graph.nodes.concat(subRegions);
211 }
212
Sean Condon71910542019-02-16 18:16:42 +0000213 // If a node has a fixed location then assign it to fx and fy so
214 // that it doesn't get affected by forces
215 this.graph.nodes
216 .forEach((n) => {
217 const loc: Location = <Location>n['location'];
218 if (loc && loc.locType === LocationType.GEO) {
219 const position: MetaUi =
Sean Condon1ae15802019-03-02 09:07:18 +0000220 ZoomUtils.convertGeoToCanvas(
Sean Condon71910542019-02-16 18:16:42 +0000221 <LocMeta>{lng: loc.longOrX, lat: loc.latOrY});
222 n.fx = position.x;
223 n.fy = position.y;
224 this.log.debug('Found node', n.id, 'with', loc.locType);
225 }
226 });
227
Sean Condon0c577f62018-11-18 22:40:05 +0000228 // Associate the endpoints of each link with a real node
229 this.graph.links = [];
230 for (const linkIdx of Object.keys(this.regionData.links)) {
Sean Condon021f0fa2018-12-06 23:31:11 -0800231 const epA = ForceSvgComponent.extractNodeName(
232 this.regionData.links[linkIdx].epA);
Sean Condon0c577f62018-11-18 22:40:05 +0000233 this.regionData.links[linkIdx].source =
234 this.graph.nodes.find((node) =>
Sean Condon021f0fa2018-12-06 23:31:11 -0800235 node.id === epA);
236 const epB = ForceSvgComponent.extractNodeName(
237 this.regionData.links[linkIdx].epB);
Sean Condon0c577f62018-11-18 22:40:05 +0000238 this.regionData.links[linkIdx].target =
239 this.graph.nodes.find((node) =>
Sean Condon021f0fa2018-12-06 23:31:11 -0800240 node.id === epB);
Sean Condon0c577f62018-11-18 22:40:05 +0000241 this.regionData.links[linkIdx].index = Number(linkIdx);
242 }
243
244 this.graph.links = this.regionData.links;
245
246 this.graph.initSimulation(this.options);
247 this.graph.initNodes();
Sean Condon50855cf2018-12-23 15:37:42 +0000248 this.graph.initLinks();
Sean Condon0c577f62018-11-18 22:40:05 +0000249 this.log.debug('ForceSvgComponent input changed',
250 this.graph.nodes.length, 'nodes,', this.graph.links.length, 'links');
251 }
Sean Condon021f0fa2018-12-06 23:31:11 -0800252
Sean Condon021f0fa2018-12-06 23:31:11 -0800253 this.ref.markForCheck();
Sean Condon0c577f62018-11-18 22:40:05 +0000254 }
255
256 /**
257 * Get the index of LayerType so it can drive the visibility of nodes and
258 * hosts on layers
259 */
260 visibleLayerIdx(): number {
261 const layerKeys: string[] = Object.keys(LayerType);
262 for (const idx in layerKeys) {
263 if (LayerType[layerKeys[idx]] === this.visibleLayer) {
264 return Number(idx);
265 }
266 }
267 return -1;
268 }
269
270 selectLink(link: RegionLink): void {
271 this.selectedLink = link;
272 this.linkSelected.emit(link);
273 }
274
275 get options() {
276 return this._options = {
277 width: window.innerWidth,
278 height: window.innerHeight
279 };
280 }
281
Sean Condon021f0fa2018-12-06 23:31:11 -0800282 /**
283 * Iterate through all hosts and devices to deselect the previously selected
284 * node. The emit an event to the parent that lets it know the selection has
285 * changed.
286 * @param selectedNode the newly selected node
287 */
Sean Condon50855cf2018-12-23 15:37:42 +0000288 updateSelected(selectedNode: UiElement): void {
Sean Condon91481822019-01-01 13:56:14 +0000289 this.log.debug('Node or link selected', selectedNode ? selectedNode.id : 'none');
Sean Condon021f0fa2018-12-06 23:31:11 -0800290 this.devices
291 .filter((d) =>
292 selectedNode === undefined || d.device.id !== selectedNode.id)
293 .forEach((d) => d.deselect());
294 this.hosts
295 .filter((h) =>
296 selectedNode === undefined || h.host.id !== selectedNode.id)
297 .forEach((h) => h.deselect());
298
Sean Condon50855cf2018-12-23 15:37:42 +0000299 this.links
300 .filter((l) =>
301 selectedNode === undefined || l.link.id !== selectedNode.id)
302 .forEach((l) => l.deselect());
Sean Condon91481822019-01-01 13:56:14 +0000303 // Push the changes back up to parent (Topology Component)
Sean Condon021f0fa2018-12-06 23:31:11 -0800304 this.selectedNodeEvent.emit(selectedNode);
Sean Condon0c577f62018-11-18 22:40:05 +0000305 }
306
Sean Condon021f0fa2018-12-06 23:31:11 -0800307 /**
308 * We want to filter links to show only those not related to hosts if the
Sean Condon50855cf2018-12-23 15:37:42 +0000309 * 'showHosts' flag has been switched off. If 'showHosts' is true, then
Sean Condon021f0fa2018-12-06 23:31:11 -0800310 * display all links.
311 */
Sean Condon50855cf2018-12-23 15:37:42 +0000312 filteredLinks(): Link[] {
Sean Condon021f0fa2018-12-06 23:31:11 -0800313 return this.regionData.links.filter((h) =>
314 this.showHosts ||
315 ((<Host>h.source).nodeType !== 'host' &&
316 (<Host>h.target).nodeType !== 'host'));
Sean Condon0c577f62018-11-18 22:40:05 +0000317 }
Sean Condon50855cf2018-12-23 15:37:42 +0000318
319 /**
320 * When changes happen in the model, then model events are sent up through the
321 * Web Socket
322 * @param type - the type of the change
323 * @param memo - a qualifier on the type
324 * @param subject - the item that the update is for
325 * @param data - the new definition of the item
326 */
327 handleModelEvent(type: ModelEventType, memo: ModelEventMemo, subject: string, data: UiElement): void {
328 switch (type) {
329 case ModelEventType.DEVICE_ADDED_OR_UPDATED:
330 if (memo === ModelEventMemo.ADDED) {
331 this.regionData.devices[this.visibleLayerIdx()].push(<Device>data);
Sean Condonee545762019-03-09 10:43:58 +0000332 this.graph.nodes.push(<Device>data);
333 this.log.debug('Device added', (<Device>data).id);
Sean Condon50855cf2018-12-23 15:37:42 +0000334 } else if (memo === ModelEventMemo.UPDATED) {
335 const oldDevice: Device =
336 this.regionData.devices[this.visibleLayerIdx()]
337 .find((d) => d.id === subject);
Sean Condonee545762019-03-09 10:43:58 +0000338 const changes = ForceSvgComponent.updateObject(oldDevice, <Device>data);
339 if (changes > 0) {
340 this.log.debug('Device ', oldDevice.id, memo, ' - ', changes, 'changes');
341 }
Sean Condon50855cf2018-12-23 15:37:42 +0000342 } else {
343 this.log.warn('Device ', memo, ' - not yet implemented', data);
344 }
Sean Condon50855cf2018-12-23 15:37:42 +0000345 break;
346 case ModelEventType.HOST_ADDED_OR_UPDATED:
347 if (memo === ModelEventMemo.ADDED) {
348 this.regionData.hosts[this.visibleLayerIdx()].push(<Host>data);
Sean Condonee545762019-03-09 10:43:58 +0000349 this.graph.nodes.push(<Host>data);
350 this.log.debug('Host added', (<Host>data).id);
Sean Condon50855cf2018-12-23 15:37:42 +0000351 } else if (memo === ModelEventMemo.UPDATED) {
352 const oldHost: Host = this.regionData.hosts[this.visibleLayerIdx()]
353 .find((h) => h.id === subject);
Sean Condonee545762019-03-09 10:43:58 +0000354 const changes = ForceSvgComponent.updateObject(oldHost, <Host>data);
355 if (changes > 0) {
356 this.log.debug('Host ', oldHost.id, memo, ' - ', changes, 'changes');
357 }
Sean Condon50855cf2018-12-23 15:37:42 +0000358 } else {
359 this.log.warn('Host change', memo, ' - unexpected');
360 }
361 break;
362 case ModelEventType.DEVICE_REMOVED:
363 if (memo === ModelEventMemo.REMOVED || memo === undefined) {
364 const removeIdx: number =
365 this.regionData.devices[this.visibleLayerIdx()]
366 .findIndex((d) => d.id === subject);
Sean Condonee545762019-03-09 10:43:58 +0000367 this.regionData.devices[this.visibleLayerIdx()].splice(removeIdx, 1);
368 this.removeRelatedLinks(subject);
369 this.log.debug('Device ', subject, 'removed. Links', this.regionData.links);
Sean Condon50855cf2018-12-23 15:37:42 +0000370 } else {
371 this.log.warn('Device removed - unexpected memo', memo);
372 }
373 break;
374 case ModelEventType.HOST_REMOVED:
375 if (memo === ModelEventMemo.REMOVED || memo === undefined) {
376 const removeIdx: number =
377 this.regionData.hosts[this.visibleLayerIdx()]
378 .findIndex((h) => h.id === subject);
Sean Condonee545762019-03-09 10:43:58 +0000379 this.regionData.hosts[this.visibleLayerIdx()].splice(removeIdx, 1);
380 this.removeRelatedLinks(subject);
381 this.log.warn('Host ', subject, 'removed');
Sean Condon50855cf2018-12-23 15:37:42 +0000382 } else {
383 this.log.warn('Host removed - unexpected memo', memo);
384 }
385 break;
386 case ModelEventType.LINK_ADDED_OR_UPDATED:
Sean Condonee545762019-03-09 10:43:58 +0000387 if (memo === ModelEventMemo.ADDED &&
388 this.regionData.links.findIndex((l) => l.id === subject) === -1) {
389 const listLen = this.regionData.links.push(<RegionLink>data);
390 const epA = ForceSvgComponent.extractNodeName(
391 this.regionData.links[listLen - 1].epA);
392 this.regionData.links[listLen - 1].source =
393 this.graph.nodes.find((node) =>
394 node.id === epA);
395 const epB = ForceSvgComponent.extractNodeName(
396 this.regionData.links[listLen - 1].epB);
397 this.regionData.links[listLen - 1].target =
398 this.graph.nodes.find((node) =>
399 node.id === epB);
400 this.log.debug('Link added', subject);
401 } else if (memo === ModelEventMemo.UPDATED) {
402 const oldLink = this.regionData.links.find((l) => l.id === subject);
403 const changes = ForceSvgComponent.updateObject(oldLink, <RegionLink>data);
404 this.log.debug('Link ', subject, '. Updated', changes, 'items');
405 } else {
406 this.log.warn('Link added or updated - unexpected memo', memo);
407 }
Sean Condon50855cf2018-12-23 15:37:42 +0000408 break;
409 default:
410 this.log.error('Unexpected model event', type, 'for', subject);
411 }
Sean Condonee545762019-03-09 10:43:58 +0000412 this.ref.markForCheck();
413 this.graph.initSimulation(this.options);
Sean Condon50855cf2018-12-23 15:37:42 +0000414 }
415
Sean Condonee545762019-03-09 10:43:58 +0000416 private removeRelatedLinks(subject: string) {
417 const len = this.regionData.links.length;
418 for (let i = 0; i < len; i++) {
419 const linkIdx = this.regionData.links.findIndex((l) =>
420 (ForceSvgComponent.extractNodeName(l.epA) === subject ||
421 ForceSvgComponent.extractNodeName(l.epB) === subject));
422 if (linkIdx >= 0) {
423 this.regionData.links.splice(linkIdx, 1);
424 this.log.debug('Link ', linkIdx, 'removed on attempt', i);
425 }
Sean Condon50855cf2018-12-23 15:37:42 +0000426 }
427 }
428
429 /**
430 * When traffic monitoring is turned on (A key) highlights will be sent back
431 * from the WebSocket through the Traffic Service
432 * @param devices - an array of device highlights
433 * @param hosts - an array of host highlights
434 * @param links - an array of link highlights
435 */
436 handleHighlights(devices: Device[], hosts: Host[], links: LinkHighlight[]): void {
437
438 if (devices.length > 0) {
439 this.log.debug(devices.length, 'Devices highlighted');
440 devices.forEach((dh) => {
441 const deviceComponent: DeviceNodeSvgComponent = this.devices.find((d) => d.device.id === dh.id );
442 if (deviceComponent) {
443 deviceComponent.ngOnChanges(
444 {'deviceHighlight': new SimpleChange(<Device>{}, dh, true)}
445 );
446 this.log.debug('Highlighting device', deviceComponent.device.id);
447 } else {
448 this.log.warn('Device component not found', dh.id);
449 }
450 });
451 }
452 if (hosts.length > 0) {
453 this.log.debug(hosts.length, 'Hosts highlighted');
454 hosts.forEach((hh) => {
455 const hostComponent: HostNodeSvgComponent = this.hosts.find((h) => h.host.id === hh.id );
456 if (hostComponent) {
457 hostComponent.ngOnChanges(
458 {'hostHighlight': new SimpleChange(<Host>{}, hh, true)}
459 );
460 this.log.debug('Highlighting host', hostComponent.host.id);
461 }
462 });
463 }
464 if (links.length > 0) {
465 this.log.debug(links.length, 'Links highlighted');
466 links.forEach((lh) => {
467 const linkComponent: LinkSvgComponent = this.links.find((l) => l.link.id === lh.id );
468 if (linkComponent) { // A link might not be present is hosts viewing is switched off
469 linkComponent.ngOnChanges(
470 {'linkHighlight': new SimpleChange(<LinkHighlight>{}, lh, true)}
471 );
472 // this.log.debug('Highlighting link', linkComponent.link.id, lh.css, lh.label);
473 }
474 });
475 }
476 }
Sean Condon71910542019-02-16 18:16:42 +0000477
478 /**
479 * As nodes are dragged around the graph, their new location should be sent
480 * back to server
481 * @param klass The class of node e.g. 'host' or 'device'
482 * @param id - the ID of the node
483 * @param newLocation - the new Location of the node
484 */
485 nodeMoved(klass: string, id: string, newLocation: MetaUi) {
486 this.wss.sendEvent('updateMeta', <UpdateMeta>{
487 id: id,
488 class: klass,
489 memento: newLocation
490 });
491 this.log.debug(klass, id, 'has been moved to', newLocation);
492 }
Sean Condon1ae15802019-03-02 09:07:18 +0000493
494 resetNodeLocations() {
495 this.devices.forEach((d) => {
496 d.resetNodeLocation();
497 });
498 }
Sean Condonf4f54a12018-10-10 23:25:46 +0100499}
Sean Condon0c577f62018-11-18 22:40:05 +0000500