Committed by
Gerrit Code Review
Added Breadcrumbs module
Change-Id: Iba897409f728ffa7e58681788c63e3c251cd8358
Showing
8 changed files
with
146 additions
and
7 deletions
... | @@ -50,3 +50,19 @@ | ... | @@ -50,3 +50,19 @@ |
50 | text-decoration: underline; | 50 | text-decoration: underline; |
51 | cursor: pointer; | 51 | cursor: pointer; |
52 | } | 52 | } |
53 | + | ||
54 | +#breadcrumbs { | ||
55 | + position: absolute; | ||
56 | + padding: 10px 30px; | ||
57 | + top: 54px; | ||
58 | + width: 100%; | ||
59 | +} | ||
60 | + | ||
61 | +#breadcrumbs .breadcrumb { | ||
62 | + display: inline-block; | ||
63 | + margin-right: 20px; | ||
64 | +} | ||
65 | + | ||
66 | +.floatpanel { | ||
67 | + top: 104px; | ||
68 | +} | ... | ... |
... | @@ -28,7 +28,7 @@ | ... | @@ -28,7 +28,7 @@ |
28 | fs, mast, ks, zs, | 28 | fs, mast, ks, zs, |
29 | gs, ms, sus, flash, | 29 | gs, ms, sus, flash, |
30 | wss, ps, th, | 30 | wss, ps, th, |
31 | - t2es, t2fs, t2is; | 31 | + t2es, t2fs, t2is, t2bcs; |
32 | 32 | ||
33 | // DOM elements | 33 | // DOM elements |
34 | var ovtopo2, svg, defs, zoomLayer, mapG, spriteG, forceG, noDevsLayer; | 34 | var ovtopo2, svg, defs, zoomLayer, mapG, spriteG, forceG, noDevsLayer; |
... | @@ -92,12 +92,13 @@ | ... | @@ -92,12 +92,13 @@ |
92 | 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService', | 92 | 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService', |
93 | 'WebSocketService', 'PrefsService', 'ThemeService', | 93 | 'WebSocketService', 'PrefsService', 'ThemeService', |
94 | 'Topo2EventService', 'Topo2ForceService', 'Topo2InstanceService', | 94 | 'Topo2EventService', 'Topo2ForceService', 'Topo2InstanceService', |
95 | + 'Topo2BreadcrumbService', | ||
95 | 96 | ||
96 | function (_$scope_, _$log_, _$loc_, | 97 | function (_$scope_, _$log_, _$loc_, |
97 | _fs_, _mast_, _ks_, _zs_, | 98 | _fs_, _mast_, _ks_, _zs_, |
98 | _gs_, _ms_, _sus_, _flash_, | 99 | _gs_, _ms_, _sus_, _flash_, |
99 | _wss_, _ps_, _th_, | 100 | _wss_, _ps_, _th_, |
100 | - _t2es_, _t2fs_, _t2is_) { | 101 | + _t2es_, _t2fs_, _t2is_, _t2bcs_) { |
101 | 102 | ||
102 | var params = _$loc_.search(), | 103 | var params = _$loc_.search(), |
103 | projection, | 104 | projection, |
... | @@ -134,6 +135,7 @@ | ... | @@ -134,6 +135,7 @@ |
134 | t2es = _t2es_; | 135 | t2es = _t2es_; |
135 | t2fs = _t2fs_; | 136 | t2fs = _t2fs_; |
136 | t2is = _t2is_; | 137 | t2is = _t2is_; |
138 | + t2bcs = _t2bcs_; | ||
137 | 139 | ||
138 | // capture selected intent parameters (if they are set in the | 140 | // capture selected intent parameters (if they are set in the |
139 | // query string) so that the traffic overlay can highlight | 141 | // query string) so that the traffic overlay can highlight |
... | @@ -179,6 +181,7 @@ | ... | @@ -179,6 +181,7 @@ |
179 | // initialize the force layout, ready to render the topology | 181 | // initialize the force layout, ready to render the topology |
180 | forceG = zoomLayer.append('g').attr('id', 'topo-force'); | 182 | forceG = zoomLayer.append('g').attr('id', 'topo-force'); |
181 | t2fs.init(svg, forceG, uplink, dim); | 183 | t2fs.init(svg, forceG, uplink, dim); |
184 | + t2bcs.init(); | ||
182 | 185 | ||
183 | 186 | ||
184 | // =-=-=-=-=-=-=-=- | 187 | // =-=-=-=-=-=-=-=- | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
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 | + */ | ||
16 | + | ||
17 | +/* | ||
18 | + ONOS GUI -- Topology Breadcrumb Module. | ||
19 | + Module that renders the breadcrumbs for regions | ||
20 | + */ | ||
21 | + | ||
22 | + (function () { | ||
23 | + 'use strict'; | ||
24 | + | ||
25 | + var $log, wss; | ||
26 | + | ||
27 | + var breadcrumbContainer, | ||
28 | + breadcrumbs; | ||
29 | + | ||
30 | + function init() { | ||
31 | + | ||
32 | + breadcrumbs = []; | ||
33 | + breadcrumbContainer = d3.select('#breadcrumbs'); | ||
34 | + render(); | ||
35 | + } | ||
36 | + | ||
37 | + function addBreadcrumb(crumbs) { | ||
38 | + | ||
39 | + // If `crumbs` is an array, merge with breadcrumbs; | ||
40 | + if (crumbs.length) { | ||
41 | + breadcrumbs = breadcrumbs.concat(crumbs); | ||
42 | + } else { | ||
43 | + breadcrumbs.push(crumbs); | ||
44 | + } | ||
45 | + | ||
46 | + render(); | ||
47 | + } | ||
48 | + | ||
49 | + function navigateToRegion(data, index) { | ||
50 | + | ||
51 | + if (index === breadcrumbs.length - 1) { | ||
52 | + return; | ||
53 | + } | ||
54 | + | ||
55 | + // Remove breadcrumbs after index; | ||
56 | + breadcrumbs.splice(index + 1); | ||
57 | + | ||
58 | + wss.sendEvent('topo2navRegion', { | ||
59 | + dir: 'up', | ||
60 | + rid: data.id | ||
61 | + }); | ||
62 | + | ||
63 | + render(); | ||
64 | + } | ||
65 | + | ||
66 | + function render() { | ||
67 | + | ||
68 | + var selection = breadcrumbContainer.selectAll('.breadcrumb') | ||
69 | + .data(breadcrumbs); | ||
70 | + | ||
71 | + selection.enter() | ||
72 | + .append('div') | ||
73 | + .attr('class', 'breadcrumb') | ||
74 | + .on('click', navigateToRegion) | ||
75 | + .append('text') | ||
76 | + .text(function (d) { | ||
77 | + return d.name; | ||
78 | + }); | ||
79 | + | ||
80 | + selection.exit() | ||
81 | + .transition() | ||
82 | + .duration(200) | ||
83 | + .style('opacity', 0) | ||
84 | + .remove(); | ||
85 | + } | ||
86 | + | ||
87 | + angular.module('ovTopo2') | ||
88 | + .factory('Topo2BreadcrumbService', | ||
89 | + ['$log', 'WebSocketService', | ||
90 | + | ||
91 | + function (_$log_, _wss_) { | ||
92 | + | ||
93 | + $log = _$log_; | ||
94 | + wss = _wss_; | ||
95 | + | ||
96 | + return { | ||
97 | + init: init, | ||
98 | + addBreadcrumb: addBreadcrumb | ||
99 | + }; | ||
100 | + }]); | ||
101 | + | ||
102 | +})(); |
... | @@ -107,7 +107,7 @@ | ... | @@ -107,7 +107,7 @@ |
107 | id = "127.0.0.1", // TODO: This should be from node.master | 107 | id = "127.0.0.1", // TODO: This should be from node.master |
108 | otag = o ? 'online' : 'offline'; | 108 | otag = o ? 'online' : 'offline'; |
109 | return o ? sus.cat7().getColor(id, 0, ts.theme()) | 109 | return o ? sus.cat7().getColor(id, 0, ts.theme()) |
110 | - : dColTheme[ts.theme()][otag]; | 110 | + : '#ff0000'; |
111 | } | 111 | } |
112 | 112 | ||
113 | function setDeviceColor() { | 113 | function setDeviceColor() { | ... | ... |
... | @@ -60,7 +60,7 @@ | ... | @@ -60,7 +60,7 @@ |
60 | linkLabel, | 60 | linkLabel, |
61 | node; | 61 | node; |
62 | 62 | ||
63 | - var $log, wss, t2is, t2rs, t2ls, t2vs; | 63 | + var $log, wss, t2is, t2rs, t2ls, t2vs, t2bcs; |
64 | var svg, forceG, uplink, dim, opts; | 64 | var svg, forceG, uplink, dim, opts; |
65 | 65 | ||
66 | // ========================== Helper Functions | 66 | // ========================== Helper Functions |
... | @@ -155,6 +155,7 @@ | ... | @@ -155,6 +155,7 @@ |
155 | 155 | ||
156 | function currentLayout(data) { | 156 | function currentLayout(data) { |
157 | $log.debug('>> topo2CurrentLayout event:', data); | 157 | $log.debug('>> topo2CurrentLayout event:', data); |
158 | + t2bcs.addBreadcrumb(data.crumbs); | ||
158 | } | 159 | } |
159 | 160 | ||
160 | function currentRegion(data) { | 161 | function currentRegion(data) { |
... | @@ -232,8 +233,8 @@ | ... | @@ -232,8 +233,8 @@ |
232 | angular.module('ovTopo2') | 233 | angular.module('ovTopo2') |
233 | .factory('Topo2ForceService', | 234 | .factory('Topo2ForceService', |
234 | ['$log', 'WebSocketService', 'Topo2InstanceService', 'Topo2RegionService', | 235 | ['$log', 'WebSocketService', 'Topo2InstanceService', 'Topo2RegionService', |
235 | - 'Topo2LayoutService', 'Topo2ViewService', | 236 | + 'Topo2LayoutService', 'Topo2ViewService', 'Topo2BreadcrumbService', |
236 | - function (_$log_, _wss_, _t2is_, _t2rs_, _t2ls_, _t2vs_) { | 237 | + function (_$log_, _wss_, _t2is_, _t2rs_, _t2ls_, _t2vs_, _t2bcs_) { |
237 | 238 | ||
238 | $log = _$log_; | 239 | $log = _$log_; |
239 | wss = _wss_; | 240 | wss = _wss_; |
... | @@ -241,6 +242,7 @@ | ... | @@ -241,6 +242,7 @@ |
241 | t2rs = _t2rs_; | 242 | t2rs = _t2rs_; |
242 | t2ls = _t2ls_; | 243 | t2ls = _t2ls_; |
243 | t2vs = _t2vs_; | 244 | t2vs = _t2vs_; |
245 | + t2bcs = _t2bcs_; | ||
244 | 246 | ||
245 | return { | 247 | return { |
246 | 248 | ... | ... |
... | @@ -127,6 +127,7 @@ | ... | @@ -127,6 +127,7 @@ |
127 | 127 | ||
128 | <!-- Under development for Region support. --> | 128 | <!-- Under development for Region support. --> |
129 | <script src="app/view/topo2/topo2.js"></script> | 129 | <script src="app/view/topo2/topo2.js"></script> |
130 | + <script src="app/view/topo2/topo2Breadcrumb.js"></script> | ||
130 | <script src="app/view/topo2/topo2Collection.js"></script> | 131 | <script src="app/view/topo2/topo2Collection.js"></script> |
131 | <script src="app/view/topo2/topo2D3.js"></script> | 132 | <script src="app/view/topo2/topo2D3.js"></script> |
132 | <script src="app/view/topo2/topo2Device.js"></script> | 133 | <script src="app/view/topo2/topo2Device.js"></script> |
... | @@ -231,6 +232,7 @@ | ... | @@ -231,6 +232,7 @@ |
231 | ng-controller="NavCtrl as navCtrl" | 232 | ng-controller="NavCtrl as navCtrl" |
232 | ng-include="'nav.html'"></div> | 233 | ng-include="'nav.html'"></div> |
233 | 234 | ||
235 | + <div id="breadcrumbs"></div> | ||
234 | <div id="floatpanels"></div> | 236 | <div id="floatpanels"></div> |
235 | <div id="alerts"></div> | 237 | <div id="alerts"></div> |
236 | <div id="tooltip"></div> | 238 | <div id="tooltip"></div> | ... | ... |
... | @@ -4,6 +4,20 @@ | ... | @@ -4,6 +4,20 @@ |
4 | "id": "_default_", | 4 | "id": "_default_", |
5 | "parent": "", | 5 | "parent": "", |
6 | "region": "", | 6 | "region": "", |
7 | - "regionName": "" | 7 | + "regionName": "", |
8 | + "crumbs": [ | ||
9 | + { | ||
10 | + "id": "(root)", | ||
11 | + "name": "(root)" | ||
12 | + }, | ||
13 | + { | ||
14 | + "id": "r1", | ||
15 | + "name": "Region-One" | ||
16 | + }, | ||
17 | + { | ||
18 | + "id": "r3", | ||
19 | + "name": "Region-Three" | ||
20 | + } | ||
21 | + ] | ||
8 | } | 22 | } |
9 | } | 23 | } | ... | ... |
-
Please register or login to post a comment