mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-24 05:41:01 +02:00
WEB UI -- Cleaned up mast.js
- removed redundant code, added clarifying comments. Change-Id: I8c0f1cfbb94ce03508884d1b1b93351587b0e7ed
This commit is contained in:
parent
5805075ccd
commit
3be2994492
@ -20,38 +20,38 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// injected services
|
|
||||||
var $log;
|
|
||||||
|
|
||||||
// configuration
|
// configuration
|
||||||
var mastHeight = 48,
|
var mastHeight = 48,
|
||||||
padMobile = 16;
|
padMobile = 16,
|
||||||
|
|
||||||
var dialogId = 'app-dialog',
|
|
||||||
dialogOpts = {
|
dialogOpts = {
|
||||||
edge: 'left'
|
edge: 'left'
|
||||||
|
},
|
||||||
|
msg = {
|
||||||
|
add: { adj: 'New', op: 'added'},
|
||||||
|
rem: { adj: 'Some', op: 'removed'}
|
||||||
};
|
};
|
||||||
|
|
||||||
angular.module('onosMast', ['onosNav'])
|
angular.module('onosMast', ['onosNav'])
|
||||||
.controller('MastCtrl', ['$log', '$scope', '$window', 'WebSocketService', 'NavService',
|
.controller('MastCtrl',
|
||||||
'DialogService',
|
['$log', '$scope', '$window', 'WebSocketService', 'NavService',
|
||||||
|
'DialogService',
|
||||||
|
|
||||||
function (_$log_, $scope, $window, wss, ns, ds) {
|
function ($log, $scope, $window, wss, ns, ds) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
$log = _$log_;
|
|
||||||
|
|
||||||
// initialize mast controller here...
|
|
||||||
self.radio = null;
|
|
||||||
|
|
||||||
function triggerRefresh(action) {
|
function triggerRefresh(action) {
|
||||||
|
|
||||||
function createConfirmationText() {
|
function createConfirmationText() {
|
||||||
var content = ds.createDiv();
|
var content = ds.createDiv(),
|
||||||
content.append('p').text(action + ' Press OK to update the GUI.');
|
txt = msg[action];
|
||||||
|
|
||||||
|
content.append('p').text(
|
||||||
|
txt.adj + ' GUI components were ' + txt.op +
|
||||||
|
'. Press OK to update the GUI.'
|
||||||
|
);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function dOk() {
|
function dOk() {
|
||||||
$log.debug('Refreshing GUI');
|
$log.debug('Refreshing GUI');
|
||||||
$window.location.reload();
|
$window.location.reload();
|
||||||
@ -61,7 +61,12 @@
|
|||||||
$log.debug('Canceling GUI refresh');
|
$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')
|
.setTitle('Confirm GUI Refresh')
|
||||||
.addContent(createConfirmationText())
|
.addContent(createConfirmationText())
|
||||||
.addOk(dOk)
|
.addOk(dOk)
|
||||||
@ -70,8 +75,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
wss.bindHandlers({
|
wss.bindHandlers({
|
||||||
'guiAdded': function () { triggerRefresh('New GUI components were added.') },
|
'guiAdded': function () { triggerRefresh('add') },
|
||||||
'guiRemoved': function () { triggerRefresh('Some GUI components were removed.') }
|
'guiRemoved': function () { triggerRefresh('rem') }
|
||||||
});
|
});
|
||||||
|
|
||||||
// delegate to NavService
|
// delegate to NavService
|
||||||
@ -79,6 +84,7 @@
|
|||||||
ns.toggleNav();
|
ns.toggleNav();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// onosAuth is a global set via the index.html generated source
|
||||||
$scope.user = onosAuth || '(no one)';
|
$scope.user = onosAuth || '(no one)';
|
||||||
|
|
||||||
$log.log('MastCtrl has been created');
|
$log.log('MastCtrl has been created');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user