Committed by
Gerrit Code Review
WEB UI -- Cleaned up mast.js
- removed redundant code, added clarifying comments. Change-Id: I8c0f1cfbb94ce03508884d1b1b93351587b0e7ed
Showing
1 changed file
with
27 additions
and
21 deletions
| ... | @@ -20,38 +20,38 @@ | ... | @@ -20,38 +20,38 @@ |
| 20 | (function () { | 20 | (function () { |
| 21 | 'use strict'; | 21 | 'use strict'; |
| 22 | 22 | ||
| 23 | - // injected services | ||
| 24 | - var $log; | ||
| 25 | - | ||
| 26 | // configuration | 23 | // configuration |
| 27 | var mastHeight = 48, | 24 | var mastHeight = 48, |
| 28 | - padMobile = 16; | 25 | + padMobile = 16, |
| 29 | - | ||
| 30 | - var dialogId = 'app-dialog', | ||
| 31 | dialogOpts = { | 26 | dialogOpts = { |
| 32 | edge: 'left' | 27 | edge: 'left' |
| 28 | + }, | ||
| 29 | + msg = { | ||
| 30 | + add: { adj: 'New', op: 'added'}, | ||
| 31 | + rem: { adj: 'Some', op: 'removed'} | ||
| 33 | }; | 32 | }; |
| 34 | 33 | ||
| 35 | - angular.module('onosMast', ['onosNav']) | 34 | + angular.module('onosMast', ['onosNav']) |
| 36 | - .controller('MastCtrl', ['$log', '$scope', '$window', 'WebSocketService', 'NavService', | 35 | + .controller('MastCtrl', |
| 37 | - 'DialogService', | 36 | + ['$log', '$scope', '$window', 'WebSocketService', 'NavService', |
| 37 | + 'DialogService', | ||
| 38 | 38 | ||
| 39 | - function (_$log_, $scope, $window, wss, ns, ds) { | 39 | + function ($log, $scope, $window, wss, ns, ds) { |
| 40 | var self = this; | 40 | var self = this; |
| 41 | 41 | ||
| 42 | - $log = _$log_; | ||
| 43 | - | ||
| 44 | - // initialize mast controller here... | ||
| 45 | - self.radio = null; | ||
| 46 | - | ||
| 47 | function triggerRefresh(action) { | 42 | function triggerRefresh(action) { |
| 43 | + | ||
| 48 | function createConfirmationText() { | 44 | function createConfirmationText() { |
| 49 | - var content = ds.createDiv(); | 45 | + var content = ds.createDiv(), |
| 50 | - content.append('p').text(action + ' Press OK to update the GUI.'); | 46 | + txt = msg[action]; |
| 47 | + | ||
| 48 | + content.append('p').text( | ||
| 49 | + txt.adj + ' GUI components were ' + txt.op + | ||
| 50 | + '. Press OK to update the GUI.' | ||
| 51 | + ); | ||
| 51 | return content; | 52 | return content; |
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | - | ||
| 55 | function dOk() { | 55 | function dOk() { |
| 56 | $log.debug('Refreshing GUI'); | 56 | $log.debug('Refreshing GUI'); |
| 57 | $window.location.reload(); | 57 | $window.location.reload(); |
| ... | @@ -61,7 +61,12 @@ | ... | @@ -61,7 +61,12 @@ |
| 61 | $log.debug('Canceling GUI refresh'); | 61 | $log.debug('Canceling GUI refresh'); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | - ds.openDialog(dialogId, dialogOpts) | 64 | + // NOTE: We use app-dialog (CSS) since we will most likely |
| 65 | + // invoke this when we (de)activate apps. | ||
| 66 | + // However we have added this to the masthead, because | ||
| 67 | + // apps could be injected externally (via the onos-app | ||
| 68 | + // command) and we might be looking at some other view. | ||
| 69 | + ds.openDialog('app-dialog', dialogOpts) | ||
| 65 | .setTitle('Confirm GUI Refresh') | 70 | .setTitle('Confirm GUI Refresh') |
| 66 | .addContent(createConfirmationText()) | 71 | .addContent(createConfirmationText()) |
| 67 | .addOk(dOk) | 72 | .addOk(dOk) |
| ... | @@ -70,8 +75,8 @@ | ... | @@ -70,8 +75,8 @@ |
| 70 | } | 75 | } |
| 71 | 76 | ||
| 72 | wss.bindHandlers({ | 77 | wss.bindHandlers({ |
| 73 | - 'guiAdded': function () { triggerRefresh('New GUI components were added.') }, | 78 | + 'guiAdded': function () { triggerRefresh('add') }, |
| 74 | - 'guiRemoved': function () { triggerRefresh('Some GUI components were removed.') } | 79 | + 'guiRemoved': function () { triggerRefresh('rem') } |
| 75 | }); | 80 | }); |
| 76 | 81 | ||
| 77 | // delegate to NavService | 82 | // delegate to NavService |
| ... | @@ -79,6 +84,7 @@ | ... | @@ -79,6 +84,7 @@ |
| 79 | ns.toggleNav(); | 84 | ns.toggleNav(); |
| 80 | }; | 85 | }; |
| 81 | 86 | ||
| 87 | + // onosAuth is a global set via the index.html generated source | ||
| 82 | $scope.user = onosAuth || '(no one)'; | 88 | $scope.user = onosAuth || '(no one)'; |
| 83 | 89 | ||
| 84 | $log.log('MastCtrl has been created'); | 90 | $log.log('MastCtrl has been created'); | ... | ... |
-
Please register or login to post a comment