Steven Burrows
Committed by Gerrit Code Review

Added Flash info for toggle summary keycommand

Clear and re-render summary panel on websocket update event
Added topo2 Panel Service

Change-Id: Ib9e6f887816d133af61cb0312c4dacd95641228d
...@@ -88,13 +88,15 @@ ...@@ -88,13 +88,15 @@
88 'WebSocketService', 'PrefsService', 'ThemeService', 88 'WebSocketService', 'PrefsService', 'ThemeService',
89 'Topo2EventService', 'Topo2ForceService', 'Topo2InstanceService', 89 'Topo2EventService', 'Topo2ForceService', 'Topo2InstanceService',
90 'Topo2BreadcrumbService', 'Topo2KeyCommandService', 'Topo2MapService', 90 'Topo2BreadcrumbService', 'Topo2KeyCommandService', 'Topo2MapService',
91 - 'Topo2MapConfigService', 91 + 'Topo2MapConfigService', 'Topo2SummaryPanelService',
92 92
93 function (_$scope_, _$log_, _$loc_, 93 function (_$scope_, _$log_, _$loc_,
94 _fs_, _mast_, _ks_, _zs_, 94 _fs_, _mast_, _ks_, _zs_,
95 _gs_, _ms_, _sus_, _flash_, 95 _gs_, _ms_, _sus_, _flash_,
96 _wss_, _ps_, _th_, 96 _wss_, _ps_, _th_,
97 - _t2es_, _t2fs_, _t2is_, _t2bcs_, _t2kcs_, _t2ms_, _t2mcs_) { 97 + _t2es_, _t2fs_, _t2is_, _t2bcs_, _t2kcs_, _t2ms_, _t2mcs_,
98 + summaryPanel
99 + ) {
98 100
99 var params = _$loc_.search(), 101 var params = _$loc_.search(),
100 dim, 102 dim,
...@@ -218,6 +220,8 @@ ...@@ -218,6 +220,8 @@
218 220
219 // $log.debug('registered overlays...', tov.list()); 221 // $log.debug('registered overlays...', tov.list());
220 222
223 + summaryPanel.init();
224 +
221 $log.log('OvTopo2Ctrl has been created'); 225 $log.log('OvTopo2Ctrl has been created');
222 }]); 226 }]);
223 })(); 227 })();
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
17 (function () { 17 (function () {
18 18
19 // Injected Services 19 // Injected Services
20 - var ks, t2ps, t2ms, ps, t2is; 20 + var ks, t2ps, t2ms, ps, t2is, t2sp;
21 +
21 var topo2ForceService; 22 var topo2ForceService;
22 23
23 // Commmands 24 // Commmands
...@@ -25,7 +26,8 @@ ...@@ -25,7 +26,8 @@
25 L: [cycleDeviceLabels, 'Cycle device labels'], 26 L: [cycleDeviceLabels, 'Cycle device labels'],
26 G: [openMapSelection, 'Select background geo map'], 27 G: [openMapSelection, 'Select background geo map'],
27 B: [toggleMap, 'Toggle background geo map'], 28 B: [toggleMap, 'Toggle background geo map'],
28 - I: [toggleInstancePanel, 'Toggle ONOS Instance Panel'] 29 + I: [toggleInstancePanel, 'Toggle ONOS Instance Panel'],
30 + O: [toggleSummary, 'Toggle the Summary Panel']
29 }; 31 };
30 32
31 function init(t2fs) { 33 function init(t2fs) {
...@@ -71,17 +73,21 @@ ...@@ -71,17 +73,21 @@
71 updatePrefsState('insts', t2is.toggle(x)); 73 updatePrefsState('insts', t2is.toggle(x));
72 } 74 }
73 75
76 + function toggleSummary() {
77 + t2sp.toggle();
78 + }
79 +
74 angular.module('ovTopo2') 80 angular.module('ovTopo2')
75 .factory('Topo2KeyCommandService', 81 .factory('Topo2KeyCommandService',
76 ['KeyService', 'Topo2PrefsService', 'Topo2MapService', 'PrefsService', 82 ['KeyService', 'Topo2PrefsService', 'Topo2MapService', 'PrefsService',
77 - 'Topo2InstanceService', 83 + 'Topo2InstanceService', 'Topo2SummaryPanelService',
78 - function (_ks_, _t2ps_, _t2ms_, _ps_, _t2is_) { 84 + function (_ks_, _t2ps_, _t2ms_, _ps_, _t2is_, _t2sp_) {
79 -
80 t2ps = _t2ps_; 85 t2ps = _t2ps_;
81 t2ms = _t2ms_; 86 t2ms = _t2ms_;
82 t2is = _t2is_; 87 t2is = _t2is_;
83 ps = _ps_; 88 ps = _ps_;
84 ks = _ks_; 89 ks = _ks_;
90 + t2sp = _t2sp_;
85 91
86 return { 92 return {
87 init: init, 93 init: init,
......
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 Layout Module.
19 + Module that contains the d3.force.layout logic
20 + */
21 +
22 +(function () {
23 + 'use strict';
24 +
25 + var ps;
26 +
27 + var Panel = function (id, options) {
28 + this.id = id;
29 + this.p = ps.createPanel(this.id, options);
30 + this.setup();
31 +
32 + this.p.show();
33 + };
34 +
35 + Panel.prototype = {
36 + setup: function () {
37 + var panel = this.p;
38 + panel.empty();
39 +
40 + panel.append('div').classed('header', true);
41 + panel.append('div').classed('body', true);
42 + panel.append('div').classed('footer', true);
43 +
44 + this.header = panel.el().select('.header');
45 + this.body = panel.el().select('.body');
46 + this.footer = panel.el().select('.body');
47 + },
48 + appendToHeader: function (x) {
49 + return this.header.append(x);
50 + },
51 + appendToBody: function (x) {
52 + return this.body.append(x);
53 + },
54 + appendToFooter: function (x) {
55 + return this.footer.append(x);
56 + },
57 + emptyRegions: function () {
58 + this.header.selectAll("*").remove();
59 + this.body.selectAll("*").remove();
60 + this.footer.selectAll("*").remove();
61 + },
62 + destory: function () {
63 + ps.destroy(this.id);
64 + }
65 + };
66 +
67 + angular.module('ovTopo2')
68 + .factory('Topo2PanelService', ['PanelService',
69 + function (_ps_) {
70 + ps = _ps_;
71 + return Panel;
72 + }
73 + ]);
74 +
75 +})();
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 Layout Module.
19 + Module that contains the d3.force.layout logic
20 + */
21 +
22 +(function () {
23 + 'use strict';
24 +
25 + // Injected Services
26 + var Panel, gs, wss, flash;
27 +
28 + // Internal State
29 + var summaryPanel, summaryData;
30 +
31 + // configuration
32 + var id = 'topo-p-summary',
33 + className = 'topo-p',
34 + handlerMap = {
35 + showSummary: handleSummaryData
36 + };
37 +
38 + function init() {
39 +
40 + bindHandlers();
41 + wss.sendEvent('requestSummary');
42 +
43 + summaryPanel = new Panel(id, {
44 + class: className
45 + });
46 +
47 + summaryPanel.p.classed(className, true);
48 + }
49 +
50 + function addProp(tbody, label, value) {
51 + var tr = tbody.append('tr'),
52 + lab;
53 + if (typeof label === 'string') {
54 + lab = label.replace(/_/g, ' ');
55 + } else {
56 + lab = label;
57 + }
58 +
59 + function addCell(cls, txt) {
60 + tr.append('td').attr('class', cls).html(txt);
61 + }
62 + addCell('label', lab + ' :');
63 + addCell('value', value);
64 + }
65 +
66 + function addSep(tbody) {
67 + tbody.append('tr').append('td').attr('colspan', 2).append('hr');
68 + }
69 +
70 + function listProps(tbody, data) {
71 + summaryData.propOrder.forEach(function (p) {
72 + if (p === '-') {
73 + addSep(tbody);
74 + } else {
75 + addProp(tbody, p, summaryData.props[p]);
76 + }
77 + });
78 + }
79 +
80 + function render() {
81 + summaryPanel.emptyRegions();
82 +
83 + var svg = summaryPanel.appendToHeader('div')
84 + .classed('icon', true)
85 + .append('svg'),
86 + title = summaryPanel.appendToHeader('h2'),
87 + table = summaryPanel.appendToBody('table'),
88 + tbody = table.append('tbody');
89 +
90 + title.text(summaryData.title);
91 + gs.addGlyph(svg, 'bird', 24, 0, [1, 1]);
92 + listProps(tbody);
93 + }
94 +
95 + function handleSummaryData(data) {
96 + summaryData = data;
97 + render();
98 + }
99 +
100 + function bindHandlers() {
101 + wss.bindHandlers(handlerMap);
102 + }
103 +
104 + function toggle() {
105 + var on = summaryPanel.p.toggle(),
106 + verb = on ? 'Show' : 'Hide';
107 + flash.flash(verb + ' Summary Panel');
108 + }
109 +
110 + angular.module('ovTopo2')
111 + .factory('Topo2SummaryPanelService',
112 + ['Topo2PanelService', 'GlyphService', 'WebSocketService', 'FlashService',
113 + function (_ps_, _gs_, _wss_, _flash_) {
114 +
115 + Panel = _ps_;
116 + gs = _gs_;
117 + wss = _wss_;
118 + flash = _flash_;
119 +
120 + return {
121 + init: init,
122 +
123 + toggle: toggle
124 + };
125 + }
126 + ]);
127 +
128 +})();
...@@ -145,9 +145,11 @@ ...@@ -145,9 +145,11 @@
145 <script src="app/view/topo2/topo2MapDialog.js"></script> 145 <script src="app/view/topo2/topo2MapDialog.js"></script>
146 <script src="app/view/topo2/topo2Model.js"></script> 146 <script src="app/view/topo2/topo2Model.js"></script>
147 <script src="app/view/topo2/topo2NodeModel.js"></script> 147 <script src="app/view/topo2/topo2NodeModel.js"></script>
148 + <script src="app/view/topo2/topo2Panel.js"></script>
148 <script src="app/view/topo2/topo2Prefs.js"></script> 149 <script src="app/view/topo2/topo2Prefs.js"></script>
149 <script src="app/view/topo2/topo2Region.js"></script> 150 <script src="app/view/topo2/topo2Region.js"></script>
150 <script src="app/view/topo2/topo2Select.js"></script> 151 <script src="app/view/topo2/topo2Select.js"></script>
152 + <script src="app/view/topo2/topo2SummaryPanel.js"></script>
151 <script src="app/view/topo2/topo2SubRegion.js"></script> 153 <script src="app/view/topo2/topo2SubRegion.js"></script>
152 <script src="app/view/topo2/topo2Theme.js"></script> 154 <script src="app/view/topo2/topo2Theme.js"></script>
153 <script src="app/view/topo2/topo2View.js"></script> 155 <script src="app/view/topo2/topo2View.js"></script>
......