Topo2: unpin nodes when a node is hovered and 'U' us pressed

Change-Id: I5f25243073ea7e32354c4777576ad402e6124296
This commit is contained in:
Steven Burrows 2017-03-10 16:00:31 +00:00 committed by Simon Hunt
parent 69ef9dde6a
commit b11a8b834a
10 changed files with 49 additions and 35 deletions

View File

@ -187,12 +187,16 @@
fill: #454545; fill: #454545;
} }
#ov-topo2 svg .node.selected .node-container { #ov-topo2 svg .node.selected .node-container {
stroke-width: 2.0; stroke-width: 2.0;
stroke: #009fdb; stroke: #009fdb;
} }
#ov-topo2 svg .node.hovered .node-container {
stroke-width: 2.0;
stroke: #454545;
}
/* Badges */ /* Badges */
/* (... works for bothand dark themes...) */ /* (... works for bothand dark themes...) */
#ov-topo2 svg .node .badge circle { #ov-topo2 svg .node .badge circle {

View File

@ -74,6 +74,7 @@
}, },
onClick: function () { onClick: function () {
if (d3.event.defaultPrevented) return;
var selected = this.select(d3.event); var selected = this.select(d3.event);
if (_.isArray(selected) && selected.length > 0) { if (_.isArray(selected) && selected.length > 0) {

View File

@ -84,7 +84,6 @@
function currentRegion(data) { function currentRegion(data) {
$log.debug('>> topo2CurrentRegion event:', data); $log.debug('>> topo2CurrentRegion event:', data);
t2rs.addRegion(data); t2rs.addRegion(data);
t2ls.createForceLayout();
} }
function topo2PeerRegions(data) { function topo2PeerRegions(data) {
@ -169,14 +168,16 @@
} }
function unpin() { function unpin() {
var hovered = t2rs.filterRegionNodes(function (model) { var hovered = t2rs.filterRegionNodes(function (model) {
return model.get('hovered'); return model.get('hovered');
}); });
angular.forEach(hovered, function (model) { angular.forEach(hovered, function (model) {
model.fixed = false; model.fix(false);
model.el.classed('fixed', false);
}); });
t2ls.start();
} }
angular.module('ovTopo2') angular.module('ovTopo2')

View File

@ -68,6 +68,7 @@
} }
}, },
onClick: function () { onClick: function () {
if (d3.event.defaultPrevented) return;
var selected = this.select(d3.select); var selected = this.select(d3.select);
if (selected.length > 0) { if (selected.length > 0) {

View File

@ -33,22 +33,19 @@
// note: key is node.class // note: key is node.class
device: -8000, device: -8000,
host: -20000, host: -20000,
region: -5000, region: -8000,
_def_: -12000 _def_: -12000
}, },
linkDistance: { linkDistance: {
// note: key is link.type // note: key is link.type
direct: 100, direct: 100,
optical: 120, optical: 120,
UiEdgeLink: 30, UiEdgeLink: 100,
_def_: 50 _def_: 50
}, },
linkStrength: { linkStrength: {
// note: key is link.type // note: key is link.type
// range: {0.0 ... 1.0} // range: {0.0 ... 1.0}
direct: 1.0,
optical: 1.0,
UiEdgeLink: 15.0,
_def_: 1.0 _def_: 1.0
} }
}; };
@ -245,7 +242,8 @@
entering.filter('.device').each(t2d3.nodeEnter); entering.filter('.device').each(t2d3.nodeEnter);
entering.filter('.sub-region').each(t2d3.nodeEnter); entering.filter('.sub-region').each(t2d3.nodeEnter);
entering.filter('.host').each(t2d3.hostEnter); entering.filter('.host').each(t2d3.nodeEnter);
entering.filter('.peer-region').each(t2d3.nodeEnter);
}, },
updateLinks: function () { updateLinks: function () {
@ -267,7 +265,7 @@
'stroke-width': linkConfig.inWidth 'stroke-width': linkConfig.inWidth
}); });
entering.each(t2d3.linkEntering); entering.each(t2d3.nodeEnter);
// operate on exiting links: // operate on exiting links:
this.link.exit() this.link.exit()
@ -333,8 +331,7 @@
}, },
atDragEnd: function (d) { atDragEnd: function (d) {
// once we've finished moving, pin the node in position // once we've finished moving, pin the node in position
d.fixed = true; d.fix(true);
d3.select(this).classed('fixed', true);
instance.sendUpdateMeta(d); instance.sendUpdateMeta(d);
t2ss.clickConsumed(true); t2ss.clickConsumed(true);
}, },

View File

@ -109,10 +109,14 @@
}); });
}, },
mouseoverHandler: function () { mouseoverHandler: function () {
this.set('hovered', true, { silent: true }); this.set('hovered', true);
}, },
mouseoutHandler: function () { mouseoutHandler: function () {
this.set('hovered', false, { silent: true }); this.set('hovered', false);
},
fix: function (fixed) {
this.set({ fixed: fixed });
this.fixed = fixed;
}, },
icon: function () { icon: function () {
return 'unknown'; return 'unknown';
@ -195,7 +199,9 @@
this.get('type'), this.get('type'),
{ {
online: this.get('online'), online: this.get('online'),
selected: this.get('selected') selected: this.get('selected'),
hovered: this.get('hovered'),
fixed: this.get('fixed')
} }
); );
}, },

