blob: 7cb0cdb1b370979584c7cd68d7d7e14d44312b90 [file] [log] [blame]
Thomas Vachuska0fa583c2015-03-30 23:07:41 -07001/*
Jian Lia54de5a2016-01-20 23:10:39 -08002 * Copyright 2015-2016 Open Networking Laboratory
Thomas Vachuska0fa583c2015-03-30 23:07:41 -07003 *
Thomas Vachuskaa7a0f562015-04-14 23:27:44 -07004 * Licensed under the Apache License, Version 2.0 (the 'License');
Thomas Vachuska0fa583c2015-03-30 23:07:41 -07005 * 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
Thomas Vachuskaa7a0f562015-04-14 23:27:44 -070011 * distributed under the License is distributed on an 'AS IS' BASIS,
Thomas Vachuska0fa583c2015-03-30 23:07:41 -070012 * 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 -- App View Module
19 */
20
21(function () {
22 'use strict';
23
Jian Lia54de5a2016-01-20 23:10:39 -080024 // injected refs
Simon Hunt31642932016-01-22 20:34:00 -080025 var $log, $scope, wss, fs, ks, ps, is;
Jian Lia54de5a2016-01-20 23:10:39 -080026
27 // internal state
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -080028 var detailsPanel,
29 pStartY,
30 pHeight,
31 top,
32 middle,
33 bottom,
34 wSize = false,
35 activateImmediately;
Jian Lia54de5a2016-01-20 23:10:39 -080036
Bri Prebilic Cole522e7562015-06-22 15:56:25 -070037 // constants
38 var INSTALLED = 'INSTALLED',
39 ACTIVE = 'ACTIVE',
Simon Hunt8d28a552016-01-11 14:01:02 -080040 appMgmtReq = 'appManagementRequest',
Jian Lia54de5a2016-01-20 23:10:39 -080041 topPdg = 50,
Simon Hunt31642932016-01-22 20:34:00 -080042 panelWidth = 500,
Jian Lia54de5a2016-01-20 23:10:39 -080043 pName = 'application-details-panel',
44 detailsReq = 'appDetailsRequest',
45 detailsResp = 'appDetailsResponse',
Simon Hunt8d28a552016-01-11 14:01:02 -080046 fileUploadUrl = 'applications/upload',
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -080047 activateOption = '?activate=true',
Jian Lia54de5a2016-01-20 23:10:39 -080048 iconUrlPrefix = 'rs/applications/',
49 iconUrlSuffix = '/icon',
Simon Hunt8d28a552016-01-11 14:01:02 -080050 dialogId = 'app-dialog',
51 dialogOpts = {
52 edge: 'right'
Simon Hunt3f92c432016-01-12 17:34:23 -080053 },
54 strongWarning = {
55 'org.onosproject.drivers': true
56 },
57 discouragement = 'Deactivating or uninstalling this component can' +
Jian Lia54de5a2016-01-20 23:10:39 -080058 ' have serious negative consequences! Do so at your own risk!!',
Simon Hunt31642932016-01-22 20:34:00 -080059 propOrder = ['id', 'state', 'category', 'version', 'origin', 'role'],
60 friendlyProps = ['App ID', 'State', 'Category', 'Version', 'Origin', 'Role'];
61 // note: url is handled separately
Jian Lia54de5a2016-01-20 23:10:39 -080062
63 function createDetailsPane() {
64 detailsPanel = ps.createPanel(pName, {
65 width: wSize.width,
66 margin: 0,
67 hideMargin: 0
68 });
69 detailsPanel.el().style({
70 position: 'absolute',
71 top: pStartY + 'px'
72 });
73 $scope.hidePanel = function () { detailsPanel.hide(); };
74 detailsPanel.hide();
75 }
76
77 function closePanel() {
78 if (detailsPanel.isVisible()) {
79 $scope.selId = null;
80 detailsPanel.hide();
81 return true;
82 }
83 return false;
84 }
85
Jian Lia54de5a2016-01-20 23:10:39 -080086 function addCloseBtn(div) {
87 is.loadEmbeddedIcon(div, 'plus', 30);
88 div.select('g').attr('transform', 'translate(25, 0) rotate(45)');
89 div.on('click', closePanel);
90 }
91
92 function setUpPanel() {
Simon Hunt31642932016-01-22 20:34:00 -080093 var container, closeBtn, div;
94
Jian Lia54de5a2016-01-20 23:10:39 -080095 detailsPanel.empty();
Simon Hunt31642932016-01-22 20:34:00 -080096 detailsPanel.width(panelWidth);
Jian Lia54de5a2016-01-20 23:10:39 -080097
98 container = detailsPanel.append('div').classed('container', true);
99
100 top = container.append('div').classed('top', true);
101 closeBtn = top.append('div').classed('close-btn', true);
102 addCloseBtn(closeBtn);
Jian Lia54de5a2016-01-20 23:10:39 -0800103
Simon Hunt31642932016-01-22 20:34:00 -0800104 div = top.append('div').classed('top-content', true);
Jian Lia54de5a2016-01-20 23:10:39 -0800105
Simon Hunt31642932016-01-22 20:34:00 -0800106 function ndiv(cls, tcls) {
107 var d = div.append('div').classed(cls, true);
108 if (tcls) {
109 d.append('table').classed(tcls, true);
110 }
111 }
112
Simon Hunt877ee982016-03-09 10:53:16 -0800113 ndiv('app-title');
Simon Hunt31642932016-01-22 20:34:00 -0800114 ndiv('left app-icon');
115 ndiv('right', 'app-props');
116 ndiv('app-url');
117
118 container.append('hr');
Jian Lia54de5a2016-01-20 23:10:39 -0800119
Jian Lida253e02016-01-21 17:46:17 -0800120 middle = container.append('div').classed('middle', true);
Simon Hunt31642932016-01-22 20:34:00 -0800121 middle.append('div').classed('app-readme', true);
Jian Lida253e02016-01-21 17:46:17 -0800122
Simon Hunt31642932016-01-22 20:34:00 -0800123 container.append('hr');
Jian Lida253e02016-01-21 17:46:17 -0800124
Simon Hunt31642932016-01-22 20:34:00 -0800125 // TODO: make bottom container scrollable
Jian Lia54de5a2016-01-20 23:10:39 -0800126 bottom = container.append('div').classed('bottom', true);
Simon Hunt31642932016-01-22 20:34:00 -0800127
128 function nTable(hdr, cls) {
129 bottom.append('h2').html(hdr);
130 bottom.append('div').classed(cls, true).append('table');
131 }
132
133 nTable('Features', 'features');
134 nTable('Required Apps', 'required-apps');
135 nTable('Permissions', 'permissions');
Jian Lia54de5a2016-01-20 23:10:39 -0800136 }
137
138 function addProp(tbody, index, value) {
Simon Hunt31642932016-01-22 20:34:00 -0800139 var tr = tbody.append('tr'),
140 vcls = index ? 'value' : 'value-bold';
Jian Lia54de5a2016-01-20 23:10:39 -0800141
142 function addCell(cls, txt) {
143 tr.append('td').attr('class', cls).html(txt);
144 }
Simon Hunt31642932016-01-22 20:34:00 -0800145
146 addCell('label', friendlyProps[index] + ':');
147 addCell(vcls, value);
Jian Lia54de5a2016-01-20 23:10:39 -0800148 }
149
Simon Hunt31642932016-01-22 20:34:00 -0800150 function urlize(u) {
151 return '<i>URL:</i> <a href="' + u + '" target="_blank">' + u + '</a>';
Simon Hunta477b602016-01-22 12:10:07 -0800152 }
153
Simon Hunt31642932016-01-22 20:34:00 -0800154 function addIcon(elem, value) {
155 elem.append('img').attr('src', iconUrlPrefix + value + iconUrlSuffix);
Jian Lia54de5a2016-01-20 23:10:39 -0800156 }
157
Simon Hunt31642932016-01-22 20:34:00 -0800158 function populateTop(details) {
159 var propsBody = top.select('.app-props').append('tbody'),
160 url = details.url;
Jian Lia54de5a2016-01-20 23:10:39 -0800161
Simon Hunt877ee982016-03-09 10:53:16 -0800162 top.select('.app-title').text(details.title);
163
Simon Hunt31642932016-01-22 20:34:00 -0800164 addIcon(top.select('.app-icon'), details.id);
Jian Lia54de5a2016-01-20 23:10:39 -0800165
Jian Lia54de5a2016-01-20 23:10:39 -0800166 propOrder.forEach(function (prop, i) {
Simon Hunt31642932016-01-22 20:34:00 -0800167 addProp(propsBody, i, details[prop]);
Jian Lia54de5a2016-01-20 23:10:39 -0800168 });
169
Simon Hunt31642932016-01-22 20:34:00 -0800170 if (url) {
171 top.select('.app-url').html(urlize(url));
172 }
Jian Lida253e02016-01-21 17:46:17 -0800173 }
174
Simon Hunt31642932016-01-22 20:34:00 -0800175 function populateMiddle(details) {
176 middle.select('.app-readme').text(details.readme);
Jian Lia54de5a2016-01-20 23:10:39 -0800177 }
178
Simon Hunt31642932016-01-22 20:34:00 -0800179 function populateBottom(details) {
180
181 function addItems(cls, items) {
182 var table = bottom.select('.' + cls).select('table'),
183 tbody = table.append('tbody');
184
185 items.forEach(function (item) {
186 tbody.append('tr').append('td').html(item);
187 });
188 }
189
190 addItems('features', details.features);
191 addItems('required-apps', details.required_apps);
192 addItems('permissions', details.permissions);
Jian Lia54de5a2016-01-20 23:10:39 -0800193 }
194
195 function populateDetails(details) {
Jian Lia54de5a2016-01-20 23:10:39 -0800196 setUpPanel();
Simon Hunt31642932016-01-22 20:34:00 -0800197 populateTop(details);
198 populateMiddle(details);
199 populateBottom(details);
Jian Lia54de5a2016-01-20 23:10:39 -0800200 detailsPanel.height(pHeight);
201 }
202
Jian Lia54de5a2016-01-20 23:10:39 -0800203 function respDetailsCb(data) {
204 $scope.panelData = data.details;
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -0800205 $scope.selId = data.details.id;
206 $scope.ctrlBtnState.selection = data.details.id;
Jian Lia54de5a2016-01-20 23:10:39 -0800207 $scope.$apply();
208 }
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700209
Thomas Vachuska0fa583c2015-03-30 23:07:41 -0700210 angular.module('ovApp', [])
211 .controller('OvAppCtrl',
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -0800212 ['$log', '$scope', '$http', '$timeout',
Simon Hunt31642932016-01-22 20:34:00 -0800213 'WebSocketService', 'FnService', 'KeyService', 'PanelService',
214 'IconService', 'UrlFnService', 'DialogService', 'TableBuilderService',
Thomas Vachuska0fa583c2015-03-30 23:07:41 -0700215
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -0800216 function (_$log_, _$scope_, $http, $timeout, _wss_, _fs_, _ks_, _ps_, _is_, ufs, ds, tbs) {
Jian Lia54de5a2016-01-20 23:10:39 -0800217 $log = _$log_;
218 $scope = _$scope_;
219 wss = _wss_;
Jian Lia54de5a2016-01-20 23:10:39 -0800220 fs = _fs_;
Simon Hunt31642932016-01-22 20:34:00 -0800221 ks = _ks_;
Jian Lia54de5a2016-01-20 23:10:39 -0800222 ps = _ps_;
223 is = _is_;
224 $scope.panelData = {};
Bri Prebilic Cole6b95a3f2015-06-04 09:15:00 -0700225 $scope.ctrlBtnState = {};
Bri Prebilic Cole6c82ade2015-08-05 11:12:30 -0700226 $scope.uploadTip = 'Upload an application (.oar file)';
Bri Prebilic Coleeef67ae2015-07-01 16:26:59 -0700227 $scope.activateTip = 'Activate selected application';
228 $scope.deactivateTip = 'Deactivate selected application';
229 $scope.uninstallTip = 'Uninstall selected application';
Bri Prebilic Cole6b95a3f2015-06-04 09:15:00 -0700230
Jian Lia54de5a2016-01-20 23:10:39 -0800231 var handlers = {};
232
233 // details panel handlers
234 handlers[detailsResp] = respDetailsCb;
235 wss.bindHandlers(handlers);
236
Bri Prebilic Coleb699a162015-04-13 12:01:39 -0700237 function selCb($event, row) {
Simon Hunt3f92c432016-01-12 17:34:23 -0800238 // $scope.selId is set by code in tableBuilder
Bri Prebilic Cole6b95a3f2015-06-04 09:15:00 -0700239 $scope.ctrlBtnState.selection = !!$scope.selId;
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700240 refreshCtrls();
Simon Hunt3f92c432016-01-12 17:34:23 -0800241 ds.closeDialog(); // don't want dialog from previous selection
Jian Lia54de5a2016-01-20 23:10:39 -0800242
243 if ($scope.selId) {
244 wss.sendEvent(detailsReq, { id: row.id });
245 } else {
246 $scope.hidePanel();
247 }
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700248 }
249
Bri Prebilic Colea7f81e52015-06-23 10:11:08 -0700250 function refreshCtrls() {
251 var row, rowIdx;
252 if ($scope.ctrlBtnState.selection) {
253 rowIdx = fs.find($scope.selId, $scope.tableData);
254 row = rowIdx >= 0 ? $scope.tableData[rowIdx] : null;
255
256 $scope.ctrlBtnState.installed = row && row.state === INSTALLED;
257 $scope.ctrlBtnState.active = row && row.state === ACTIVE;
258 } else {
259 $scope.ctrlBtnState.installed = false;
260 $scope.ctrlBtnState.active = false;
261 }
Thomas Vachuska619c5382015-04-02 13:41:47 -0700262 }
Thomas Vachuska0fa583c2015-03-30 23:07:41 -0700263
Bri Prebilic Cole6b95a3f2015-06-04 09:15:00 -0700264 tbs.buildTable({
265 scope: $scope,
266 tag: 'app',
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700267 selCb: selCb,
Simon Hunta678b842016-01-11 17:14:18 -0800268 respCb: refreshCtrls,
269 // pre-populate sort so active apps are at the top of the list
270 sortParams: {
Simon Hunt051e9fa2016-01-19 15:54:22 -0800271 firstCol: 'state',
272 firstDir: 'desc',
Simon Hunt877ee982016-03-09 10:53:16 -0800273 secondCol: 'title',
Simon Hunt051e9fa2016-01-19 15:54:22 -0800274 secondDir: 'asc'
Simon Hunta678b842016-01-11 17:14:18 -0800275 }
Bri Prebilic Cole6b95a3f2015-06-04 09:15:00 -0700276 });
277
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700278 // TODO: reexamine where keybindings should be - directive or controller?
279 ks.keyBindings({
Simon Hunt31642932016-01-22 20:34:00 -0800280 esc: [$scope.selectCallback, 'Deselect application'],
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700281 _helpFormat: ['esc']
282 });
283 ks.gestureNotes([
Simon Hunt31642932016-01-22 20:34:00 -0800284 ['click row', 'Select / deselect application'],
285 ['scroll down', 'See more applications']
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700286 ]);
287
Simon Hunt3f92c432016-01-12 17:34:23 -0800288 function createConfirmationText(action, itemId) {
Simon Hunt8d28a552016-01-11 14:01:02 -0800289 var content = ds.createDiv();
Simon Hunt40927332016-01-22 15:29:47 -0800290 content.append('p').text(fs.cap(action) + ' ' + itemId);
Simon Hunt3f92c432016-01-12 17:34:23 -0800291 if (strongWarning[itemId]) {
292 content.append('p').text(discouragement).classed('strong', true);
293 }
Simon Hunt8d28a552016-01-11 14:01:02 -0800294 return content;
295 }
296
297 function confirmAction(action) {
Simon Hunt3f92c432016-01-12 17:34:23 -0800298 var itemId = $scope.selId,
Simon Hunt8d28a552016-01-11 14:01:02 -0800299 spar = $scope.sortParams;
300
301 function dOk() {
Simon Hunt3f92c432016-01-12 17:34:23 -0800302 $log.debug('Initiating', action, 'of', itemId);
Simon Hunt8d28a552016-01-11 14:01:02 -0800303 wss.sendEvent(appMgmtReq, {
304 action: action,
Simon Hunt3f92c432016-01-12 17:34:23 -0800305 name: itemId,
Simon Hunt8d28a552016-01-11 14:01:02 -0800306 sortCol: spar.sortCol,
307 sortDir: spar.sortDir
308 });
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -0800309 if (action == 'uninstall') {
310 detailsPanel.hide();
311 } else {
312 wss.sendEvent(detailsReq, {id: itemId});
313 }
Simon Hunt8d28a552016-01-11 14:01:02 -0800314 }
315
316 function dCancel() {
Simon Hunt3f92c432016-01-12 17:34:23 -0800317 $log.debug('Canceling', action, 'of', itemId);
Simon Hunt8d28a552016-01-11 14:01:02 -0800318 }
319
320 ds.openDialog(dialogId, dialogOpts)
321 .setTitle('Confirm Action')
Simon Hunt3f92c432016-01-12 17:34:23 -0800322 .addContent(createConfirmationText(action, itemId))
Simon Hunt5198f082016-02-04 13:41:17 -0800323 .addOk(dOk)
324 .addCancel(dCancel)
325 .bindKeys();
Simon Hunt8d28a552016-01-11 14:01:02 -0800326 }
327
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700328 $scope.appAction = function (action) {
329 if ($scope.ctrlBtnState.selection) {
Simon Hunt8d28a552016-01-11 14:01:02 -0800330 confirmAction(action);
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700331 }
Bri Prebilic Colebd0bc772015-05-13 13:02:26 -0700332 };
Thomas Vachuska530e52a2015-05-06 19:51:32 -0700333
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700334 $scope.$on('FileChanged', function () {
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -0800335 var formData = new FormData(),
336 url;
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700337 if ($scope.appFile) {
338 formData.append('file', $scope.appFile);
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -0800339 url = fileUploadUrl + (activateImmediately || '');
340 $http.post(ufs.rsUrl(url), formData, {
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700341 transformRequest: angular.identity,
342 headers: {
343 'Content-Type': undefined
344 }
345 })
Bri Prebilic Colea7f81e52015-06-23 10:11:08 -0700346 .finally(function () {
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -0800347 activateImmediately = null;
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700348 $scope.sortCallback($scope.sortParams);
349 document.getElementById('inputFileForm').reset();
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -0800350 $timeout(function () { wss.sendEvent(detailsReq); }, 250);
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700351 });
Thomas Vachuskaa7a0f562015-04-14 23:27:44 -0700352 }
Thomas Vachuskaa7a0f562015-04-14 23:27:44 -0700353 });
354
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -0800355 $scope.appDropped = function() {
356 activateImmediately = activateOption;
357 $scope.$emit('FileChanged');
358 $scope.appFile = null;
359 };
360
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700361 $scope.$on('$destroy', function () {
362 ks.unbindKeys();
Jian Lia54de5a2016-01-20 23:10:39 -0800363 wss.unbindHandlers(handlers);
Bri Prebilic Cole9dcaea52015-07-21 14:39:48 -0700364 });
365
Thomas Vachuska619c5382015-04-02 13:41:47 -0700366 $log.log('OvAppCtrl has been created');
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700367 }])
368
369 // triggers the input form to appear when button is clicked
370 .directive('triggerForm', function () {
371 return {
372 restrict: 'A',
373 link: function (scope, elem) {
374 elem.bind('click', function () {
375 document.getElementById('uploadFile')
Bri Prebilic Cole6c82ade2015-08-05 11:12:30 -0700376 .dispatchEvent(new MouseEvent('click'));
Bri Prebilic Cole522e7562015-06-22 15:56:25 -0700377 });
378 }
379 };
380 })
381
382 // binds the model file to the scope in scope.appFile
383 // sends upload request to the server
384 .directive('fileModel', ['$parse',
385 function ($parse) {
386 return {
387 restrict: 'A',
388 link: function (scope, elem, attrs) {
389 var model = $parse(attrs.fileModel),
390 modelSetter = model.assign;
391
392 elem.bind('change', function () {
393 scope.$apply(function () {
394 modelSetter(scope, elem[0].files[0]);
395 });
396 scope.$emit('FileChanged');
397 });
398 }
399 };
Jian Lia54de5a2016-01-20 23:10:39 -0800400 }])
401
Thomas Vachuskaa42ce0b2016-03-09 09:02:49 -0800402 .directive("filedrop", function ($parse, $document) {
403 return {
404 restrict: "A",
405 link: function (scope, element, attrs) {
406 var onAppDrop = $parse(attrs.onFileDrop);
407
408 // When an item is dragged over the document
409 var onDragOver = function (e) {
410 e.preventDefault();
411 };
412
413 // When the user leaves the window, cancels the drag or drops the item
414 var onDragEnd = function (e) {
415 e.preventDefault();
416 };
417
418 // When a file is dropped
419 var loadFile = function (file) {
420 scope.appFile = file;
421 scope.$apply(onAppDrop(scope));
422 };
423
424 // Dragging begins on the document
425 $document.bind("dragover", onDragOver);
426
427 // Dragging ends on the overlay, which takes the whole window
428 element.bind("dragleave", onDragEnd)
429 .bind("drop", function (e) {
430 $log.info('Drag leave', e);
431 loadFile(e.dataTransfer.files[0]);
432 onDragEnd(e);
433 });
434 }
435 };
436 })
437
Jian Lia54de5a2016-01-20 23:10:39 -0800438 .directive('applicationDetailsPanel',
439 ['$rootScope', '$window', '$timeout', 'KeyService',
440 function ($rootScope, $window, $timeout, ks) {
441 return function (scope) {
442 var unbindWatch;
443
444 function heightCalc() {
445 pStartY = fs.noPxStyle(d3.select('.tabular-header'), 'height')
446 + topPdg;
447 wSize = fs.windowSize(pStartY);
448 pHeight = wSize.height;
449 }
450
451 function initPanel() {
452 heightCalc();
453 createDetailsPane();
454 $log.debug('start to initialize panel!');
455 }
456
457 // Safari has a bug where it renders the fixed-layout table wrong
458 // if you ask for the window's size too early
459 if (scope.onos.browser === 'safari') {
460 $timeout(initPanel);
461 } else {
462 initPanel();
463 }
464 // create key bindings to handle panel
465 ks.keyBindings({
Simon Hunta477b602016-01-22 12:10:07 -0800466 esc: [closePanel, 'Close the details panel'],
Jian Lia54de5a2016-01-20 23:10:39 -0800467 _helpFormat: ['esc']
468 });
469 ks.gestureNotes([
470 ['click', 'Select a row to show application details'],
471 ['scroll down', 'See more application']
472 ]);
473
474 // if the panelData changes
475 scope.$watch('panelData', function () {
476 if (!fs.isEmptyObject(scope.panelData)) {
477 populateDetails(scope.panelData);
478 detailsPanel.show();
479 }
480 });
481
482 // if the window size changes
483 unbindWatch = $rootScope.$watchCollection(
484 function () {
485 return {
486 h: $window.innerHeight,
487 w: $window.innerWidth
488 };
489 }, function () {
490 if (!fs.isEmptyObject(scope.panelData)) {
491 heightCalc();
492 populateDetails(scope.panelData);
493 }
494 }
495 );
496
497 scope.$on('$destroy', function () {
498 unbindWatch();
499 ks.unbindKeys();
500 ps.destroyPanel(pName);
501 });
502 };
503 }]);
Thomas Vachuska0fa583c2015-03-30 23:07:41 -0700504}());