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/common/directives/app-header.js b/app/common/directives/app-header.js
index 31f683c..d15697b 100644
--- a/app/common/directives/app-header.js
+++ b/app/common/directives/app-header.js
@@ -1,17 +1,18 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives')
- .directive('appHeader', ['APIUtils', function(APIUtils) {
+ angular.module('app.common.directives').directive('appHeader', [
+ 'APIUtils',
+ function(APIUtils) {
return {
'restrict': 'E',
'template': require('./app-header.html'),
- 'scope': {
- 'path': '='
- },
- 'controller': ['$rootScope', '$scope', 'dataService', 'userModel', '$location', '$route',
- function($rootScope, $scope, dataService, userModel, $location, $route) {
+ 'scope': {'path': '='},
+ 'controller': [
+ '$rootScope', '$scope', 'dataService', 'userModel', '$location',
+ '$route',
+ function(
+ $rootScope, $scope, dataService, userModel, $location, $route) {
$scope.dataService = dataService;
$scope.loadServerHealth = function() {
@@ -24,19 +25,22 @@
if (!userModel.isLoggedIn()) {
return;
}
- APIUtils.getHostState().then(function(status) {
- if (status == 'xyz.openbmc_project.State.Host.HostState.Off') {
- dataService.setPowerOffState();
- }
- else if (status == 'xyz.openbmc_project.State.Host.HostState.Running') {
- dataService.setPowerOnState();
- }
- else {
- dataService.setErrorState();
- }
- }, function(error) {
- dataService.activateErrorModal();
- });
+ APIUtils.getHostState().then(
+ function(status) {
+ if (status ==
+ 'xyz.openbmc_project.State.Host.HostState.Off') {
+ dataService.setPowerOffState();
+ } else if (
+ status ==
+ 'xyz.openbmc_project.State.Host.HostState.Running') {
+ dataService.setPowerOnState();
+ } else {
+ dataService.setErrorState();
+ }
+ },
+ function(error) {
+ dataService.activateErrorModal();
+ });
};
$scope.loadNetworkInfo = function() {
@@ -60,19 +64,19 @@
userModel.logout(function(status, error) {
if (status) {
$location.path('/logout');
- }
- else {
+ } else {
console.log(error);
}
});
};
$scope.refresh = function() {
- //reload current page controllers and header
+ // reload current page controllers and header
loadData();
$route.reload();
- //Add flash class to header timestamp on click of refresh
- var myEl = angular.element(document.querySelector('.header__refresh'));
+ // Add flash class to header timestamp on click of refresh
+ var myEl =
+ angular.element(document.querySelector('.header__refresh'));
myEl.addClass('flash');
setTimeout(function() {
myEl.removeClass('flash');
@@ -80,9 +84,10 @@
};
- var loginListener = $rootScope.$on('user-logged-in', function(event, arg) {
- loadData();
- });
+ var loginListener =
+ $rootScope.$on('user-logged-in', function(event, arg) {
+ loadData();
+ });
$scope.$on('$destroy', function() {
loginListener();
@@ -94,5 +99,6 @@
}
]
};
- }]);
+ }
+ ]);
})(window.angular);
diff --git a/app/common/directives/app-navigation.js b/app/common/directives/app-navigation.js
index 80d09ec..c1272de 100644
--- a/app/common/directives/app-navigation.js
+++ b/app/common/directives/app-navigation.js
@@ -1,75 +1,67 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives')
- .directive('appNavigation', function() {
- return {
- 'restrict': 'E',
- 'template': require('./app-navigation.html'),
- 'scope': {
- 'path': '=',
- 'showNavigation': '='
- },
- 'controller': ['$scope', '$location', 'dataService', function($scope, $location, dataService) {
- $scope.dataService = dataService;
- $scope.showSubMenu = false;
- $scope.change = function(firstLevel) {
- if (firstLevel != $scope.firstLevel) {
- $scope.firstLevel = firstLevel;
- $scope.showSubMenu = true;
- }
- else {
- $scope.showSubMenu = !$scope.showSubMenu;
- }
- };
- $scope.closeSubnav = function() {
- $scope.showSubMenu = false;
- };
- $scope.$watch('path', function() {
- var urlRoot = $location.path().split('/')[1];
- if (urlRoot != '') {
- $scope.firstLevel = urlRoot;
- }
- else {
- $scope.firstLevel = 'overview';
- }
- $scope.showSubMenu = false;
- });
- $scope.$watch('showNavigation', function() {
- var paddingTop = 0;
- var urlRoot = $location.path().split('/')[1];
- if (urlRoot != '') {
- $scope.firstLevel = urlRoot;
- }
- else {
- $scope.firstLevel = 'overview';
- }
+ angular.module('app.common.directives')
+ .directive('appNavigation', function() {
+ return {
+ 'restrict': 'E',
+ 'template': require('./app-navigation.html'),
+ 'scope': {'path': '=', 'showNavigation': '='},
+ 'controller': [
+ '$scope', '$location', 'dataService',
+ function($scope, $location, dataService) {
+ $scope.dataService = dataService;
+ $scope.showSubMenu = false;
+ $scope.change = function(firstLevel) {
+ if (firstLevel != $scope.firstLevel) {
+ $scope.firstLevel = firstLevel;
+ $scope.showSubMenu = true;
+ } else {
+ $scope.showSubMenu = !$scope.showSubMenu;
+ }
+ };
+ $scope.closeSubnav = function() {
+ $scope.showSubMenu = false;
+ };
+ $scope.$watch('path', function() {
+ var urlRoot = $location.path().split('/')[1];
+ if (urlRoot != '') {
+ $scope.firstLevel = urlRoot;
+ } else {
+ $scope.firstLevel = 'overview';
+ }
+ $scope.showSubMenu = false;
+ });
+ $scope.$watch('showNavigation', function() {
+ var paddingTop = 0;
+ var urlRoot = $location.path().split('/')[1];
+ if (urlRoot != '') {
+ $scope.firstLevel = urlRoot;
+ } else {
+ $scope.firstLevel = 'overview';
+ }
- if ($scope.showNavigation) {
- paddingTop = document.getElementById('header__wrapper').offsetHeight;
- }
- dataService.bodyStyle = {
- 'padding-top': paddingTop + 'px'
- };
- $scope.navStyle = {
- 'top': paddingTop + 'px'
- };
- });
- }],
- link: function(scope, element, attributes) {
- var rawNavElement = angular.element(element)[0];
- angular.element(window.document).bind('click', function(event) {
- if (rawNavElement.contains(event.target))
- return;
-
- if (scope.showSubMenu) {
- scope.$apply(function() {
- scope.showSubMenu = false;
+ if ($scope.showNavigation) {
+ paddingTop =
+ document.getElementById('header__wrapper').offsetHeight;
+ }
+ dataService.bodyStyle = {'padding-top': paddingTop + 'px'};
+ $scope.navStyle = {'top': paddingTop + 'px'};
});
}
- });
- }
- };
- });
+ ],
+ link: function(scope, element, attributes) {
+ var rawNavElement = angular.element(element)[0];
+ angular.element(window.document).bind('click', function(event) {
+ if (rawNavElement.contains(event.target)) return;
+
+ if (scope.showSubMenu) {
+ scope.$apply(function() {
+ scope.showSubMenu = false;
+ });
+ }
+ });
+ }
+ };
+ });
})(window.angular);
diff --git a/app/common/directives/confirm.js b/app/common/directives/confirm.js
index a542783..b537905 100644
--- a/app/common/directives/confirm.js
+++ b/app/common/directives/confirm.js
@@ -1,44 +1,42 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives')
- .directive('confirm', ['$timeout', function($timeout) {
+ angular.module('app.common.directives').directive('confirm', [
+ '$timeout',
+ function($timeout) {
return {
'restrict': 'E',
'template': require('./confirm.html'),
- 'scope': {
- 'title': '@',
- 'message': '@',
- 'confirm': '=',
- 'callback': '='
- },
- 'controller': ['$scope', function($scope) {
- $scope.cancel = function() {
- $scope.confirm = false;
- $scope.$parent.confirm = false;
- };
- $scope.accept = function() {
- $scope.callback();
- $scope.cancel();
- };
- }],
+ 'scope':
+ {'title': '@', 'message': '@', 'confirm': '=', 'callback': '='},
+ 'controller': [
+ '$scope',
+ function($scope) {
+ $scope.cancel = function() {
+ $scope.confirm = false;
+ $scope.$parent.confirm = false;
+ };
+ $scope.accept = function() {
+ $scope.callback();
+ $scope.cancel();
+ };
+ }
+ ],
link: function(scope, e) {
scope.$watch('confirm', function() {
if (scope.confirm) {
$timeout(function() {
angular.element(e[0].parentNode).css({
- 'min-height': e[0].querySelector('.inline__confirm').offsetHeight + 'px'
+ 'min-height':
+ e[0].querySelector('.inline__confirm').offsetHeight + 'px'
});
}, 0);
- }
- else {
- angular.element(e[0].parentNode).css({
- 'min-height': 0 + 'px'
- });
+ } else {
+ angular.element(e[0].parentNode).css({'min-height': 0 + 'px'});
}
});
}
};
- }]);
+ }
+ ]);
})(window.angular);
diff --git a/app/common/directives/errors.js b/app/common/directives/errors.js
index 8123694..5bd1e52 100644
--- a/app/common/directives/errors.js
+++ b/app/common/directives/errors.js
@@ -1,18 +1,20 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives')
- .directive('errors', ['APIUtils', function(APIUtils) {
+ angular.module('app.common.directives').directive('errors', [
+ 'APIUtils',
+ function(APIUtils) {
return {
'restrict': 'E',
'template': require('./errors.html'),
- 'scope': {
- 'path': '='
- },
- 'controller': ['$scope', 'dataService', function($scope, dataService) {
- $scope.dataService = dataService;
- }]
+ 'scope': {'path': '='},
+ 'controller': [
+ '$scope', 'dataService',
+ function($scope, dataService) {
+ $scope.dataService = dataService;
+ }
+ ]
};
- }]);
+ }
+ ]);
})(window.angular);
diff --git a/app/common/directives/file.js b/app/common/directives/file.js
index 8ed6c2e..b0f5289 100644
--- a/app/common/directives/file.js
+++ b/app/common/directives/file.js
@@ -1,21 +1,17 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives')
- .directive('file', function() {
- return {
- scope: {
- file: '='
- },
- link: function(scope, el, attrs) {
- el.bind('change', function(event) {
- var file = event.target.files[0];
- scope.file = file ? file : undefined;
- scope.$apply();
- });
- }
- };
- });
+ angular.module('app.common.directives').directive('file', function() {
+ return {
+ scope: {file: '='},
+ link: function(scope, el, attrs) {
+ el.bind('change', function(event) {
+ var file = event.target.files[0];
+ scope.file = file ? file : undefined;
+ scope.$apply();
+ });
+ }
+ };
+ });
})(window.angular);
diff --git a/app/common/directives/firmware-list.js b/app/common/directives/firmware-list.js
index 163df82..a08ef8d 100644
--- a/app/common/directives/firmware-list.js
+++ b/app/common/directives/firmware-list.js
@@ -1,32 +1,32 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives')
- .directive('firmwareList', ['APIUtils', function(APIUtils) {
+ angular.module('app.common.directives').directive('firmwareList', [
+ 'APIUtils',
+ function(APIUtils) {
return {
'restrict': 'E',
'template': require('./firmware-list.html'),
- 'scope': {
- 'title': '@',
- 'firmwares': '=',
- 'filterBy': '=',
- 'version': '='
- },
- 'controller': ['$rootScope', '$scope', 'dataService', '$location', '$timeout', function($rootScope, $scope, dataService, $location, $timeout) {
- $scope.dataService = dataService;
- $scope.activate = function(imageId, imageVersion, imageType) {
- $scope.$parent.activateImage(imageId, imageVersion, imageType);
- };
+ 'scope':
+ {'title': '@', 'firmwares': '=', 'filterBy': '=', 'version': '='},
+ 'controller': [
+ '$rootScope', '$scope', 'dataService', '$location', '$timeout',
+ function($rootScope, $scope, dataService, $location, $timeout) {
+ $scope.dataService = dataService;
+ $scope.activate = function(imageId, imageVersion, imageType) {
+ $scope.$parent.activateImage(imageId, imageVersion, imageType);
+ };
- $scope.delete = function(imageId, imageVersion) {
- $scope.$parent.deleteImage(imageId, imageVersion);
- };
+ $scope.delete = function(imageId, imageVersion) {
+ $scope.$parent.deleteImage(imageId, imageVersion);
+ };
- $scope.changePriority = function(imageId, imageVersion, from, to) {
- $scope.$parent.changePriority(imageId, imageVersion, from, to);
- };
- }]
+ $scope.changePriority = function(imageId, imageVersion, from, to) {
+ $scope.$parent.changePriority(imageId, imageVersion, from, to);
+ };
+ }
+ ]
};
- }]);
+ }
+ ]);
})(window.angular);
diff --git a/app/common/directives/index.js b/app/common/directives/index.js
index 33155f4..150b43f 100644
--- a/app/common/directives/index.js
+++ b/app/common/directives/index.js
@@ -1,9 +1,6 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives', [
- 'app.common.services'
- ]);
+ angular.module('app.common.directives', ['app.common.services']);
})(window.angular);
diff --git a/app/common/directives/loader.js b/app/common/directives/loader.js
index 8edc128..46fba9a 100644
--- a/app/common/directives/loader.js
+++ b/app/common/directives/loader.js
@@ -1,16 +1,12 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives')
- .directive('loader', function() {
- return {
- 'restrict': 'E',
- 'template': require('./loader.html'),
- scope: {
- loading: '='
- }
- };
- });
+ angular.module('app.common.directives').directive('loader', function() {
+ return {
+ 'restrict': 'E',
+ 'template': require('./loader.html'),
+ scope: {loading: '='}
+ };
+ });
})(window.angular);
diff --git a/app/common/directives/log-event.js b/app/common/directives/log-event.js
index c48a3ee..2a71164 100644
--- a/app/common/directives/log-event.js
+++ b/app/common/directives/log-event.js
@@ -1,43 +1,41 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives')
- .directive('logEvent', ['APIUtils', function(APIUtils) {
+ angular.module('app.common.directives').directive('logEvent', [
+ 'APIUtils',
+ function(APIUtils) {
return {
'restrict': 'E',
'template': require('./log-event.html'),
- 'scope': {
- 'event': '=',
- 'tmz': '=',
- 'multiSelected': '='
- },
- 'controller': ['$rootScope', '$scope', 'dataService', '$location', '$timeout', function($rootScope, $scope, dataService, $location, $timeout) {
- $scope.dataService = dataService;
- $scope.copySuccess = function(event) {
- event.copied = true;
- $timeout(function() {
- event.copied = false;
- }, 5000);
- };
- $scope.copyFailed = function(err) {
- console.error('Error!', err);
- };
- $scope.resolveEvent = function(event) {
- APIUtils.resolveLogs([{
- Id: event.Id
- }]).then(function() {
- event.Resolved = 1;
- });
- };
+ 'scope': {'event': '=', 'tmz': '=', 'multiSelected': '='},
+ 'controller': [
+ '$rootScope', '$scope', 'dataService', '$location', '$timeout',
+ function($rootScope, $scope, dataService, $location, $timeout) {
+ $scope.dataService = dataService;
+ $scope.copySuccess = function(event) {
+ event.copied = true;
+ $timeout(function() {
+ event.copied = false;
+ }, 5000);
+ };
+ $scope.copyFailed = function(err) {
+ console.error('Error!', err);
+ };
+ $scope.resolveEvent = function(event) {
+ APIUtils.resolveLogs([{Id: event.Id}]).then(function() {
+ event.Resolved = 1;
+ });
+ };
- $scope.accept = function() {
- $scope.event.selected = true;
- $timeout(function() {
- $scope.$parent.accept();
- }, 10);
- };
- }]
+ $scope.accept = function() {
+ $scope.event.selected = true;
+ $timeout(function() {
+ $scope.$parent.accept();
+ }, 10);
+ };
+ }
+ ]
};
- }]);
+ }
+ ]);
})(window.angular);
diff --git a/app/common/directives/log-filter.js b/app/common/directives/log-filter.js
index 69bb8e3..fcbe0b3 100644
--- a/app/common/directives/log-filter.js
+++ b/app/common/directives/log-filter.js
@@ -1,51 +1,54 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives')
- .directive('logFilter', ['APIUtils', function(APIUtils) {
+ angular.module('app.common.directives').directive('logFilter', [
+ 'APIUtils',
+ function(APIUtils) {
return {
'restrict': 'E',
'template': require('./log-filter.html'),
- 'controller': ['$rootScope', '$scope', 'dataService', '$location', function($rootScope, $scope, dataService, $location) {
- $scope.dataService = dataService;
- $scope.toggleSeverityAll = function() {
- $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
+ 'controller': [
+ '$rootScope', '$scope', 'dataService', '$location',
+ function($rootScope, $scope, dataService, $location) {
+ $scope.dataService = dataService;
+ $scope.toggleSeverityAll = function() {
+ $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
- if ($scope.selectedSeverity.all) {
- $scope.selectedSeverity.low = false;
- $scope.selectedSeverity.medium = false;
- $scope.selectedSeverity.high = false;
- }
- };
-
- $scope.toggleSeverity = function(severity) {
- $scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
-
- if (['high', 'medium', 'low'].indexOf(severity) > -1) {
- if ($scope.selectedSeverity[severity] == false &&
- (!$scope.selectedSeverity.low &&
- !$scope.selectedSeverity.medium &&
- !$scope.selectedSeverity.high
- )) {
- $scope.selectedSeverity.all = true;
- return;
+ if ($scope.selectedSeverity.all) {
+ $scope.selectedSeverity.low = false;
+ $scope.selectedSeverity.medium = false;
+ $scope.selectedSeverity.high = false;
}
- }
+ };
- if ($scope.selectedSeverity.low &&
- $scope.selectedSeverity.medium &&
- $scope.selectedSeverity.high) {
- $scope.selectedSeverity.all = true;
- $scope.selectedSeverity.low = false;
- $scope.selectedSeverity.medium = false;
- $scope.selectedSeverity.high = false;
- }
- else {
- $scope.selectedSeverity.all = false;
- }
- };
- }]
+ $scope.toggleSeverity = function(severity) {
+ $scope.selectedSeverity[severity] =
+ !$scope.selectedSeverity[severity];
+
+ if (['high', 'medium', 'low'].indexOf(severity) > -1) {
+ if ($scope.selectedSeverity[severity] == false &&
+ (!$scope.selectedSeverity.low &&
+ !$scope.selectedSeverity.medium &&
+ !$scope.selectedSeverity.high)) {
+ $scope.selectedSeverity.all = true;
+ return;
+ }
+ }
+
+ if ($scope.selectedSeverity.low &&
+ $scope.selectedSeverity.medium &&
+ $scope.selectedSeverity.high) {
+ $scope.selectedSeverity.all = true;
+ $scope.selectedSeverity.low = false;
+ $scope.selectedSeverity.medium = false;
+ $scope.selectedSeverity.high = false;
+ } else {
+ $scope.selectedSeverity.all = false;
+ }
+ };
+ }
+ ]
};
- }]);
+ }
+ ]);
})(window.angular);
diff --git a/app/common/directives/log-search-control.js b/app/common/directives/log-search-control.js
index f262f5f..abdc9ff 100644
--- a/app/common/directives/log-search-control.js
+++ b/app/common/directives/log-search-control.js
@@ -1,46 +1,49 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives')
- .directive('logSearchControl', ['APIUtils', function(APIUtils) {
+ angular.module('app.common.directives').directive('logSearchControl', [
+ 'APIUtils',
+ function(APIUtils) {
return {
'restrict': 'E',
'template': require('./log-search-control.html'),
- 'controller': ['$rootScope', '$scope', 'dataService', '$location', function($rootScope, $scope, dataService, $location) {
- $scope.dataService = dataService;
- $scope.doSearchOnEnter = function(event) {
- var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
- if (event.keyCode === 13 &&
- search.length >= 2) {
- $scope.clearSearchItem();
- $scope.addSearchItem(search);
- }
- else {
- if (search.length == 0) {
+ 'controller': [
+ '$rootScope', '$scope', 'dataService', '$location',
+ function($rootScope, $scope, dataService, $location) {
+ $scope.dataService = dataService;
+ $scope.doSearchOnEnter = function(event) {
+ var search =
+ $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+ if (event.keyCode === 13 && search.length >= 2) {
$scope.clearSearchItem();
+ $scope.addSearchItem(search);
+ } else {
+ if (search.length == 0) {
+ $scope.clearSearchItem();
+ }
}
- }
- };
+ };
- $scope.clear = function() {
- $scope.customSearch = '';
- $scope.clearSearchItem();
- };
-
- $scope.doSearchOnClick = function() {
- var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
- if (search.length >= 2) {
+ $scope.clear = function() {
+ $scope.customSearch = '';
$scope.clearSearchItem();
- $scope.addSearchItem(search);
- }
- else {
- if (search.length == 0) {
+ };
+
+ $scope.doSearchOnClick = function() {
+ var search =
+ $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+ if (search.length >= 2) {
$scope.clearSearchItem();
+ $scope.addSearchItem(search);
+ } else {
+ if (search.length == 0) {
+ $scope.clearSearchItem();
+ }
}
- }
- };
- }]
+ };
+ }
+ ]
};
- }]);
+ }
+ ]);
})(window.angular);
diff --git a/app/common/directives/toggle-flag.js b/app/common/directives/toggle-flag.js
index 4a4e454..0869af3 100644
--- a/app/common/directives/toggle-flag.js
+++ b/app/common/directives/toggle-flag.js
@@ -1,31 +1,30 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.directives')
- .directive('toggleFlag', function($document) {
- return {
- restrict: 'A',
- link: function(scope, element, attrs) {
+ angular.module('app.common.directives')
+ .directive('toggleFlag', function($document) {
+ return {
+ restrict: 'A',
+ link: function(scope, element, attrs) {
- function elementClick(e) {
- e.stopPropagation();
+ function elementClick(e) {
+ e.stopPropagation();
+ }
+
+ function documentClick(e) {
+ scope[attrs.toggleFlag] = false;
+ scope.$apply();
+ }
+
+ element.on('click', elementClick);
+ $document.on('click', documentClick);
+
+ // remove event handlers when directive is destroyed
+ scope.$on('$destroy', function() {
+ element.off('click', elementClick);
+ $document.off('click', documentClick);
+ });
}
-
- function documentClick(e) {
- scope[attrs.toggleFlag] = false;
- scope.$apply();
- }
-
- element.on('click', elementClick);
- $document.on('click', documentClick);
-
- // remove event handlers when directive is destroyed
- scope.$on('$destroy', function() {
- element.off('click', elementClick);
- $document.off('click', documentClick);
- });
- }
- };
- });
+ };
+ });
})(window.angular);
diff --git a/app/common/filters/index.js b/app/common/filters/index.js
index f3de907..743bd4e 100644
--- a/app/common/filters/index.js
+++ b/app/common/filters/index.js
@@ -1,25 +1,25 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.filters', [])
- .filter('unResolvedCount', function() {
- return function(data) {
- data = data.filter(function(item) {
- return item.Resolved == 0;
- });
- return data.length;
- }
- })
- .filter('quiescedToError', function() {
- return function(state) {
- if (state.toLowerCase() == 'quiesced') {
- return 'Error';
+ angular.module('app.common.filters', [])
+ .filter(
+ 'unResolvedCount',
+ function() {
+ return function(data) {
+ data = data.filter(function(item) {
+ return item.Resolved == 0;
+ });
+ return data.length;
+ }
+ })
+ .filter('quiescedToError', function() {
+ return function(state) {
+ if (state.toLowerCase() == 'quiesced') {
+ return 'Error';
+ } else {
+ return state;
+ }
}
- else {
- return state;
- }
- }
- });
+ });
})(window.angular);
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index a024142..7354385 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -8,9 +8,9 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.services')
- .factory('APIUtils', ['$http', 'Constants', '$q', 'dataService', function($http, Constants, $q, DataService) {
+ angular.module('app.common.services').factory('APIUtils', [
+ '$http', 'Constants', '$q', 'dataService',
+ function($http, Constants, $q, DataService) {
var getScaledValue = function(value, scale) {
scale = scale + '';
scale = parseInt(scale, 10);
@@ -18,8 +18,7 @@
if (scale > 0) {
value = value * Math.pow(10, power);
- }
- else if (scale < 0) {
+ } else if (scale < 0) {
value = value / Math.pow(10, power);
}
return value;
@@ -37,155 +36,175 @@
var deferred = $q.defer();
$http({
method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/state/chassis0/attr/CurrentPowerState',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/state/chassis0/attr/CurrentPowerState',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content.data);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content.data);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
getHostState: function() {
var deferred = $q.defer();
$http({
method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/state/host0/attr/CurrentHostState',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/state/host0/attr/CurrentHostState',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content.data);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content.data);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
getNetworkInfo: function() {
var deferred = $q.defer();
$http({
method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/network/enumerate',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/network/enumerate',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- var hostname = '';
- var macAddress = '';
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ var hostname = '';
+ var macAddress = '';
- function parseNetworkData(content) {
- var data = {
- interface_ids: [],
- interfaces: {},
- ip_addresses: {
- ipv4: [],
- ipv6: []
- },
- };
- var interfaceId = '',
- keyParts = [],
- interfaceHash = '',
- interfaceType = '';
- for (var key in content.data) {
- if (key.match(/network\/eth\d+$/ig)) {
- interfaceId = key.split('/').pop();
- if (data.interface_ids.indexOf(interfaceId) == -1) {
- data.interface_ids.push(interfaceId);
- data.interfaces[interfaceId] = {
- interfaceIname: '',
- DomainName: '',
- MACAddress: '',
- Nameservers: [],
- DHCPEnabled: 0,
- ipv4: {
- ids: [],
- values: []
- },
- ipv6: {
- ids: [],
- values: []
+ function parseNetworkData(content) {
+ var data = {
+ interface_ids: [],
+ interfaces: {},
+ ip_addresses: {ipv4: [], ipv6: []},
+ };
+ var interfaceId = '', keyParts = [], interfaceHash = '',
+ interfaceType = '';
+ for (var key in content.data) {
+ if (key.match(/network\/eth\d+$/ig)) {
+ interfaceId = key.split('/').pop();
+ if (data.interface_ids.indexOf(interfaceId) == -1) {
+ data.interface_ids.push(interfaceId);
+ data.interfaces[interfaceId] = {
+ interfaceIname: '',
+ DomainName: '',
+ MACAddress: '',
+ Nameservers: [],
+ DHCPEnabled: 0,
+ ipv4: {ids: [], values: []},
+ ipv6: {ids: [], values: []}
+ };
+ data.interfaces[interfaceId].MACAddress =
+ content.data[key].MACAddress;
+ data.interfaces[interfaceId].DomainName =
+ content.data[key].DomainName.join(' ');
+ data.interfaces[interfaceId].Nameservers =
+ content.data[key].Nameservers;
+ data.interfaces[interfaceId].DHCPEnabled =
+ content.data[key].DHCPEnabled;
+ }
+ } else if (
+ key.match(
+ /network\/eth\d+\/ipv[4|6]\/[a-z0-9]+$/ig)) {
+ keyParts = key.split('/');
+ interfaceHash = keyParts.pop();
+ interfaceType = keyParts.pop();
+ interfaceId = keyParts.pop();
+
+ if (data.interfaces[interfaceId][interfaceType]
+ .ids.indexOf(interfaceHash) == -1) {
+ data.interfaces[interfaceId][interfaceType]
+ .ids.push(interfaceHash);
+ data.interfaces[interfaceId][interfaceType]
+ .values.push(content.data[key]);
+ data.ip_addresses[interfaceType].push(
+ content.data[key]['Address']);
+ }
+ }
}
- };
- data.interfaces[interfaceId].MACAddress = content.data[key].MACAddress;
- data.interfaces[interfaceId].DomainName = content.data[key].DomainName.join(' ');
- data.interfaces[interfaceId].Nameservers = content.data[key].Nameservers;
- data.interfaces[interfaceId].DHCPEnabled = content.data[key].DHCPEnabled;
- }
- }
- else if (key.match(/network\/eth\d+\/ipv[4|6]\/[a-z0-9]+$/ig)) {
- keyParts = key.split('/');
- interfaceHash = keyParts.pop();
- interfaceType = keyParts.pop();
- interfaceId = keyParts.pop();
+ return data;
+ }
- if (data.interfaces[interfaceId][interfaceType].ids.indexOf(interfaceHash) == -1) {
- data.interfaces[interfaceId][interfaceType].ids.push(interfaceHash);
- data.interfaces[interfaceId][interfaceType].values.push(content.data[key]);
- data.ip_addresses[interfaceType].push(content.data[key]['Address']);
- }
- }
- }
- return data;
- }
+ if (content.data.hasOwnProperty(
+ '/xyz/openbmc_project/network/config') &&
+ content.data['/xyz/openbmc_project/network/config']
+ .hasOwnProperty('HostName')) {
+ hostname =
+ content.data['/xyz/openbmc_project/network/config']
+ .HostName;
+ }
- if (content.data.hasOwnProperty('/xyz/openbmc_project/network/config') &&
- content.data['/xyz/openbmc_project/network/config'].hasOwnProperty('HostName')
- ) {
- hostname = content.data['/xyz/openbmc_project/network/config'].HostName;
- }
+ if (content.data.hasOwnProperty(
+ '/xyz/openbmc_project/network/eth0') &&
+ content.data['/xyz/openbmc_project/network/eth0']
+ .hasOwnProperty('MACAddress')) {
+ macAddress =
+ content.data['/xyz/openbmc_project/network/eth0']
+ .MACAddress;
+ }
- if (content.data.hasOwnProperty('/xyz/openbmc_project/network/eth0') &&
- content.data['/xyz/openbmc_project/network/eth0'].hasOwnProperty('MACAddress')
- ) {
- macAddress = content.data['/xyz/openbmc_project/network/eth0'].MACAddress;
- }
-
- deferred.resolve({
- data: content.data,
- hostname: hostname,
- mac_address: macAddress,
- formatted_data: parseNetworkData(content)
- });
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ deferred.resolve({
+ data: content.data,
+ hostname: hostname,
+ mac_address: macAddress,
+ formatted_data: parseNetworkData(content)
+ });
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
getLEDState: function() {
var deferred = $q.defer();
$http({
method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/led/groups/enclosure_identify',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/led/groups/enclosure_identify',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content.data.Asserted);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content.data.Asserted);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
login: function(username, password, callback) {
@@ -197,43 +216,42 @@
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': [username, password]
- })
- }).then(function(response) {
- if (callback) {
- callback(response.data);
- }
- }, function(error) {
- if (callback) {
- if (error && error.status && error.status == 'error') {
- callback(error);
- }
- else {
- callback(error, true);
- }
- }
- console.log(error);
- });
+ data: JSON.stringify({'data': [username, password]})
+ })
+ .then(
+ function(response) {
+ if (callback) {
+ callback(response.data);
+ }
+ },
+ function(error) {
+ if (callback) {
+ if (error && error.status && error.status == 'error') {
+ callback(error);
+ } else {
+ callback(error, true);
+ }
+ }
+ console.log(error);
+ });
},
testPassword: function(username, password) {
- // Calls /login without the current session to verify the given password is correct
- // ignore the interceptor logout on a bad password
+ // Calls /login without the current session to verify the given
+ // password is correct ignore the interceptor logout on a bad password
DataService.ignoreHttpError = true;
return $http({
- method: 'POST',
- url: DataService.getHost() + '/login',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: false,
- data: JSON.stringify({
- 'data': [username, password]
- })
- }).then(function(response) {
- return response.data;
- });
+ method: 'POST',
+ url: DataService.getHost() + '/login',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: false,
+ data: JSON.stringify({'data': [username, password]})
+ })
+ .then(function(response) {
+ return response.data;
+ });
},
logout: function(callback) {
$http({
@@ -244,44 +262,44 @@
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': []
- })
- }).then(function(response) {
- if (callback) {
- callback(response.data);
- }
- }, function(error) {
- if (callback) {
- callback(null, error);
- }
- console.log(error);
- });
+ data: JSON.stringify({'data': []})
+ })
+ .then(
+ function(response) {
+ if (callback) {
+ callback(response.data);
+ }
+ },
+ function(error) {
+ if (callback) {
+ callback(null, error);
+ }
+ console.log(error);
+ });
},
changePassword: function(user, newPassword) {
var deferred = $q.defer();
$http({
method: 'POST',
- url: DataService.getHost() + '/xyz/openbmc_project/user/' + user + '/action/SetPassword',
+ url: DataService.getHost() + '/xyz/openbmc_project/user/' + user +
+ '/action/SetPassword',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': [newPassword]
- }),
+ data: JSON.stringify({'data': [newPassword]}),
responseType: 'arraybuffer'
- }).then(function(response, status, headers) {
- deferred.resolve({
- data: response,
- status: status,
- headers: headers
- });
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ })
+ .then(
+ function(response, status, headers) {
+ deferred.resolve(
+ {data: response, status: status, headers: headers});
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
chassisPowerOn: function(callback) {
@@ -293,168 +311,183 @@
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': []
- })
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- if (callback) {
- return callback(content.data.CurrentPowerState);
- }
- }, function(error) {
- if (callback) {
- callback(error);
- }
- else {
- console.log(error);
- }
- });
+ data: JSON.stringify({'data': []})
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ if (callback) {
+ return callback(content.data.CurrentPowerState);
+ }
+ },
+ function(error) {
+ if (callback) {
+ callback(error);
+ } else {
+ console.log(error);
+ }
+ });
},
chassisPowerOff: function() {
var deferred = $q.defer();
$http({
method: 'PUT',
- url: DataService.getHost() + '/xyz/openbmc_project/state/chassis0/attr/RequestedPowerTransition',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/state/chassis0/attr/RequestedPowerTransition',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': 'xyz.openbmc_project.State.Chassis.Transition.Off'
- })
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content.status);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ data: JSON.stringify(
+ {'data': 'xyz.openbmc_project.State.Chassis.Transition.Off'})
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content.status);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
setLEDState: function(state, callback) {
$http({
method: 'PUT',
- url: DataService.getHost() + '/xyz/openbmc_project/led/groups/enclosure_identify/attr/Asserted',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/led/groups/enclosure_identify/attr/Asserted',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': state
- })
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- if (callback) {
- return callback(content.status);
- }
- }, function(error) {
- if (callback) {
- callback(error);
- }
- else {
- console.log(error);
- }
- });
+ data: JSON.stringify({'data': state})
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ if (callback) {
+ return callback(content.status);
+ }
+ },
+ function(error) {
+ if (callback) {
+ callback(error);
+ } else {
+ console.log(error);
+ }
+ });
},
bmcReboot: function(callback) {
$http({
method: 'PUT',
- url: DataService.getHost() + '/xyz/openbmc_project/state/bmc0/attr/RequestedBmcTransition',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/state/bmc0/attr/RequestedBmcTransition',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': 'xyz.openbmc_project.State.BMC.Transition.Reboot'
- })
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- if (callback) {
- return callback(content.status);
- }
- }, function(error) {
- if (callback) {
- callback(error);
- }
- else {
- console.log(error);
- }
- });
+ data: JSON.stringify(
+ {'data': 'xyz.openbmc_project.State.BMC.Transition.Reboot'})
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ if (callback) {
+ return callback(content.status);
+ }
+ },
+ function(error) {
+ if (callback) {
+ callback(error);
+ } else {
+ console.log(error);
+ }
+ });
},
hostPowerOn: function() {
var deferred = $q.defer();
$http({
method: 'PUT',
- url: DataService.getHost() + '/xyz/openbmc_project/state/host0/attr/RequestedHostTransition',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/state/host0/attr/RequestedHostTransition',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': 'xyz.openbmc_project.State.Host.Transition.On'
- })
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content.status);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ data: JSON.stringify(
+ {'data': 'xyz.openbmc_project.State.Host.Transition.On'})
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content.status);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
hostPowerOff: function() {
var deferred = $q.defer();
$http({
method: 'PUT',
- url: DataService.getHost() + '/xyz/openbmc_project/state/host0/attr/RequestedHostTransition',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/state/host0/attr/RequestedHostTransition',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': 'xyz.openbmc_project.State.Host.Transition.Off'
- })
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content.status);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ data: JSON.stringify(
+ {'data': 'xyz.openbmc_project.State.Host.Transition.Off'})
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content.status);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
hostReboot: function() {
var deferred = $q.defer();
$http({
method: 'PUT',
- url: DataService.getHost() + '/xyz/openbmc_project/state/host0/attr/RequestedHostTransition',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/state/host0/attr/RequestedHostTransition',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': 'xyz.openbmc_project.State.Host.Transition.Reboot'
- })
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content.status);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ data: JSON.stringify(
+ {'data': 'xyz.openbmc_project.State.Host.Transition.Reboot'})
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content.status);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
@@ -467,350 +500,391 @@
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': []
- })
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- if (callback) {
- return callback(content);
- }
- }, function(error) {
- if (callback) {
- callback(error);
- }
- else {
- console.log(error);
- }
- });
+ data: JSON.stringify({'data': []})
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ if (callback) {
+ return callback(content);
+ }
+ },
+ function(error) {
+ if (callback) {
+ callback(error);
+ } else {
+ console.log(error);
+ }
+ });
},
getLogs: function() {
var deferred = $q.defer();
$http({
method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/logging/enumerate',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/logging/enumerate',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- var dataClone = JSON.parse(JSON.stringify(content.data));
- var data = [];
- var severityCode = '';
- var priority = '';
- var health = '';
- var relatedItems = [];
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ var dataClone = JSON.parse(JSON.stringify(content.data));
+ var data = [];
+ var severityCode = '';
+ var priority = '';
+ var health = '';
+ var relatedItems = [];
- for (var key in content.data) {
- if (content.data.hasOwnProperty(key) && content.data[key].hasOwnProperty('Id')) {
- var severityFlags = {
- low: false,
- medium: false,
- high: false
- };
- var healthFlags = {
- critical: false,
- warning: false,
- good: false
- };
- severityCode = content.data[key].Severity.split('.').pop();
- priority = Constants.SEVERITY_TO_PRIORITY_MAP[severityCode];
- severityFlags[priority.toLowerCase()] = true;
- health = Constants.SEVERITY_TO_HEALTH_MAP[severityCode];
- healthFlags[health.toLowerCase()] = true;
- relatedItems = [];
- content.data[key].associations.forEach(function(item) {
- relatedItems.push(item[2]);
- });
+ for (var key in content.data) {
+ if (content.data.hasOwnProperty(key) &&
+ content.data[key].hasOwnProperty('Id')) {
+ var severityFlags = {
+ low: false,
+ medium: false,
+ high: false
+ };
+ var healthFlags = {
+ critical: false,
+ warning: false,
+ good: false
+ };
+ severityCode =
+ content.data[key].Severity.split('.').pop();
+ priority =
+ Constants.SEVERITY_TO_PRIORITY_MAP[severityCode];
+ severityFlags[priority.toLowerCase()] = true;
+ health = Constants.SEVERITY_TO_HEALTH_MAP[severityCode];
+ healthFlags[health.toLowerCase()] = true;
+ relatedItems = [];
+ content.data[key].associations.forEach(function(item) {
+ relatedItems.push(item[2]);
+ });
- data.push(Object.assign({
- path: key,
- copied: false,
- priority: priority,
- severity_code: severityCode,
- severity_flags: severityFlags,
- health_flags: healthFlags,
- additional_data: content.data[key].AdditionalData.join('\n'),
- type: content.data[key].Message,
- selected: false,
- search_text: ('#' + content.data[key].Id + ' ' + severityCode + ' ' + content.data[key].Severity + ' ' + content.data[key].AdditionalData.join(' ')).toLowerCase(),
- meta: false,
- confirm: false,
- related_items: relatedItems,
- data: {
- key: key,
- value: content.data[key]
- }
- }, content.data[key]));
- }
- }
- deferred.resolve({
- data: data,
- original: dataClone
- });
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ data.push(Object.assign(
+ {
+ path: key,
+ copied: false,
+ priority: priority,
+ severity_code: severityCode,
+ severity_flags: severityFlags,
+ health_flags: healthFlags,
+ additional_data:
+ content.data[key].AdditionalData.join('\n'),
+ type: content.data[key].Message,
+ selected: false,
+ search_text:
+ ('#' + content.data[key].Id + ' ' +
+ severityCode + ' ' +
+ content.data[key].Severity + ' ' +
+ content.data[key].AdditionalData.join(' '))
+ .toLowerCase(),
+ meta: false,
+ confirm: false,
+ related_items: relatedItems,
+ data: {key: key, value: content.data[key]}
+ },
+ content.data[key]));
+ }
+ }
+ deferred.resolve({data: data, original: dataClone});
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
getAllSensorStatus: function(callback) {
$http({
method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/sensors/enumerate',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/sensors/enumerate',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- var dataClone = JSON.parse(JSON.stringify(content.data));
- var sensorData = [];
- var severity = {};
- var title = '';
- var tempKeyParts = [];
- var order = 0;
- var customOrder = 0;
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ var dataClone = JSON.parse(JSON.stringify(content.data));
+ var sensorData = [];
+ var severity = {};
+ var title = '';
+ var tempKeyParts = [];
+ var order = 0;
+ var customOrder = 0;
- function getSensorStatus(reading) {
- var severityFlags = {
- critical: false,
- warning: false,
- normal: false
- },
- severityText = '',
- order = 0;
+ function getSensorStatus(reading) {
+ var severityFlags = {
+ critical: false,
+ warning: false,
+ normal: false
+ },
+ severityText = '', order = 0;
- if (reading.hasOwnProperty('CriticalLow') &&
- reading.Value < reading.CriticalLow
- ) {
- severityFlags.critical = true;
- severityText = 'critical';
- order = 2;
- }
- else if (reading.hasOwnProperty('CriticalHigh') &&
- reading.Value > reading.CriticalHigh
- ) {
- severityFlags.critical = true;
- severityText = 'critical';
- order = 2;
- }
- else if (reading.hasOwnProperty('CriticalLow') &&
- reading.hasOwnProperty('WarningLow') &&
- reading.Value >= reading.CriticalLow && reading.Value <= reading.WarningLow) {
- severityFlags.warning = true;
- severityText = 'warning';
- order = 1;
- }
- else if (reading.hasOwnProperty('WarningHigh') &&
- reading.hasOwnProperty('CriticalHigh') &&
- reading.Value >= reading.WarningHigh && reading.Value <= reading.CriticalHigh) {
- severityFlags.warning = true;
- severityText = 'warning';
- order = 1;
- }
- else {
- severityFlags.normal = true;
- severityText = 'normal';
- }
- return {
- flags: severityFlags,
- severityText: severityText,
- order: order
- };
- }
+ if (reading.hasOwnProperty('CriticalLow') &&
+ reading.Value < reading.CriticalLow) {
+ severityFlags.critical = true;
+ severityText = 'critical';
+ order = 2;
+ } else if (
+ reading.hasOwnProperty('CriticalHigh') &&
+ reading.Value > reading.CriticalHigh) {
+ severityFlags.critical = true;
+ severityText = 'critical';
+ order = 2;
+ } else if (
+ reading.hasOwnProperty('CriticalLow') &&
+ reading.hasOwnProperty('WarningLow') &&
+ reading.Value >= reading.CriticalLow &&
+ reading.Value <= reading.WarningLow) {
+ severityFlags.warning = true;
+ severityText = 'warning';
+ order = 1;
+ } else if (
+ reading.hasOwnProperty('WarningHigh') &&
+ reading.hasOwnProperty('CriticalHigh') &&
+ reading.Value >= reading.WarningHigh &&
+ reading.Value <= reading.CriticalHigh) {
+ severityFlags.warning = true;
+ severityText = 'warning';
+ order = 1;
+ } else {
+ severityFlags.normal = true;
+ severityText = 'normal';
+ }
+ return {
+ flags: severityFlags,
+ severityText: severityText,
+ order: order
+ };
+ }
- for (var key in content.data) {
- if (content.data.hasOwnProperty(key) && content.data[key].hasOwnProperty('Unit')) {
+ for (var key in content.data) {
+ if (content.data.hasOwnProperty(key) &&
+ content.data[key].hasOwnProperty('Unit')) {
+ severity = getSensorStatus(content.data[key]);
- severity = getSensorStatus(content.data[key]);
+ if (!content.data[key].hasOwnProperty('CriticalLow')) {
+ content.data[key].CriticalLow = '--';
+ content.data[key].CriticalHigh = '--';
+ }
- if (!content.data[key].hasOwnProperty('CriticalLow')) {
- content.data[key].CriticalLow = '--';
- content.data[key].CriticalHigh = '--';
- }
+ if (!content.data[key].hasOwnProperty('WarningLow')) {
+ content.data[key].WarningLow = '--';
+ content.data[key].WarningHigh = '--';
+ }
- if (!content.data[key].hasOwnProperty('WarningLow')) {
- content.data[key].WarningLow = '--';
- content.data[key].WarningHigh = '--';
- }
+ tempKeyParts = key.split('/');
+ title = tempKeyParts.pop();
+ title = tempKeyParts.pop() + '_' + title;
+ title = title.split('_')
+ .map(function(item) {
+ return item.toLowerCase()
+ .charAt(0)
+ .toUpperCase() +
+ item.slice(1);
+ })
+ .reduce(function(prev, el) {
+ return prev + ' ' + el;
+ });
- tempKeyParts = key.split('/');
- title = tempKeyParts.pop();
- title = tempKeyParts.pop() + '_' + title;
- title = title.split('_').map(function(item) {
- return item.toLowerCase().charAt(0).toUpperCase() + item.slice(1);
- }).reduce(function(prev, el) {
- return prev + ' ' + el;
- });
+ content.data[key].Value = getScaledValue(
+ content.data[key].Value, content.data[key].Scale);
+ content.data[key].CriticalLow = getScaledValue(
+ content.data[key].CriticalLow,
+ content.data[key].Scale);
+ content.data[key].CriticalHigh = getScaledValue(
+ content.data[key].CriticalHigh,
+ content.data[key].Scale);
+ content.data[key].WarningLow = getScaledValue(
+ content.data[key].WarningLow,
+ content.data[key].Scale);
+ content.data[key].WarningHigh = getScaledValue(
+ content.data[key].WarningHigh,
+ content.data[key].Scale);
+ if (Constants.SENSOR_SORT_ORDER.indexOf(
+ content.data[key].Unit) > -1) {
+ customOrder = Constants.SENSOR_SORT_ORDER.indexOf(
+ content.data[key].Unit);
+ } else {
+ customOrder = Constants.SENSOR_SORT_ORDER_DEFAULT;
+ }
- content.data[key].Value = getScaledValue(content.data[key].Value, content.data[key].Scale);
- content.data[key].CriticalLow = getScaledValue(content.data[key].CriticalLow, content.data[key].Scale);
- content.data[key].CriticalHigh = getScaledValue(content.data[key].CriticalHigh, content.data[key].Scale);
- content.data[key].WarningLow = getScaledValue(content.data[key].WarningLow, content.data[key].Scale);
- content.data[key].WarningHigh = getScaledValue(content.data[key].WarningHigh, content.data[key].Scale);
- if (Constants.SENSOR_SORT_ORDER.indexOf(content.data[key].Unit) > -1) {
- customOrder = Constants.SENSOR_SORT_ORDER.indexOf(content.data[key].Unit);
- }
- else {
- customOrder = Constants.SENSOR_SORT_ORDER_DEFAULT;
- }
+ sensorData.push(Object.assign(
+ {
+ path: key,
+ selected: false,
+ confirm: false,
+ copied: false,
+ title: title,
+ unit:
+ Constants
+ .SENSOR_UNIT_MAP[content.data[key].Unit],
+ severity_flags: severity.flags,
+ status: severity.severityText,
+ order: severity.order,
+ custom_order: customOrder,
+ search_text:
+ (title + ' ' + content.data[key].Value + ' ' +
+ Constants.SENSOR_UNIT_MAP[content.data[key]
+ .Unit] +
+ ' ' + severity.severityText + ' ' +
+ content.data[key].CriticalLow + ' ' +
+ content.data[key].CriticalHigh + ' ' +
+ content.data[key].WarningLow + ' ' +
+ content.data[key].WarningHigh + ' ')
+ .toLowerCase(),
+ original_data:
+ {key: key, value: content.data[key]}
+ },
+ content.data[key]));
+ }
+ }
- sensorData.push(Object.assign({
- path: key,
- selected: false,
- confirm: false,
- copied: false,
- title: title,
- unit: Constants.SENSOR_UNIT_MAP[content.data[key].Unit],
- severity_flags: severity.flags,
- status: severity.severityText,
- order: severity.order,
- custom_order: customOrder,
- search_text: (title + ' ' + content.data[key].Value + ' ' +
- Constants.SENSOR_UNIT_MAP[content.data[key].Unit] + ' ' +
- severity.severityText + ' ' +
- content.data[key].CriticalLow + ' ' +
- content.data[key].CriticalHigh + ' ' +
- content.data[key].WarningLow + ' ' +
- content.data[key].WarningHigh + ' '
- ).toLowerCase(),
- original_data: {
- key: key,
- value: content.data[key]
- }
- }, content.data[key]));
- }
- }
-
- callback(sensorData, dataClone);
- }, function(error) {
- console.log(error);
- });
+ callback(sensorData, dataClone);
+ },
+ function(error) {
+ console.log(error);
+ });
},
getActivation: function(imageId) {
return $http({
- method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/software/' + imageId + '/attr/Activation',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true
- }).then(function(response) {
- return response.data;
- });
+ method: 'GET',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/software/' + imageId +
+ '/attr/Activation',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true
+ })
+ .then(function(response) {
+ return response.data;
+ });
},
getFirmwares: function() {
var deferred = $q.defer();
$http({
method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/software/enumerate',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/software/enumerate',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- var data = [];
- var activationStatus = '';
- var isExtended = false;
- var bmcActiveVersion = '';
- var hostActiveVersion = '';
- var imageType = '';
- var extendedVersions = [];
- var functionalImages = [];
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ var data = [];
+ var activationStatus = '';
+ var isExtended = false;
+ var bmcActiveVersion = '';
+ var hostActiveVersion = '';
+ var imageType = '';
+ var extendedVersions = [];
+ var functionalImages = [];
- function getFormatedExtendedVersions(extendedVersion) {
- var versions = [];
- extendedVersion = extendedVersion.split(',');
+ function getFormatedExtendedVersions(extendedVersion) {
+ var versions = [];
+ extendedVersion = extendedVersion.split(',');
- extendedVersion.forEach(function(item) {
- var parts = item.split('-');
- var numberIndex = 0;
- for (var i = 0; i < parts.length; i++) {
- if (/[0-9]/.test(parts[i])) {
- numberIndex = i;
- break;
- }
- }
- var titlePart = parts.splice(0, numberIndex);
- titlePart = titlePart.join('');
- titlePart = titlePart[0].toUpperCase() + titlePart.substr(1, titlePart.length);
- var versionPart = parts.join('-');
- versions.push({
- title: titlePart,
- version: versionPart
- });
- });
+ extendedVersion.forEach(function(item) {
+ var parts = item.split('-');
+ var numberIndex = 0;
+ for (var i = 0; i < parts.length; i++) {
+ if (/[0-9]/.test(parts[i])) {
+ numberIndex = i;
+ break;
+ }
+ }
+ var titlePart = parts.splice(0, numberIndex);
+ titlePart = titlePart.join('');
+ titlePart = titlePart[0].toUpperCase() +
+ titlePart.substr(1, titlePart.length);
+ var versionPart = parts.join('-');
+ versions.push({title: titlePart, version: versionPart});
+ });
- return versions;
- }
+ return versions;
+ }
- // Get the list of functional images so we can compare
- // later if an image is functional
- if (content.data[Constants.FIRMWARE.FUNCTIONAL_OBJPATH]) {
- functionalImages = content.data[Constants.FIRMWARE.FUNCTIONAL_OBJPATH].endpoints;
- }
- for (var key in content.data) {
- if (content.data.hasOwnProperty(key) && content.data[key].hasOwnProperty('Version')) {
- // If the image is "Functional" use that for the
- // activation status, else use the value of "Activation"
- // github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Software/Activation.interface.yaml
- activationStatus = content.data[key].Activation.split('.').pop();
- if (functionalImages.includes(key)) {
- activationStatus = 'Functional';
- }
+ // Get the list of functional images so we can compare
+ // later if an image is functional
+ if (content.data[Constants.FIRMWARE.FUNCTIONAL_OBJPATH]) {
+ functionalImages =
+ content.data[Constants.FIRMWARE.FUNCTIONAL_OBJPATH]
+ .endpoints;
+ }
+ for (var key in content.data) {
+ if (content.data.hasOwnProperty(key) &&
+ content.data[key].hasOwnProperty('Version')) {
+ // If the image is "Functional" use that for the
+ // activation status, else use the value of "Activation"
+ // github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Software/Activation.interface.yaml
+ activationStatus =
+ content.data[key].Activation.split('.').pop();
+ if (functionalImages.includes(key)) {
+ activationStatus = 'Functional';
+ }
- imageType = content.data[key].Purpose.split('.').pop();
- isExtended = content.data[key].hasOwnProperty('ExtendedVersion') && content.data[key].ExtendedVersion != '';
- if (isExtended) {
- extendedVersions = getFormatedExtendedVersions(content.data[key].ExtendedVersion);
- }
- data.push(Object.assign({
- path: key,
- activationStatus: activationStatus,
- imageId: key.split('/').pop(),
- imageType: imageType,
- isExtended: isExtended,
- extended: {
- show: false,
- versions: extendedVersions
+ imageType = content.data[key].Purpose.split('.').pop();
+ isExtended = content.data[key].hasOwnProperty(
+ 'ExtendedVersion') &&
+ content.data[key].ExtendedVersion != '';
+ if (isExtended) {
+ extendedVersions = getFormatedExtendedVersions(
+ content.data[key].ExtendedVersion);
+ }
+ data.push(Object.assign(
+ {
+ path: key,
+ activationStatus: activationStatus,
+ imageId: key.split('/').pop(),
+ imageType: imageType,
+ isExtended: isExtended,
+ extended:
+ {show: false, versions: extendedVersions},
+ data: {key: key, value: content.data[key]}
+ },
+ content.data[key]));
+
+ if (activationStatus == 'Functional' &&
+ imageType == 'BMC') {
+ bmcActiveVersion = content.data[key].Version;
+ }
+
+ if (activationStatus == 'Functional' &&
+ imageType == 'Host') {
+ hostActiveVersion = content.data[key].Version;
+ }
+ }
+ }
+
+ deferred.resolve({
+ data: data,
+ bmcActiveVersion: bmcActiveVersion,
+ hostActiveVersion: hostActiveVersion
+ });
},
- data: {
- key: key,
- value: content.data[key]
- }
- }, content.data[key]));
-
- if (activationStatus == 'Functional' && imageType == 'BMC') {
- bmcActiveVersion = content.data[key].Version;
- }
-
- if (activationStatus == 'Functional' && imageType == 'Host') {
- hostActiveVersion = content.data[key].Version;
- }
- }
- }
-
- deferred.resolve({
- data: data,
- bmcActiveVersion: bmcActiveVersion,
- hostActiveVersion: hostActiveVersion
- });
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
@@ -818,23 +892,25 @@
var deferred = $q.defer();
$http({
method: 'PUT',
- url: DataService.getHost() + '/xyz/openbmc_project/software/' + imageId + '/attr/Priority',
+ url: DataService.getHost() + '/xyz/openbmc_project/software/' +
+ imageId + '/attr/Priority',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': priority
- })
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ data: JSON.stringify({'data': priority})
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
@@ -842,23 +918,25 @@
var deferred = $q.defer();
$http({
method: 'POST',
- url: DataService.getHost() + '/xyz/openbmc_project/software/' + imageId + '/action/Delete',
+ url: DataService.getHost() + '/xyz/openbmc_project/software/' +
+ imageId + '/action/Delete',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': []
- })
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ data: JSON.stringify({'data': []})
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
@@ -866,75 +944,81 @@
var deferred = $q.defer();
$http({
method: 'PUT',
- url: DataService.getHost() + '/xyz/openbmc_project/software/' + imageId + '/attr/RequestedActivation',
+ url: DataService.getHost() + '/xyz/openbmc_project/software/' +
+ imageId + '/attr/RequestedActivation',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': Constants.FIRMWARE.ACTIVATE_FIRMWARE
- })
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ data:
+ JSON.stringify({'data': Constants.FIRMWARE.ACTIVATE_FIRMWARE})
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
uploadImage: function(file) {
return $http({
- method: 'POST',
- timeout: 5 * 60 * 1000,
- url: DataService.getHost() + '/upload/image',
- headers: {
- 'Content-Type': 'application/octet-stream'
- },
- withCredentials: true,
- data: file
- }).then(function(response) {
- return response.data;
- });
+ method: 'POST',
+ timeout: 5 * 60 * 1000,
+ url: DataService.getHost() + '/upload/image',
+ headers: {'Content-Type': 'application/octet-stream'},
+ withCredentials: true,
+ data: file
+ })
+ .then(function(response) {
+ return response.data;
+ });
},
downloadImage: function(host, filename) {
return $http({
- method: 'POST',
- url: DataService.getHost() + '/xyz/openbmc_project/software/action/DownloadViaTFTP',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true,
- data: JSON.stringify({
- 'data': [filename, host]
- }),
- responseType: 'arraybuffer'
- }).then(function(response) {
- return response.data;
- });
+ method: 'POST',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/software/action/DownloadViaTFTP',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true,
+ data: JSON.stringify({'data': [filename, host]}),
+ responseType: 'arraybuffer'
+ })
+ .then(function(response) {
+ return response.data;
+ });
},
getBMCEthernetInfo: function() {
var deferred = $q.defer();
$http({
method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/inventory/system/chassis/motherboard/boxelder/bmc/ethernet',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/inventory/system/chassis/motherboard/boxelder/bmc/ethernet',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content.data);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content.data);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
@@ -942,20 +1026,24 @@
var deferred = $q.defer();
$http({
method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/inventory/system/chassis/motherboard/boxelder/bmc',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/inventory/system/chassis/motherboard/boxelder/bmc',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
- deferred.resolve(content.data);
- }, function(error) {
- console.log(error);
- deferred.reject(error);
- });
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
+ deferred.resolve(content.data);
+ },
+ function(error) {
+ console.log(error);
+ deferred.reject(error);
+ });
return deferred.promise;
},
getServerInfo: function() {
@@ -963,34 +1051,38 @@
// interfaces so we can get the system object(s) by the looking
// for the system interface.
return $http({
- method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/inventory/system',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true
- }).then(function(response) {
- return response.data;
- });
+ method: 'GET',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/inventory/system',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true
+ })
+ .then(function(response) {
+ return response.data;
+ });
},
getBMCTime: function() {
return $http({
- method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/time/bmc',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true
- }).then(function(response) {
- return response.data;
- });
+ method: 'GET',
+ url: DataService.getHost() + '/xyz/openbmc_project/time/bmc',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true
+ })
+ .then(function(response) {
+ return response.data;
+ });
},
getHardwares: function(callback) {
$http({
method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/inventory/enumerate',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/inventory/enumerate',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
@@ -1007,11 +1099,12 @@
var componentIndex = -1;
var tempParts = [];
-
function isSubComponent(key) {
-
- for (var i = 0; i < Constants.HARDWARE.parent_components.length; i++) {
- if (key.split(Constants.HARDWARE.parent_components[i]).length == 2) return true;
+ for (var i = 0; i < Constants.HARDWARE.parent_components.length;
+ i++) {
+ if (key.split(Constants.HARDWARE.parent_components[i]).length ==
+ 2)
+ return true;
}
return false;
@@ -1019,8 +1112,10 @@
function titlelize(title) {
title = title.replace(/([A-Z0-9]+)/g, ' $1').replace(/^\s+/, '');
- for (var i = 0; i < Constants.HARDWARE.uppercase_titles.length; i++) {
- if (title.toLowerCase().indexOf((Constants.HARDWARE.uppercase_titles[i] + ' ')) > -1) {
+ for (var i = 0; i < Constants.HARDWARE.uppercase_titles.length;
+ i++) {
+ if (title.toLowerCase().indexOf(
+ (Constants.HARDWARE.uppercase_titles[i] + ' ')) > -1) {
return title.toUpperCase();
}
}
@@ -1029,9 +1124,7 @@
}
function camelcaseToLabel(obj) {
- var transformed = [],
- label = '',
- value = '';
+ var transformed = [], label = '', value = '';
for (var key in obj) {
label = key.replace(/([A-Z0-9]+)/g, ' $1').replace(/^\s+/, '');
if (obj[key] !== '') {
@@ -1039,10 +1132,7 @@
if (value == 1 || value == 0) {
value = (value == 1) ? 'Yes' : 'No';
}
- transformed.push({
- key: label,
- value: value
- });
+ transformed.push({key: label, value: value});
}
}
@@ -1060,8 +1150,7 @@
for (var key in content.data) {
if (content.data.hasOwnProperty(key) &&
- key.indexOf(Constants.HARDWARE.component_key_filter) == 0) {
-
+ key.indexOf(Constants.HARDWARE.component_key_filter) == 0) {
data = camelcaseToLabel(content.data[key]);
searchText = getSearchText(data);
title = key.split('/').pop();
@@ -1069,24 +1158,21 @@
title = titlelize(title);
if (!isSubComponent(key)) {
- hardwareData.push(Object.assign({
- path: key,
- title: title,
- selected: false,
- expanded: false,
- search_text: title.toLowerCase() + ' ' + searchText.toLowerCase(),
- sub_components: [],
- original_data: {
- key: key,
- value: content.data[key]
- }
- }, {
- items: data
- }));
+ hardwareData.push(Object.assign(
+ {
+ path: key,
+ title: title,
+ selected: false,
+ expanded: false,
+ search_text: title.toLowerCase() + ' ' +
+ searchText.toLowerCase(),
+ sub_components: [],
+ original_data: {key: key, value: content.data[key]}
+ },
+ {items: data}));
keyIndexMap[key] = hardwareData.length - 1;
- }
- else {
+ } else {
var tempParts = key.split('/');
tempParts.pop();
tempParts = tempParts.join('/');
@@ -1094,14 +1180,16 @@
data = content.data[key];
data.title = title;
hardwareData[componentIndex].sub_components.push(data);
- hardwareData[componentIndex].search_text += ' ' + title.toLowerCase();
+ hardwareData[componentIndex].search_text +=
+ ' ' + title.toLowerCase();
- // Sort the subcomponents alphanumeric so they are displayed on the
- // inventory page in order (e.g. core 0, core 1, core 2, ... core 12, core 13)
- hardwareData[componentIndex].sub_components.sort(function(a, b) {
- return a.title.localeCompare(b.title, 'en', {
- numeric: true
- });
+ // Sort the subcomponents alphanumeric so they are displayed
+ // on the inventory page in order (e.g. core 0, core 1, core
+ // 2, ... core 12, core 13)
+ hardwareData[componentIndex].sub_components.sort(function(
+ a, b) {
+ return a.title.localeCompare(
+ b.title, 'en', {numeric: true});
});
}
}
@@ -1109,12 +1197,8 @@
if (callback) {
callback(hardwareData, content.data);
- }
- else {
- return {
- data: hardwareData,
- original_data: content.data
- };
+ } else {
+ return {data: hardwareData, original_data: content.data};
}
});
},
@@ -1129,15 +1213,15 @@
logs.forEach(function(item) {
promises.push($http({
method: 'POST',
- url: DataService.getHost() + '/xyz/openbmc_project/logging/entry/' + item.Id + '/action/Delete',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/logging/entry/' + item.Id +
+ '/action/Delete',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': []
- })
+ data: JSON.stringify({'data': []})
}));
});
@@ -1156,15 +1240,15 @@
logs.forEach(function(item) {
promises.push($http({
method: 'PUT',
- url: DataService.getHost() + '/xyz/openbmc_project/logging/entry/' + item.Id + '/attr/Resolved',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/logging/entry/' + item.Id +
+ '/attr/Resolved',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
withCredentials: true,
- data: JSON.stringify({
- 'data': '1'
- })
+ data: JSON.stringify({'data': '1'})
}));
});
@@ -1174,65 +1258,72 @@
},
getPowerConsumption: function() {
return $http({
- method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/sensors/power/total_power',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
+ method: 'GET',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/sensors/power/total_power',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true
+ })
+ .then(
+ function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
- return getScaledValue(content.data.Value,
- content.data.Scale) + ' ' +
- Constants.POWER_CONSUMPTION_TEXT[content.data.Unit];
- }, function(error) {
- if ('Not Found' == error.statusText) {
- return Constants.POWER_CONSUMPTION_TEXT.notavailable;
- }
- else {
- throw error;
- }
- });
+ return getScaledValue(
+ content.data.Value, content.data.Scale) +
+ ' ' +
+ Constants.POWER_CONSUMPTION_TEXT[content.data.Unit];
+ },
+ function(error) {
+ if ('Not Found' == error.statusText) {
+ return Constants.POWER_CONSUMPTION_TEXT.notavailable;
+ } else {
+ throw error;
+ }
+ });
},
getPowerCap: function() {
return $http({
- method: 'GET',
- url: DataService.getHost() + '/xyz/openbmc_project/control/host0/power_cap',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true
- }).then(function(response) {
- var json = JSON.stringify(response.data);
- var content = JSON.parse(json);
+ method: 'GET',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/control/host0/power_cap',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true
+ })
+ .then(function(response) {
+ var json = JSON.stringify(response.data);
+ var content = JSON.parse(json);
- return (false == content.data.PowerCapEnable) ?
- Constants.POWER_CAP_TEXT.disabled :
- content.data.PowerCap + ' ' + Constants.POWER_CAP_TEXT.unit;
- });
+ return (false == content.data.PowerCapEnable) ?
+ Constants.POWER_CAP_TEXT.disabled :
+ content.data.PowerCap + ' ' + Constants.POWER_CAP_TEXT.unit;
+ });
},
setHostname: function(hostname) {
return $http({
- method: 'PUT',
- url: DataService.getHost() + '/xyz/openbmc_project/network/config/attr/HostName',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true,
- data: JSON.stringify({
- 'data': hostname
- })
- }).then(function(response) {
- return response.data;
- });
+ method: 'PUT',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/network/config/attr/HostName',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true,
+ data: JSON.stringify({'data': hostname})
+ })
+ .then(function(response) {
+ return response.data;
+ });
},
};
return SERVICE;
- }]);
+ }
+ ]);
})(window.angular);
diff --git a/app/common/services/apiInterceptor.js b/app/common/services/apiInterceptor.js
index b3f2ff4..03a43a3 100644
--- a/app/common/services/apiInterceptor.js
+++ b/app/common/services/apiInterceptor.js
@@ -10,9 +10,9 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.services')
- .service('apiInterceptor', ['$q', '$rootScope', 'dataService', function($q, $rootScope, dataService) {
+ angular.module('app.common.services').service('apiInterceptor', [
+ '$q', '$rootScope', 'dataService',
+ function($q, $rootScope, dataService) {
return {
'request': function(config) {
dataService.loading = true;
@@ -25,7 +25,7 @@
'response': function(response) {
dataService.loading = false;
- //not interested in template requests
+ // not interested in template requests
if (!/^https?\:/i.test(response.config.url)) {
return response;
}
@@ -33,13 +33,12 @@
dataService.last_updated = new Date();
if (!response) {
dataService.server_unreachable = true;
- }
- else {
+ } else {
dataService.server_unreachable = false;
}
if (response && response.status == 'error' &&
- dataService.path != '/login') {
+ dataService.path != '/login') {
$rootScope.$emit('timedout-user', {});
}
@@ -52,8 +51,7 @@
if (dataService.path != '/login') {
$rootScope.$emit('timedout-user', {});
}
- }
- else if (rejection.status == -1) {
+ } else if (rejection.status == -1) {
dataService.server_unreachable = true;
}
@@ -62,6 +60,7 @@
return $q.reject(rejection);
}
};
- }]);
+ }
+ ]);
})(window.angular);
diff --git a/app/common/services/constants.js b/app/common/services/constants.js
index d749ea8..112c90e 100644
--- a/app/common/services/constants.js
+++ b/app/common/services/constants.js
@@ -10,158 +10,142 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.services', [])
- .service('Constants', function() {
- return {
- API_CREDENTIALS: {
- host_storage_key: 'API_HOST_KEY',
- default_protocol: 'https'
- },
- API_RESPONSE: {
- ERROR_STATUS: 'error',
- ERROR_MESSAGE: '401 Unauthorized',
- SUCCESS_STATUS: 'ok',
- SUCCESS_MESSAGE: '200 OK'
- },
- CHASSIS_POWER_STATE: {
- on: 'On',
- on_code: 'xyz.openbmc_project.State.Chassis.PowerState.On',
- off: 'Off',
- off_code: 'xyz.openbmc_project.State.Chassis.PowerState.Off'
- },
- HOST_STATE_TEXT: {
- on: 'Running',
- on_code: 'xyz.openbmc_project.State.Host.HostState.Running',
- off: 'Off',
- off_code: 'xyz.openbmc_project.State.Host.HostState.Off',
- error: 'Quiesced',
- error_code: 'xyz.openbmc_project.State.Host.HostState.Quiesced',
- unreachable: 'Unreachable'
- },
- HOST_STATE: {
- on: 1,
- off: -1,
- error: 0,
- unreachable: -2
- },
- LED_STATE: {
- on: true,
- off: false
- },
- LED_STATE_TEXT: {
- on: 'on',
- off: 'off'
- },
- SEVERITY_TO_HEALTH_MAP: {
- Emergency: 'Critical',
- Alert: 'Critical',
- Critical: 'Critical',
- Error: 'Warning',
- Warning: 'Warning',
- Notice: 'Good',
- Debug: 'Good',
- Informational: 'Good'
- },
- SEVERITY_TO_PRIORITY_MAP: {
- Emergency: 'High',
- Alert: 'High',
- Critical: 'High',
- Error: 'High',
- Warning: 'Medium',
- Notice: 'Low',
- Debug: 'Low',
- Informational: 'Low'
- },
- PAGINATION: {
- LOG_ITEMS_PER_PAGE: 25
- },
- HARDWARE: {
- component_key_filter: '/xyz/openbmc_project/inventory/system',
- parent_components: [
- /xyz\/openbmc_project\/inventory\/system\/chassis\/motherboard\/cpu\d+\//
- ],
- uppercase_titles: [
- 'cpu', 'dimm'
- ]
- },
- SENSOR_UNIT_MAP: {
- 'xyz.openbmc_project.Sensor.Value.Unit.RPMS': 'rpms',
- 'xyz.openbmc_project.Sensor.Value.Unit.DegreesC': 'C',
- 'xyz.openbmc_project.Sensor.Value.Unit.Volts': 'volts',
- 'xyz.openbmc_project.Sensor.Value.Unit.Meters': 'meters',
- 'xyz.openbmc_project.Sensor.Value.Unit.Watts': 'watts',
- 'xyz.openbmc_project.Sensor.Value.Unit.Amperes': 'amperes',
- 'xyz.openbmc_project.Sensor.Value.Unit.Joules': 'joules'
- },
- SERVER_HEALTH: {
- critical: 'Critical',
- warning: 'Warning',
- good: 'Good',
- unknown: 'Unknown'
- },
- SENSOR_SORT_ORDER: [
- 'xyz.openbmc_project.Sensor.Value.Unit.DegreesC',
- 'xyz.openbmc_project.Sensor.Value.Unit.RPMS',
- 'xyz.openbmc_project.Sensor.Value.Unit.Meters',
- 'xyz.openbmc_project.Sensor.Value.Unit.Volts',
- 'xyz.openbmc_project.Sensor.Value.Unit.Amperes',
- 'xyz.openbmc_project.Sensor.Value.Unit.Joules',
- 'xyz.openbmc_project.Sensor.Value.Unit.Meters'
+ angular.module('app.common.services', []).service('Constants', function() {
+ return {
+ API_CREDENTIALS:
+ {host_storage_key: 'API_HOST_KEY', default_protocol: 'https'},
+ API_RESPONSE: {
+ ERROR_STATUS: 'error',
+ ERROR_MESSAGE: '401 Unauthorized',
+ SUCCESS_STATUS: 'ok',
+ SUCCESS_MESSAGE: '200 OK'
+ },
+ CHASSIS_POWER_STATE: {
+ on: 'On',
+ on_code: 'xyz.openbmc_project.State.Chassis.PowerState.On',
+ off: 'Off',
+ off_code: 'xyz.openbmc_project.State.Chassis.PowerState.Off'
+ },
+ HOST_STATE_TEXT: {
+ on: 'Running',
+ on_code: 'xyz.openbmc_project.State.Host.HostState.Running',
+ off: 'Off',
+ off_code: 'xyz.openbmc_project.State.Host.HostState.Off',
+ error: 'Quiesced',
+ error_code: 'xyz.openbmc_project.State.Host.HostState.Quiesced',
+ unreachable: 'Unreachable'
+ },
+ HOST_STATE: {on: 1, off: -1, error: 0, unreachable: -2},
+ LED_STATE: {on: true, off: false},
+ LED_STATE_TEXT: {on: 'on', off: 'off'},
+ SEVERITY_TO_HEALTH_MAP: {
+ Emergency: 'Critical',
+ Alert: 'Critical',
+ Critical: 'Critical',
+ Error: 'Warning',
+ Warning: 'Warning',
+ Notice: 'Good',
+ Debug: 'Good',
+ Informational: 'Good'
+ },
+ SEVERITY_TO_PRIORITY_MAP: {
+ Emergency: 'High',
+ Alert: 'High',
+ Critical: 'High',
+ Error: 'High',
+ Warning: 'Medium',
+ Notice: 'Low',
+ Debug: 'Low',
+ Informational: 'Low'
+ },
+ PAGINATION: {LOG_ITEMS_PER_PAGE: 25},
+ HARDWARE: {
+ component_key_filter: '/xyz/openbmc_project/inventory/system',
+ parent_components: [
+ /xyz\/openbmc_project\/inventory\/system\/chassis\/motherboard\/cpu\d+\//
],
- SENSOR_SORT_ORDER_DEFAULT: 8,
- FIRMWARE: {
- ACTIVATE_FIRMWARE: 'xyz.openbmc_project.Software.Activation.RequestedActivations.Active',
- FUNCTIONAL_OBJPATH: '/xyz/openbmc_project/software/functional'
+ uppercase_titles: ['cpu', 'dimm']
+ },
+ SENSOR_UNIT_MAP: {
+ 'xyz.openbmc_project.Sensor.Value.Unit.RPMS': 'rpms',
+ 'xyz.openbmc_project.Sensor.Value.Unit.DegreesC': 'C',
+ 'xyz.openbmc_project.Sensor.Value.Unit.Volts': 'volts',
+ 'xyz.openbmc_project.Sensor.Value.Unit.Meters': 'meters',
+ 'xyz.openbmc_project.Sensor.Value.Unit.Watts': 'watts',
+ 'xyz.openbmc_project.Sensor.Value.Unit.Amperes': 'amperes',
+ 'xyz.openbmc_project.Sensor.Value.Unit.Joules': 'joules'
+ },
+ SERVER_HEALTH: {
+ critical: 'Critical',
+ warning: 'Warning',
+ good: 'Good',
+ unknown: 'Unknown'
+ },
+ SENSOR_SORT_ORDER: [
+ 'xyz.openbmc_project.Sensor.Value.Unit.DegreesC',
+ 'xyz.openbmc_project.Sensor.Value.Unit.RPMS',
+ 'xyz.openbmc_project.Sensor.Value.Unit.Meters',
+ 'xyz.openbmc_project.Sensor.Value.Unit.Volts',
+ 'xyz.openbmc_project.Sensor.Value.Unit.Amperes',
+ 'xyz.openbmc_project.Sensor.Value.Unit.Joules',
+ 'xyz.openbmc_project.Sensor.Value.Unit.Meters'
+ ],
+ SENSOR_SORT_ORDER_DEFAULT: 8,
+ FIRMWARE: {
+ ACTIVATE_FIRMWARE:
+ 'xyz.openbmc_project.Software.Activation.RequestedActivations.Active',
+ FUNCTIONAL_OBJPATH: '/xyz/openbmc_project/software/functional'
+ },
+ POLL_INTERVALS: {
+ ACTIVATION: 5000,
+ DOWNLOAD_IMAGE: 5000,
+ POWER_OP: 5000,
+ },
+ TIMEOUT: {
+ ACTIVATION: 1000 * 60 * 10, // 10 mins
+ DOWNLOAD_IMAGE: 1000 * 60 * 2, // 2 mins
+ CHASSIS_OFF: 1000 * 60 * 5, // 5 mins
+ HOST_ON: 1000 * 60 * 5, // 5 mins
+ HOST_OFF: 1000 * 60 * 5, // 5 mins
+ },
+ MESSAGES: {
+ POLL: {
+ CHASSIS_OFF_TIMEOUT:
+ 'Time out. Chassis did not reach power off state in allotted time.',
+ HOST_ON_TIMEOUT:
+ 'Time out. System did not reach Running state in allotted time.',
+ HOST_OFF_TIMEOUT:
+ 'Time out. System did not reach Off state in allotted time.',
+ HOST_QUIESCED: 'System is in Error state.',
+ DOWNLOAD_IMAGE_TIMEOUT:
+ 'Time out. Did not download image in allotted time.',
},
- POLL_INTERVALS: {
- ACTIVATION: 5000,
- DOWNLOAD_IMAGE: 5000,
- POWER_OP: 5000,
+ POWER_OP: {
+ POWER_ON_FAILED: 'Power On Failed',
+ WARM_REBOOT_FAILED: 'Warm Reboot Failed',
+ COLD_REBOOT_FAILED: 'Cold Reboot Failed',
+ ORDERLY_SHUTDOWN_FAILED: 'Orderly Shutdown Failed',
+ IMMEDIATE_SHUTDOWN_FAILED: 'Immediate Shutdown Failed',
},
- TIMEOUT: {
- ACTIVATION: 1000 * 60 * 10, // 10 mins
- DOWNLOAD_IMAGE: 1000 * 60 * 2, // 2 mins
- CHASSIS_OFF: 1000 * 60 * 5, // 5 mins
- HOST_ON: 1000 * 60 * 5, // 5 mins
- HOST_OFF: 1000 * 60 * 5, // 5 mins
+ SENSOR: {
+ NO_SENSOR_DATA: 'There are no sensors found.',
+ CRITICAL_NO_SENSOR_DATA: 'There are no sensors in Critical state.',
+ WARNING_NO_SENSOR_DATA: 'There are no sensors in Warning state.',
+ NORMAL_NO_SENSOR_DATA: 'There are no sensors in Normal state.'
},
- MESSAGES: {
- POLL: {
- CHASSIS_OFF_TIMEOUT: 'Time out. Chassis did not reach power off state in allotted time.',
- HOST_ON_TIMEOUT: 'Time out. System did not reach Running state in allotted time.',
- HOST_OFF_TIMEOUT: 'Time out. System did not reach Off state in allotted time.',
- HOST_QUIESCED: 'System is in Error state.',
- DOWNLOAD_IMAGE_TIMEOUT: 'Time out. Did not download image in allotted time.',
- },
- POWER_OP: {
- POWER_ON_FAILED: 'Power On Failed',
- WARM_REBOOT_FAILED: 'Warm Reboot Failed',
- COLD_REBOOT_FAILED: 'Cold Reboot Failed',
- ORDERLY_SHUTDOWN_FAILED: 'Orderly Shutdown Failed',
- IMMEDIATE_SHUTDOWN_FAILED: 'Immediate Shutdown Failed',
- },
- SENSOR: {
- NO_SENSOR_DATA: 'There are no sensors found.',
- CRITICAL_NO_SENSOR_DATA: 'There are no sensors in Critical state.',
- WARNING_NO_SENSOR_DATA: 'There are no sensors in Warning state.',
- NORMAL_NO_SENSOR_DATA: 'There are no sensors in Normal state.'
- },
- ERROR_MODAL: {
- TITLE: 'Unexpected error',
- DESCRIPTION: 'Oops! An unexpected error occurred. Record specific details of the issue, then contact your company support services.'
- },
- ERROR_MESSAGE_DESC_TEMPLATE: '{{status}} - {{description}}',
+ ERROR_MODAL: {
+ TITLE: 'Unexpected error',
+ DESCRIPTION:
+ 'Oops! An unexpected error occurred. Record specific details of the issue, then contact your company support services.'
},
- POWER_CAP_TEXT: {
- unit: 'W',
- disabled: 'Not Enabled'
- },
- POWER_CONSUMPTION_TEXT: {
- 'xyz.openbmc_project.Sensor.Value.Unit.Watts': 'W',
- notavailable: 'Not Available'
- },
- };
- });
+ ERROR_MESSAGE_DESC_TEMPLATE: '{{status}} - {{description}}',
+ },
+ POWER_CAP_TEXT: {unit: 'W', disabled: 'Not Enabled'},
+ POWER_CONSUMPTION_TEXT: {
+ 'xyz.openbmc_project.Sensor.Value.Unit.Watts': 'W',
+ notavailable: 'Not Available'
+ },
+ };
+ });
})(window.angular);
diff --git a/app/common/services/dataService.js b/app/common/services/dataService.js
index 79a3a0e..ffe15a2 100644
--- a/app/common/services/dataService.js
+++ b/app/common/services/dataService.js
@@ -10,9 +10,9 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.services')
- .service('dataService', ['Constants', function(Constants) {
+ angular.module('app.common.services').service('dataService', [
+ 'Constants',
+ function(Constants) {
this.server_health = Constants.SERVER_HEALTH.unknown;
this.server_state = 'Unreachable';
this.server_status = -2;
@@ -45,20 +45,23 @@
};
this.getHost = function() {
- if (sessionStorage.getItem(Constants.API_CREDENTIALS.host_storage_key) !== null) {
- return sessionStorage.getItem(Constants.API_CREDENTIALS.host_storage_key);
- }
- else {
+ if (sessionStorage.getItem(
+ Constants.API_CREDENTIALS.host_storage_key) !== null) {
+ return sessionStorage.getItem(
+ Constants.API_CREDENTIALS.host_storage_key);
+ } else {
return Constants.API_CREDENTIALS.default_protocol + '://' +
- window.location.hostname +
- (window.location.port ? ':' + window.location.port : '');
+ window.location.hostname +
+ (window.location.port ? ':' + window.location.port : '');
}
};
this.setHost = function(hostWithPort) {
hostWithPort = hostWithPort.replace(/^https?\:\/\//ig, '');
- var hostURL = Constants.API_CREDENTIALS.default_protocol + '://' + hostWithPort;
- sessionStorage.setItem(Constants.API_CREDENTIALS.host_storage_key, hostURL);
+ var hostURL =
+ Constants.API_CREDENTIALS.default_protocol + '://' + hostWithPort;
+ sessionStorage.setItem(
+ Constants.API_CREDENTIALS.host_storage_key, hostURL);
this.host = hostURL;
this.reloadServerId();
};
@@ -128,16 +131,15 @@
this.activateErrorModal = function(data) {
if (data && data.hasOwnProperty('title')) {
this.errorModalDetails.title = data.title;
- }
- else {
+ } else {
this.errorModalDetails.title = Constants.MESSAGES.ERROR_MODAL.TITLE;
}
if (data && data.hasOwnProperty('description')) {
this.errorModalDetails.description = data.description;
- }
- else {
- this.errorModalDetails.description = Constants.MESSAGES.ERROR_MODAL.DESCRIPTION;
+ } else {
+ this.errorModalDetails.description =
+ Constants.MESSAGES.ERROR_MODAL.DESCRIPTION;
}
this.displayErrorModal = true;
};
@@ -145,6 +147,7 @@
this.deactivateErrorModal = function() {
this.displayErrorModal = false;
};
- }]);
+ }
+ ]);
})(window.angular);
diff --git a/app/common/services/index.js b/app/common/services/index.js
index d234069..a56dce1 100644
--- a/app/common/services/index.js
+++ b/app/common/services/index.js
@@ -8,10 +8,9 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.services', [
- // Dependencies
- // Basic resources
- ]);
+ angular.module('app.common.services', [
+ // Dependencies
+ // Basic resources
+ ]);
})(window.angular);
diff --git a/app/common/services/userModel.js b/app/common/services/userModel.js
index cd943f9..0232200 100644
--- a/app/common/services/userModel.js
+++ b/app/common/services/userModel.js
@@ -10,29 +10,26 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.common.services')
- .service('userModel', ['APIUtils', function(APIUtils) {
+ angular.module('app.common.services').service('userModel', [
+ 'APIUtils',
+ function(APIUtils) {
return {
login: function(username, password, callback) {
APIUtils.login(username, password, function(response, error) {
if (response &&
- (response.status == APIUtils.API_RESPONSE.SUCCESS_STATUS ||
- response.status === undefined)) {
+ (response.status == APIUtils.API_RESPONSE.SUCCESS_STATUS ||
+ response.status === undefined)) {
sessionStorage.setItem('LOGIN_ID', username);
callback(true);
- }
- else if (response && response.data && response.data.data &&
- response.data.data.description) {
+ } else if (
+ response && response.data && response.data.data &&
+ response.data.data.description) {
callback(false, response.data.data.description);
- }
- else if (response && response.message) {
+ } else if (response && response.message) {
callback(false, response.message);
- }
- else if (error) {
+ } else if (error) {
callback(false, 'Server unreachable');
- }
- else {
+ } else {
callback(false, 'Internal error');
}
});
@@ -46,20 +43,19 @@
logout: function(callback) {
APIUtils.logout(function(response, error) {
if (response &&
- response.status == APIUtils.API_RESPONSE.SUCCESS_STATUS) {
+ response.status == APIUtils.API_RESPONSE.SUCCESS_STATUS) {
sessionStorage.removeItem('LOGIN_ID');
sessionStorage.removeItem(APIUtils.HOST_SESSION_STORAGE_KEY);
callback(true);
- }
- else if (response.status == APIUtils.API_RESPONSE.ERROR_STATUS) {
+ } else if (response.status == APIUtils.API_RESPONSE.ERROR_STATUS) {
callback(false);
- }
- else {
+ } else {
callback(false, error);
}
});
}
};
- }]);
+ }
+ ]);
})(window.angular);