WEB UI -- Cleaned up mast.js
- removed redundant code, added clarifying comments.
Change-Id: I8c0f1cfbb94ce03508884d1b1b93351587b0e7ed
diff --git a/web/gui/src/main/webapp/app/fw/mast/mast.js b/web/gui/src/main/webapp/app/fw/mast/mast.js
index 5dad95f..d43987d 100644
--- a/web/gui/src/main/webapp/app/fw/mast/mast.js
+++ b/web/gui/src/main/webapp/app/fw/mast/mast.js
@@ -20,38 +20,38 @@
(function () {
'use strict';
- // injected services
- var $log;
-
// configuration
var mastHeight = 48,
- padMobile = 16;
-
- var dialogId = 'app-dialog',
+ padMobile = 16,
dialogOpts = {
edge: 'left'
+ },
+ msg = {
+ add: { adj: 'New', op: 'added'},
+ rem: { adj: 'Some', op: 'removed'}
};
- angular.module('onosMast', ['onosNav'])
- .controller('MastCtrl', ['$log', '$scope', '$window', 'WebSocketService', 'NavService',
- 'DialogService',
+ angular.module('onosMast', ['onosNav'])
+ .controller('MastCtrl',
+ ['$log', '$scope', '$window', 'WebSocketService', 'NavService',
+ 'DialogService',
- function (_$log_, $scope, $window, wss, ns, ds) {
+ function ($log, $scope, $window, wss, ns, ds) {
var self = this;
- $log = _$log_;
-
- // initialize mast controller here...
- self.radio = null;
-
function triggerRefresh(action) {
+
function createConfirmationText() {
- var content = ds.createDiv();
- content.append('p').text(action + ' Press OK to update the GUI.');
+ var content = ds.createDiv(),
+ txt = msg[action];
+
+ content.append('p').text(
+ txt.adj + ' GUI components were ' + txt.op +
+ '. Press OK to update the GUI.'
+ );
return content;
}
-
function dOk() {
$log.debug('Refreshing GUI');
$window.location.reload();
@@ -61,7 +61,12 @@
$log.debug('Canceling GUI refresh');
}
- ds.openDialog(dialogId, dialogOpts)
+ // NOTE: We use app-dialog (CSS) since we will most likely
+ // invoke this when we (de)activate apps.
+ // However we have added this to the masthead, because
+ // apps could be injected externally (via the onos-app
+ // command) and we might be looking at some other view.
+ ds.openDialog('app-dialog', dialogOpts)
.setTitle('Confirm GUI Refresh')
.addContent(createConfirmationText())
.addOk(dOk)
@@ -70,8 +75,8 @@
}
wss.bindHandlers({
- 'guiAdded': function () { triggerRefresh('New GUI components were added.') },
- 'guiRemoved': function () { triggerRefresh('Some GUI components were removed.') }
+ 'guiAdded': function () { triggerRefresh('add') },
+ 'guiRemoved': function () { triggerRefresh('rem') }
});
// delegate to NavService
@@ -79,6 +84,7 @@
ns.toggleNav();
};
+ // onosAuth is a global set via the index.html generated source
$scope.user = onosAuth || '(no one)';
$log.log('MastCtrl has been created');