Format code using clang-format-5.0
Once merged, this repository will have CI enforce
the coding guidelines in the .clang-format file.
Change-Id: I96a05972665f9c67625c6850c3da25edc540be06
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/app/server-control/controllers/bmc-reboot-controller.js b/app/server-control/controllers/bmc-reboot-controller.js
index 8be09eb..06097b8 100644
--- a/app/server-control/controllers/bmc-reboot-controller.js
+++ b/app/server-control/controllers/bmc-reboot-controller.js
@@ -9,30 +9,26 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.serverControl')
- .controller('bmcRebootController', [
- '$scope',
- '$window',
- 'APIUtils',
- 'dataService',
- function($scope, $window, APIUtils, dataService) {
- $scope.dataService = dataService;
- $scope.confirm = false;
- $scope.rebootConfirm = function() {
- if ($scope.confirm) {
- return;
- }
- $scope.confirm = true;
- };
- $scope.reboot = function() {
- dataService.setUnreachableState();
- APIUtils.bmcReboot(function(response) {
- //@NOTE: using common event to reload server status, may be a better event listener name?
- $scope.$emit('user-logged-in', {});
- });
- };
- }
- ]);
+ angular.module('app.serverControl').controller('bmcRebootController', [
+ '$scope', '$window', 'APIUtils', 'dataService',
+ function($scope, $window, APIUtils, dataService) {
+ $scope.dataService = dataService;
+ $scope.confirm = false;
+ $scope.rebootConfirm = function() {
+ if ($scope.confirm) {
+ return;
+ }
+ $scope.confirm = true;
+ };
+ $scope.reboot = function() {
+ dataService.setUnreachableState();
+ APIUtils.bmcReboot(function(response) {
+ //@NOTE: using common event to reload server status, may be a better
+ // event listener name?
+ $scope.$emit('user-logged-in', {});
+ });
+ };
+ }
+ ]);
})(angular);
diff --git a/app/server-control/controllers/power-operations-controller.js b/app/server-control/controllers/power-operations-controller.js
index 06fb371..4ae732f 100644
--- a/app/server-control/controllers/power-operations-controller.js
+++ b/app/server-control/controllers/power-operations-controller.js
@@ -9,302 +9,329 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.serverControl')
- .controller('powerOperationsController', [
- '$scope',
- 'APIUtils',
- 'dataService',
- 'Constants',
- '$timeout',
- '$interval',
- '$interpolate',
- '$q',
- function($scope, APIUtils, dataService, Constants, $timeout,
- $interval, $interpolate, $q) {
- $scope.dataService = dataService;
- $scope.confirm = false;
- $scope.power_confirm = false;
- $scope.warmboot_confirm = false;
- $scope.coldboot_confirm = false;
- $scope.orderly_confirm = false;
- $scope.immediately_confirm = false;
- $scope.loading = false;
+ angular.module('app.serverControl').controller('powerOperationsController', [
+ '$scope', 'APIUtils', 'dataService', 'Constants', '$timeout', '$interval',
+ '$interpolate', '$q',
+ function(
+ $scope, APIUtils, dataService, Constants, $timeout, $interval,
+ $interpolate, $q) {
+ $scope.dataService = dataService;
+ $scope.confirm = false;
+ $scope.power_confirm = false;
+ $scope.warmboot_confirm = false;
+ $scope.coldboot_confirm = false;
+ $scope.orderly_confirm = false;
+ $scope.immediately_confirm = false;
+ $scope.loading = false;
- var pollChassisStatusTimer = undefined;
- var pollHostStatusTimer = undefined;
- var pollStartTime = null;
+ var pollChassisStatusTimer = undefined;
+ var pollHostStatusTimer = undefined;
+ var pollStartTime = null;
- //@TODO: call api and get proper state
- $scope.toggleState = function() {
- dataService.server_state = (dataService.server_state == 'Running') ? 'Off' : 'Running';
- };
+ //@TODO: call api and get proper state
+ $scope.toggleState = function() {
+ dataService.server_state =
+ (dataService.server_state == 'Running') ? 'Off' : 'Running';
+ };
- $scope.powerOn = function() {
- $scope.loading = true;
- dataService.setUnreachableState();
- APIUtils.hostPowerOn().then(function(response) {
- return response;
- }).then(function(lastStatus) {
- pollStartTime = new Date();
- return pollHostStatusTillOn();
- }).then(function(hostState) {
- $scope.loading = false;
- }).catch(function(error) {
- dataService.activateErrorModal({
- title: Constants.MESSAGES.POWER_OP.POWER_ON_FAILED,
- description: error.statusText ?
- $interpolate(Constants.MESSAGES.ERROR_MESSAGE_DESC_TEMPLATE)({
- status: error.status,
- description: error.statusText
- }) : error
+ $scope.powerOn = function() {
+ $scope.loading = true;
+ dataService.setUnreachableState();
+ APIUtils.hostPowerOn()
+ .then(function(response) {
+ return response;
+ })
+ .then(function(lastStatus) {
+ pollStartTime = new Date();
+ return pollHostStatusTillOn();
+ })
+ .then(function(hostState) {
+ $scope.loading = false;
+ })
+ .catch(function(error) {
+ dataService.activateErrorModal({
+ title: Constants.MESSAGES.POWER_OP.POWER_ON_FAILED,
+ description: error.statusText ?
+ $interpolate(
+ Constants.MESSAGES.ERROR_MESSAGE_DESC_TEMPLATE)(
+ {status: error.status, description: error.statusText}) :
+ error
+ });
+ $scope.loading = false;
});
- $scope.loading = false;
- });
- };
- $scope.powerOnConfirm = function() {
- if ($scope.confirm) {
- return;
- }
- $scope.confirm = true;
- $scope.power_confirm = true;
- };
-
- function setHostState(state) {
- if (state == Constants.HOST_STATE_TEXT.off_code) {
- dataService.setPowerOffState();
- }
- else if (state == Constants.HOST_STATE_TEXT.on_code) {
- dataService.setPowerOnState();
- }
- else {
- dataService.setErrorState();
- }
+ };
+ $scope.powerOnConfirm = function() {
+ if ($scope.confirm) {
+ return;
}
+ $scope.confirm = true;
+ $scope.power_confirm = true;
+ };
- function pollChassisStatusTillOff() {
- var deferred = $q.defer();
- pollChassisStatusTimer = $interval(function() {
- var now = new Date();
- if ((now.getTime() - pollStartTime.getTime()) >= Constants.TIMEOUT.CHASSIS_OFF) {
- $interval.cancel(pollChassisStatusTimer);
- pollChassisStatusTimer = undefined;
- deferred.reject(new Error(Constants.MESSAGES.POLL.CHASSIS_OFF_TIMEOUT));
- }
- APIUtils.getChassisState().then(function(state) {
- if (state === Constants.CHASSIS_POWER_STATE.off_code) {
+ function setHostState(state) {
+ if (state == Constants.HOST_STATE_TEXT.off_code) {
+ dataService.setPowerOffState();
+ } else if (state == Constants.HOST_STATE_TEXT.on_code) {
+ dataService.setPowerOnState();
+ } else {
+ dataService.setErrorState();
+ }
+ }
+
+ function pollChassisStatusTillOff() {
+ var deferred = $q.defer();
+ pollChassisStatusTimer = $interval(function() {
+ var now = new Date();
+ if ((now.getTime() - pollStartTime.getTime()) >=
+ Constants.TIMEOUT.CHASSIS_OFF) {
+ $interval.cancel(pollChassisStatusTimer);
+ pollChassisStatusTimer = undefined;
+ deferred.reject(
+ new Error(Constants.MESSAGES.POLL.CHASSIS_OFF_TIMEOUT));
+ }
+ APIUtils.getChassisState()
+ .then(function(state) {
+ if (state === Constants.CHASSIS_POWER_STATE.off_code) {
+ $interval.cancel(pollChassisStatusTimer);
+ pollChassisStatusTimer = undefined;
+ deferred.resolve(state);
+ }
+ })
+ .catch(function(error) {
$interval.cancel(pollChassisStatusTimer);
pollChassisStatusTimer = undefined;
- deferred.resolve(state);
- }
- }).catch(function(error) {
- $interval.cancel(pollChassisStatusTimer);
- pollChassisStatusTimer = undefined;
- deferred.reject(error);
- });
- }, Constants.POLL_INTERVALS.POWER_OP);
+ deferred.reject(error);
+ });
+ }, Constants.POLL_INTERVALS.POWER_OP);
- return deferred.promise;
- }
-
- function pollHostStatusTillOn() {
- var deferred = $q.defer();
- pollHostStatusTimer = $interval(function() {
- var now = new Date();
- if ((now.getTime() - pollStartTime.getTime()) >= Constants.TIMEOUT.HOST_ON) {
- $interval.cancel(pollHostStatusTimer);
- pollHostStatusTimer = undefined;
- deferred.reject(new Error(Constants.MESSAGES.POLL.HOST_ON_TIMEOUT));
- }
- APIUtils.getHostState().then(function(state) {
- setHostState(state);
- if (state === Constants.HOST_STATE_TEXT.on_code) {
- $interval.cancel(pollHostStatusTimer);
- pollHostStatusTimer = undefined;
- deferred.resolve(state);
- }
- else if (state === Constants.HOST_STATE_TEXT.error_code) {
- $interval.cancel(pollHostStatusTimer);
- pollHostStatusTimer = undefined;
- deferred.reject(new Error(Constants.MESSAGES.POLL.HOST_QUIESCED));
- }
- }).catch(function(error) {
- $interval.cancel(pollHostStatusTimer);
- pollHostStatusTimer = undefined;
- deferred.reject(error);
- });
- }, Constants.POLL_INTERVALS.POWER_OP);
-
- return deferred.promise;
- }
-
- function pollHostStatusTillOff() {
- var deferred = $q.defer();
- pollHostStatusTimer = $interval(function() {
- var now = new Date();
- if ((now.getTime() - pollStartTime.getTime()) >= Constants.TIMEOUT.HOST_OFF) {
- $interval.cancel(pollHostStatusTimer);
- pollHostStatusTimer = undefined;
- deferred.reject(new Error(Constants.MESSAGES.POLL.HOST_OFF_TIMEOUT));
- }
- APIUtils.getHostState().then(function(state) {
- setHostState(state);
- if (state === Constants.HOST_STATE_TEXT.off_code) {
- $interval.cancel(pollHostStatusTimer);
- pollHostStatusTimer = undefined;
- deferred.resolve(state);
- }
- }).catch(function(error) {
- $interval.cancel(pollHostStatusTimer);
- pollHostStatusTimer = undefined;
- deferred.reject(error);
- });
- }, Constants.POLL_INTERVALS.POWER_OP);
-
- return deferred.promise;
- }
- $scope.warmReboot = function() {
- $scope.loading = true;
- dataService.setUnreachableState();
- APIUtils.hostReboot().then(function(response) {
- return response;
- }).then(function(lastStatus) {
- pollStartTime = new Date();
- return pollHostStatusTillOff();
- }).then(function(hostState) {
- pollStartTime = new Date();
- return pollHostStatusTillOn();
- }).then(function(hostState) {
- $scope.loading = false;
- }).catch(function(error) {
- dataService.activateErrorModal({
- title: Constants.MESSAGES.POWER_OP.WARM_REBOOT_FAILED,
- description: error.statusText ?
- $interpolate(Constants.MESSAGES.ERROR_MESSAGE_DESC_TEMPLATE)({
- status: error.status,
- description: error.statusText
- }) : error
- });
- $scope.loading = false;
- });
- };
- $scope.testState = function() {
- $timeout(function() {
- dataService.setPowerOffState();
- $timeout(function() {
- dataService.setPowerOnState();
- }, 2000);
- }, 1000);
- };
- $scope.warmRebootConfirm = function() {
- if ($scope.confirm) {
- return;
- }
- $scope.confirm = true;
- $scope.warmboot_confirm = true;
- };
-
- $scope.coldReboot = function() {
- $scope.loading = true;
- dataService.setUnreachableState();
- APIUtils.chassisPowerOff().then(function(state) {
- return state;
- }).then(function(lastState) {
- pollStartTime = new Date();
- return pollChassisStatusTillOff();
- }).then(function(chassisState) {
- return APIUtils.hostPowerOn().then(function(hostState) {
- return hostState;
- });
- }).then(function(hostState) {
- pollStartTime = new Date();
- return pollHostStatusTillOn();
- }).then(function(state) {
- $scope.loading = false;
- }).catch(function(error) {
- dataService.activateErrorModal({
- title: Constants.MESSAGES.POWER_OP.COLD_REBOOT_FAILED,
- description: error.statusText ?
- $interpolate(Constants.MESSAGES.ERROR_MESSAGE_DESC_TEMPLATE)({
- status: error.status,
- description: error.statusText
- }) : error
- });
- $scope.loading = false;
- });
- };
- $scope.coldRebootConfirm = function() {
- if ($scope.confirm) {
- return;
- }
- $scope.confirm = true;
- $scope.coldboot_confirm = true;
- };
-
- $scope.orderlyShutdown = function() {
- $scope.loading = true;
- dataService.setUnreachableState();
- APIUtils.hostPowerOff().then(function(response) {
- return response;
- }).then(function(lastStatus) {
- pollStartTime = new Date();
- return pollHostStatusTillOff();
- }).then(function(hostState) {
- pollStartTime = new Date();
- return pollChassisStatusTillOff();
- }).then(function(chassisState) {
- $scope.loading = false;
- }).catch(function(error) {
- dataService.activateErrorModal({
- title: Constants.MESSAGES.POWER_OP.ORDERLY_SHUTDOWN_FAILED,
- description: error.statusText ?
- $interpolate(Constants.MESSAGES.ERROR_MESSAGE_DESC_TEMPLATE)({
- status: error.status,
- description: error.statusText
- }) : error
- });
- $scope.loading = false;
- });
- };
- $scope.orderlyShutdownConfirm = function() {
- if ($scope.confirm) {
- return;
- }
- $scope.confirm = true;
- $scope.orderly_confirm = true;
- };
-
- $scope.immediateShutdown = function() {
- $scope.loading = true;
- dataService.setUnreachableState();
- APIUtils.chassisPowerOff().then(function(response) {
- return response;
- }).then(function(lastStatus) {
- pollStartTime = new Date();
- return pollChassisStatusTillOff();
- }).then(function(chassisState) {
- dataService.setPowerOffState();
- $scope.loading = false;
- }).catch(function(error) {
- dataService.activateErrorModal({
- title: Constants.MESSAGES.POWER_OP.IMMEDIATE_SHUTDOWN_FAILED,
- description: error.statusText ?
- $interpolate(Constants.MESSAGES.ERROR_MESSAGE_DESC_TEMPLATE)({
- status: error.status,
- description: error.statusText
- }) : error
- });
- $scope.loading = false;
- });
- };
- $scope.immediateShutdownConfirm = function() {
- if ($scope.confirm) {
- return;
- }
- $scope.confirm = true;
- $scope.immediately_confirm = true;
- };
+ return deferred.promise;
}
- ]);
+
+ function pollHostStatusTillOn() {
+ var deferred = $q.defer();
+ pollHostStatusTimer = $interval(function() {
+ var now = new Date();
+ if ((now.getTime() - pollStartTime.getTime()) >=
+ Constants.TIMEOUT.HOST_ON) {
+ $interval.cancel(pollHostStatusTimer);
+ pollHostStatusTimer = undefined;
+ deferred.reject(new Error(Constants.MESSAGES.POLL.HOST_ON_TIMEOUT));
+ }
+ APIUtils.getHostState()
+ .then(function(state) {
+ setHostState(state);
+ if (state === Constants.HOST_STATE_TEXT.on_code) {
+ $interval.cancel(pollHostStatusTimer);
+ pollHostStatusTimer = undefined;
+ deferred.resolve(state);
+ } else if (state === Constants.HOST_STATE_TEXT.error_code) {
+ $interval.cancel(pollHostStatusTimer);
+ pollHostStatusTimer = undefined;
+ deferred.reject(
+ new Error(Constants.MESSAGES.POLL.HOST_QUIESCED));
+ }
+ })
+ .catch(function(error) {
+ $interval.cancel(pollHostStatusTimer);
+ pollHostStatusTimer = undefined;
+ deferred.reject(error);
+ });
+ }, Constants.POLL_INTERVALS.POWER_OP);
+
+ return deferred.promise;
+ }
+
+ function pollHostStatusTillOff() {
+ var deferred = $q.defer();
+ pollHostStatusTimer = $interval(function() {
+ var now = new Date();
+ if ((now.getTime() - pollStartTime.getTime()) >=
+ Constants.TIMEOUT.HOST_OFF) {
+ $interval.cancel(pollHostStatusTimer);
+ pollHostStatusTimer = undefined;
+ deferred.reject(
+ new Error(Constants.MESSAGES.POLL.HOST_OFF_TIMEOUT));
+ }
+ APIUtils.getHostState()
+ .then(function(state) {
+ setHostState(state);
+ if (state === Constants.HOST_STATE_TEXT.off_code) {
+ $interval.cancel(pollHostStatusTimer);
+ pollHostStatusTimer = undefined;
+ deferred.resolve(state);
+ }
+ })
+ .catch(function(error) {
+ $interval.cancel(pollHostStatusTimer);
+ pollHostStatusTimer = undefined;
+ deferred.reject(error);
+ });
+ }, Constants.POLL_INTERVALS.POWER_OP);
+
+ return deferred.promise;
+ }
+ $scope.warmReboot = function() {
+ $scope.loading = true;
+ dataService.setUnreachableState();
+ APIUtils.hostReboot()
+ .then(function(response) {
+ return response;
+ })
+ .then(function(lastStatus) {
+ pollStartTime = new Date();
+ return pollHostStatusTillOff();
+ })
+ .then(function(hostState) {
+ pollStartTime = new Date();
+ return pollHostStatusTillOn();
+ })
+ .then(function(hostState) {
+ $scope.loading = false;
+ })
+ .catch(function(error) {
+ dataService.activateErrorModal({
+ title: Constants.MESSAGES.POWER_OP.WARM_REBOOT_FAILED,
+ description: error.statusText ?
+ $interpolate(
+ Constants.MESSAGES.ERROR_MESSAGE_DESC_TEMPLATE)(
+ {status: error.status, description: error.statusText}) :
+ error
+ });
+ $scope.loading = false;
+ });
+ };
+ $scope.testState = function() {
+ $timeout(function() {
+ dataService.setPowerOffState();
+ $timeout(function() {
+ dataService.setPowerOnState();
+ }, 2000);
+ }, 1000);
+ };
+ $scope.warmRebootConfirm = function() {
+ if ($scope.confirm) {
+ return;
+ }
+ $scope.confirm = true;
+ $scope.warmboot_confirm = true;
+ };
+
+ $scope.coldReboot = function() {
+ $scope.loading = true;
+ dataService.setUnreachableState();
+ APIUtils.chassisPowerOff()
+ .then(function(state) {
+ return state;
+ })
+ .then(function(lastState) {
+ pollStartTime = new Date();
+ return pollChassisStatusTillOff();
+ })
+ .then(function(chassisState) {
+ return APIUtils.hostPowerOn().then(function(hostState) {
+ return hostState;
+ });
+ })
+ .then(function(hostState) {
+ pollStartTime = new Date();
+ return pollHostStatusTillOn();
+ })
+ .then(function(state) {
+ $scope.loading = false;
+ })
+ .catch(function(error) {
+ dataService.activateErrorModal({
+ title: Constants.MESSAGES.POWER_OP.COLD_REBOOT_FAILED,
+ description: error.statusText ?
+ $interpolate(
+ Constants.MESSAGES.ERROR_MESSAGE_DESC_TEMPLATE)(
+ {status: error.status, description: error.statusText}) :
+ error
+ });
+ $scope.loading = false;
+ });
+ };
+ $scope.coldRebootConfirm = function() {
+ if ($scope.confirm) {
+ return;
+ }
+ $scope.confirm = true;
+ $scope.coldboot_confirm = true;
+ };
+
+ $scope.orderlyShutdown = function() {
+ $scope.loading = true;
+ dataService.setUnreachableState();
+ APIUtils.hostPowerOff()
+ .then(function(response) {
+ return response;
+ })
+ .then(function(lastStatus) {
+ pollStartTime = new Date();
+ return pollHostStatusTillOff();
+ })
+ .then(function(hostState) {
+ pollStartTime = new Date();
+ return pollChassisStatusTillOff();
+ })
+ .then(function(chassisState) {
+ $scope.loading = false;
+ })
+ .catch(function(error) {
+ dataService.activateErrorModal({
+ title: Constants.MESSAGES.POWER_OP.ORDERLY_SHUTDOWN_FAILED,
+ description: error.statusText ?
+ $interpolate(
+ Constants.MESSAGES.ERROR_MESSAGE_DESC_TEMPLATE)(
+ {status: error.status, description: error.statusText}) :
+ error
+ });
+ $scope.loading = false;
+ });
+ };
+ $scope.orderlyShutdownConfirm = function() {
+ if ($scope.confirm) {
+ return;
+ }
+ $scope.confirm = true;
+ $scope.orderly_confirm = true;
+ };
+
+ $scope.immediateShutdown = function() {
+ $scope.loading = true;
+ dataService.setUnreachableState();
+ APIUtils.chassisPowerOff()
+ .then(function(response) {
+ return response;
+ })
+ .then(function(lastStatus) {
+ pollStartTime = new Date();
+ return pollChassisStatusTillOff();
+ })
+ .then(function(chassisState) {
+ dataService.setPowerOffState();
+ $scope.loading = false;
+ })
+ .catch(function(error) {
+ dataService.activateErrorModal({
+ title: Constants.MESSAGES.POWER_OP.IMMEDIATE_SHUTDOWN_FAILED,
+ description: error.statusText ?
+ $interpolate(
+ Constants.MESSAGES.ERROR_MESSAGE_DESC_TEMPLATE)(
+ {status: error.status, description: error.statusText}) :
+ error
+ });
+ $scope.loading = false;
+ });
+ };
+ $scope.immediateShutdownConfirm = function() {
+ if ($scope.confirm) {
+ return;
+ }
+ $scope.confirm = true;
+ $scope.immediately_confirm = true;
+ };
+ }
+ ]);
})(angular);
diff --git a/app/server-control/controllers/remote-console-controller.js b/app/server-control/controllers/remote-console-controller.js
index c2e1435..45156fb 100644
--- a/app/server-control/controllers/remote-console-controller.js
+++ b/app/server-control/controllers/remote-console-controller.js
@@ -6,75 +6,68 @@
* @name remoteConsoleController
*/
-import {
- hterm,
- lib
-}
-from 'hterm-umdjs';
+import {hterm, lib} from 'hterm-umdjs';
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.serverControl')
- .controller('remoteConsoleController', [
- '$scope',
- '$window',
- 'APIUtils',
- 'dataService',
- function($scope, $window, APIUtils, dataService) {
- $scope.dataService = dataService;
+ angular.module('app.serverControl').controller('remoteConsoleController', [
+ '$scope', '$window', 'APIUtils', 'dataService',
+ function($scope, $window, APIUtils, dataService) {
+ $scope.dataService = dataService;
- // See https://github.com/macton/hterm for available hterm options
+ // See https://github.com/macton/hterm for available hterm options
- hterm.defaultStorage = new lib.Storage.Local();
- var term = new hterm.Terminal('host-console');
- term.decorate(document.querySelector('#terminal'));
- //Set cursor color
- term.prefs_.set('cursor-color', 'rgba(83, 146, 255, .5)');
- //Set background color
- term.prefs_.set('background-color', '#19273c');
- //Allows keyboard input
- term.installKeyboard();
+ hterm.defaultStorage = new lib.Storage.Local();
+ var term = new hterm.Terminal('host-console');
+ term.decorate(document.querySelector('#terminal'));
+ // Set cursor color
+ term.prefs_.set('cursor-color', 'rgba(83, 146, 255, .5)');
+ // Set background color
+ term.prefs_.set('background-color', '#19273c');
+ // Allows keyboard input
+ term.installKeyboard();
- //The BMC exposes a websocket at /console0. This can be read
- //or written to access the host serial console.
- var hostname = dataService.getHost().replace('https://', '');
- var host = 'wss://' + hostname + '/console0';
- var ws = new WebSocket(host);
- ws.onmessage = function(evt) {
- //websocket -> terminal
- term.io.print(evt.data);
+ // The BMC exposes a websocket at /console0. This can be read
+ // or written to access the host serial console.
+ var hostname = dataService.getHost().replace('https://', '');
+ var host = 'wss://' + hostname + '/console0';
+ var ws = new WebSocket(host);
+ ws.onmessage = function(evt) {
+ // websocket -> terminal
+ term.io.print(evt.data);
+ };
+
+ // terminal -> websocket
+ term.onTerminalReady = function() {
+ var io = term.io.push();
+ io.onVTKeystroke = function(str) {
+ ws.send(str);
};
+ io.sendString = function(str) {
+ ws.send(str);
+ };
+ };
- //terminal -> websocket
- term.onTerminalReady = function() {
- var io = term.io.push();
- io.onVTKeystroke = function(str) {
- ws.send(str);
- };
- io.sendString = function(str) {
- ws.send(str);
- };
- };
+ ws.onopen = function() {
+ console.log('websocket opened');
+ };
+ ws.onclose = function() {
+ console.log('websocket closed');
+ };
+ $scope.$on('$destroy', function() {
+ if (ws) {
+ ws.close();
+ }
+ });
- ws.onopen = function() {
- console.log('websocket opened');
- };
- ws.onclose = function() {
- console.log('websocket closed');
- };
- $scope.$on('$destroy', function() {
- if (ws) {
- ws.close();
- }
- });
-
- $scope.openTerminalWindow = function() {
- dataService.setRemoteWindowActive();
- $window.open('#/server-control/remote-console-window', 'Remote Console Window', 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=400');
- };
- }
- ]);
+ $scope.openTerminalWindow = function() {
+ dataService.setRemoteWindowActive();
+ $window.open(
+ '#/server-control/remote-console-window', 'Remote Console Window',
+ 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=400');
+ };
+ }
+ ]);
})(angular);
diff --git a/app/server-control/controllers/remote-console-window-controller.js b/app/server-control/controllers/remote-console-window-controller.js
index 685b45e..bcf311b 100644
--- a/app/server-control/controllers/remote-console-window-controller.js
+++ b/app/server-control/controllers/remote-console-window-controller.js
@@ -9,54 +9,50 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.serverControl')
- .controller('remoteConsoleWindowController', [
- '$scope',
- '$window',
- 'APIUtils',
- 'dataService',
- function($scope, $window, APIUtils, dataService) {
- $scope.dataService = dataService;
- dataService.showNavigation = false;
+ angular.module('app.serverControl')
+ .controller('remoteConsoleWindowController', [
+ '$scope', '$window', 'APIUtils', 'dataService',
+ function($scope, $window, APIUtils, dataService) {
+ $scope.dataService = dataService;
+ dataService.showNavigation = false;
- // See https://github.com/macton/hterm for available hterm options
+ // See https://github.com/macton/hterm for available hterm options
- //Storage
- hterm.defaultStorage = new lib.Storage.Local();
+ // Storage
+ hterm.defaultStorage = new lib.Storage.Local();
- var term = new hterm.Terminal('foo');
- term.onTerminalReady = function() {
- var io = term.io.push();
- io.onVTKeystroke = function(str) {
- console.log(str);
- term.io.print(str);
+ var term = new hterm.Terminal('foo');
+ term.onTerminalReady = function() {
+ var io = term.io.push();
+ io.onVTKeystroke = function(str) {
+ console.log(str);
+ term.io.print(str);
+ };
+ io.sendString = function(str) {
+ console.log(str);
+ };
};
- io.sendString = function(str) {
- console.log(str);
+ term.decorate(document.querySelector('#terminal'));
+
+ // Set cursor color
+ term.prefs_.set('cursor-color', 'rgba(83, 146, 255, .5)');
+
+ // Set background color
+ term.prefs_.set('background-color', '#19273c');
+
+ // Print to console window
+ term.io.println('OpenBMC ver.00');
+ term.io.println('This is not an actual live connection.');
+ term.io.print('root@IBM:');
+
+ // Allows keyboard input
+ term.installKeyboard();
+
+ $scope.close = function() {
+ dataService.setRemoteWindowInactive();
+ $window.close();
};
- };
- term.decorate(document.querySelector('#terminal'));
-
- //Set cursor color
- term.prefs_.set('cursor-color', 'rgba(83, 146, 255, .5)');
-
- //Set background color
- term.prefs_.set('background-color', '#19273c');
-
- //Print to console window
- term.io.println('OpenBMC ver.00');
- term.io.println('This is not an actual live connection.');
- term.io.print('root@IBM:');
-
- //Allows keyboard input
- term.installKeyboard();
-
- $scope.close = function() {
- dataService.setRemoteWindowInactive();
- $window.close();
- };
- }
- ]);
+ }
+ ]);
})(angular);
diff --git a/app/server-control/index.js b/app/server-control/index.js
index 12debcf..797f144 100644
--- a/app/server-control/index.js
+++ b/app/server-control/index.js
@@ -9,44 +9,50 @@
'use strict';
angular
- .module('app.serverControl', [
- 'ngRoute',
- 'app.constants',
- 'app.common.services'
- ])
- // Route configuration
- .config(['$routeProvider', function($routeProvider) {
- $routeProvider
- .when('/server-control/bmc-reboot', {
- 'template': require('./controllers/bmc-reboot-controller.html'),
- 'controller': 'bmcRebootController',
- authenticated: true
- })
- .when('/server-control/server-led', {
- 'template': require('../server-health/controllers/unit-id-controller.html'),
- 'controller': 'unitIdController',
- authenticated: true
- })
- .when('/server-control/power-operations', {
- 'template': require('./controllers/power-operations-controller.html'),
- 'controller': 'powerOperationsController',
- authenticated: true
- })
- .when('/server-control/remote-console', {
- 'template': require('./controllers/remote-console-controller.html'),
- 'controller': 'remoteConsoleController',
- authenticated: true
- })
- .when('/server-control/remote-console-window', {
- 'template': require('./controllers/remote-console-window-controller.html'),
- 'controller': 'remoteConsoleWindowController',
- authenticated: true
- })
- .when('/server-control', {
- 'template': require('./controllers/power-operations-controller.html'),
- 'controller': 'powerOperationsController',
- authenticated: true
- });
- }]);
+ .module(
+ 'app.serverControl',
+ ['ngRoute', 'app.constants', 'app.common.services'])
+ // Route configuration
+ .config([
+ '$routeProvider',
+ function($routeProvider) {
+ $routeProvider
+ .when('/server-control/bmc-reboot', {
+ 'template': require('./controllers/bmc-reboot-controller.html'),
+ 'controller': 'bmcRebootController',
+ authenticated: true
+ })
+ .when('/server-control/server-led', {
+ 'template': require(
+ '../server-health/controllers/unit-id-controller.html'),
+ 'controller': 'unitIdController',
+ authenticated: true
+ })
+ .when('/server-control/power-operations', {
+ 'template':
+ require('./controllers/power-operations-controller.html'),
+ 'controller': 'powerOperationsController',
+ authenticated: true
+ })
+ .when('/server-control/remote-console', {
+ 'template':
+ require('./controllers/remote-console-controller.html'),
+ 'controller': 'remoteConsoleController',
+ authenticated: true
+ })
+ .when('/server-control/remote-console-window', {
+ 'template': require(
+ './controllers/remote-console-window-controller.html'),
+ 'controller': 'remoteConsoleWindowController',
+ authenticated: true
+ })
+ .when('/server-control', {
+ 'template':
+ require('./controllers/power-operations-controller.html'),
+ 'controller': 'powerOperationsController',
+ authenticated: true
+ });
+ }
+ ]);
})(window.angular);