blob: 75bcee30a5589ac207298d93cda397babdbb73d8 [file] [log] [blame]
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -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/*
Bri Prebilic Coleaa0f0882015-02-04 15:27:55 -080018 ONOS GUI -- Device View Module
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -080019 */
20
21(function () {
22 'use strict';
23
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -070024 // injected refs
Simon Huntd5579252015-10-06 15:09:14 -070025 var $log, $scope, $loc, fs, mast, ps, wss, is, ns, ks;
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -070026
27 // internal state
Bri Prebilic Colee568ead2015-05-01 09:51:28 -070028 var detailsPanel,
Simon Huntd766c312015-10-06 11:46:32 -070029 pStartY,
30 pHeight,
31 top,
32 bottom,
33 iconDiv,
34 wSize,
Alan Deikman8d858752017-02-14 18:08:29 -080035 editingName = false,
36 device;
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -070037
38 // constants
Simon Hunt986b92f2016-06-03 15:46:59 -070039 var topPdg = 28,
Bri Prebilic Cole45069382015-04-14 15:21:38 -070040 ctnrPdg = 24,
Bri Prebilic Cole9cf1a8d2015-04-21 13:15:29 -070041 scrollSize = 17,
Bri Prebilic Cole45069382015-04-14 15:21:38 -070042 portsTblPdg = 50,
43
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -070044 pName = 'device-details-panel',
45 detailsReq = 'deviceDetailsRequest',
46 detailsResp = 'deviceDetailsResponse',
Simon Huntd5579252015-10-06 15:09:14 -070047 nameChangeReq = 'deviceNameChangeRequest',
48 nameChangeResp = 'deviceNameChangeResponse',
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -070049 friendlyProps = [
Simon Huntd5579252015-10-06 15:09:14 -070050 'URI', 'Type', 'Master ID', 'Chassis ID',
Steven Burrows1c2a9682017-07-14 16:52:46 +010051 'Vendor', 'H/W Version', 'S/W Version', 'Protocol', 'Serial #',
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -070052 ],
53 portCols = [
Steven Burrows1c2a9682017-07-14 16:52:46 +010054 'enabled', 'id', 'speed', 'type', 'elinks_dest', 'name',
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -070055 ],
56 friendlyPortCols = [
Steven Burrows1c2a9682017-07-14 16:52:46 +010057 'Enabled', 'ID', 'Speed', 'Type', 'Egress Links', 'Name',
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -070058 ];
59
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -070060 function closePanel() {
61 if (detailsPanel.isVisible()) {
62 $scope.selId = null;
63 detailsPanel.hide();
Simon Huntd766c312015-10-06 11:46:32 -070064 return true;
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -070065 }
Simon Huntd766c312015-10-06 11:46:32 -070066 return false;
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -070067 }
68
Bri Prebilic Coleb699a162015-04-13 12:01:39 -070069 function addCloseBtn(div) {
Simon Hunt986b92f2016-06-03 15:46:59 -070070 is.loadEmbeddedIcon(div, 'close', 20);
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -070071 div.on('click', closePanel);
Bri Prebilic Coleb699a162015-04-13 12:01:39 -070072 }
73
Simon Huntd5579252015-10-06 15:09:14 -070074 function exitEditMode(nameH2, name) {
Simon Hunt239f09e2017-05-18 13:10:09 -070075 nameH2.text(name);
Simon Hunt986b92f2016-06-03 15:46:59 -070076 nameH2.classed('editable clickable', true);
Simon Huntd5579252015-10-06 15:09:14 -070077 editingName = false;
78 ks.enableGlobalKeys(true);
Simon Huntd766c312015-10-06 11:46:32 -070079 }
80
81 function editNameSave() {
Simon Huntd5579252015-10-06 15:09:14 -070082 var nameH2 = top.select('h2'),
83 id = $scope.panelData.id,
84 val,
Simon Huntd766c312015-10-06 11:46:32 -070085 newVal;
Simon Huntd5579252015-10-06 15:09:14 -070086
Simon Huntd766c312015-10-06 11:46:32 -070087 if (editingName) {
Simon Huntd5579252015-10-06 15:09:14 -070088 val = nameH2.select('input').property('value').trim();
89 newVal = val || id;
Simon Huntd766c312015-10-06 11:46:32 -070090
Simon Huntd5579252015-10-06 15:09:14 -070091 exitEditMode(nameH2, newVal);
Simon Huntd766c312015-10-06 11:46:32 -070092 $scope.panelData.name = newVal;
Simon Huntd5579252015-10-06 15:09:14 -070093 wss.sendEvent(nameChangeReq, { id: id, name: val });
Simon Huntd766c312015-10-06 11:46:32 -070094 }
95 }
96
97 function editNameCancel() {
Simon Huntd766c312015-10-06 11:46:32 -070098 if (editingName) {
Simon Huntd5579252015-10-06 15:09:14 -070099 exitEditMode(top.select('h2'), $scope.panelData.name);
Simon Huntd766c312015-10-06 11:46:32 -0700100 return true;
101 }
102 return false;
103 }
104
105 function editName() {
Simon Huntd5579252015-10-06 15:09:14 -0700106 var nameH2 = top.select('h2'),
107 tf, el;
108
Simon Huntd766c312015-10-06 11:46:32 -0700109 if (!editingName) {
Simon Hunt986b92f2016-06-03 15:46:59 -0700110 nameH2.classed('editable clickable', false);
Simon Hunt239f09e2017-05-18 13:10:09 -0700111 nameH2.text('');
Simon Huntd5579252015-10-06 15:09:14 -0700112 tf = nameH2.append('input').classed('name-input', true)
Simon Huntd766c312015-10-06 11:46:32 -0700113 .attr('type', 'text')
114 .attr('value', $scope.panelData.name);
Simon Huntd5579252015-10-06 15:09:14 -0700115 el = tf[0][0];
116 el.focus();
117 el.select();
118 editingName = true;
119 ks.enableGlobalKeys(false);
Simon Huntd766c312015-10-06 11:46:32 -0700120 }
121 }
122
123 function handleEscape() {
124 return editNameCancel() || closePanel();
125 }
126
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700127 function setUpPanel() {
Bri Prebilic Cole8f07f0d2015-04-23 13:28:43 -0700128 var container, closeBtn, tblDiv;
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700129 detailsPanel.empty();
130
131 container = detailsPanel.append('div').classed('container', true);
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700132
133 top = container.append('div').classed('top', true);
134 closeBtn = top.append('div').classed('close-btn', true);
135 addCloseBtn(closeBtn);
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700136 iconDiv = top.append('div').classed('dev-icon', true);
Simon Hunt986b92f2016-06-03 15:46:59 -0700137 top.append('h2').classed('editable clickable', true).on('click', editName);
Simon Huntd766c312015-10-06 11:46:32 -0700138
Bri Prebilic Cole8f07f0d2015-04-23 13:28:43 -0700139 tblDiv = top.append('div').classed('top-tables', true);
140 tblDiv.append('div').classed('left', true).append('table');
141 tblDiv.append('div').classed('right', true).append('table');
142
Bri Prebilic Cole45069382015-04-14 15:21:38 -0700143 top.append('hr');
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700144
145 bottom = container.append('div').classed('bottom', true);
Simon Hunt239f09e2017-05-18 13:10:09 -0700146 bottom.append('h2').classed('ports-title', true).text('Ports');
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700147 bottom.append('table');
148 }
149
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700150 function addProp(tbody, index, value) {
151 var tr = tbody.append('tr');
152
153 function addCell(cls, txt) {
Simon Hunt239f09e2017-05-18 13:10:09 -0700154 tr.append('td').attr('class', cls).text(txt);
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700155 }
156 addCell('label', friendlyProps[index] + ' :');
157 addCell('value', value);
158 }
159
Bri Prebilic Cole9b1fb9a2015-07-01 13:57:11 -0700160 function populateTop(tblDiv, details) {
Bri Prebilic Cole8f07f0d2015-04-23 13:28:43 -0700161 var leftTbl = tblDiv.select('.left')
162 .select('table')
163 .append('tbody'),
164 rightTbl = tblDiv.select('.right')
165 .select('table')
166 .append('tbody');
167
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700168 is.loadEmbeddedIcon(iconDiv, details._iconid_type, 40);
Simon Hunt239f09e2017-05-18 13:10:09 -0700169 top.select('h2').text(details.name);
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700170
Alan Deikman8d858752017-02-14 18:08:29 -0800171 // === demonstrate use of JsonCodec object see ONOS-5976
Steven Burrows1c2a9682017-07-14 16:52:46 +0100172 addProp(leftTbl, 0, device.id);
173 addProp(leftTbl, 1, device.type);
174 addProp(leftTbl, 2, details['masterid']);
175 addProp(leftTbl, 3, details['chassid']);
Alan Deikman8d858752017-02-14 18:08:29 -0800176 addProp(rightTbl, 4, device.mfr);
177 addProp(rightTbl, 5, device.hw);
178 addProp(rightTbl, 6, device.sw);
179 addProp(rightTbl, 7, details['protocol']);
180 addProp(rightTbl, 8, device.serial);
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700181 }
182
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700183 function addPortRow(tbody, port) {
184 var tr = tbody.append('tr');
185
186 portCols.forEach(function (col) {
Simon Hunt239f09e2017-05-18 13:10:09 -0700187 tr.append('td').text(port[col]);
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700188 });
189 }
190
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700191 function populateBottom(table, ports) {
192 var theader = table.append('thead').append('tr'),
193 tbody = table.append('tbody'),
Bri Prebilic Cole45069382015-04-14 15:21:38 -0700194 tbWidth, tbHeight;
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700195
196 friendlyPortCols.forEach(function (col) {
Simon Hunt239f09e2017-05-18 13:10:09 -0700197 theader.append('th').text(col);
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700198 });
199 ports.forEach(function (port) {
200 addPortRow(tbody, port);
201 });
202
203 tbWidth = fs.noPxStyle(tbody, 'width') + scrollSize;
Bri Prebilic Cole45069382015-04-14 15:21:38 -0700204 tbHeight = pHeight
205 - (fs.noPxStyle(detailsPanel.el()
206 .select('.top'), 'height')
207 + fs.noPxStyle(detailsPanel.el()
208 .select('.ports-title'), 'height')
209 + portsTblPdg);
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700210
211 table.style({
212 height: tbHeight + 'px',
213 width: tbWidth + 'px',
214 overflow: 'auto',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100215 display: 'block',
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700216 });
217
Bri Prebilic Cole45069382015-04-14 15:21:38 -0700218 detailsPanel.width(tbWidth + ctnrPdg);
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700219 }
220
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700221 function populateDetails(details) {
Simon Hunta9301bb2016-10-20 11:38:10 -0700222 var topTbs, btmTbl, ports;
223
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700224 setUpPanel();
225
Bri Prebilic Cole8f07f0d2015-04-23 13:28:43 -0700226 topTbs = top.select('.top-tables');
Bri Prebilic Cole45069382015-04-14 15:21:38 -0700227 btmTbl = bottom.select('table');
228 ports = details.ports;
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700229
Bri Prebilic Cole9b1fb9a2015-07-01 13:57:11 -0700230 populateTop(topTbs, details);
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700231 populateBottom(btmTbl, ports);
Bri Prebilic Cole45069382015-04-14 15:21:38 -0700232
233 detailsPanel.height(pHeight);
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700234 }
235
236 function respDetailsCb(data) {
Bri Prebilic Colee568ead2015-05-01 09:51:28 -0700237 $scope.panelData = data.details;
Alan Deikman8d858752017-02-14 18:08:29 -0800238 device = data.device;
Bri Prebilic Cole54bbfb92015-05-28 16:02:28 -0700239 $scope.$apply();
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700240 }
241
Simon Huntd5579252015-10-06 15:09:14 -0700242 function respNameCb(data) {
243 if (data.warn) {
244 $log.warn(data.warn, data.id);
Simon Hunt239f09e2017-05-18 13:10:09 -0700245 top.select('h2').text(data.id);
Simon Huntd5579252015-10-06 15:09:14 -0700246 }
247 }
248
Bri Prebilic Cole45069382015-04-14 15:21:38 -0700249 function createDetailsPane() {
250 detailsPanel = ps.createPanel(pName, {
251 width: wSize.width,
252 margin: 0,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100253 hideMargin: 0,
Bri Prebilic Cole45069382015-04-14 15:21:38 -0700254 });
255 detailsPanel.el().style({
256 position: 'absolute',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100257 top: pStartY + 'px',
Bri Prebilic Cole45069382015-04-14 15:21:38 -0700258 });
Bri Prebilic Cole68844ba2015-07-22 15:41:37 -0700259 $scope.hidePanel = function () { detailsPanel.hide(); };
Bri Prebilic Cole45069382015-04-14 15:21:38 -0700260 detailsPanel.hide();
261 }
262
Simon Hunt400ebbf2017-01-06 20:07:50 -0800263 // Sample functions for detail panel creation
264 function popTop(div) {
265 $log.debug('populateTop');
266 // TODO: real work
267 // div.append(.....);
268 // div.append(.....);
269 // div.append(.....);
270 }
271
272 function popMid(div) {
273 $log.debug('populateMiddle');
274 // TODO: real work
275 }
276
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -0800277 angular.module('ovDevice', [])
Simon Hunta89f0f92015-02-26 16:47:12 -0800278 .controller('OvDeviceCtrl',
Simon Hunt400ebbf2017-01-06 20:07:50 -0800279 ['$log', '$scope', '$location', 'TableBuilderService',
280 'TableDetailService', 'FnService',
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700281 'MastService', 'PanelService', 'WebSocketService', 'IconService',
Simon Huntd5579252015-10-06 15:09:14 -0700282 'NavService', 'KeyService',
Simon Hunta89f0f92015-02-26 16:47:12 -0800283
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700284 function (_$log_, _$scope_, _$location_,
Simon Hunt400ebbf2017-01-06 20:07:50 -0800285 tbs, tds, _fs_, _mast_, _ps_, _wss_, _is_, _ns_, _ks_) {
Simon Huntd5579252015-10-06 15:09:14 -0700286 var params,
287 handlers = {};
288
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700289 $log = _$log_;
290 $scope = _$scope_;
Simon Huntd5579252015-10-06 15:09:14 -0700291 $loc = _$location_;
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700292 fs = _fs_;
293 mast = _mast_;
294 ps = _ps_;
295 wss = _wss_;
296 is = _is_;
Bri Prebilic Cole8f07f0d2015-04-23 13:28:43 -0700297 ns = _ns_;
Simon Huntd5579252015-10-06 15:09:14 -0700298 ks = _ks_;
299
300 params = $loc.search();
301
Bri Prebilic Cole68844ba2015-07-22 15:41:37 -0700302 $scope.panelData = {};
Bri Prebilic Coleeef67ae2015-07-01 16:26:59 -0700303 $scope.flowTip = 'Show flow view for selected device';
304 $scope.portTip = 'Show port view for selected device';
305 $scope.groupTip = 'Show group view for selected device';
Jian Li1f544732015-12-30 23:36:37 -0800306 $scope.meterTip = 'Show meter view for selected device';
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700307
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700308 // details panel handlers
309 handlers[detailsResp] = respDetailsCb;
Simon Huntd5579252015-10-06 15:09:14 -0700310 handlers[nameChangeResp] = respNameCb;
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700311 wss.bindHandlers(handlers);
312
313 // query for if a certain device needs to be highlighted
314 if (params.hasOwnProperty('devId')) {
315 $scope.selId = params['devId'];
316 wss.sendEvent(detailsReq, { id: $scope.selId });
317 }
318
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700319 function selCb($event, row) {
Bri Prebilic Colebfab9c72015-06-01 14:33:18 -0700320 if ($scope.selId) {
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700321 wss.sendEvent(detailsReq, { id: row.id });
322 } else {
Bri Prebilic Cole68844ba2015-07-22 15:41:37 -0700323 $scope.hidePanel();
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700324 }
325 $log.debug('Got a click on:', row);
326 }
327
Bri Prebilic Cole864cdd62015-04-02 15:46:47 -0700328 tbs.buildTable({
Bri Prebilic Cole864cdd62015-04-02 15:46:47 -0700329 scope: $scope,
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700330 tag: 'device',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100331 selCb: selCb,
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700332 });
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700333
Simon Hunt400ebbf2017-01-06 20:07:50 -0800334
335 // ==================== for testing for now ===============
336 // TODO: more than just an example
337 tds.buildBasePanel({
338 popTop: popTop,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100339 popMid: popMid,
Simon Hunt400ebbf2017-01-06 20:07:50 -0800340 });
341 // ==================== for testing for now ===============
342
343
Bri Prebilic Cole9b1fb9a2015-07-01 13:57:11 -0700344 $scope.nav = function (path) {
345 if ($scope.selId) {
346 ns.navTo(path, { devId: $scope.selId });
347 }
348 };
349
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700350 $scope.$on('$destroy', function () {
Bri Prebilic Cole0feedc02015-04-09 14:17:37 -0700351 wss.unbindHandlers(handlers);
Simon Hunta89f0f92015-02-26 16:47:12 -0800352 });
353
Bri Prebilic Cole72eb6db2015-03-30 16:58:53 -0700354 $log.log('OvDeviceCtrl has been created');
Bri Prebilic Cole54bbfb92015-05-28 16:02:28 -0700355 }])
356
Bri Prebilic Cole55ee09b2015-08-04 14:34:07 -0700357 .directive('deviceDetailsPanel',
358 ['$rootScope', '$window', '$timeout', 'KeyService',
359 function ($rootScope, $window, $timeout, ks) {
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700360 return function (scope) {
Bri Prebilic Cole0bc4de22015-07-20 17:07:55 -0700361 var unbindWatch;
Bri Prebilic Cole54bbfb92015-05-28 16:02:28 -0700362
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700363 function heightCalc() {
364 pStartY = fs.noPxStyle(d3.select('.tabular-header'), 'height')
365 + mast.mastHeight() + topPdg;
366 wSize = fs.windowSize(pStartY);
367 pHeight = wSize.height;
368 }
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700369
Bri Prebilic Cole55ee09b2015-08-04 14:34:07 -0700370 function initPanel() {
371 heightCalc();
372 createDetailsPane();
373 }
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700374
Bri Prebilic Cole55ee09b2015-08-04 14:34:07 -0700375 // Safari has a bug where it renders the fixed-layout table wrong
376 // if you ask for the window's size too early
377 if (scope.onos.browser === 'safari') {
378 $timeout(initPanel);
379 } else {
380 initPanel();
381 }
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700382 // create key bindings to handle panel
383 ks.keyBindings({
Simon Huntd766c312015-10-06 11:46:32 -0700384 enter: editNameSave,
385 esc: [handleEscape, 'Close the details panel'],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100386 _helpFormat: ['esc'],
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700387 });
388 ks.gestureNotes([
389 ['click', 'Select a row to show device details'],
Steven Burrows1c2a9682017-07-14 16:52:46 +0100390 ['scroll down', 'See more devices'],
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700391 ]);
392
Bri Prebilic Cole55ee09b2015-08-04 14:34:07 -0700393 // if the panelData changes
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700394 scope.$watch('panelData', function () {
395 if (!fs.isEmptyObject(scope.panelData)) {
396 populateDetails(scope.panelData);
397 detailsPanel.show();
Bri Prebilic Cole54bbfb92015-05-28 16:02:28 -0700398 }
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700399 });
Bri Prebilic Cole54bbfb92015-05-28 16:02:28 -0700400
Bri Prebilic Cole55ee09b2015-08-04 14:34:07 -0700401 // if the window size changes
Bri Prebilic Cole0bc4de22015-07-20 17:07:55 -0700402 unbindWatch = $rootScope.$watchCollection(
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700403 function () {
404 return {
405 h: $window.innerHeight,
Steven Burrows1c2a9682017-07-14 16:52:46 +0100406 w: $window.innerWidth,
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700407 };
408 }, function () {
Bri Prebilic Cole54bbfb92015-05-28 16:02:28 -0700409 if (!fs.isEmptyObject(scope.panelData)) {
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700410 heightCalc();
Bri Prebilic Cole54bbfb92015-05-28 16:02:28 -0700411 populateDetails(scope.panelData);
Bri Prebilic Cole54bbfb92015-05-28 16:02:28 -0700412 }
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700413 }
414 );
Bri Prebilic Cole54bbfb92015-05-28 16:02:28 -0700415
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700416 scope.$on('$destroy', function () {
Bri Prebilic Cole0bc4de22015-07-20 17:07:55 -0700417 unbindWatch();
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700418 ks.unbindKeys();
Bri Prebilic Cole17c6d0a2015-07-16 14:56:40 -0700419 ps.destroyPanel(pName);
420 });
421 };
422 }]);
Bri Prebilic Cole7c92a3d2015-01-09 16:50:03 -0800423}());