GUI2 Minor bug fixes to position of devices
Change-Id: I8fff317ea17a7b9311a2900ace75893b234f5633
diff --git a/web/gui2-fw-lib/BUILD b/web/gui2-fw-lib/BUILD
index a3e2b2c..2843d3d 100644
--- a/web/gui2-fw-lib/BUILD
+++ b/web/gui2-fw-lib/BUILD
@@ -255,6 +255,7 @@
"@nodejs//:bin/nodejs/bin/node",
"@nodejs//:bin/nodejs/bin/npm",
":onos-gui2-fw-npm-install",
+ "//web/gui:onos-gui-data-for-gui2",
":_root_level_files",
":_gui2_fw_lib_src",
":_gui2_fw_lib_tests",
@@ -274,6 +275,9 @@
" cd web/gui2-fw-lib &&" +
" jar xf ../../$(location :_gui2_fw_lib_tests) &&" +
" jar xf $$ROOT/$${INSTALL_FILES[0]} &&" +
+ # next 2 lines needed for png file referenced from mast.component.css
+ " unzip -q $$ROOT/$(location //web/gui:onos-gui-data-for-gui2) web/gui/src/main/webapp/data/img/dropdown-icon.png &&" +
+ " mv web/gui/src/main/webapp/data projects/gui2-fw-lib/src/lib/mast/mast/ &&" +
" chmod +x $$ROOT/web/gui2-fw-lib/node_modules/@angular/cli/bin/ng &&" +
" export PATH=$$ROOT/$$(dirname $${NODE}):$$ROOT/web/gui2-fw-lib/node_modules/@angular/cli/bin:$$PATH &&" +
" node -v > ../../$(location onos-gui2-fw-ng-ver.log) &&" +
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/mast/mast/mast.component.css b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/mast/mast/mast.component.css
index a767b2e..8e8c0f5 100644
--- a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/mast/mast/mast.component.css
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/mast/mast/mast.component.css
@@ -98,7 +98,7 @@
height: 7px;
width: 9px;
margin-left: 10px;
- background: url('/data/img/dropdown-icon.png') no-repeat;
+ background: url('data/img/dropdown-icon.png') no-repeat;
}
#mast .dropdown {
diff --git a/web/gui2/src/main/webapp/app/view/topology/layer/forcesvg/forcesvg.component.ts b/web/gui2/src/main/webapp/app/view/topology/layer/forcesvg/forcesvg.component.ts
index 48d973b..7185625 100644
--- a/web/gui2/src/main/webapp/app/view/topology/layer/forcesvg/forcesvg.component.ts
+++ b/web/gui2/src/main/webapp/app/view/topology/layer/forcesvg/forcesvg.component.ts
@@ -328,8 +328,25 @@
switch (type) {
case ModelEventType.DEVICE_ADDED_OR_UPDATED:
if (memo === ModelEventMemo.ADDED) {
- this.regionData.devices[this.visibleLayerIdx()].push(<Device>data);
+ const loc = (<Device>data).location;
+ if (loc && loc.locType === LocationType.GEO) {
+ const position =
+ ZoomUtils.convertGeoToCanvas(<LocMeta>{ lng: loc.longOrX, lat: loc.latOrY});
+ (<Device>data).fx = position.x;
+ (<Device>data).fy = position.y;
+ this.log.debug('Using long', loc.longOrX, 'lat', loc.latOrY, '(', position.x, position.y, ')');
+ } else if (loc && loc.locType === LocationType.GRID) {
+ (<Device>data).fx = loc.longOrX;
+ (<Device>data).fy = loc.latOrY;
+ this.log.debug('Using grid', loc.longOrX, loc.latOrY);
+ } else {
+ (<Device>data).fx = null;
+ (<Device>data).fy = null;
+ // (<Device>data).x = 500;
+ // (<Device>data).y = 500;
+ }
this.graph.nodes.push(<Device>data);
+ this.regionData.devices[this.visibleLayerIdx()].push(<Device>data);
this.log.debug('Device added', (<Device>data).id);
} else if (memo === ModelEventMemo.UPDATED) {
const oldDevice: Device =
@@ -411,6 +428,8 @@
}
this.ref.markForCheck();
this.graph.initSimulation(this.options);
+ this.graph.initNodes();
+ this.graph.initLinks();
}
private removeRelatedLinks(subject: string) {
diff --git a/web/gui2/src/main/webapp/app/view/topology/layer/forcesvg/models/node.ts b/web/gui2/src/main/webapp/app/view/topology/layer/forcesvg/models/node.ts
index af280a4..d3219b4 100644
--- a/web/gui2/src/main/webapp/app/view/topology/layer/forcesvg/models/node.ts
+++ b/web/gui2/src/main/webapp/app/view/topology/layer/forcesvg/models/node.ts
@@ -16,8 +16,7 @@
import * as d3 from 'd3';
import {LocationType} from '../../backgroundsvg/backgroundsvg.component';
import {LayerType, Location, NodeType, RegionProps} from './regions';
-import {LocMeta, LogService, MetaUi} from 'gui2-fw-lib';
-import {ZoomUtils} from 'gui2-fw-lib';
+import {MetaUi} from 'gui2-fw-lib';
export interface UiElement {
index?: number;
diff --git a/web/gui2/src/main/webapp/app/view/topology/topology/topology.component.html b/web/gui2/src/main/webapp/app/view/topology/topology/topology.component.html
index 8f3378f..b7526f1 100644
--- a/web/gui2/src/main/webapp/app/view/topology/topology/topology.component.html
+++ b/web/gui2/src/main/webapp/app/view/topology/topology/topology.component.html
@@ -81,7 +81,7 @@
[hostLabelToggle]="prefsState.hlbls"
[showHosts]="prefsState.hosts"
[highlightPorts]="prefsState.porthl"
- [scale]="1 / (2 * zoomDirective.zoomCached.sc)"
+ [scale]="1 / (1.5 * zoomDirective.zoomCached.sc)"
(selectedNodeEvent)="nodeSelected($event)">
<svg:desc>The Force SVG component - contains all the devices, hosts and links</svg:desc>
</svg:g>