blob: af2c4bcd5be998114d7874836290a898978d8824 [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,
226 roadm: 1
227 };
228
Simon Hunt08f841d02015-02-10 14:39:20 -0800229 function displaySingle(data) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700230 detail.setup();
Simon Hunt08f841d02015-02-10 14:39:20 -0800231
Bri Prebilic Cole8d3de3d2015-05-15 16:02:59 -0700232 var svg = detail.appendHeader('div')
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700233 .classed('icon clickable', true)
Bri Prebilic Cole8d3de3d2015-05-15 16:02:59 -0700234 .append('svg'),
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700235 title = detail.appendHeader('h2')
236 .classed('clickable', true),
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700237 table = detail.appendBody('table'),
Simon Huntb745ca62015-07-28 15:37:11 -0700238 tbody = table.append('tbody'),
239 navFn;
Simon Hunt08f841d02015-02-10 14:39:20 -0800240
241 gs.addGlyph(svg, (data.type || 'unknown'), 40);
Simon Huntb745ca62015-07-28 15:37:11 -0700242 title.text(data.title);
243
244 // only add navigation when displaying a device
245 if (isDevice[data.type]) {
246 navFn = function () {
247 ns.navTo(devPath, { devId: data.id });
248 };
249
250 svg.on('click', navFn);
251 title.on('click', navFn);
252 }
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700253
Simon Hunt08f841d02015-02-10 14:39:20 -0800254 listProps(tbody, data);
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700255 addBtnFooter();
Simon Hunt08f841d02015-02-10 14:39:20 -0800256 }
257
258 function displayMulti(ids) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700259 detail.setup();
Simon Hunt08f841d02015-02-10 14:39:20 -0800260
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700261 var title = detail.appendHeader('h3'),
262 table = detail.appendBody('table'),
Simon Hunt08f841d02015-02-10 14:39:20 -0800263 tbody = table.append('tbody');
264
265 title.text('Selected Nodes');
266 ids.forEach(function (d, i) {
267 addProp(tbody, i+1, d);
268 });
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700269 addBtnFooter();
Simon Hunt08f841d02015-02-10 14:39:20 -0800270 }
271
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -0700272 function addAction(o) {
273 var btnDiv = d3.select('#' + idDet)
274 .select('.actionBtns')
275 .append('div')
276 .classed('actionBtn', true);
Simon Hunt3a0598f2015-08-04 19:59:04 -0700277 bns.button(btnDiv, idDet + '-' + o.id, o.gid, o.cb, o.tt);
Simon Hunt08f841d02015-02-10 14:39:20 -0800278 }
279
Simon Hunta36f03b2015-04-01 15:22:49 -0700280 var friendlyIndex = {
281 device: 1,
282 host: 0
283 };
284
285 function friendly(d) {
286 var i = friendlyIndex[d.class] || 0;
287 return (d.labels && d.labels[i]) || '';
288 }
289
290 function linkSummary(d) {
291 var o = d && d.online ? 'online' : 'offline';
292 return d ? d.type + ' / ' + o : '-';
293 }
294
Simon Hunte25c5a22015-04-02 14:37:12 -0700295 // provided to change presentation of internal type name
296 var linkTypePres = {
297 hostLink: 'edge link'
298 };
299
300 function linkType(d) {
301 return linkTypePres[d.type()] || d.type();
302 }
303
304 var coreOrder = [
305 'Type', '-',
306 'A_type', 'A_id', 'A_label', 'A_port', '-',
307 'B_type', 'B_id', 'B_label', 'B_port', '-'
308 ],
309 edgeOrder = [
310 'Type', '-',
311 'A_type', 'A_id', 'A_label', '-',
312 'B_type', 'B_id', 'B_label', 'B_port'
313 ];
314
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700315 function displayLink(data) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700316 detail.setup();
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700317
Bri Prebilic Cole8d3de3d2015-05-15 16:02:59 -0700318 var svg = detail.appendHeader('div')
319 .classed('icon', true)
320 .append('svg'),
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700321 title = detail.appendHeader('h2'),
322 table = detail.appendBody('table'),
Simon Hunte25c5a22015-04-02 14:37:12 -0700323 tbody = table.append('tbody'),
324 edgeLink = data.type() === 'hostLink',
325 order = edgeLink ? edgeOrder : coreOrder;
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700326
327 gs.addGlyph(svg, 'ports', 40);
328 title.text('Link');
Simon Hunta36f03b2015-04-01 15:22:49 -0700329
Simon Hunta36f03b2015-04-01 15:22:49 -0700330
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700331 listProps(tbody, {
Simon Hunta36f03b2015-04-01 15:22:49 -0700332 propOrder: order,
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700333 props: {
Simon Hunte25c5a22015-04-02 14:37:12 -0700334 Type: linkType(data),
Simon Hunta36f03b2015-04-01 15:22:49 -0700335
336 A_type: data.source.class,
337 A_id: data.source.id,
338 A_label: friendly(data.source),
339 A_port: data.srcPort,
340
341 B_type: data.target.class,
342 B_id: data.target.id,
343 B_label: friendly(data.target),
344 B_port: data.tgtPort
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700345 }
346 });
Simon Hunta36f03b2015-04-01 15:22:49 -0700347
Simon Hunte25c5a22015-04-02 14:37:12 -0700348 if (!edgeLink) {
349 addProp(tbody, 'A &rarr; B', linkSummary(data.fromSource));
350 addProp(tbody, 'B &rarr; A', linkSummary(data.fromTarget));
351 }
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700352 }
353
354 function displayNothing() {
355 haveDetails = false;
356 hideDetailPanel();
357 }
358
359 function displaySomething() {
360 haveDetails = true;
361 if (useDetails) {
362 showDetailPanel();
363 }
364 }
365
Simon Hunt08f841d02015-02-10 14:39:20 -0800366 // === -----------------------------------------------------
367 // Event Handlers
368
369 function showSummary(data) {
370 populateSummary(data);
371 showSummaryPanel();
372 }
373
Simon Hunt36a58c62015-04-08 11:00:07 -0700374 function toggleSummary(x) {
Simon Huntee7a3ce2015-04-09 13:28:37 -0700375 var kev = (x === 'keyev'),
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700376 on = kev ? !summary.panel().isVisible() : !!x,
Simon Huntee7a3ce2015-04-09 13:28:37 -0700377 verb = on ? 'Show' : 'Hide';
Simon Hunt36a58c62015-04-08 11:00:07 -0700378
379 if (on) {
Simon Hunta0eb0a82015-02-11 12:30:06 -0800380 // ask server to start sending summary data.
Simon Hunt237676b52015-03-10 19:04:26 -0700381 wss.sendEvent('requestSummary');
Simon Hunta0eb0a82015-02-11 12:30:06 -0800382 // note: the summary panel will appear, once data arrives
Simon Hunt36a58c62015-04-08 11:00:07 -0700383 } else {
384 hideSummaryPanel();
Simon Hunt6036b192015-02-11 11:20:26 -0800385 }
Simon Huntee7a3ce2015-04-09 13:28:37 -0700386 flash.flash(verb + ' summary panel');
387 return on;
Simon Hunt6036b192015-02-11 11:20:26 -0800388 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800389
390 // === -----------------------------------------------------
391 // === LOGIC For showing/hiding summary and detail panels...
392
Simon Hunt626d2102015-01-29 11:54:50 -0800393 function showSummaryPanel() {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700394 function _show() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700395 summary.panel().show();
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700396 summary.adjustHeight(sumFromTop, sumMax);
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700397 }
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700398 if (detail.panel().isVisible()) {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700399 detail.down(_show);
Simon Hunt6036b192015-02-11 11:20:26 -0800400 } else {
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700401 _show();
Simon Hunt6036b192015-02-11 11:20:26 -0800402 }
Simon Huntc252aa62015-02-10 16:45:39 -0800403 }
404
405 function hideSummaryPanel() {
Simon Hunta0eb0a82015-02-11 12:30:06 -0800406 // instruct server to stop sending summary data
Simon Hunt237676b52015-03-10 19:04:26 -0700407 wss.sendEvent("cancelSummary");
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700408 summary.panel().hide(detail.up);
Simon Hunt4b668592015-01-29 17:33:53 -0800409 }
Simon Hunt626d2102015-01-29 11:54:50 -0800410
Simon Hunt08f841d02015-02-10 14:39:20 -0800411 function showDetailPanel() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700412 if (summary.panel().isVisible()) {
413 detail.down(detail.panel().show);
Simon Hunt6036b192015-02-11 11:20:26 -0800414 } else {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700415 detail.up(detail.panel().show);
Simon Hunt6036b192015-02-11 11:20:26 -0800416 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800417 }
418
419 function hideDetailPanel() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700420 detail.panel().hide();
Simon Hunt08f841d02015-02-10 14:39:20 -0800421 }
422
Simon Hunt6036b192015-02-11 11:20:26 -0800423 // ==========================
Simon Hunt08f841d02015-02-10 14:39:20 -0800424
Simon Hunt6036b192015-02-11 11:20:26 -0800425 function augmentDetailPanel() {
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700426 var d = detail,
427 downPos = sumFromTop + sumMax + 20;
428 d.ypos = { up: sumFromTop, down: downPos, current: downPos};
Simon Hunt6036b192015-02-11 11:20:26 -0800429
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700430 d._move = function (y, cb) {
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700431 var yp = d.ypos,
432 endCb;
433
434 if (fs.isF(cb)) {
435 endCb = function () {
436 cb();
437 d.adjustHeight(d.ypos.current);
438 }
439 } else {
440 endCb = function () {
441 d.adjustHeight(d.ypos.current);
442 }
443 }
Simon Hunt6036b192015-02-11 11:20:26 -0800444 if (yp.current !== y) {
445 yp.current = y;
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700446 d.panel().el().transition().duration(300)
Simon Hunt6036b192015-02-11 11:20:26 -0800447 .each('end', endCb)
448 .style('top', yp.current + 'px');
449 } else {
450 endCb();
451 }
452 };
453
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700454 d.down = function (cb) { d._move(d.ypos.down, cb); };
455 d.up = function (cb) { d._move(d.ypos.up, cb); };
Simon Hunt6036b192015-02-11 11:20:26 -0800456 }
Simon Hunt08f841d02015-02-10 14:39:20 -0800457
Simon Hunt239e5882015-04-23 15:07:04 -0700458 function toggleUseDetailsFlag(x) {
Simon Huntee7a3ce2015-04-09 13:28:37 -0700459 var kev = (x === 'keyev'),
460 verb;
461
462 useDetails = kev ? !useDetails : !!x;
463 verb = useDetails ? 'Enable' : 'Disable';
464
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700465 if (useDetails) {
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700466 if (haveDetails) {
467 showDetailPanel();
468 }
469 } else {
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700470 hideDetailPanel();
471 }
Simon Huntee7a3ce2015-04-09 13:28:37 -0700472 flash.flash(verb + ' details panel');
473 return useDetails;
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700474 }
475
Simon Hunt4b668592015-01-29 17:33:53 -0800476 // ==========================
477
Simon Hunt237676b52015-03-10 19:04:26 -0700478 function initPanels() {
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700479 sumFromTop = mast.mastHeight() + padTop;
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700480 summary = createTopoPanel(idSum, panelOpts);
481 detail = createTopoPanel(idDet, panelOpts);
Simon Hunt6036b192015-02-11 11:20:26 -0800482
483 augmentDetailPanel();
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700484 watchWindow();
Simon Hunt4b668592015-01-29 17:33:53 -0800485 }
486
487 function destroyPanels() {
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700488 summary.destroy();
489 summary = null;
490
491 detail.destroy();
492 detail = null;
Simon Hunt239e5882015-04-23 15:07:04 -0700493 haveDetails = false;
Bri Prebilic Cole0a6ffb62015-06-04 09:32:12 -0700494 unbindWatch();
Simon Hunt626d2102015-01-29 11:54:50 -0800495 }
496
497 // ==========================
498
Simon Huntb0ec1e52015-01-28 18:13:49 -0800499 angular.module('ovTopo')
500 .factory('TopoPanelService',
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700501 ['$log', '$window', '$rootScope', 'FnService', 'PanelService', 'GlyphService',
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700502 'FlashService', 'WebSocketService', 'ButtonService', 'MastService',
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700503 'NavService',
Simon Huntb0ec1e52015-01-28 18:13:49 -0800504
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700505 function (_$log_, _$window_, _$rootScope_,
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700506 _fs_, _ps_, _gs_, _flash_, _wss_, _bns_, _mast_, _ns_) {
Simon Huntb0ec1e52015-01-28 18:13:49 -0800507 $log = _$log_;
Bri Prebilic Cole69d5f4e2015-05-19 15:59:55 -0700508 $window = _$window_;
509 $rootScope = _$rootScope_;
Simon Hunt6036b192015-02-11 11:20:26 -0800510 fs = _fs_;
Simon Huntb0ec1e52015-01-28 18:13:49 -0800511 ps = _ps_;
Simon Huntc9b73162015-01-29 14:02:15 -0800512 gs = _gs_;
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700513 flash = _flash_;
Simon Hunt237676b52015-03-10 19:04:26 -0700514 wss = _wss_;
Bri Prebilic Colef5e48b12015-04-21 14:52:36 -0700515 bns = _bns_;
Bri Prebilic Coled8745462015-06-01 16:08:57 -0700516 mast = _mast_;
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700517 ns = _ns_;
Simon Huntb0ec1e52015-01-28 18:13:49 -0800518
Simon Huntb0ec1e52015-01-28 18:13:49 -0800519 return {
520 initPanels: initPanels,
Simon Hunt626d2102015-01-29 11:54:50 -0800521 destroyPanels: destroyPanels,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700522 createTopoPanel: createTopoPanel,
Simon Hunt08f841d02015-02-10 14:39:20 -0800523
524 showSummary: showSummary,
Simon Hunt6036b192015-02-11 11:20:26 -0800525 toggleSummary: toggleSummary,
Simon Hunt08f841d02015-02-10 14:39:20 -0800526
Simon Hunt239e5882015-04-23 15:07:04 -0700527 toggleUseDetailsFlag: toggleUseDetailsFlag,
Simon Hunt08f841d02015-02-10 14:39:20 -0800528 displaySingle: displaySingle,
529 displayMulti: displayMulti,
Simon Hunt0c6b2d32015-03-26 17:46:29 -0700530 displayLink: displayLink,
531 displayNothing: displayNothing,
532 displaySomething: displaySomething,
Bri Prebilic Cole684bcb72015-05-11 12:00:24 -0700533 addAction: addAction,
Simon Hunt08f841d02015-02-10 14:39:20 -0800534
Simon Huntc252aa62015-02-10 16:45:39 -0800535 hideSummaryPanel: hideSummaryPanel,
Simon Hunt08f841d02015-02-10 14:39:20 -0800536
Bri Prebilic Cole35d29712015-05-11 16:01:32 -0700537 detailVisible: function () { return detail.panel().isVisible(); },
538 summaryVisible: function () { return summary.panel().isVisible(); }
Simon Huntb0ec1e52015-01-28 18:13:49 -0800539 };
540 }]);
541}());