blob: e1cef91ecfdf942ec24ceeca9875a135bbee1fcb [file] [log] [blame]
Simon Huntb0ec1e52015-01-28 18:13:49 -08001/*
2 * Copyright 2015 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 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 Hunt626d2102015-01-29 11:54:50 -080028 // constants
Simon Hunt08f841d02015-02-10 14:39:20 -080029 var pCls = 'topo-p',
30 idSum = 'topo-p-summary',
Simon Hunt626d2102015-01-29 11:54:50 -080031 idDet = 'topo-p-detail',
Simon Hunt626d2102015-01-29 11:54:50 -080032 panelOpts = {
Simon Hunt06909ef2016-01-07 10:11:20 -080033 width: 268
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -070034 },
Thomas Vachuskae50b6212015-12-02 08:00:09 -080035 sumMax = 262,
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -070036 padTop = 20,
37 devPath = 'device';
Simon Hunt626d2102015-01-29 11:54:50 -080038
Simon Hunt0c6b2d32015-03-26 17:46:29 -070039 // internal state
40 var useDetails = true, // should we show details if we have 'em?
Bri Prebilic Coled8745462015-06-01 16:08:57 -070041 haveDetails = false, // do we have details that we could show?
Bri Prebilic Cole0a6ffb62015-06-04 09:32:12 -070042 sumFromTop, // summary panel distance from top of screen
43 unbindWatch;
Simon Huntb0ec1e52015-01-28 18:13:49 -080044
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -070045 // panels
46 var summary, detail;
47
48 // === -----------------------------------------------------
49 // Panel API
50 function createTopoPanel(id, opts) {
51 var p = ps.createPanel(id, opts),
Bri Prebilic Cole35d29712015-05-11 16:01:32 -070052 pid = id,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -070053 header, body, footer;
54 p.classed(pCls, true);
55
Bri Prebilic Cole35d29712015-05-11 16:01:32 -070056 function panel() {
57 return p;
58 }
59
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -070060 function hAppend(x) {
61 return header.append(x);
62 }
63
64 function bAppend(x) {
65 return body.append(x);
66 }
67
68 function fAppend(x) {
69 return footer.append(x);
70 }
71
72 function setup() {
73 p.empty();
74
75 p.append('div').classed('header', true);
76 p.append('div').classed('body', true);
77 p.append('div').classed('footer', true);
78
79 header = p.el().select('.header');
80 body = p.el().select('.body');
81 footer = p.el().select('.footer');
82 }
83
Bri Prebilic Cole35d29712015-05-11 16:01:32 -070084 function destroy() {
85 ps.destroyPanel(pid);
86 }
87
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -070088 // fromTop is how many pixels from the top of the page the panel is
89 // max is the max height of the panel in pixels
90 // only adjusts if the body content would be 10px or larger
91 function adjustHeight(fromTop, max) {
92 var totalPHeight, avSpace,
93 overflow = 0,
94 pdg = 30;
95
96 if (!fromTop) {
97 $log.warn('adjustHeight: height from top of page not given');
98 return null;
99 } else if (!body || !p) {
Simon Hunt5b024d72016-01-29 11:02:43 -0800100 // panel contents are not defined
101 // this may happen when window is resizing but panel has
102 // been cleared or removed
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700103 return null;
104 }
105
106 p.el().style('height', null);
107 body.style('height', null);
108
109 totalPHeight = fromTop + p.height();
110 avSpace = fs.windowSize(pdg).height;
111
112 if (totalPHeight >= avSpace) {
113 overflow = totalPHeight - avSpace;
114 }
115
116 function _adjustBody(height) {
117 if (height < 10) {
118 return false;
119 } else {
120 body.style('height', height + 'px');
121 }
122 return true;
123 }
124
125 if (!_adjustBody(fs.noPxStyle(body, 'height') - overflow)) {
126 return;
127 }
128
129 if (max && p.height() > max) {
130 _adjustBody(fs.noPxStyle(body, 'height') - (p.height() - max));
131 }
132 }
133
134 return {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700135 panel: panel,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700136 setup: setup,
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700137 destroy: destroy,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700138 appendHeader: hAppend,
139 appendBody: bAppend,
140 appendFooter: fAppend,
141 adjustHeight: adjustHeight
142 };
143 }
144
Simon Hunt08f841d02015-02-10 14:39:20 -0800145 // === -----------------------------------------------------
146 // Utility functions
Simon Hunt626d2102015-01-29 11:54:50 -0800147
Simon Hunt4b668592015-01-29 17:33:53 -0800148 function addSep(tbody) {
149 tbody.append('tr').append('td').attr('colspan', 2).append('hr');
150 }
151
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700152 function addBtnFooter() {
153 detail.appendFooter('hr');
154 detail.appendFooter('div').classed('actionBtns', true);
155 }
156
Simon Hunt4b668592015-01-29 17:33:53 -0800157 function addProp(tbody, label, value) {
Simon Hunte25c5a22015-04-02 14:37:12 -0700158 var tr = tbody.append('tr'),
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -0700159 lab;
160 if (typeof label === 'string') {
Simon Hunte25c5a22015-04-02 14:37:12 -0700161 lab = label.replace(/_/g, ' ');
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -0700162 } else {
163 lab = label;
164 }
Simon Hunt4b668592015-01-29 17:33:53 -0800165
166 function addCell(cls, txt) {
Simon Hunta36f03b2015-04-01 15:22:49 -0700167 tr.append('td').attr('class', cls).html(txt);
Simon Hunt4b668592015-01-29 17:33:53 -0800168 }
Simon Hunte25c5a22015-04-02 14:37:12 -0700169 addCell('label', lab + ' :');
Simon Hunt4b668592015-01-29 17:33:53 -0800170 addCell('value', value);
171 }
172
Simon Hunt08f841d02015-02-10 14:39:20 -0800173 function listProps(tbody, data) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700174 data.propOrder.forEach(function (p) {
Simon Hunt08f841d02015-02-10 14:39:20 -0800175 if (p === '-') {
176 addSep(tbody);
177 } else {
178 addProp(tbody, p, data.props[p]);
179 }
180 });
181 }
182
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700183 function watchWindow() {
Bri Prebilic Cole0a6ffb62015-06-04 09:32:12 -0700184 unbindWatch = $rootScope.$watchCollection(
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700185 function () {
186 return {
187 h: $window.innerHeight,
188 w: $window.innerWidth
189 };
190 }, function () {
191 summary.adjustHeight(sumFromTop, sumMax);
192 detail.adjustHeight(detail.ypos.current);
193 }
194 );
195 }
196
Simon Hunt08f841d02015-02-10 14:39:20 -0800197 // === -----------------------------------------------------
198 // Functions for populating the summary panel
199
200 function populateSummary(data) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700201 summary.setup();
Simon Hunt08f841d02015-02-10 14:39:20 -0800202
Bri Prebilic Cole8d3de3d2015-05-15 16:02:59 -0700203 var svg = summary.appendHeader('div')
204 .classed('icon', true)
205 .append('svg'),
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700206 title = summary.appendHeader('h2'),
207 table = summary.appendBody('table'),
Simon Hunt629b99e2015-07-27 17:38:33 -0700208 tbody = table.append('tbody'),
209 glyphId = data.type || 'node';
Simon Hunt08f841d02015-02-10 14:39:20 -0800210
Simon Hunt629b99e2015-07-27 17:38:33 -0700211 gs.addGlyph(svg, glyphId, 40);
212
213 if (glyphId === 'node') {
214 gs.addGlyph(svg, 'bird', 24, true, [8,12]);
215 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800216
Simon Hunt0af1ec32015-07-24 12:17:55 -0700217 title.text(data.title);
Simon Hunt08f841d02015-02-10 14:39:20 -0800218 listProps(tbody, data);
219 }
220
221 // === -----------------------------------------------------
222 // Functions for populating the detail panel
223
Simon Huntb745ca62015-07-28 15:37:11 -0700224 var isDevice = {
225 switch: 1,
Rimon Ashkenazy8ebfff02016-02-01 11:56:36 +0200226 roadm: 1,
227 otn:1
Simon Huntb745ca62015-07-28 15:37:11 -0700228 };
229
Simon Hunt08f841d02015-02-10 14:39:20 -0800230 function displaySingle(data) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700231 detail.setup();
Simon Hunt08f841d02015-02-10 14:39:20 -0800232
Bri Prebilic Cole8d3de3d2015-05-15 16:02:59 -0700233 var svg = detail.appendHeader('div')
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700234 .classed('icon clickable', true)
Bri Prebilic Cole8d3de3d2015-05-15 16:02:59 -0700235 .append('svg'),
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700236 title = detail.appendHeader('h2')
237 .classed('clickable', true),
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700238 table = detail.appendBody('table'),
Simon Huntb745ca62015-07-28 15:37:11 -0700239 tbody = table.append('tbody'),
240 navFn;
Simon Hunt08f841d02015-02-10 14:39:20 -0800241
242 gs.addGlyph(svg, (data.type || 'unknown'), 40);
Simon Huntb745ca62015-07-28 15:37:11 -0700243 title.text(data.title);
244
245 // only add navigation when displaying a device
246 if (isDevice[data.type]) {
247 navFn = function () {
248 ns.navTo(devPath, { devId: data.id });
249 };
250
251 svg.on('click', navFn);
252 title.on('click', navFn);
253 }
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700254
Simon Hunt08f841d02015-02-10 14:39:20 -0800255 listProps(tbody, data);
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700256 addBtnFooter();
Simon Hunt08f841d02015-02-10 14:39:20 -0800257 }
258
259 function displayMulti(ids) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700260 detail.setup();
Simon Hunt08f841d02015-02-10 14:39:20 -0800261
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700262 var title = detail.appendHeader('h3'),
263 table = detail.appendBody('table'),
Simon Hunt08f841d02015-02-10 14:39:20 -0800264 tbody = table.append('tbody');
265
266 title.text('Selected Nodes');
267 ids.forEach(function (d, i) {
268 addProp(tbody, i+1, d);
269 });
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700270 addBtnFooter();
Simon Hunt08f841d02015-02-10 14:39:20 -0800271 }
272
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -0700273 function addAction(o) {
274 var btnDiv = d3.select('#' + idDet)
275 .select('.actionBtns')
276 .append('div')
277 .classed('actionBtn', true);
Simon Hunt3a0598f2015-08-04 19:59:04 -0700278 bns.button(btnDiv, idDet + '-' + o.id, o.gid, o.cb, o.tt);
Simon Hunt08f841d02015-02-10 14:39:20 -0800279 }
280
Simon Hunta36f03b2015-04-01 15:22:49 -0700281 var friendlyIndex = {
282 device: 1,
283 host: 0
284 };
285
286 function friendly(d) {
287 var i = friendlyIndex[d.class] || 0;
288 return (d.labels && d.labels[i]) || '';
289 }
290
291 function linkSummary(d) {
292 var o = d && d.online ? 'online' : 'offline';
293 return d ? d.type + ' / ' + o : '-';
294 }
295
Simon Hunte25c5a22015-04-02 14:37:12 -0700296 // provided to change presentation of internal type name
297 var linkTypePres = {
298 hostLink: 'edge link'
299 };
300
301 function linkType(d) {
302 return linkTypePres[d.type()] || d.type();
303 }
304
Ray Milkeyb7f0f642016-01-22 16:08:14 -0800305 function linkExpected(d) {
306 return d.expected();
307 }
308
Simon Hunte25c5a22015-04-02 14:37:12 -0700309 var coreOrder = [
Ray Milkeyb7f0f642016-01-22 16:08:14 -0800310 'Type', 'Expected', '-',
Simon Hunte25c5a22015-04-02 14:37:12 -0700311 'A_type', 'A_id', 'A_label', 'A_port', '-',
312 'B_type', 'B_id', 'B_label', 'B_port', '-'
313 ],
314 edgeOrder = [
315 'Type', '-',
316 'A_type', 'A_id', 'A_label', '-',
317 'B_type', 'B_id', 'B_label', 'B_port'
318 ];
319
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700320 function displayLink(data) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700321 detail.setup();
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700322
Bri Prebilic Cole8d3de3d2015-05-15 16:02:59 -0700323 var svg = detail.appendHeader('div')
324 .classed('icon', true)
325 .append('svg'),
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700326 title = detail.appendHeader('h2'),
327 table = detail.appendBody('table'),
Simon Hunte25c5a22015-04-02 14:37:12 -0700328 tbody = table.append('tbody'),
329 edgeLink = data.type() === 'hostLink',
330 order = edgeLink ? edgeOrder : coreOrder;
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700331
332 gs.addGlyph(svg, 'ports', 40);
333 title.text('Link');
Simon Hunta36f03b2015-04-01 15:22:49 -0700334
Simon Hunta36f03b2015-04-01 15:22:49 -0700335
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700336 listProps(tbody, {
Simon Hunta36f03b2015-04-01 15:22:49 -0700337 propOrder: order,
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700338 props: {
Simon Hunte25c5a22015-04-02 14:37:12 -0700339 Type: linkType(data),
Ray Milkeyb7f0f642016-01-22 16:08:14 -0800340 Expected: linkExpected(data),
Simon Hunta36f03b2015-04-01 15:22:49 -0700341
342 A_type: data.source.class,
343 A_id: data.source.id,
344 A_label: friendly(data.source),
345 A_port: data.srcPort,
346
347 B_type: data.target.class,
348 B_id: data.target.id,
349 B_label: friendly(data.target),
350 B_port: data.tgtPort
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700351 }
352 });
Simon Hunta36f03b2015-04-01 15:22:49 -0700353
Simon Hunte25c5a22015-04-02 14:37:12 -0700354 if (!edgeLink) {
355 addProp(tbody, 'A &rarr; B', linkSummary(data.fromSource));
356 addProp(tbody, 'B &rarr; A', linkSummary(data.fromTarget));
357 }
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700358 }
359
360 function displayNothing() {
361 haveDetails = false;
362 hideDetailPanel();
363 }
364
365 function displaySomething() {
366 haveDetails = true;
367 if (useDetails) {
368 showDetailPanel();
369 }
370 }
371
Simon Hunt08f841d02015-02-10 14:39:20 -0800372 // === -----------------------------------------------------
373 // Event Handlers
374
375 function showSummary(data) {
376 populateSummary(data);
377 showSummaryPanel();
378 }
379
Simon Hunt36a58c62015-04-08 11:00:07 -0700380 function toggleSummary(x) {
Simon Huntee7a3ce2015-04-09 13:28:37 -0700381 var kev = (x === 'keyev'),
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700382 on = kev ? !summary.panel().isVisible() : !!x,
Simon Huntee7a3ce2015-04-09 13:28:37 -0700383 verb = on ? 'Show' : 'Hide';
Simon Hunt36a58c62015-04-08 11:00:07 -0700384
385 if (on) {
Simon Hunta0eb0a82015-02-11 12:30:06 -0800386 // ask server to start sending summary data.
Simon Hunt237676b52015-03-10 19:04:26 -0700387 wss.sendEvent('requestSummary');
Simon Hunta0eb0a82015-02-11 12:30:06 -0800388 // note: the summary panel will appear, once data arrives
Simon Hunt36a58c62015-04-08 11:00:07 -0700389 } else {
390 hideSummaryPanel();
Simon Hunt6036b192015-02-11 11:20:26 -0800391 }
Simon Huntee7a3ce2015-04-09 13:28:37 -0700392 flash.flash(verb + ' summary panel');
393 return on;
Simon Hunt6036b192015-02-11 11:20:26 -0800394 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800395
396 // === -----------------------------------------------------
397 // === LOGIC For showing/hiding summary and detail panels...
398
Simon Hunt626d2102015-01-29 11:54:50 -0800399 function showSummaryPanel() {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700400 function _show() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700401 summary.panel().show();
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700402 summary.adjustHeight(sumFromTop, sumMax);
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700403 }
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700404 if (detail.panel().isVisible()) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700405 detail.down(_show);
Simon Hunt6036b192015-02-11 11:20:26 -0800406 } else {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700407 _show();
Simon Hunt6036b192015-02-11 11:20:26 -0800408 }
Simon Huntc252aa62015-02-10 16:45:39 -0800409 }
410
411 function hideSummaryPanel() {
Simon Hunta0eb0a82015-02-11 12:30:06 -0800412 // instruct server to stop sending summary data
Simon Hunt237676b52015-03-10 19:04:26 -0700413 wss.sendEvent("cancelSummary");
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700414 summary.panel().hide(detail.up);
Simon Hunt4b668592015-01-29 17:33:53 -0800415 }
Simon Hunt626d2102015-01-29 11:54:50 -0800416
Simon Hunt08f841d02015-02-10 14:39:20 -0800417 function showDetailPanel() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700418 if (summary.panel().isVisible()) {
419 detail.down(detail.panel().show);
Simon Hunt6036b192015-02-11 11:20:26 -0800420 } else {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700421 detail.up(detail.panel().show);
Simon Hunt6036b192015-02-11 11:20:26 -0800422 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800423 }
424
425 function hideDetailPanel() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700426 detail.panel().hide();
Simon Hunt08f841d02015-02-10 14:39:20 -0800427 }
428
Simon Hunt6036b192015-02-11 11:20:26 -0800429 // ==========================
Simon Hunt08f841d02015-02-10 14:39:20 -0800430
Simon Hunt6036b192015-02-11 11:20:26 -0800431 function augmentDetailPanel() {
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700432 var d = detail,
433 downPos = sumFromTop + sumMax + 20;
434 d.ypos = { up: sumFromTop, down: downPos, current: downPos};
Simon Hunt6036b192015-02-11 11:20:26 -0800435
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700436 d._move = function (y, cb) {
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700437 var yp = d.ypos,
438 endCb;
439
440 if (fs.isF(cb)) {
441 endCb = function () {
442 cb();
443 d.adjustHeight(d.ypos.current);
444 }
445 } else {
446 endCb = function () {
447 d.adjustHeight(d.ypos.current);
448 }
449 }
Simon Hunt6036b192015-02-11 11:20:26 -0800450 if (yp.current !== y) {
451 yp.current = y;
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700452 d.panel().el().transition().duration(300)
Simon Hunt6036b192015-02-11 11:20:26 -0800453 .each('end', endCb)
454 .style('top', yp.current + 'px');
455 } else {
456 endCb();
457 }
458 };
459
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700460 d.down = function (cb) { d._move(d.ypos.down, cb); };
461 d.up = function (cb) { d._move(d.ypos.up, cb); };
Simon Hunt6036b192015-02-11 11:20:26 -0800462 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800463
Simon Hunt239e5882015-04-23 15:07:04 -0700464 function toggleUseDetailsFlag(x) {
Simon Huntee7a3ce2015-04-09 13:28:37 -0700465 var kev = (x === 'keyev'),
466 verb;
467
468 useDetails = kev ? !useDetails : !!x;
469 verb = useDetails ? 'Enable' : 'Disable';
470
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700471 if (useDetails) {
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700472 if (haveDetails) {
473 showDetailPanel();
474 }
475 } else {
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700476 hideDetailPanel();
477 }
Simon Huntee7a3ce2015-04-09 13:28:37 -0700478 flash.flash(verb + ' details panel');
479 return useDetails;
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700480 }
481
Simon Hunt4b668592015-01-29 17:33:53 -0800482 // ==========================
483
Simon Hunt237676b52015-03-10 19:04:26 -0700484 function initPanels() {
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700485 sumFromTop = mast.mastHeight() + padTop;
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700486 summary = createTopoPanel(idSum, panelOpts);
487 detail = createTopoPanel(idDet, panelOpts);
Simon Hunt6036b192015-02-11 11:20:26 -0800488
489 augmentDetailPanel();
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700490 watchWindow();
Simon Hunt4b668592015-01-29 17:33:53 -0800491 }
492
493 function destroyPanels() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700494 summary.destroy();
495 summary = null;
496
497 detail.destroy();
498 detail = null;
Simon Hunt239e5882015-04-23 15:07:04 -0700499 haveDetails = false;
Bri Prebilic Cole0a6ffb62015-06-04 09:32:12 -0700500 unbindWatch();
Simon Hunt626d2102015-01-29 11:54:50 -0800501 }
502
503 // ==========================
504
Simon Huntb0ec1e52015-01-28 18:13:49 -0800505 angular.module('ovTopo')
506 .factory('TopoPanelService',
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700507 ['$log', '$window', '$rootScope', 'FnService', 'PanelService', 'GlyphService',
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700508 'FlashService', 'WebSocketService', 'ButtonService', 'MastService',
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700509 'NavService',
Simon Huntb0ec1e52015-01-28 18:13:49 -0800510
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700511 function (_$log_, _$window_, _$rootScope_,
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700512 _fs_, _ps_, _gs_, _flash_, _wss_, _bns_, _mast_, _ns_) {
Simon Huntb0ec1e52015-01-28 18:13:49 -0800513 $log = _$log_;
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700514 $window = _$window_;
515 $rootScope = _$rootScope_;
Simon Hunt6036b192015-02-11 11:20:26 -0800516 fs = _fs_;
Simon Huntb0ec1e52015-01-28 18:13:49 -0800517 ps = _ps_;
Simon Huntc9b73162015-01-29 14:02:15 -0800518 gs = _gs_;
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700519 flash = _flash_;
Simon Hunt237676b52015-03-10 19:04:26 -0700520 wss = _wss_;
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -0700521 bns = _bns_;
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700522 mast = _mast_;
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700523 ns = _ns_;
Simon Huntb0ec1e52015-01-28 18:13:49 -0800524
Simon Huntb0ec1e52015-01-28 18:13:49 -0800525 return {
526 initPanels: initPanels,
Simon Hunt626d2102015-01-29 11:54:50 -0800527 destroyPanels: destroyPanels,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700528 createTopoPanel: createTopoPanel,
Simon Hunt08f841d02015-02-10 14:39:20 -0800529
530 showSummary: showSummary,
Simon Hunt6036b192015-02-11 11:20:26 -0800531 toggleSummary: toggleSummary,
Thomas Vachuska0af26912016-03-21 21:37:30 -0700532 hideSummary: hideSummaryPanel,
Simon Hunt08f841d02015-02-10 14:39:20 -0800533
Simon Hunt239e5882015-04-23 15:07:04 -0700534 toggleUseDetailsFlag: toggleUseDetailsFlag,
Simon Hunt08f841d02015-02-10 14:39:20 -0800535 displaySingle: displaySingle,
536 displayMulti: displayMulti,
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700537 displayLink: displayLink,
538 displayNothing: displayNothing,
539 displaySomething: displaySomething,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700540 addAction: addAction,
Simon Hunt08f841d02015-02-10 14:39:20 -0800541
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700542 detailVisible: function () { return detail.panel().isVisible(); },
543 summaryVisible: function () { return summary.panel().isVisible(); }
Simon Huntb0ec1e52015-01-28 18:13:49 -0800544 };
545 }]);
546}());