View File

@ -43,7 +43,7 @@
// else if we have [x,y] cached in meta data, use that... // else if we have [x,y] cached in meta data, use that...
if (x !== undefined && y !== undefined) { if (x !== undefined && y !== undefined) {
node.fixed = true; node.fix(true);
node.px = node.x = x; node.px = node.x = x;
node.py = node.y = y; node.py = node.y = y;
return; return;
@ -100,7 +100,7 @@
} }
coord = coordFromLngLat(loc); coord = coordFromLngLat(loc);
el.fixed = true; el.fix(true);
el.x = el.px = coord[0]; el.x = el.px = coord[0];
el.y = el.py = coord[1]; el.y = el.py = coord[1];
@ -114,7 +114,7 @@
} }
coord = coordFromXY(loc); coord = coordFromXY(loc);
el.fixed = true; el.fix(true);
el.x = el.px = coord[0]; el.x = el.px = coord[0];
el.y = el.py = coord[1]; el.y = el.py = coord[1];

View File

@ -37,7 +37,8 @@
'Topo2HostService', 'Topo2LinkService', 'Topo2ZoomService', 'Topo2DetailsPanelService', 'Topo2HostService', 'Topo2LinkService', 'Topo2ZoomService', 'Topo2DetailsPanelService',
'Topo2BreadcrumbService', 'Topo2ViewController', 'Topo2SpriteLayerService', 'Topo2MapService', 'Topo2BreadcrumbService', 'Topo2ViewController', 'Topo2SpriteLayerService', 'Topo2MapService',
'Topo2MapConfigService', 'Topo2MapConfigService',
function ($log, _Model_, t2sr, t2ds, t2hs, t2ls, t2zs, t2dps, t2bcs, ViewController, t2sls, t2ms, t2mcs) { function ($log, _Model_, t2sr, t2ds, t2hs, t2ls, t2zs, t2dps, t2bcs, ViewController,
t2sls, t2ms, t2mcs) {
Model = _Model_; Model = _Model_;
@ -46,6 +47,13 @@
instance = this; instance = this;
this.model = null; this.model = null;
this.bgRendered = false; this.bgRendered = false;
var RegionModel = Model.extend({
findNodeById: this.findNodeById,
nodes: this.regionNodes.bind(this)
});
this.model = new RegionModel();
}, },
backgroundRendered: function () { backgroundRendered: function () {
this.bgRendered = true; this.bgRendered = true;
@ -64,17 +72,9 @@
}, },
startRegion: function () { startRegion: function () {
var RegionModel = Model.extend({
findNodeById: this.findNodeById,
nodes: this.regionNodes.bind(this)
});
this.model = new RegionModel({
id: this.regionData.id,
layerOrder: this.regionData.layerOrder
});
this.model.set({ this.model.set({
id: this.regionData.id,
layerOrder: this.regionData.layerOrder,
subregions: t2sr.createSubRegionCollection(this.regionData.subregions, this), subregions: t2sr.createSubRegionCollection(this.regionData.subregions, this),
devices: t2ds.createDeviceCollection(this.regionData.devices, this), devices: t2ds.createDeviceCollection(this.regionData.devices, this),
hosts: t2hs.createHostCollection(this.regionData.hosts, this), hosts: t2hs.createHostCollection(this.regionData.hosts, this),
@ -90,7 +90,7 @@
t2bcs.hide(); t2bcs.hide();
} }
// this.layout.update(); this.layout.createForceLayout();
}, },
clear: function () { clear: function () {
@ -122,7 +122,6 @@
this.model.get('subregions').get(id); this.model.get('subregions').get(id);
}, },
regionNodes: function () { regionNodes: function () {
if (this.model) { if (this.model) {
return [].concat( return [].concat(
this.model.get('devices').models, this.model.get('devices').models,
@ -130,11 +129,10 @@
this.model.get('subregions').models this.model.get('subregions').models
); );
} }
return []; return [];
}, },
regionLinks: function () { regionLinks: function () {
return (this.model) ? this.model.get('links').models : []; return this.model.get('links').models;
}, },
getLink: function (linkId) { getLink: function (linkId) {
return this.model.get('links').get(linkId); return this.model.get('links').get(linkId);

View File

@ -122,7 +122,11 @@
return mdist(p, m) <= proximity; return mdist(p, m) <= proximity;
} }
var links = t2rs.regionLinks(); var links = [];
if (t2rs.model.get('links')) {
links = (t2rs.backgroundRendered) ? t2rs.regionLinks() : [];
}
if (links.length) { if (links.length) {
minDist = proximity * 2; minDist = proximity * 2;

View File

@ -68,6 +68,8 @@
return remappedDeviceTypes[type] || type || 'm_cloud'; return remappedDeviceTypes[type] || type || 'm_cloud';
}, },
onClick: function () { onClick: function () {
if (d3.event.defaultPrevented) return;
var selected = this.select(d3.event); var selected = this.select(d3.event);
if (selected.length > 0) { if (selected.length > 0) {