blob: 3301e5b13fc4fee5d3b14eb858f3e4a9e66b20df [file] [log] [blame]
Simon Huntb0ec1e52015-01-28 18:13:49 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Simon Huntb0ec1e52015-01-28 18:13:49 -08003 *
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 Panel Module.
19 Defines functions for manipulating the summary, detail, and instance panels.
20 */
21
22(function () {
23 'use strict';
24
25 // injected refs
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -070026 var $log, $window, $rootScope, fs, ps, gs, flash, wss, bns, mast, ns;
Simon Huntb0ec1e52015-01-28 18:13:49 -080027
Simon Hunt879ce452017-08-10 23:32:00 -070028 // function to be replaced by the localization bundle function
29 var topoLion = function (x) {
30 return '#tps#' + x + '#';
31 };
32
Simon Hunt626d2102015-01-29 11:54:50 -080033 // constants
Simon Hunt08f841d02015-02-10 14:39:20 -080034 var pCls = 'topo-p',
35 idSum = 'topo-p-summary',
Simon Hunt626d2102015-01-29 11:54:50 -080036 idDet = 'topo-p-detail',
Simon Hunt626d2102015-01-29 11:54:50 -080037 panelOpts = {
Steven Burrows1c2a9682017-07-14 16:52:46 +010038 width: 260, // summary and detail panel width
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -070039 },
Steven Burrows1c2a9682017-07-14 16:52:46 +010040 sumMax = 226, // summary panel max height
41 padTop = 16, // summary panel padding below masthead
42 padding = 16, // panel internal padding
Simon Hunt10618f62017-06-15 19:30:52 -070043 padFudge = padTop + 2 * padding;
Simon Hunt626d2102015-01-29 11:54:50 -080044
Simon Hunt0c6b2d32015-03-26 17:46:29 -070045 // internal state
Steven Burrows1c2a9682017-07-14 16:52:46 +010046 var useDetails = true, // should we show details if we have 'em?
47 haveDetails = false, // do we have details that we could show?
48 sumFromTop, // summary panel distance from top of screen
Bri Prebilic Cole0a6ffb62015-06-04 09:32:12 -070049 unbindWatch;
Simon Huntb0ec1e52015-01-28 18:13:49 -080050
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -070051 // panels
52 var summary, detail;
53
54 // === -----------------------------------------------------
55 // Panel API
56 function createTopoPanel(id, opts) {
57 var p = ps.createPanel(id, opts),
Bri Prebilic Cole35d29712015-05-11 16:01:32 -070058 pid = id,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -070059 header, body, footer;
60 p.classed(pCls, true);
61
Bri Prebilic Cole35d29712015-05-11 16:01:32 -070062 function panel() {
63 return p;
64 }
65
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -070066 function hAppend(x) {
67 return header.append(x);
68 }
69
70 function bAppend(x) {
71 return body.append(x);
72 }
73
74 function fAppend(x) {
75 return footer.append(x);
76 }
77
78 function setup() {
79 p.empty();
80
81 p.append('div').classed('header', true);
82 p.append('div').classed('body', true);
83 p.append('div').classed('footer', true);
84
85 header = p.el().select('.header');
86 body = p.el().select('.body');
87 footer = p.el().select('.footer');
88 }
89
Bri Prebilic Cole35d29712015-05-11 16:01:32 -070090 function destroy() {
91 ps.destroyPanel(pid);
92 }
93
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -070094 // fromTop is how many pixels from the top of the page the panel is
95 // max is the max height of the panel in pixels
96 // only adjusts if the body content would be 10px or larger
97 function adjustHeight(fromTop, max) {
98 var totalPHeight, avSpace,
Simon Hunt8d47a5c2016-06-15 12:56:50 -070099 overflow = 0;
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700100
101 if (!fromTop) {
102 $log.warn('adjustHeight: height from top of page not given');
103 return null;
104 } else if (!body || !p) {
Simon Hunt5b024d72016-01-29 11:02:43 -0800105 // panel contents are not defined
106 // this may happen when window is resizing but panel has
107 // been cleared or removed
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700108 return null;
109 }
110
Simon Hunt8d47a5c2016-06-15 12:56:50 -0700111 p.el().style('top', fromTop + 'px');
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700112 p.el().style('height', null);
113 body.style('height', null);
114
115 totalPHeight = fromTop + p.height();
Simon Hunt8d47a5c2016-06-15 12:56:50 -0700116 avSpace = fs.windowSize(padFudge).height;
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700117
118 if (totalPHeight >= avSpace) {
119 overflow = totalPHeight - avSpace;
120 }
121
122 function _adjustBody(height) {
123 if (height < 10) {
124 return false;
125 } else {
126 body.style('height', height + 'px');
127 }
128 return true;
129 }
130
131 if (!_adjustBody(fs.noPxStyle(body, 'height') - overflow)) {
Simon Hunt8d47a5c2016-06-15 12:56:50 -0700132 return p.height();
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700133 }
134
135 if (max && p.height() > max) {
136 _adjustBody(fs.noPxStyle(body, 'height') - (p.height() - max));
137 }
Simon Hunt8d47a5c2016-06-15 12:56:50 -0700138 return p.height();
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700139 }
140
141 return {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700142 panel: panel,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700143 setup: setup,
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700144 destroy: destroy,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700145 appendHeader: hAppend,
146 appendBody: bAppend,
147 appendFooter: fAppend,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100148 adjustHeight: adjustHeight,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700149 };
150 }
151
Simon Hunt08f841d02015-02-10 14:39:20 -0800152 // === -----------------------------------------------------
153 // Utility functions
Simon Hunt626d2102015-01-29 11:54:50 -0800154
Simon Hunt4b668592015-01-29 17:33:53 -0800155 function addSep(tbody) {
156 tbody.append('tr').append('td').attr('colspan', 2).append('hr');
157 }
158
Simon Hunta58d8942017-08-11 12:51:14 -0700159 function addBtnFooter(sepAlreadyThere) {
160 if (!sepAlreadyThere) {
161 detail.appendFooter('hr');
162 }
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700163 detail.appendFooter('div').classed('actionBtns', true);
164 }
165
Simon Hunt4b668592015-01-29 17:33:53 -0800166 function addProp(tbody, label, value) {
Simon Hunte25c5a22015-04-02 14:37:12 -0700167 var tr = tbody.append('tr'),
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -0700168 lab;
169 if (typeof label === 'string') {
Simon Hunte25c5a22015-04-02 14:37:12 -0700170 lab = label.replace(/_/g, ' ');
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -0700171 } else {
172 lab = label;
173 }
Simon Hunt4b668592015-01-29 17:33:53 -0800174
175 function addCell(cls, txt) {
Simon Hunt239f09e2017-05-18 13:10:09 -0700176 tr.append('td').attr('class', cls).text(txt);
Simon Hunt4b668592015-01-29 17:33:53 -0800177 }
Simon Hunta58d8942017-08-11 12:51:14 -0700178
Simon Hunte25c5a22015-04-02 14:37:12 -0700179 addCell('label', lab + ' :');
Simon Hunt4b668592015-01-29 17:33:53 -0800180 addCell('value', value);
181 }
182
Simon Hunt08f841d02015-02-10 14:39:20 -0800183 function listProps(tbody, data) {
Simon Hunta58d8942017-08-11 12:51:14 -0700184 var sepLast = false;
Steven Burrowscdf6b332017-05-05 11:29:29 -0400185
Simon Hunta58d8942017-08-11 12:51:14 -0700186 // note: track whether we end with a separator or not...
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700187 data.propOrder.forEach(function (p) {
Simon Hunt08f841d02015-02-10 14:39:20 -0800188 if (p === '-') {
189 addSep(tbody);
Simon Hunta58d8942017-08-11 12:51:14 -0700190 sepLast = true;
Simon Hunt08f841d02015-02-10 14:39:20 -0800191 } else {
Simon Hunta58d8942017-08-11 12:51:14 -0700192 addProp(tbody, data.propLabels[p], data.propValues[p]);
193 sepLast = false;
Simon Hunt08f841d02015-02-10 14:39:20 -0800194 }
195 });
Simon Hunta58d8942017-08-11 12:51:14 -0700196 return sepLast;
Simon Hunt08f841d02015-02-10 14:39:20 -0800197 }
198
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700199 function watchWindow() {
Bri Prebilic Cole0a6ffb62015-06-04 09:32:12 -0700200 unbindWatch = $rootScope.$watchCollection(
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700201 function () {
202 return {
203 h: $window.innerHeight,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100204 w: $window.innerWidth,
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700205 };
206 }, function () {
Simon Hunt8d47a5c2016-06-15 12:56:50 -0700207 var h = summary.adjustHeight(sumFromTop, sumMax),
208 ss = summary.panel().isVisible(),
209 dtop = h && ss ? sumFromTop + h + padFudge : 0,
210 dy = dtop || ss ? detail.ypos.current : sumFromTop;
211 detail.adjustHeight(dy);
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700212 }
213 );
214 }
215
Simon Hunt08f841d02015-02-10 14:39:20 -0800216 // === -----------------------------------------------------
217 // Functions for populating the summary panel
218
219 function populateSummary(data) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700220 summary.setup();
Simon Hunt08f841d02015-02-10 14:39:20 -0800221
Bri Prebilic Cole8d3de3d2015-05-15 16:02:59 -0700222 var svg = summary.appendHeader('div')
223 .classed('icon', true)
224 .append('svg'),
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700225 title = summary.appendHeader('h2'),
226 table = summary.appendBody('table'),
Simon Hunta58d8942017-08-11 12:51:14 -0700227 tbody = table.append('tbody'),
228 glyphId = data.glyphId || 'bird';
Simon Hunt08f841d02015-02-10 14:39:20 -0800229
Simon Hunta58d8942017-08-11 12:51:14 -0700230 gs.addGlyph(svg, glyphId, 24, 0, [1, 1]);
Simon Hunt08f841d02015-02-10 14:39:20 -0800231
Simon Hunt0af1ec32015-07-24 12:17:55 -0700232 title.text(data.title);
Simon Hunt08f841d02015-02-10 14:39:20 -0800233 listProps(tbody, data);
234 }
235
236 // === -----------------------------------------------------
237 // Functions for populating the detail panel
238
Simon Hunt10618f62017-06-15 19:30:52 -0700239 var navPathIdKey = {
240 device: 'devId',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100241 host: 'hostId',
Simon Huntb745ca62015-07-28 15:37:11 -0700242 };
243
Simon Hunt08f841d02015-02-10 14:39:20 -0800244 function displaySingle(data) {
Simon Hunta58d8942017-08-11 12:51:14 -0700245 var sepLast;
246
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700247 detail.setup();
Simon Hunt08f841d02015-02-10 14:39:20 -0800248
Bri Prebilic Cole8d3de3d2015-05-15 16:02:59 -0700249 var svg = detail.appendHeader('div')
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700250 .classed('icon clickable', true)
Bri Prebilic Cole8d3de3d2015-05-15 16:02:59 -0700251 .append('svg'),
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700252 title = detail.appendHeader('h2')
253 .classed('clickable', true),
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700254 table = detail.appendBody('table'),
Simon Huntb745ca62015-07-28 15:37:11 -0700255 tbody = table.append('tbody'),
Simon Hunt10618f62017-06-15 19:30:52 -0700256 navFn,
257 navPath;
Simon Hunt08f841d02015-02-10 14:39:20 -0800258
Simon Hunta58d8942017-08-11 12:51:14 -0700259 gs.addGlyph(svg, (data.glyphId || 'm_unknown'), 26);
Simon Huntb745ca62015-07-28 15:37:11 -0700260 title.text(data.title);
261
Simon Hunt10618f62017-06-15 19:30:52 -0700262 // add navigation hot-link if defined
263 navPath = data.navPath;
264 if (navPath) {
Simon Huntb745ca62015-07-28 15:37:11 -0700265 navFn = function () {
Simon Hunt10618f62017-06-15 19:30:52 -0700266 var arg = {};
267 arg[navPathIdKey[navPath]] = data.id;
268 ns.navTo(navPath, arg);
Simon Huntb745ca62015-07-28 15:37:11 -0700269 };
270
271 svg.on('click', navFn);
272 title.on('click', navFn);
273 }
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700274
Simon Hunta58d8942017-08-11 12:51:14 -0700275 sepLast = listProps(tbody, data);
276 addBtnFooter(sepLast);
Simon Hunt08f841d02015-02-10 14:39:20 -0800277 }
278
279 function displayMulti(ids) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700280 detail.setup();
Simon Hunt08f841d02015-02-10 14:39:20 -0800281
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700282 var title = detail.appendHeader('h3'),
283 table = detail.appendBody('table'),
Simon Hunt08f841d02015-02-10 14:39:20 -0800284 tbody = table.append('tbody');
285
Simon Hunta58d8942017-08-11 12:51:14 -0700286 title.text(topoLion('title_selected_items'));
Simon Hunt08f841d02015-02-10 14:39:20 -0800287 ids.forEach(function (d, i) {
Simon Hunta58d8942017-08-11 12:51:14 -0700288 addProp(tbody, i + 1, d);
Simon Hunt08f841d02015-02-10 14:39:20 -0800289 });
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700290 addBtnFooter();
Simon Hunt08f841d02015-02-10 14:39:20 -0800291 }
292
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -0700293 function addAction(o) {
294 var btnDiv = d3.select('#' + idDet)
295 .select('.actionBtns')
296 .append('div')
297 .classed('actionBtn', true);
Simon Hunt3a0598f2015-08-04 19:59:04 -0700298 bns.button(btnDiv, idDet + '-' + o.id, o.gid, o.cb, o.tt);
Simon Hunt08f841d02015-02-10 14:39:20 -0800299 }
300
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700301 function displayNothing() {
302 haveDetails = false;
303 hideDetailPanel();
304 }
305
306 function displaySomething() {
307 haveDetails = true;
308 if (useDetails) {
309 showDetailPanel();
310 }
311 }
312
Simon Hunt08f841d02015-02-10 14:39:20 -0800313 // === -----------------------------------------------------
314 // Event Handlers
315
316 function showSummary(data) {
317 populateSummary(data);
318 showSummaryPanel();
319 }
320
Simon Hunt36a58c62015-04-08 11:00:07 -0700321 function toggleSummary(x) {
Simon Huntee7a3ce2015-04-09 13:28:37 -0700322 var kev = (x === 'keyev'),
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700323 on = kev ? !summary.panel().isVisible() : !!x,
Simon Hunt879ce452017-08-10 23:32:00 -0700324 verb = on ? topoLion('show') : topoLion('hide'),
325 sumpan = topoLion('fl_panel_summary');
Simon Hunt36a58c62015-04-08 11:00:07 -0700326
327 if (on) {
Simon Hunta0eb0a82015-02-11 12:30:06 -0800328 // ask server to start sending summary data.
Simon Hunt237676b52015-03-10 19:04:26 -0700329 wss.sendEvent('requestSummary');
Simon Hunta0eb0a82015-02-11 12:30:06 -0800330 // note: the summary panel will appear, once data arrives
Simon Hunt36a58c62015-04-08 11:00:07 -0700331 } else {
332 hideSummaryPanel();
Simon Hunt6036b192015-02-11 11:20:26 -0800333 }
Simon Hunt879ce452017-08-10 23:32:00 -0700334 flash.flash(verb + ' ' + sumpan);
Simon Huntee7a3ce2015-04-09 13:28:37 -0700335 return on;
Simon Hunt6036b192015-02-11 11:20:26 -0800336 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800337
338 // === -----------------------------------------------------
339 // === LOGIC For showing/hiding summary and detail panels...
340
Simon Hunt626d2102015-01-29 11:54:50 -0800341 function showSummaryPanel() {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700342 function _show() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700343 summary.panel().show();
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700344 summary.adjustHeight(sumFromTop, sumMax);
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700345 }
Simon Hunta58d8942017-08-11 12:51:14 -0700346
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700347 if (detail.panel().isVisible()) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700348 detail.down(_show);
Simon Hunt6036b192015-02-11 11:20:26 -0800349 } else {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700350 _show();
Simon Hunt6036b192015-02-11 11:20:26 -0800351 }
Simon Huntc252aa62015-02-10 16:45:39 -0800352 }
353
354 function hideSummaryPanel() {
Simon Hunta0eb0a82015-02-11 12:30:06 -0800355 // instruct server to stop sending summary data
Steven Burrows1c2a9682017-07-14 16:52:46 +0100356 wss.sendEvent('cancelSummary');
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700357 summary.panel().hide(detail.up);
Simon Hunt4b668592015-01-29 17:33:53 -0800358 }
Simon Hunt626d2102015-01-29 11:54:50 -0800359
Simon Hunt08f841d02015-02-10 14:39:20 -0800360 function showDetailPanel() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700361 if (summary.panel().isVisible()) {
362 detail.down(detail.panel().show);
Simon Hunt6036b192015-02-11 11:20:26 -0800363 } else {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700364 detail.up(detail.panel().show);
Simon Hunt6036b192015-02-11 11:20:26 -0800365 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800366 }
367
368 function hideDetailPanel() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700369 detail.panel().hide();
Simon Hunt08f841d02015-02-10 14:39:20 -0800370 }
371
Simon Hunt6036b192015-02-11 11:20:26 -0800372 // ==========================
Simon Hunt08f841d02015-02-10 14:39:20 -0800373
Simon Hunt6036b192015-02-11 11:20:26 -0800374 function augmentDetailPanel() {
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700375 var d = detail,
Simon Hunt8d47a5c2016-06-15 12:56:50 -0700376 downPos = sumFromTop + sumMax + padFudge;
Steven Burrows1c2a9682017-07-14 16:52:46 +0100377 d.ypos = { up: sumFromTop, down: downPos, current: downPos };
Simon Hunt6036b192015-02-11 11:20:26 -0800378
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700379 d._move = function (y, cb) {
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700380 var yp = d.ypos,
381 endCb;
382
383 if (fs.isF(cb)) {
384 endCb = function () {
385 cb();
386 d.adjustHeight(d.ypos.current);
Steven Burrows1c2a9682017-07-14 16:52:46 +0100387 };
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700388 } else {
389 endCb = function () {
390 d.adjustHeight(d.ypos.current);
Steven Burrows1c2a9682017-07-14 16:52:46 +0100391 };
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700392 }
Simon Hunt6036b192015-02-11 11:20:26 -0800393 if (yp.current !== y) {
394 yp.current = y;
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700395 d.panel().el().transition().duration(300)
Simon Hunt6036b192015-02-11 11:20:26 -0800396 .each('end', endCb)
397 .style('top', yp.current + 'px');
398 } else {
399 endCb();
400 }
401 };
402
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700403 d.down = function (cb) { d._move(d.ypos.down, cb); };
404 d.up = function (cb) { d._move(d.ypos.up, cb); };
Simon Hunt6036b192015-02-11 11:20:26 -0800405 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800406
Simon Hunt239e5882015-04-23 15:07:04 -0700407 function toggleUseDetailsFlag(x) {
Simon Huntee7a3ce2015-04-09 13:28:37 -0700408 var kev = (x === 'keyev'),
409 verb;
410
411 useDetails = kev ? !useDetails : !!x;
Simon Hunt8032d8b2017-08-11 19:46:48 -0700412 verb = topoLion(useDetails ? 'enable' : 'disable');
Simon Huntee7a3ce2015-04-09 13:28:37 -0700413
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700414 if (useDetails) {
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700415 if (haveDetails) {
416 showDetailPanel();
417 }
418 } else {
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700419 hideDetailPanel();
420 }
Simon Hunt8032d8b2017-08-11 19:46:48 -0700421 flash.flash(verb + ' ' + topoLion('fl_panel_details'));
Simon Huntee7a3ce2015-04-09 13:28:37 -0700422 return useDetails;
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700423 }
424
Simon Hunt4b668592015-01-29 17:33:53 -0800425 // ==========================
426
Simon Hunt237676b52015-03-10 19:04:26 -0700427 function initPanels() {
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700428 sumFromTop = mast.mastHeight() + padTop;
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700429 summary = createTopoPanel(idSum, panelOpts);
430 detail = createTopoPanel(idDet, panelOpts);
Simon Hunt6036b192015-02-11 11:20:26 -0800431
432 augmentDetailPanel();
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700433 watchWindow();
Simon Hunt4b668592015-01-29 17:33:53 -0800434 }
435
436 function destroyPanels() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700437 summary.destroy();
438 summary = null;
439
440 detail.destroy();
441 detail = null;
Simon Hunt239e5882015-04-23 15:07:04 -0700442 haveDetails = false;
Bri Prebilic Cole0a6ffb62015-06-04 09:32:12 -0700443 unbindWatch();
Simon Hunt626d2102015-01-29 11:54:50 -0800444 }
445
446 // ==========================
447
Simon Huntb0ec1e52015-01-28 18:13:49 -0800448 angular.module('ovTopo')
449 .factory('TopoPanelService',
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700450 ['$log', '$window', '$rootScope', 'FnService', 'PanelService', 'GlyphService',
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700451 'FlashService', 'WebSocketService', 'ButtonService', 'MastService',
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700452 'NavService',
Simon Huntb0ec1e52015-01-28 18:13:49 -0800453
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700454 function (_$log_, _$window_, _$rootScope_,
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700455 _fs_, _ps_, _gs_, _flash_, _wss_, _bns_, _mast_, _ns_) {
Simon Huntb0ec1e52015-01-28 18:13:49 -0800456 $log = _$log_;
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700457 $window = _$window_;
458 $rootScope = _$rootScope_;
Simon Hunt6036b192015-02-11 11:20:26 -0800459 fs = _fs_;
Simon Huntb0ec1e52015-01-28 18:13:49 -0800460 ps = _ps_;
Simon Huntc9b73162015-01-29 14:02:15 -0800461 gs = _gs_;
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700462 flash = _flash_;
Simon Hunt237676b52015-03-10 19:04:26 -0700463 wss = _wss_;
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -0700464 bns = _bns_;
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700465 mast = _mast_;
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700466 ns = _ns_;
Simon Huntb0ec1e52015-01-28 18:13:49 -0800467
Simon Huntb0ec1e52015-01-28 18:13:49 -0800468 return {
469 initPanels: initPanels,
Simon Hunt626d2102015-01-29 11:54:50 -0800470 destroyPanels: destroyPanels,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700471 createTopoPanel: createTopoPanel,
Simon Hunt08f841d02015-02-10 14:39:20 -0800472
473 showSummary: showSummary,
Simon Hunt6036b192015-02-11 11:20:26 -0800474 toggleSummary: toggleSummary,
Thomas Vachuska0af26912016-03-21 21:37:30 -0700475 hideSummary: hideSummaryPanel,
Simon Hunt08f841d02015-02-10 14:39:20 -0800476
Simon Hunt239e5882015-04-23 15:07:04 -0700477 toggleUseDetailsFlag: toggleUseDetailsFlag,
Simon Hunt08f841d02015-02-10 14:39:20 -0800478 displaySingle: displaySingle,
479 displayMulti: displayMulti,
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700480 displayNothing: displayNothing,
481 displaySomething: displaySomething,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700482 addAction: addAction,
Simon Hunt08f841d02015-02-10 14:39:20 -0800483
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700484 detailVisible: function () { return detail.panel().isVisible(); },
Steven Burrows1c2a9682017-07-14 16:52:46 +0100485 summaryVisible: function () { return summary.panel().isVisible(); },
Simon Hunt879ce452017-08-10 23:32:00 -0700486
487 setLionBundle: function (bundle) { topoLion = bundle; },
Simon Huntb0ec1e52015-01-28 18:13:49 -0800488 };
489 }]);
490}());