Topo2: Refactored NavigateToRegion events
There was duplicated logic in Topo2Breadcrumb|SubRegion|PeerRegion. This has been refactored out so
all the logic for navigating to a new region is handled in a single place (Topo2RegionNavigationService).
Topo2RegionNavigationService is a pub/sub class. There are two reasons for this choice;
1. Topo2Layout needs to create the new force layout simulation for the region that is about to enter. Then it creates a transition between the old and new.
2. This will allow application developers to hook into the region:navigation event incase they need
to update the topology for the new region displayed.
Change-Id: Ie8dad531b50afe2e4735086395c1285fb982122e
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2PeerRegion.js b/web/gui/src/main/webapp/app/view/topo2/topo2PeerRegion.js
index 469e0a8..9e8ad31 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2PeerRegion.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2PeerRegion.js
@@ -41,9 +41,9 @@
angular.module('ovTopo2')
.factory('Topo2PeerRegionService', [
'WebSocketService', 'Topo2Collection', 'Topo2NodeModel',
- 'Topo2SubRegionPanelService',
+ 'Topo2SubRegionPanelService', 'Topo2RegionNavigationService',
- function (wss, _c_, NodeModel, t2srp) {
+ function (wss, _c_, NodeModel, t2srp, t2rns) {
Collection = _c_;
@@ -73,17 +73,8 @@
return remappedDeviceTypes[type] || type || 'm_cloud';
},
navigateToRegion: function () {
-
if (d3.event.defaultPrevented) return;
-
- wss.sendEvent('topo2navRegion', {
- rid: this.get('id')
- });
-
- var layout = this.collection.region.layout;
- layout.createForceElements();
- layout.transitionDownRegion();
-
+ t2rns.navigateToRegion(this.get('id'));
t2srp.hide();
}
});