Major update to code structure
* Split files into independent files based on functionality.
* Switch to bower/gulp for build.
Change-Id: Ibc775dd9b7f6a0a49f63c22162b7582e781e2d9c
Signed-off-by: Iftekharul Islam <iislam@us.ibm.com>
diff --git a/.gitignore b/.gitignore
index e845085..8574c3b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,9 @@
npm-debug.log
node_modules/
+bower_components/
dist/
+target/
+.temp/
*.swp
.idea
+app/styles/index.css
diff --git a/src/img/icon-power.svg b/app/assets/images/icon-power.svg
similarity index 87%
rename from src/img/icon-power.svg
rename to app/assets/images/icon-power.svg
index 8844297..6c534e1 100644
--- a/src/img/icon-power.svg
+++ b/app/assets/images/icon-power.svg
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" baseProfile="tiny" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px" y="0px" viewBox="0 0 75 75" xml:space="preserve">
<path fill="#3C6DF0" d="M17,14.6L17,14.6c1.2-1,1.3-2.7,0.3-3.9c-1-1.1-2.7-1.3-3.9-0.2C1.8,20.6-2.3,36.8,3.1,51.2
diff --git a/src/img/icon-refresh-white.svg b/app/assets/images/icon-refresh-white.svg
similarity index 100%
rename from src/img/icon-refresh-white.svg
rename to app/assets/images/icon-refresh-white.svg
diff --git a/src/img/logo.svg b/app/assets/images/logo.svg
similarity index 100%
rename from src/img/logo.svg
rename to app/assets/images/logo.svg
diff --git a/src/header.html b/app/common/directives/app-header.html
similarity index 60%
rename from src/header.html
rename to app/common/directives/app-header.html
index 2019c0e..5b2de3d 100644
--- a/src/header.html
+++ b/app/common/directives/app-header.html
@@ -7,13 +7,13 @@
<a href="" class="header__logout" ng-click="logout()">Log out</a>
</header>
<div class="header__functions-wrapper" role="heading">
- <div class="logo__wrapper"><img src="img/logo.svg" id="header__logo" alt="company logo"/></div>
+ <div class="logo__wrapper"><img src="assets/images/logo.svg" id="header__logo" alt="company logo"/></div>
<button id="header__server-name">{{dataService.server_id}}</button>
<div class="header__functions">
<a href="" id="header__server-health">Server health<span class="status-light__error">{{dataService.server_health}}</span></a>
- <a href="#/power-operations" class="header__server-power" role="button">Server power<span ng-class="{'status-light__error': dataService.server_state == 'Off', 'status-light__disabled': dataService.server_state == 'Unreachable', 'status-light__good': dataService.server_state == 'Running', 'status-light__warn': dataService.server_state == 'Quiesced'}">{{dataService.server_state}}</span></a>
+ <a href="#/overview/power-operations" class="header__server-power" role="button">Server power<span ng-class="{'status-light__error': dataService.server_state == 'Off', 'status-light__disabled': dataService.server_state == 'Unreachable', 'status-light__good': dataService.server_state == 'Running', 'status-light__warn': dataService.server_state == 'Quiesced'}">{{dataService.server_state}}</span></a>
<p class="header__refresh">Page last refreshed <span>{{dataService.last_updated |date:'h:mm:ss MMM dd yyyy'}}</span></p>
- <button class="header__page-refresh" ng-click="refresh()"><img src="img/icon-refresh-white.svg" alt="refresh page" role="button"/></button>
+ <button class="header__page-refresh" ng-click="refresh()"><img src="assets/images/icon-refresh-white.svg" alt="refresh page" role="button"/></button>
</div>
</div>
</div>
diff --git a/app/common/directives/app-header.js b/app/common/directives/app-header.js
new file mode 100644
index 0000000..23038a1
--- /dev/null
+++ b/app/common/directives/app-header.js
@@ -0,0 +1,57 @@
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.directives')
+ .directive('appHeader', ['APIUtils', function (APIUtils) {
+ return {
+ 'restrict': 'E',
+ 'templateUrl': 'common/directives/app-header.html',
+ 'scope': {
+ 'path': '='
+ },
+ 'controller': ['$rootScope', '$scope','dataService', 'userModel', '$location', function($rootScope, $scope, dataService, userModel, $location){
+ $scope.dataService = dataService;
+
+ $scope.loadServerStatus = function(){
+ if(!userModel.isLoggedIn()){
+ //@TODO:some error message?
+ return;
+ }
+ APIUtils.getHostState(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.setBootingState();
+ }
+ });
+ }
+ $scope.loadServerStatus();
+
+ $scope.logout = function(){
+ userModel.logout(function(status, error){
+ if(status){
+ $location.path('/logout');
+ }else{
+ console.log(error);
+ }
+ });
+ }
+
+ $scope.refresh = function(){
+ $scope.loadServerStatus();
+ }
+
+ var loginListener = $rootScope.$on('user-logged-in', function(event, arg){
+ $scope.loadServerStatus();
+ });
+
+ $scope.$on('$destroy', function(){
+ loginListener();
+ });
+ }]
+ };
+ }]);
+})(window.angular);
diff --git a/src/navigation.html b/app/common/directives/app-navigation.html
similarity index 89%
rename from src/navigation.html
rename to app/common/directives/app-navigation.html
index c4695fb..f2c6ed0 100644
--- a/src/navigation.html
+++ b/app/common/directives/app-navigation.html
@@ -21,7 +21,7 @@
<span class="">Overview</span></button>
</li>
<li>
- <button class="btn-settings" ng-class="{opened: firstLevel == 'settings'}" ng-click="firstLevel = 'settings';" tabindex="8">
+ <button class="btn-settings" ng-class="{opened: firstLevel == 'settings'}" ng-click="firstLevel = 'settings';" tabindex="9">
<svg class="nav__icon" viewBox="0 0 20 20">
<path d="M17.498,11.697c-0.453-0.453-0.704-1.055-0.704-1.697c0-0.642,0.251-1.244,0.704-1.697c0.069-0.071,0.15-0.141,0.257-0.22c0.127-0.097,0.181-0.262,0.137-0.417c-0.164-0.558-0.388-1.093-0.662-1.597c-0.075-0.141-0.231-0.22-0.391-0.199c-0.13,0.02-0.238,0.027-0.336,0.027c-1.325,0-2.401-1.076-2.401-2.4c0-0.099,0.008-0.207,0.027-0.336c0.021-0.158-0.059-0.316-0.199-0.391c-0.503-0.274-1.039-0.498-1.597-0.662c-0.154-0.044-0.32,0.01-0.416,0.137c-0.079,0.106-0.148,0.188-0.22,0.257C11.244,2.956,10.643,3.207,10,3.207c-0.642,0-1.244-0.25-1.697-0.704c-0.071-0.069-0.141-0.15-0.22-0.257C7.987,2.119,7.821,2.065,7.667,2.109C7.109,2.275,6.571,2.497,6.07,2.771C5.929,2.846,5.85,3.004,5.871,3.162c0.02,0.129,0.027,0.237,0.027,0.336c0,1.325-1.076,2.4-2.401,2.4c-0.098,0-0.206-0.007-0.335-0.027C3.001,5.851,2.845,5.929,2.77,6.07C2.496,6.572,2.274,7.109,2.108,7.667c-0.044,0.154,0.01,0.32,0.137,0.417c0.106,0.079,0.187,0.148,0.256,0.22c0.938,0.936,0.938,2.458,0,3.394c-0.069,0.072-0.15,0.141-0.256,0.221c-0.127,0.096-0.181,0.262-0.137,0.416c0.166,0.557,0.388,1.096,0.662,1.596c0.075,0.143,0.231,0.221,0.392,0.199c0.129-0.02,0.237-0.027,0.335-0.027c1.325,0,2.401,1.076,2.401,2.402c0,0.098-0.007,0.205-0.027,0.334C5.85,16.996,5.929,17.154,6.07,17.23c0.501,0.273,1.04,0.496,1.597,0.66c0.154,0.047,0.32-0.008,0.417-0.137c0.079-0.105,0.148-0.186,0.22-0.256c0.454-0.453,1.055-0.703,1.697-0.703c0.643,0,1.244,0.25,1.697,0.703c0.071,0.07,0.141,0.15,0.22,0.256c0.073,0.098,0.188,0.152,0.307,0.152c0.036,0,0.073-0.004,0.109-0.016c0.558-0.164,1.096-0.387,1.597-0.66c0.141-0.076,0.22-0.234,0.199-0.393c-0.02-0.129-0.027-0.236-0.027-0.334c0-1.326,1.076-2.402,2.401-2.402c0.098,0,0.206,0.008,0.336,0.027c0.159,0.021,0.315-0.057,0.391-0.199c0.274-0.5,0.496-1.039,0.662-1.596c0.044-0.154-0.01-0.32-0.137-0.416C17.648,11.838,17.567,11.77,17.498,11.697 M16.671,13.334c-0.059-0.002-0.114-0.002-0.168-0.002c-1.749,0-3.173,1.422-3.173,3.172c0,0.053,0.002,0.109,0.004,0.166c-0.312,0.158-0.64,0.295-0.976,0.406c-0.039-0.045-0.077-0.086-0.115-0.123c-0.601-0.6-1.396-0.93-2.243-0.93s-1.643,0.33-2.243,0.93c-0.039,0.037-0.077,0.078-0.116,0.123c-0.336-0.111-0.664-0.248-0.976-0.406c0.002-0.057,0.004-0.113,0.004-0.166c0-1.75-1.423-3.172-3.172-3.172c-0.054,0-0.11,0-0.168,0.002c-0.158-0.312-0.293-0.639-0.405-0.975c0.044-0.039,0.085-0.078,0.124-0.115c1.236-1.236,1.236-3.25,0-4.486C3.009,7.719,2.969,7.68,2.924,7.642c0.112-0.336,0.247-0.664,0.405-0.976C3.387,6.668,3.443,6.67,3.497,6.67c1.75,0,3.172-1.423,3.172-3.172c0-0.054-0.002-0.11-0.004-0.168c0.312-0.158,0.64-0.293,0.976-0.405C7.68,2.969,7.719,3.01,7.757,3.048c0.6,0.6,1.396,0.93,2.243,0.93s1.643-0.33,2.243-0.93c0.038-0.039,0.076-0.079,0.115-0.123c0.336,0.112,0.663,0.247,0.976,0.405c-0.002,0.058-0.004,0.114-0.004,0.168c0,1.749,1.424,3.172,3.173,3.172c0.054,0,0.109-0.002,0.168-0.004c0.158,0.312,0.293,0.64,0.405,0.976c-0.045,0.038-0.086,0.077-0.124,0.116c-0.6,0.6-0.93,1.396-0.93,2.242c0,0.847,0.33,1.645,0.93,2.244c0.038,0.037,0.079,0.076,0.124,0.115C16.964,12.695,16.829,13.021,16.671,13.334 M10,5.417c-2.528,0-4.584,2.056-4.584,4.583c0,2.529,2.056,4.584,4.584,4.584s4.584-2.055,4.584-4.584C14.584,7.472,12.528,5.417,10,5.417 M10,13.812c-2.102,0-3.812-1.709-3.812-3.812c0-2.102,1.71-3.812,3.812-3.812c2.102,0,3.812,1.71,3.812,3.812C13.812,12.104,12.102,13.812,10,13.812"></path>
</svg>
@@ -44,12 +44,13 @@
</li>
</ul>
<ul class="nav__second-level btn-overview" ng-style="navStyle" ng-class="{opened: firstLevel == 'overview'}">
- <li ng-class="{'active': (path == '/system-overview')}" tabindex="2"><a href="#/system-overview">System Overview</a></li>
- <li ng-class="{'active': (path == '/power-operations')}" tabindex="3"><a href="#/power-operations">Server power operations</a></li>
- <li ng-class="{'active': (path == '/power-consumption')}"><a href="" tabindex="4">Power consumption</a></li>
- <li ng-class="{'active': (path == '/remote-console')}"><a href="" tabindex="5">Remote console</a></li>
- <li ng-class="{'active': (path == '/unit-id')}"><a href="#/unit-id" tabindex="6">Unit ID</a></li>
- <li ng-class="{'active': (path == '/bmc-reboot')}"><a href="#/bmc-reboot" tabindex="7">Reboot BMC</a></li>
+ <li ng-class="{'active': (path == '/overview/system')}" tabindex="2"><a href="#/system-overview">System Overview</a></li>
+ <li ng-class="{'active': (path == '/overview/power-operations')}" tabindex="3"><a href="#/overview/power-operations">Server power operations</a></li>
+ <li ng-class="{'active': (path == '/overview/power-consumption')}"><a href="" tabindex="4">Power consumption</a></li>
+ <li ng-class="{'active': (path == '/overview/remote-console')}"><a href="" tabindex="5">Remote console</a></li>
+ <li ng-class="{'active': (path == '/overview/unit-id')}"><a href="#/overview/unit-id" tabindex="6">Unit ID</a></li>
+ <li ng-class="{'active': (path == '/overview/log')}"><a href="#/overview/log" tabindex="7">Log</a></li>
+ <li ng-class="{'active': (path == '/overview/bmc-reboot')}"><a href="#/overview/bmc-reboot" tabindex="8">Reboot BMC</a></li>
</ul>
<ul class="nav__second-level btn-settings" ng-style="navStyle" ng-class="{opened: firstLevel == 'settings'}">
<li><a href="">2nd level 4</a></li>
@@ -66,4 +67,4 @@
<li><a href="">2nd level 212</a></li>
<li><a href="">2nd level 312</a></li>
</ul>
-</nav>
+</nav>
\ No newline at end of file
diff --git a/app/common/directives/app-navigation.js b/app/common/directives/app-navigation.js
new file mode 100644
index 0000000..d09588a
--- /dev/null
+++ b/app/common/directives/app-navigation.js
@@ -0,0 +1,28 @@
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.directives')
+ .directive('appNavigation', function () {
+ return {
+ 'restrict': 'E',
+ 'templateUrl': 'common/directives/app-navigation.html',
+ 'scope': {
+ 'path': '=',
+ 'showNavigation': '='
+ },
+ 'controller': ['$scope', 'dataService', function($scope, dataService){
+ $scope.$watch('showNavigation', function(){
+ var paddingTop = 0;
+ $scope.firstLevel = 'overview';
+ $scope.secondLevel = 'system_overview';
+ if($scope.showNavigation){
+ paddingTop = document.getElementById('header__wrapper').offsetHeight;
+ }
+ dataService.bodyStyle = {'padding-top': paddingTop + 'px'};
+ $scope.navStyle = {'top': paddingTop + 'px'};
+ });
+ }]
+ };
+ });
+})(window.angular);
diff --git a/src/confirm.html b/app/common/directives/confirm.html
similarity index 71%
rename from src/confirm.html
rename to app/common/directives/confirm.html
index 59ca2ad..a38cf60 100644
--- a/src/confirm.html
+++ b/app/common/directives/confirm.html
@@ -1,4 +1,3 @@
-<!-- Confirmation message - to accommodate the message for smaller screens we need to grab the height of the message and apply that height to "power-option" row -->
<div class="inline__confirm" ng-class="{active: confirm}">
<div class="inline__confirm-message">
<p class="h3"><i></i>Are you sure you want to <strong>{{title}}?</strong></p>
diff --git a/app/common/directives/confirm.js b/app/common/directives/confirm.js
new file mode 100644
index 0000000..ed8c9dc
--- /dev/null
+++ b/app/common/directives/confirm.js
@@ -0,0 +1,39 @@
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.directives')
+ .directive('confirm', ['$timeout', function($timeout){
+ return {
+ 'restrict': 'E',
+ 'templateUrl': 'common/directives/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();
+ }
+ }],
+ 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'});
+ }, 0);
+ }else{
+ angular.element(e[0].parentNode).css({'min-height': 0+ 'px'});
+ }
+ });
+ }
+ };
+ }]);
+})(window.angular);
diff --git a/app/common/directives/index.js b/app/common/directives/index.js
new file mode 100644
index 0000000..1fed678
--- /dev/null
+++ b/app/common/directives/index.js
@@ -0,0 +1,9 @@
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.directives', [
+ 'app.common.services'
+ ]);
+
+})(window.angular);
diff --git a/app/common/filters/index.js b/app/common/filters/index.js
new file mode 100644
index 0000000..d1b4b44
--- /dev/null
+++ b/app/common/filters/index.js
@@ -0,0 +1,7 @@
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.filters', []);
+
+})(window.angular);
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
new file mode 100644
index 0000000..af66f81
--- /dev/null
+++ b/app/common/services/api-utils.js
@@ -0,0 +1,252 @@
+/**
+ * API utilities service
+ *
+ * @module app/common/services/api-utils
+ * @exports APIUtils
+ * @name APIUtils
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+ angular
+ .module('app.common.services')
+ .factory('APIUtils', ['$http', 'Constants', function($http, Constants){
+ var SERVICE = {
+ LOGIN_CREDENTIALS: Constants.LOGIN_CREDENTIALS,
+ API_CREDENTIALS: Constants.API_CREDENTIALS,
+ API_RESPONSE: Constants.API_RESPONSE,
+ CHASSIS_POWER_STATE: Constants.CHASSIS_POWER_STATE,
+ HOST_STATE_TEXT: Constants.HOST_STATE,
+ HOST_STATE: Constants.HOST_STATE,
+ getChassisState: function(callback){
+ $http({
+ method: 'GET',
+ url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/chassis0",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true
+ }).success(function(response){
+ var json = JSON.stringify(response);
+ var content = JSON.parse(json);
+ callback(content.data.CurrentPowerState);
+ }).error(function(error){
+ console.log(error);
+ });
+ },
+ getHostState: function(callback){
+ $http({
+ method: 'GET',
+ url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true
+ }).success(function(response){
+ var json = JSON.stringify(response);
+ var content = JSON.parse(json);
+ callback(content.data.CurrentHostState);
+ }).error(function(error){
+ console.log(error);
+ });
+ },
+ login: function(username, password, callback){
+ $http({
+ method: 'POST',
+ url: SERVICE.API_CREDENTIALS.host + "/login",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true,
+ data: JSON.stringify({"data": [username, password]})
+ }).success(function(response){
+ if(callback){
+ callback(response);
+ }
+ }).error(function(error){
+ if(callback){
+ callback(null, true);
+ }
+ console.log(error);
+ });
+ },
+ logout: function(callback){
+ $http({
+ method: 'POST',
+ url: SERVICE.API_CREDENTIALS.host + "/logout",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true,
+ data: JSON.stringify({"data": []})
+ }).success(function(response){
+ if(callback){
+ callback(response);
+ }
+ }).error(function(error){
+ if(callback){
+ callback(null, error);
+ }
+ console.log(error);
+ });
+ },
+ chassisPowerOn: function(callback){
+ $http({
+ method: 'POST',
+ url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true,
+ data: JSON.stringify({"data": []})
+ }).success(function(response){
+ var json = JSON.stringify(response);
+ var content = JSON.parse(json);
+ if(callback){
+ return callback(content.data.CurrentPowerState);
+ }
+ }).error(function(error){
+ if(callback){
+ callback(error);
+ }else{
+ console.log(error);
+ }
+ });
+ },
+ chassisPowerOff: function(callback){
+ $http({
+ method: 'POST',
+ url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true,
+ data: JSON.stringify({"data": []})
+ }).success(function(response){
+ var json = JSON.stringify(response);
+ var content = JSON.parse(json);
+ if(callback){
+ return callback(content.data.CurrentPowerState);
+ }
+ }).error(function(error){
+ if(callback){
+ callback(error);
+ }else{
+ console.log(error);
+ }
+ });
+ },
+ hostPowerOn: function(callback){
+ /**
+ curl -c cjar -b cjar -k -H "Content-Type: application/json" -d
+ "{\"data\": \"xyz.openbmc_project.State.Host.Transition.Off\"}"
+ -X PUT
+ https://9.3.164.147/xyz/openbmc_project/state/host0/attr/RequestedHostTransition
+ **/
+ $http({
+ method: 'PUT',
+ url: SERVICE.API_CREDENTIALS.host + "/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"})
+ }).success(function(response){
+ var json = JSON.stringify(response);
+ var content = JSON.parse(json);
+ if(callback){
+ return callback(content.status);
+ }
+ }).error(function(error){
+ if(callback){
+ callback(error);
+ }else{
+ console.log(error);
+ }
+ });
+ },
+ hostPowerOff: function(callback){
+ $http({
+ method: 'PUT',
+ url: SERVICE.API_CREDENTIALS.host + "/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"})
+ }).success(function(response){
+ var json = JSON.stringify(response);
+ var content = JSON.parse(json);
+ if(callback){
+ return callback(content.status);
+ }
+ }).error(function(error){
+ if(callback){
+ callback(error);
+ }else{
+ console.log(error);
+ }
+ });
+ },
+ hostReboot: function(callback){
+ $http({
+ method: 'POST',
+ url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true,
+ data: JSON.stringify({"data": []}),
+ }).success(function(response){
+ var json = JSON.stringify(response);
+ var content = JSON.parse(json);
+ if(callback){
+ return callback(content);
+ }
+ }).error(function(error){
+ if(callback){
+ callback(error);
+ }else{
+ console.log(error);
+ }
+ });
+ },
+ hostShutdown: function(callback){
+ $http({
+ method: 'POST',
+ url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true,
+ data: JSON.stringify({"data": []})
+ }).success(function(response){
+ var json = JSON.stringify(response);
+ var content = JSON.parse(json);
+ if(callback){
+ return callback(content);
+ }
+ }).error(function(error){
+ if(callback){
+ callback(error);
+ }else{
+ console.log(error);
+ }
+ });
+ }
+ };
+ return SERVICE;
+ }]);
+
+ })(window.angular);
diff --git a/app/common/services/apiInterceptor.js b/app/common/services/apiInterceptor.js
new file mode 100644
index 0000000..5a715ec
--- /dev/null
+++ b/app/common/services/apiInterceptor.js
@@ -0,0 +1,46 @@
+/**
+ * api Interceptor
+ *
+ * @module app/common/services/apiInterceptor
+ * @exports apiInterceptor
+ * @name apiInterceptor
+
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.services')
+ .service('apiInterceptor', ['$q', '$rootScope', 'dataService', function($q, $rootScope, dataService){
+ return {
+ 'request': function(config){
+ dataService.server_unreachable = false;
+ dataService.loading = true;
+ return config;
+ },
+ 'response': function(response){
+ dataService.loading = false;
+ dataService.last_updated = new Date();
+
+ if(response == null){
+ dataService.server_unreachable = true;
+ }
+
+ if(response && response.status == 'error' &&
+ dataService.path != '/login'){
+ $rootScope.$emit('timedout-user', {});
+ }
+
+ return response;
+ },
+ 'responseError': function(rejection){
+ dataService.server_unreachable = true;
+ dataService.loading = false;
+ return $q.reject(rejection);
+ }
+ };
+ }]);
+
+})(window.angular);
\ No newline at end of file
diff --git a/app/common/services/constants.js b/app/common/services/constants.js
new file mode 100644
index 0000000..b98d5d6
--- /dev/null
+++ b/app/common/services/constants.js
@@ -0,0 +1,50 @@
+/**
+ * common Constant service
+ *
+ * @module app/common/services/constants
+ * @exports Constants
+ * @name Constants
+
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.services')
+ .service('Constants', function () {
+ return {
+ LOGIN_CREDENTIALS: {
+ username: "test",
+ password: "testpass",
+ },
+ API_CREDENTIALS: {
+ host: 'https://9.3.164.147'
+ },
+ API_RESPONSE: {
+ ERROR_STATUS: 'error',
+ ERROR_MESSAGE: '401 Unauthorized',
+ SUCCESS_STATUS: 'ok',
+ SUCCESS_MESSAGE: '200 OK'
+ },
+ CHASSIS_POWER_STATE: {
+ on: 'On',
+ off: 'Off'
+ },
+ HOST_STATE_TEXT: {
+ on: 'Running',
+ off: 'Off',
+ booting: 'Quiesced',
+ unreachable: 'Unreachable'
+ },
+ HOST_STATE: {
+ on: 1,
+ off: -1,
+ booting: 0,
+ unreachable: -2
+ }
+ };
+ });
+
+})(window.angular);
\ No newline at end of file
diff --git a/app/common/services/dataService.js b/app/common/services/dataService.js
new file mode 100644
index 0000000..704df75
--- /dev/null
+++ b/app/common/services/dataService.js
@@ -0,0 +1,53 @@
+/**
+ * data service
+ *
+ * @module app/common/services/dataService
+ * @exports dataService
+ * @name dataService
+
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.services')
+ .service('dataService', ['Constants', function (Constants) {
+ this.app_version = "openBMC V.0.0.1";
+ this.server_health = 'Error';
+ this.server_state = 'Unreachable';
+ this.server_status = -2;
+ this.chassis_state = 'On';
+ this.server_id = "Server 9.3.164.147";
+ this.last_updated = new Date();
+
+ this.loading = false;
+ this.server_unreachable = false;
+ this.loading_message = "";
+ this.showNavigation = false;
+ this.bodyStyle = {};
+ this.path = '';
+
+ this.setPowerOnState = function(){
+ this.server_state = Constants.HOST_STATE_TEXT.on;
+ this.server_status = Constants.HOST_STATE.on;
+ },
+
+ this.setPowerOffState = function(){
+ this.server_state = Constants.HOST_STATE_TEXT.off;
+ this.server_status = Constants.HOST_STATE.off;
+ },
+
+ this.setBootingState = function(){
+ this.server_state = Constants.HOST_STATE_TEXT.booting;
+ this.server_status = Constants.HOST_STATE.booting;
+ },
+
+ this.setUnreachableState = function(){
+ this.server_state = Constants.HOST_STATE_TEXT.unreachable;
+ this.server_status = Constants.HOST_STATE.unreachable;
+ }
+ }]);
+
+})(window.angular);
\ No newline at end of file
diff --git a/app/common/services/index.js b/app/common/services/index.js
new file mode 100644
index 0000000..f54f6eb
--- /dev/null
+++ b/app/common/services/index.js
@@ -0,0 +1,18 @@
+/**
+ * A module to contain common services
+ *
+ * @module app/common/services/index
+ * @exports app/common/services/index
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.services', [
+ // Dependencies
+ // Basic resources
+ ]);
+
+})(window.angular);
diff --git a/app/common/services/userModel.js b/app/common/services/userModel.js
new file mode 100644
index 0000000..e44ba8c
--- /dev/null
+++ b/app/common/services/userModel.js
@@ -0,0 +1,49 @@
+/**
+ * userModel
+ *
+ * @module app/common/services/userModel
+ * @exports userModel
+ * @name userModel
+
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ 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){
+ sessionStorage.setItem('LOGIN_ID', username);
+ callback(true);
+ }else{
+ callback(false, error);
+ }
+ });
+ },
+ isLoggedIn : function(){
+ if(sessionStorage.getItem('LOGIN_ID') === null){
+ return false;
+ }
+ return true;
+ },
+ logout : function(callback){
+ APIUtils.logout(function(response, error){
+ if(response &&
+ response.status == APIUtils.API_RESPONSE.SUCCESS_STATUS){
+ sessionStorage.removeItem('LOGIN_ID');
+ callback(true);
+ }else{
+ callback(false, error);
+ }
+ });
+ }
+ };
+ }]);
+
+})(window.angular);
\ No newline at end of file
diff --git a/src/scss/base/_buttons.scss b/app/common/styles/base/buttons.scss
similarity index 100%
rename from src/scss/base/_buttons.scss
rename to app/common/styles/base/buttons.scss
diff --git a/src/scss/base/_colors.scss b/app/common/styles/base/colors.scss
similarity index 100%
rename from src/scss/base/_colors.scss
rename to app/common/styles/base/colors.scss
diff --git a/src/scss/base/_core.scss b/app/common/styles/base/core.scss
similarity index 100%
rename from src/scss/base/_core.scss
rename to app/common/styles/base/core.scss
diff --git a/src/scss/base/_forms.scss b/app/common/styles/base/forms.scss
similarity index 100%
rename from src/scss/base/_forms.scss
rename to app/common/styles/base/forms.scss
diff --git a/src/scss/base/_foundation b/app/common/styles/base/foundation
similarity index 100%
rename from src/scss/base/_foundation
rename to app/common/styles/base/foundation
diff --git a/src/scss/base/_all.scss b/app/common/styles/base/index.scss
similarity index 100%
rename from src/scss/base/_all.scss
rename to app/common/styles/base/index.scss
diff --git a/src/scss/base/_mixins.scss b/app/common/styles/base/mixins.scss
similarity index 100%
rename from src/scss/base/_mixins.scss
rename to app/common/styles/base/mixins.scss
diff --git a/src/scss/base/_typography.scss b/app/common/styles/base/typography.scss
similarity index 100%
rename from src/scss/base/_typography.scss
rename to app/common/styles/base/typography.scss
diff --git a/src/scss/base/_utility.scss b/app/common/styles/base/utility.scss
similarity index 100%
rename from src/scss/base/_utility.scss
rename to app/common/styles/base/utility.scss
diff --git a/src/scss/base/_variables.scss b/app/common/styles/base/variables.scss
similarity index 100%
rename from src/scss/base/_variables.scss
rename to app/common/styles/base/variables.scss
diff --git a/src/scss/base/_variables.scss b/app/common/styles/components/form-elements.scss
old mode 100755
new mode 100644
similarity index 100%
copy from src/scss/base/_variables.scss
copy to app/common/styles/components/form-elements.scss
diff --git a/app/common/styles/components/index.scss b/app/common/styles/components/index.scss
new file mode 100644
index 0000000..fc36b38
--- /dev/null
+++ b/app/common/styles/components/index.scss
@@ -0,0 +1,2 @@
+@import "./form-elements.scss";
+@import "./table.scss";
\ No newline at end of file
diff --git a/src/scss/utils/_all.scss b/app/common/styles/components/table.scss
similarity index 100%
copy from src/scss/utils/_all.scss
copy to app/common/styles/components/table.scss
diff --git a/src/scss/utils/_all.scss b/app/common/styles/directives/app-header.scss
similarity index 100%
copy from src/scss/utils/_all.scss
copy to app/common/styles/directives/app-header.scss
diff --git a/app/common/styles/directives/app-navigation.scss b/app/common/styles/directives/app-navigation.scss
new file mode 100644
index 0000000..29932e4
--- /dev/null
+++ b/app/common/styles/directives/app-navigation.scss
@@ -0,0 +1,142 @@
+$nav__toplvlWidth: 120px;
+$nav__seclvlWidth: 240px;
+
+// Top level navigation
+#nav__top-level {
+ background: $nav__top-level-color;
+ height: 100%;
+ position: fixed;
+ left: 0;
+ top: 0;
+ bottom: 0;
+ z-index: 99;
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+ width: $nav__toplvlWidth;
+ li {
+ margin: 0;
+ }
+ .button, button, a {
+ background: transparent;
+ height: auto;
+ border: 0;
+ color: $white;
+ fill: $white;
+ width: 100%;
+ padding: 1em;
+ display: block;
+ text-align: center;
+ margin-bottom: 0;
+ white-space: normal;
+ border-radius: 0;
+ .nav__icon {
+ color: $white;
+ max-height: 40px;
+ stroke-width: .5;
+ margin-bottom: -.5em;
+ }
+ a {
+ margin-bottom: 5px;
+ }
+ span {
+ margin: 1em 0 0 0;
+ display: block;
+ font-size: .9em;
+ font-weight: normal;
+ line-height: 1rem;
+ }
+
+ .nav__icon-help__outer {
+ fill: transparent;
+ stroke: $white;
+ stroke-miterlimit: 10;
+ stroke-width: 1px;
+ }
+ .nav__icon-help__Inner {
+ fill: $white;
+ }
+ &:hover {
+ background: $nav__second-level-color;
+ fill: $black;
+ color: $black;
+ padding: 1em;
+ border-radius: 0;
+ .nav__icon-help__outer {
+ stroke: $black;
+ }
+ .nav__icon-help__inner {
+ fill: $lightbg__primary;
+ }
+ }
+ }
+ .opened {
+ background: $nav__second-level-color;
+ fill: $black;
+ color: $black;
+ .nav__icon-help__outer {
+ stroke: $lightbg__primary;
+ }
+ }
+}
+
+// Second Level Navigation
+.nav__second-level {
+ position: fixed;
+ background: $nav__second-level-color;
+ top: 0;
+ bottom: 0;
+ left: -$nav__toplvlWidth;
+ width: $nav__seclvlWidth;
+ z-index: 97;
+ padding: 0;
+ margin: 0;
+ display: none;
+ list-style-type: none;
+ @include fastTransition-all;
+ @include mediaQuery(medium) {
+ left: $nav__toplvlWidth;
+ &.btn-overview {
+ display: block;
+ }
+ }
+ &.opened {
+ left: $nav__toplvlWidth;
+ display: block;
+ @include fastTransition-all;
+ }
+
+ a {
+ padding: 1.2em 1em 1.2em 1em;
+ display: block;
+ color: $black;
+ text-decoration: none;
+ position: relative;
+ font-weight: 400;
+ }
+
+ li {
+ a:after{
+ content: '\203A';
+ position: absolute;
+ font-size: 2em;
+ font-weight: 700;
+ top: 50%;
+ right: .6em;
+ transform: translateY(-59%);
+ color: #4b5d78;
+ opacity: 0;
+ }
+ &.active {background: $white;}
+ &.active,
+ &:focus,
+ &:hover {
+ a {color: #4b5d78;}
+ a:after {
+ opacity: 1;
+ right: .3em;
+ @include fastTransition-all;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/scss/utils/_all.scss b/app/common/styles/directives/confirm.scss
similarity index 100%
copy from src/scss/utils/_all.scss
copy to app/common/styles/directives/confirm.scss
diff --git a/app/common/styles/directives/index.scss b/app/common/styles/directives/index.scss
new file mode 100644
index 0000000..a70c007
--- /dev/null
+++ b/app/common/styles/directives/index.scss
@@ -0,0 +1,3 @@
+@import "./app-header.scss";
+@import "./app-navigation.scss";
+@import "./confirm.scss";
\ No newline at end of file
diff --git a/src/scss/elements/_alerts.scss b/app/common/styles/elements/alerts.scss
similarity index 100%
rename from src/scss/elements/_alerts.scss
rename to app/common/styles/elements/alerts.scss
diff --git a/src/scss/elements/_all.scss b/app/common/styles/elements/index.scss
similarity index 100%
rename from src/scss/elements/_all.scss
rename to app/common/styles/elements/index.scss
diff --git a/src/scss/elements/_inline-confirm.scss b/app/common/styles/elements/inline-confirm.scss
similarity index 100%
rename from src/scss/elements/_inline-confirm.scss
rename to app/common/styles/elements/inline-confirm.scss
diff --git a/src/scss/elements/_status.scss b/app/common/styles/elements/status.scss
similarity index 100%
rename from src/scss/elements/_status.scss
rename to app/common/styles/elements/status.scss
diff --git a/src/scss/elements/_toggle-switch.scss b/app/common/styles/elements/toggle-switch.scss
similarity index 100%
rename from src/scss/elements/_toggle-switch.scss
rename to app/common/styles/elements/toggle-switch.scss
diff --git a/app/common/styles/index.scss b/app/common/styles/index.scss
new file mode 100644
index 0000000..13804a7
--- /dev/null
+++ b/app/common/styles/index.scss
@@ -0,0 +1,6 @@
+
+@import "./base/index.scss";
+@import "./elements/index.scss";
+@import "./components/index.scss";
+@import "./layout/index.scss";
+@import "./directives/index.scss";
\ No newline at end of file
diff --git a/src/scss/layout/_content.scss b/app/common/styles/layout/content.scss
similarity index 100%
rename from src/scss/layout/_content.scss
rename to app/common/styles/layout/content.scss
diff --git a/src/scss/layout/_header.scss b/app/common/styles/layout/header.scss
similarity index 100%
rename from src/scss/layout/_header.scss
rename to app/common/styles/layout/header.scss
diff --git a/src/scss/layout/_all.scss b/app/common/styles/layout/index.scss
similarity index 100%
rename from src/scss/layout/_all.scss
rename to app/common/styles/layout/index.scss
diff --git a/src/scss/layout/_navigation.scss b/app/common/styles/layout/navigation.scss
similarity index 100%
rename from src/scss/layout/_navigation.scss
rename to app/common/styles/layout/navigation.scss
diff --git a/app/constants/environment-constants.js b/app/constants/environment-constants.js
new file mode 100644
index 0000000..e93182a
--- /dev/null
+++ b/app/constants/environment-constants.js
@@ -0,0 +1,30 @@
+/**
+ * A module with constants for the REST API
+ *
+ * @module app/constants
+ * @exports app/constants
+ *
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.constants')
+ .constant('EnvironmentConstants', {
+ 'inDevelopmentMode': true,
+ 'RestConstants': {
+ },
+ FLASH_MESSAGE : {
+ duration: 2000,
+ classes: {
+ warning: 'message-warning',
+ info: 'message-info',
+ error: 'message-error',
+ success: 'message-success'
+ }
+ }
+ });
+
+})(window.angular);
diff --git a/app/constants/index.js b/app/constants/index.js
new file mode 100644
index 0000000..c27d81d
--- /dev/null
+++ b/app/constants/index.js
@@ -0,0 +1,17 @@
+/**
+ * A module with constants for the application
+ *
+ * @module app/constants/index
+ * @exports app/constants/index
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.constants', [])
+ .constant('AppConstants', {
+ });
+
+})(window.angular);
diff --git a/app/index.html b/app/index.html
new file mode 100644
index 0000000..fd308fc
--- /dev/null
+++ b/app/index.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html lang="en" ng-app="app">
+<head>
+ <base href="/">
+ <meta charset="UTF-8">
+ <title>openBMC</title>
+ <link rel="icon" href="favicon.ico?v=2"/>
+ <!-- build:css styles/app.min.css -->
+ <link rel="stylesheet" href="styles/index.css">
+ <!-- endbuild -->
+</head>
+<body ng-style="dataService.bodyStyle" ng-attr-id="{{dataService.path == '/login' ? 'login': ''}}">
+
+ <app-header ng-if="dataService.showNavigation" path="dataService.path"></app-header>
+ <app-navigation ng-if="dataService.showNavigation" path="dataService.path" show-navigation=" dataService.showNavigation"></app-navigation>
+
+ <main ng-view ng-class="{'content__container': dataService.path != '/login', 'login__wrapper': dataService.path == '/login'}">
+ </main>
+
+ <!-- build:js scripts/vendor.min.js -->
+ <script src="../bower_components/angular/angular.min.js"></script>
+ <script src="../bower_components/angular-route/angular-route.min.js"></script>
+ <!-- endbuild -->
+
+ <!-- build:js scripts/app.min.js -->
+ <script src="index.js"></script>
+ <script src="templates.js"></script>
+ <script src="vendors.js"></script>
+
+ <script src="constants/index.js"></script>
+ <script src="constants/environment-constants.js"></script>
+
+ <script src="common/services/index.js"></script>
+ <script src="common/services/constants.js"></script>
+ <script src="common/services/dataService.js"></script>
+ <script src="common/services/api-utils.js"></script>
+ <script src="common/services/userModel.js"></script>
+ <script src="common/services/apiInterceptor.js"></script>
+
+ <script src="common/filters/index.js"></script>
+
+ <script src="common/directives/index.js"></script>
+ <script src="common/directives/app-header.js"></script>
+ <script src="common/directives/app-navigation.js"></script>
+ <script src="common/directives/confirm.js"></script>
+
+ <script src="login/index.js"></script>
+ <script src="login/controllers/login-controller.js"></script>
+ <script src="overview/index.js"></script>
+ <script src="overview/controllers/bmc-reboot-controller.js"></script>
+ <script src="overview/controllers/power-operations-controller.js"></script>
+ <script src="overview/controllers/system-overview-controller.js"></script>
+ <script src="overview/controllers/unit-id-controller.js"></script>
+ <script src="overview/controllers/log-controller.js"></script>
+ <!-- endbuild -->
+</body>
+
+</html>
diff --git a/app/index.js b/app/index.js
new file mode 100644
index 0000000..f5c2692
--- /dev/null
+++ b/app/index.js
@@ -0,0 +1,83 @@
+/**
+ * A module which contains the definition of the application and the base of configuration
+ *
+ * @module app/index/services/index
+ * @exports app/index
+ *
+ * @author Developer Developer
+ * @version 0.10.0
+ * @since 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app', [
+ // Dependencies
+ 'ngRoute',
+ // Basic resources
+ 'app.constants',
+ 'app.templates',
+ 'app.vendors',
+ 'app.common.services',
+ 'app.common.directives',
+ 'app.common.filters',
+ // Model resources
+ 'app.login',
+ 'app.overview'
+ ])
+ // Route configuration
+ .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
+ $locationProvider.hashPrefix('');
+ $routeProvider
+ .otherwise({
+ 'redirectTo': '/login'
+ });
+ }])
+ .config(['$httpProvider', function($httpProvider){
+ //console.log($httpProvider.interceptors);
+ $httpProvider.interceptors.push('apiInterceptor');
+ }])
+ .run(['$rootScope', '$location', 'dataService', 'userModel',
+ function($rootScope, $location, dataService, userModel){
+ $rootScope.dataService = dataService;
+ dataService.path = $location.path();
+ $rootScope.$on('$routeChangeStart', function(event, next, current){
+
+ if(next.$$route == null || next.$$route == undefined) return;
+ if(next.$$route.authenticated){
+ if(!userModel.isLoggedIn()){
+ $location.path('/login');
+ }
+ }
+
+ if(next.$$route.originalPath == '/' ||
+ next.$$route.originalPath == '/login'){
+ if(userModel.isLoggedIn()){
+ if(current && current.$$route){
+ $location.path(current.$$route.originalPath);
+ }else{
+ $location.path('/overview/system');
+ }
+ }
+ }
+ });
+ $rootScope.$on('$locationChangeSuccess', function(event){
+ var path = $location.path();
+ dataService.path = path;
+ if(['/','/login','/logout'].indexOf(path) == -1){
+ dataService.showNavigation = true;
+ }else{
+ dataService.showNavigation = false;
+ }
+ });
+
+ $rootScope.$on('timedout-user', function(){
+ sessionStorage.removeItem('LOGIN_ID');
+ $location.path('/login');
+ });
+ }
+ ]);
+
+})(window.angular);
diff --git a/src/login.html b/app/login/controllers/login-controller.html
similarity index 94%
rename from src/login.html
rename to app/login/controllers/login-controller.html
index 122cd84..a249726 100644
--- a/src/login.html
+++ b/app/login/controllers/login-controller.html
@@ -1,7 +1,7 @@
<div>
<div class="row">
<div class="columns large-6">
- <img src="img/logo.svg" class="login__logo" alt="IBM logo" role="img"/>
+ <img src="assets/images/logo.svg" class="login__logo" alt="IBM logo" role="img"/>
</div>
<div class="columns large-6">
</div>
diff --git a/app/login/controllers/login-controller.js b/app/login/controllers/login-controller.js
new file mode 100644
index 0000000..b1a0d45
--- /dev/null
+++ b/app/login/controllers/login-controller.js
@@ -0,0 +1,52 @@
+/**
+ * Controller for the login page
+ *
+ * @module app/login/controllers/index
+ * @exports LoginController
+ * @name LoginController
+ * @version 0.1.0
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.login')
+ .controller('LoginController', [
+ '$scope',
+ '$window',
+ 'APIUtils',
+ 'dataService',
+ 'userModel',
+ function($scope, $window, APIUtils, dataService, userModel){
+ $scope.dataService = dataService;
+
+ $scope.tryLogin = function(username, password, event){
+ if(event.keyCode === 13){
+ $scope.login(username, password);
+ }
+ };
+ $scope.login = function(username, password){
+ $scope.error = false;
+
+ if(!username || username == "" ||
+ !password || password == ""){
+ return false;
+ }else{
+ userModel.login(username, password, function(status, unreachable){
+ if(status){
+ $scope.$emit('user-logged-in',{});
+ $window.location.hash = '#/system-overview';
+ }else{
+ if(!unreachable){
+ $scope.error = true;
+ }
+ };
+ });
+ }
+ }
+ }
+ ]
+ );
+
+})(angular);
diff --git a/app/login/index.js b/app/login/index.js
new file mode 100644
index 0000000..7e86ac4
--- /dev/null
+++ b/app/login/index.js
@@ -0,0 +1,28 @@
+/**
+ * A module for the login
+ *
+ * @module app/login/index
+ * @exports app/login/index
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.login', [
+ 'ngRoute',
+ 'app.constants',
+ 'app.common.services'
+ ])
+ // Route configuration
+ .config(['$routeProvider', function ($routeProvider) {
+ $routeProvider
+ .when('/login', {
+ 'templateUrl': 'login/controllers/login-controller.html',
+ 'controller': 'LoginController',
+ authenticated: false
+ });
+ }]);
+
+})(window.angular);
diff --git a/src/scss/components/_login.scss b/app/login/styles/index.scss
similarity index 100%
rename from src/scss/components/_login.scss
rename to app/login/styles/index.scss
diff --git a/src/bmc-reboot.html b/app/overview/controllers/bmc-reboot-controller.html
similarity index 100%
rename from src/bmc-reboot.html
rename to app/overview/controllers/bmc-reboot-controller.html
diff --git a/app/overview/controllers/bmc-reboot-controller.js b/app/overview/controllers/bmc-reboot-controller.js
new file mode 100644
index 0000000..040b444
--- /dev/null
+++ b/app/overview/controllers/bmc-reboot-controller.js
@@ -0,0 +1,26 @@
+/**
+ * Controller for bmc-reboot
+ *
+ * @module app/overview
+ * @exports bmcRebootController
+ * @name bmcRebootController
+ * @version 0.1.0
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.overview')
+ .controller('bmcRebootController', [
+ '$scope',
+ '$window',
+ 'APIUtils',
+ 'dataService',
+ function($scope, $window, APIUtils, dataService, userModel){
+ $scope.dataService = dataService;
+ }
+ ]
+ );
+
+})(angular);
diff --git a/app/overview/controllers/log-controller.html b/app/overview/controllers/log-controller.html
new file mode 100644
index 0000000..cf70c95
--- /dev/null
+++ b/app/overview/controllers/log-controller.html
@@ -0,0 +1,3 @@
+<div id="uid-log">
+ Log contents here
+</div>
\ No newline at end of file
diff --git a/app/overview/controllers/log-controller.js b/app/overview/controllers/log-controller.js
new file mode 100644
index 0000000..3b85605
--- /dev/null
+++ b/app/overview/controllers/log-controller.js
@@ -0,0 +1,26 @@
+/**
+ * Controller for log
+ *
+ * @module app/overview
+ * @exports logController
+ * @name logController
+ * @version 0.1.0
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.overview')
+ .controller('logController', [
+ '$scope',
+ '$window',
+ 'APIUtils',
+ 'dataService',
+ function($scope, $window, APIUtils, dataService, userModel){
+ $scope.dataService = dataService;
+ }
+ ]
+ );
+
+})(angular);
diff --git a/src/power-operations.html b/app/overview/controllers/power-operations-controller.html
similarity index 96%
rename from src/power-operations.html
rename to app/overview/controllers/power-operations-controller.html
index adcdd0e..48d4357 100644
--- a/src/power-operations.html
+++ b/app/overview/controllers/power-operations-controller.html
@@ -42,12 +42,12 @@
<confirm title="Cold Reboot" message="Shutdown server immediately." confirm="coldboot_confirm" ng-show="coldboot_confirm" cancel="coldbootCancel" callback="coldReboot"></confirm>
</div>
<div class="row column power-option" ng-hide="dataService.server_state == 'Off'" ng-class="{disabled: (confirm && !orderly_confirm) || dataService.loading, transitionAll: confirm && orderly_confirm}">
- <button id="power__soft-shutdown" class="btn-secondary" ng-click="orderlyShutdownConfirm()" role="button"><img src="img/icon-power.svg" />Orderly shutdown</button>
+ <button id="power__soft-shutdown" class="btn-secondary" ng-click="orderlyShutdownConfirm()" role="button"><img src="assets/images/icon-power.svg" />Orderly shutdown</button>
<p>Attempts to stop all software on the server before removing power</p>
<confirm title="Orderly shutdown" message="Attempts to stop all software orderly." confirm="orderly_confirm" ng-show="orderly_confirm" cancel="orderlyShutdownCancel" callback="orderlyShutdown"></confirm>
</div>
<div class="row column power-option" ng-hide="dataService.server_state == 'Off'" ng-class="{disabled: (confirm && !immediately_confirm) || dataService.loading, transitionAll: confirm && immediately_confirm}">
- <button id="power__hard-shutdown" class="btn-secondary" ng-click="immediateShutdownConfirm()" role="button"><img src="img/icon-power.svg" />Immediate shutdown</button>
+ <button id="power__hard-shutdown" class="btn-secondary" ng-click="immediateShutdownConfirm()" role="button"><img src="assets/images/icon-power.svg" />Immediate shutdown</button>
<p>Removes power from the server without waiting for software to stop</p>
<confirm title="Immediate shutdown" message="Removes power from the server immediately." confirm="immediately_confirm" ng-show="immediately_confirm" cancel="immediatelyShutdownCancel" callback="immediateShutdown"></confirm>
</div>
diff --git a/app/overview/controllers/power-operations-controller.js b/app/overview/controllers/power-operations-controller.js
new file mode 100644
index 0000000..1780da3
--- /dev/null
+++ b/app/overview/controllers/power-operations-controller.js
@@ -0,0 +1,134 @@
+/**
+ * Controller for power-operations
+ *
+ * @module app/overview
+ * @exports powerOperationsController
+ * @name powerOperationsController
+ * @version 0.1.0
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.overview')
+ .controller('powerOperationsController', [
+ '$scope',
+ 'APIUtils',
+ 'dataService',
+ '$timeout',
+ function($scope, APIUtils, dataService, $timeout){
+ $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;
+
+ //@TODO: call api and get proper state
+ $scope.toggleState = function(){
+ dataService.server_state = (dataService.server_state == 'Running') ? 'Off': 'Running';
+ }
+
+ $scope.togglePower = function(){
+ var method = (dataService.server_state == 'Running') ? 'hostPowerOff' : 'hostPowerOn';
+ //@TODO: show progress or set class orange
+ APIUtils[method](function(response){
+ //update state based on response
+ //error case?
+ if(response == null){
+ console.log("Failed request.");
+ }else{
+ //@TODO::need to get the server status
+ if(dataService.server_state == 'Running'){
+ dataService.setPowerOffState();
+ }else{
+ dataService.setPowerOnState();
+ }
+ }
+ });
+ }
+ $scope.powerOnConfirm = function(){
+ if($scope.confirm) {
+ return;
+ }
+ $scope.confirm = true;
+ $scope.power_confirm = true;
+ };
+ $scope.warmReboot = function(){
+ //@TODO:show progress
+ dataService.setBootingState();
+ APIUtils.hostPowerOff(function(response){
+ if(response){
+ APIUtils.hostPowerOn(function(response){
+ if(response){
+ dataService.setPowerOnState();
+ }else{
+ //@TODO:show error message
+ }
+ });
+ }else{
+ }
+ });
+ };
+ $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.warmReboot();
+ };
+ $scope.coldRebootConfirm = function(){
+ if($scope.confirm) {
+ return;
+ }
+ $scope.confirm = true;
+ $scope.coldboot_confirm = true;
+ };
+
+ $scope.orderlyShutdown = function(){
+ //@TODO:show progress
+ APIUtils.hostPowerOff(function(response){
+ if(response){
+ dataService.setPowerOffState();
+ }else{
+ //@TODO:hide progress & show error message
+ }
+ });
+ };
+ $scope.orderlyShutdownConfirm = function(){
+ if($scope.confirm) {
+ return;
+ }
+ $scope.confirm = true;
+ $scope.orderly_confirm = true;
+ };
+
+ $scope.immediateShutdown = function(){
+ $scope.orderlyShutdown();
+ };
+ $scope.immediateShutdownConfirm = function(){
+ if($scope.confirm) {
+ return;
+ }
+ $scope.confirm = true;
+ $scope.immediately_confirm = true;
+ };
+ }
+ ]
+ );
+
+})(angular);
diff --git a/src/system-overview.html b/app/overview/controllers/system-overview-controller.html
similarity index 100%
rename from src/system-overview.html
rename to app/overview/controllers/system-overview-controller.html
diff --git a/app/overview/controllers/system-overview-controller.js b/app/overview/controllers/system-overview-controller.js
new file mode 100644
index 0000000..e3841cb
--- /dev/null
+++ b/app/overview/controllers/system-overview-controller.js
@@ -0,0 +1,26 @@
+/**
+ * Controller for system overview
+ *
+ * @module app/overview
+ * @exports systemOverviewController
+ * @name systemOverviewController
+ * @version 0.1.0
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.overview')
+ .controller('systemOverviewController', [
+ '$scope',
+ '$window',
+ 'APIUtils',
+ 'dataService',
+ function($scope, $window, APIUtils, dataService, userModel){
+ $scope.dataService = dataService;
+ }
+ ]
+ );
+
+})(angular);
diff --git a/src/unit-id.html b/app/overview/controllers/unit-id-controller.html
similarity index 100%
rename from src/unit-id.html
rename to app/overview/controllers/unit-id-controller.html
diff --git a/app/overview/controllers/unit-id-controller.js b/app/overview/controllers/unit-id-controller.js
new file mode 100644
index 0000000..c59f411
--- /dev/null
+++ b/app/overview/controllers/unit-id-controller.js
@@ -0,0 +1,26 @@
+/**
+ * Controller for unit Id
+ *
+ * @module app/overview
+ * @exports unitIdController
+ * @name unitIdController
+ * @version 0.1.0
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.overview')
+ .controller('unitIdController', [
+ '$scope',
+ '$window',
+ 'APIUtils',
+ 'dataService',
+ function($scope, $window, APIUtils, dataService, userModel){
+ $scope.dataService = dataService;
+ }
+ ]
+ );
+
+})(angular);
diff --git a/app/overview/index.js b/app/overview/index.js
new file mode 100644
index 0000000..bc37a37
--- /dev/null
+++ b/app/overview/index.js
@@ -0,0 +1,48 @@
+/**
+ * A module for the overview
+ *
+ * @module app/overview/index
+ * @exports app/overview/index
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.overview', [
+ 'ngRoute',
+ 'app.constants',
+ 'app.common.services'
+ ])
+ // Route configuration
+ .config(['$routeProvider', function ($routeProvider) {
+ $routeProvider
+ .when('/overview/bmc-reboot', {
+ 'templateUrl': 'overview/controllers/bmc-reboot-controller.html',
+ 'controller': 'bmcRebootController',
+ authenticated: true
+ })
+ .when('/overview/log', {
+ 'templateUrl': 'overview/controllers/log-controller.html',
+ 'controller': 'logController',
+ authenticated: true
+ })
+ .when('/overview/power-operations', {
+ 'templateUrl': 'overview/controllers/power-operations-controller.html',
+ 'controller': 'powerOperationsController',
+ authenticated: true
+ })
+ .when('/overview/unit-id', {
+ 'templateUrl': 'overview/controllers/unit-id-controller.html',
+ 'controller': 'unitIdController',
+ authenticated: true
+ })
+ .when('/overview/system', {
+ 'templateUrl': 'overview/controllers/system-overview-controller.html',
+ 'controller': 'systemOverviewController',
+ authenticated: true
+ });
+ }]);
+
+})(window.angular);
diff --git a/src/scss/components/_bmc-reboot.scss b/app/overview/styles/bmc-reboot.scss
similarity index 100%
rename from src/scss/components/_bmc-reboot.scss
rename to app/overview/styles/bmc-reboot.scss
diff --git a/app/overview/styles/index.scss b/app/overview/styles/index.scss
new file mode 100644
index 0000000..43fca4b
--- /dev/null
+++ b/app/overview/styles/index.scss
@@ -0,0 +1,5 @@
+@import "./bmc-reboot.scss";
+@import "./log.scss";
+@import "./power-operations.scss";
+@import "./system-overview.scss";
+@import "./unit-id.scss";
\ No newline at end of file
diff --git a/src/scss/utils/_all.scss b/app/overview/styles/log.scss
similarity index 100%
rename from src/scss/utils/_all.scss
rename to app/overview/styles/log.scss
diff --git a/src/scss/components/_power-ops.scss b/app/overview/styles/power-operations.scss
similarity index 100%
rename from src/scss/components/_power-ops.scss
rename to app/overview/styles/power-operations.scss
diff --git a/src/scss/utils/_all.scss b/app/overview/styles/system-overview.scss
similarity index 100%
copy from src/scss/utils/_all.scss
copy to app/overview/styles/system-overview.scss
diff --git a/src/scss/components/_uid-light.scss b/app/overview/styles/unit-id.scss
similarity index 100%
rename from src/scss/components/_uid-light.scss
rename to app/overview/styles/unit-id.scss
diff --git a/app/styles/index.scss b/app/styles/index.scss
new file mode 100644
index 0000000..32112de
--- /dev/null
+++ b/app/styles/index.scss
@@ -0,0 +1,5 @@
+$charset: "UTF-8";
+
+@import "../common/styles/index.scss";
+@import "../login/styles/index.scss";
+@import "../overview/styles/index.scss";
\ No newline at end of file
diff --git a/app/templates.js b/app/templates.js
new file mode 100644
index 0000000..399c280
--- /dev/null
+++ b/app/templates.js
@@ -0,0 +1,19 @@
+/**
+ * A module which contains all compiled templates for the angular application
+ *
+ * @module app/templates
+ * @exports app/templates
+ * @version 0.0.1
+ * @since 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ /**
+ * Used for gulp template cache plugin.
+ */
+ angular
+ .module('app.templates', []);
+
+})(window.angular);
diff --git a/app/vendors.js b/app/vendors.js
new file mode 100644
index 0000000..31f501e
--- /dev/null
+++ b/app/vendors.js
@@ -0,0 +1,14 @@
+/**
+ * A module to easily inject vendors dependencies as angular service
+ *
+ * @module app/vendors
+ * @exports app/vendors
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.vendors', [])
+})(window.angular);
diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..86b31a7
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,35 @@
+{
+ "name": "openbmc-wires",
+ "description": "openbmc-wires",
+ "version": "0.0.1",
+ "dependencies": {
+ "angular": "1.5.6",
+ "angular-route": "1.5.6"
+ },
+ "resolutions": {
+ "angular": "1.5.6"
+ },
+ "devDependencies": {
+ },
+ "authors": [
+ {
+ "name": "Iftekharul Islam",
+ "email": "iislam@us.ibm.com"
+ }
+ ],
+ "license": "private",
+ "private": true,
+ "ignore": [
+ "node_modules",
+ "bower_components",
+ "config",
+ "test",
+ "target",
+ ".*",
+ "README*",
+ "karma.conf.js",
+ "gulpfile.js",
+ "bower.json",
+ "package.json"
+ ]
+}
\ No newline at end of file
diff --git a/gulp-options.js b/gulp-options.js
new file mode 100644
index 0000000..68240d7
--- /dev/null
+++ b/gulp-options.js
@@ -0,0 +1,14 @@
+/*eslint-env node */
+/*global module: true, __dirname: true */
+
+'use strict';
+
+module.exports = {
+ 'targetFolderPath': './target',
+ 'srcFolderPath': './app',
+ 'tempFolderPath': __dirname + '/.temp',
+ 'nodeModulesFolderPath': './node_modules',
+ 'bowerFolderPath': './app/bower_components',
+ 'dirname': __dirname,
+ 'excludePath': '!./app/vendors/**/*'
+};
diff --git a/gulp_tasks/checkstyle.js b/gulp_tasks/checkstyle.js
new file mode 100644
index 0000000..bd76a8b
--- /dev/null
+++ b/gulp_tasks/checkstyle.js
@@ -0,0 +1,31 @@
+/*eslint-env node */
+/*global require: true, module: true */
+
+'use strict';
+
+var options = require('../gulp-options.js'),
+ gulp = require('gulp'),
+ clean = require('gulp-clean'),
+ eslint = require('gulp-eslint');
+
+var runSequence = require('run-sequence'),
+ fs = require('fs');
+
+gulp.task('checkstyle:clean', function () {
+ return gulp
+ .src([options.targetFolderPath + '/eslint-report-checkstyle.xml'], {'read': false})
+ .pipe(clean({'force': true}));
+});
+
+gulp.task('checkstyle:eslint', function () {
+ return gulp
+ .src([options.srcFolderPath + '/**/*.js', options.excludePath])
+ .pipe(eslint({'useEslintrc': true}))
+ .pipe(eslint.format('checkstyle', function (output) {
+ fs.writeFileSync(options.targetFolderPath + '/eslint-report-checkstyle.xml', output);
+ }));
+});
+
+module.exports = function (callback) {
+ return runSequence('checkstyle:clean', 'checkstyle:eslint', callback);
+};
diff --git a/gulp_tasks/distribution.js b/gulp_tasks/distribution.js
new file mode 100644
index 0000000..ec5aac0
--- /dev/null
+++ b/gulp_tasks/distribution.js
@@ -0,0 +1,45 @@
+/*eslint-env node */
+/*global require: true, module: true */
+
+'use strict';
+
+var options = require('../gulp-options.js'),
+ gulp = require('gulp'),
+ clean = require('gulp-clean'),
+ webapp = require('./webapp.js'),
+ imagemin = require('gulp-imagemin');
+
+var runSequence = require('run-sequence');
+
+gulp.task('webapp', function (callback) {
+ return webapp(callback);
+});
+
+gulp.task('distribution:clean', function () {
+ return gulp
+ .src([options.dirname + '/dist'], { 'read': false })
+ .pipe(clean({'force': true}));
+});
+
+gulp.task('distribution:copy', function () {
+ return gulp
+ .src(['**/*'], { 'cwd': options.targetFolderPath + '/webapp' })
+ .pipe(gulp.dest(options.dirname + '/dist'));
+});
+
+gulp.task('imagemin', () =>
+ gulp.src([options.dirname + '/app/assets/images/*'])
+ .pipe(imagemin({
+ optimizationLevel: 3,
+ progressive: true,
+ interlaced: false,
+ svgoPlugins: [{
+ removeViewBox: false
+ }]
+ }))
+ .pipe(gulp.dest('dist/assets/images'))
+);
+
+module.exports = function (callback) {
+ return runSequence('distribution:clean', 'webapp', 'distribution:copy', 'imagemin', callback);
+};
diff --git a/gulp_tasks/server.js b/gulp_tasks/server.js
new file mode 100644
index 0000000..b965786
--- /dev/null
+++ b/gulp_tasks/server.js
@@ -0,0 +1,32 @@
+var options = require('../gulp-options.js'),
+ gulp = require('gulp'),
+ connect = require('gulp-connect'),
+ distribution = require('./distribution.js');
+
+var runSequence = require('run-sequence');
+
+gulp.task('distribution', function (callback) {
+ return distribution(callback);
+});
+
+gulp.task('connect', function() {
+ connect.server({
+ root: 'dist',
+ livereload: true
+ });
+});
+
+gulp.task('livereload', function() {
+ gulp.src(['./dist/**/*.html','./dist/**/*.js','./dist/**/*.css'])
+ .pipe(connect.reload());
+});
+
+gulp.task('watch', function () {
+ gulp.watch('./app/**/*', function(callback){
+ return runSequence('distribution', 'livereload');
+ });
+});
+
+module.exports = function (callback) {
+ return runSequence('connect', 'watch', callback);
+};
\ No newline at end of file
diff --git a/gulp_tasks/webapp.js b/gulp_tasks/webapp.js
new file mode 100644
index 0000000..e514543
--- /dev/null
+++ b/gulp_tasks/webapp.js
@@ -0,0 +1,131 @@
+/*eslint-env node */
+/*global require: true, module: true */
+
+'use strict';
+
+var options = require('../gulp-options.js'),
+ gulp = require('gulp'),
+
+ // Base dependencies
+ clean = require('gulp-clean'),
+ rename = require('gulp-rename'),
+ util = require('gulp-util'),
+
+ // Angular gulp dependencies
+ ngTemplateCache = require('gulp-angular-templatecache'),
+ ngAnnotate = require('gulp-ng-annotate'),
+ ngConstant = require('gulp-ng-constant'),
+
+ // Classical gulp dependencies
+ stripDebug = require('gulp-strip-debug'),
+ uglify = require('gulp-uglify'),
+ sass = require('gulp-sass'),
+ cleanCss = require('gulp-clean-css'),
+ rev = require('gulp-rev'),
+ revReplace = require('gulp-rev-replace'),
+ gulpIf = require('gulp-if'),
+ useref = require('gulp-useref'),
+ jsoncombine = require('gulp-jsoncombine'),
+ htmlParser = require('gulp-htmlparser');
+
+
+var runSequence = require('run-sequence'),
+ es = require('event-stream');
+
+gulp.task('webapp:clean', function () {
+ return gulp
+ .src([options.targetFolderPath + '/webapp', options.dirname + '/.temp'], { 'read': false })
+ .pipe(clean({'force': true}));
+});
+
+gulp.task('webapp:sasscompile', function () {
+ return gulp
+ .src('app/styles/index.scss')
+ .pipe(sass.sync().on('error', util.log))
+ .pipe(gulp.dest(options.srcFolderPath + '/styles'))
+});
+
+// ----- To .temp from app
+gulp.task('webapp:copyjs', function () {
+ return gulp.src(options.srcFolderPath + '/**/*.js')
+ .pipe(ngAnnotate()) // Check angular dependencies injection
+ .pipe(stripDebug()) // Remove all logs
+ .pipe(uglify({ 'mangle': false }))
+ .pipe(gulp.dest(options.dirname + '/.temp'));
+});
+
+gulp.task('webapp:copyothers', function () {
+ return gulp.src(['**/*', '!**/*.js', '!**/*.css', '!**/*.scss'], { 'cwd': options.srcFolderPath }) // All except JS files
+ .pipe(gulp.dest(options.tempFolderPath));
+});
+
+gulp.task('webapp:copycss', function () {
+ return gulp
+ .src('app/styles/index.css')
+ .pipe(cleanCss())
+ .pipe(gulp.dest(options.tempFolderPath + '/styles'));
+});
+
+gulp.task('webapp:constants', function () {
+ return gulp
+ .src('environment-constants.json')
+ .pipe(ngConstant({
+ 'name': 'app.constants',
+ 'deps': false
+ }))
+ .pipe(rename('environment-constants.js'))
+ .pipe(gulp.dest(options.tempFolderPath + '/constants'));
+});
+
+// ----- To target/webapp from .temp and bower_components
+gulp.task('webapp:template', function () {
+ return gulp.src([options.srcFolderPath + '/**/*.html', '!' + options.srcFolderPath + '/index.html'])
+ .pipe(ngTemplateCache('templates.js', {
+ 'module': 'app.templates',
+ 'standalone': true
+ }))
+ .pipe(gulp.dest(options.tempFolderPath));
+});
+
+gulp.task('webapp:useref', function () {
+ var tasks = ['index.html'].map(function (indexPage) {
+ var assets = useref.assets({ });
+
+ return gulp.src(options.tempFolderPath + '/' + indexPage)
+ .pipe(assets)
+ .pipe(assets.restore())
+ .pipe(useref())
+ .pipe(revReplace()) // Force useref to apply the 'rev' method
+ .pipe(gulp.dest(options.targetFolderPath + '/webapp'));
+ });
+
+ return es.concat.apply(null, tasks);
+});
+
+gulp.task('webapp:copyresources', function () {
+ return gulp.src(['**/*.*', '!**/*.js', '!**/*.css', '!**/*.html', '!**/*.log'], { 'cwd': options.tempFolderPath })
+ .pipe(gulp.dest(options.targetFolderPath + '/webapp'));
+});
+
+module.exports = function (callback) {
+ return runSequence(
+ 'webapp:clean',
+ 'webapp:sasscompile',
+ [
+ 'webapp:copyjs',
+ 'webapp:copycss',
+ 'webapp:copyothers'
+ ],
+ [
+ 'webapp:constants',
+ 'webapp:template'
+ ],
+ [
+ 'webapp:useref'
+ ],
+ [
+ 'webapp:copyresources'
+ ],
+ callback
+ );
+};
diff --git a/gulpfile.js b/gulpfile.js
new file mode 100644
index 0000000..16d940f
--- /dev/null
+++ b/gulpfile.js
@@ -0,0 +1,14 @@
+/*eslint-env node */
+/*global require: true*/
+
+/**
+ * Gulp file declaration
+ */
+
+'use strict';
+
+var gulp = require('gulp');
+var sass = require('gulp-sass');
+
+// Load gulp tasks automatically
+require('gulp-load-tasks')('gulp_tasks');
diff --git a/package.json b/package.json
index 1b5f55a..8005c7e 100644
--- a/package.json
+++ b/package.json
@@ -1,43 +1,70 @@
{
"name": "openbmc-wires",
+ "description": "openbmc-wires",
"version": "0.0.1",
+ "private": false,
"scripts": {
- "clean": "rimraf dist/*",
- "prebuild": "npm run clean -s",
- "scss": "node-sass --output-style compressed -o dist/css src/scss/",
- "autoprefixer": "postcss -u autoprefixer -r dist/css/*",
- "uglify": "mkdir -p dist/js && cat src/js/*.js > dist/js/app.min.js && uglifyjs dist/js/app.min.js -m -o dist/js/app.min.js && mkdir -p dist/js/vendor && cat node_modules/angular/angular.js node_modules/angular-route/angular-route.js node_modules/zepto/dist/zepto.js > dist/js/vendor/vendor.min.js && uglifyjs dist/js/vendor/vendor.min.js -m -o dist/js/vendor/vendor.min.js",
- "imagemin": "imagemin src/img/* --out-dir=dist/img/",
- "serve": "browser-sync start --server 'dist' --files 'dist/css/*.css, dist/js/*.js, dist/*.html'",
- "build:css": "npm run scss && npm run autoprefixer",
- "build:js": "npm run uglify",
- "build:html": "html-minifier --input-dir ./src/ --output-dir ./dist --collapse-whitespace --remove-comments --file-ext html ",
- "build:images": "npm run imagemin ",
- "build:all": "npm run prebuild && npm run build:css && npm run build:js && npm run build:html && npm run build:images",
- "watch:css": "onchange 'src/scss/' -- npm run build:css",
- "watch:js": "onchange 'src/js/*.js' -- npm run build:js",
- "watch:html": "onchange 'src/*.html' -- npm run build:html",
- "watch:images": "onchange 'src/img/*.*' -- npm run build:images",
- "watch:all": "parallelshell 'npm run serve' 'npm run watch:css' 'npm run watch:js' 'npm run watch:html'",
- "postinstall": "npm run build:all && npm run watch:all",
- "start": "npm run build:all && npm run watch:all",
- "gzip": "tar -czf openBMC.tar.gz dist"
+ "bower": "node node_modules/bower/bin/bower",
+ "gulp": "node node_modules/gulp/bin/gulp.js",
+ "distribution": "npm run gulp distribution",
+ "serve": "npm run gulp server",
+ "shrinkwrap": "npm shrinkwrap --dev",
+ "start-dev": "npm run gulp server",
+ "webapp": "npm run gulp webapp",
+ "start": "npm run gulp server",
+ "postinstall": "bower install"
},
+ "contributors": [
+ "Iftekharul Islam <iislam@us.ibm.com>"
+ ],
+ "files": [
+ "dist"
+ ],
+ "keywords": [
+ "node"
+ ],
+ "dependencies": {
+ },
+ "peerDependencies": {},
"devDependencies": {
"angular": "^1.5.6",
"angular-route": "^1.5.6",
+ "bower": "1.8.0",
+ "eslint-plugin-angular": "2.0.0",
+ "event-stream": "3.3.4",
+ "gulp": "3.9.1",
+ "gulp-angular-templatecache": "2.0.0",
+ "gulp-clean": "^0.3.2",
+ "gulp-connect": "5.0.0",
+ "gulp-eslint": "3.0.1",
+ "gulp-htmlparser": "^0.0.4",
+ "gulp-if": "^1.2.5",
+ "gulp-jsoncombine": "^1.0.3",
+ "gulp-load-tasks": "^0.8.3",
+ "gulp-clean-css": "^3.0.4",
+ "gulp-ng-annotate": "^1.1.0",
+ "gulp-ng-constant": "^0.3.0",
+ "gulp-nodemon": "^2.1.0",
+ "gulp-rename": "^1.2.2",
+ "gulp-rev": "^0.4.0",
+ "gulp-rev-replace": "^0.4.2",
+ "gulp-sass": "^2.3.2",
+ "gulp-strip-debug": "^1.0.2",
+ "gulp-uglify": "^1.2.0",
+ "gulp-useref": "^1.2.0",
+ "gulp-util": "^3.0.6",
+ "gulp-imagemin": "^3.1.1",
"autoprefixer": "^6.6.1",
- "browser-sync": "^2.18.6",
"html-minifier": "^3.3.0",
- "imagemin-cli": "^3.0.0",
"node-sass": "^4.3.0",
"onchange": "^3.2.1",
"parallelshell": "^2.0.0",
- "postcss-cli": "^2.6.0",
- "uglify-js": "^2.7.5",
- "zepto": "^1.2.0"
+ "run-sequence": "^1.1.2"
},
- "dependencies": {
- "imagemin": "^5.2.2"
- }
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.11.13",
+ "npm": ">=1.4.28"
+ },
+ "author": ""
}
diff --git a/src/elements.html b/src/elements.html
deleted file mode 100644
index 1d16b39..0000000
--- a/src/elements.html
+++ /dev/null
@@ -1,90 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <title>openBMC</title>
- <link rel="icon" href="favicon.ico?v=2"/>
- <link rel="stylesheet" href="css/main.css">
- <script src="js/vendor/vendor.min.js"></script>
-</head>
-<body>
-
-<div class="login__wrapper" style="height: auto">
- <form id="login__form">
- <div class="row">
- <div class="column column-60">
- <h1>Header 1 Quisque velit nisi, pretium ut lacinia in</h1>
- <h2>Header 2 Curabitur aliquet quam id dui</h2>
- <h3>Header 3 convallis a pellentesque nec, egestas</h3>
- <h4>Header 4 diam sit amet quam vehicula elementum</h4>
- <h5>Header 5 ipsum id orci porta dapibus. Curabitur aliquet </h5>
- </div>
- </div>
- <p>Server IP</p>
- <p>Quisque velit nisi, pretium ut lacinia in, elementum id enim. Proin eget tortor risus. Praesent sapien massa,
- <a href="#">convallis a pellentesque</a> nec, egestas non nisi. Proin eget tortor risus. Pellentesque in ipsum id orci porta
- dapibus. Curabitur aliquet quam id dui posuere <span class="disabled">blandit</span>. Vestibulum ac diam sit amet quam vehicula elementum
- sed sit amet dui. Vivamus suscipit tortor eget felis porttitor volutpat. Praesent sapien massa, convallis a
- pellentesque nec, egestas non nisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere
- cubilia Curae; Donec velit neque, auctor sit amet aliquam vel, ullamcorper sit amet ligula.</p>
- <label for="">User Name</label>
- <input type="text" name="name" required placeholder="User Name">
-
- <label for="">Password <span class="error float-right">error message</span></label>
- <input type="password" name="password" required placeholder="Password" class="input__error">
-
-
- <label for="" class="disabled">Disabled label</label>
- <input type="text" name="IP" class="disabled" disabled placeholder="Disabled input">
- <input type="submit" value="Login" style="display: block;">
-
- <h2>Text Box</h2>
- <div>
- <label for="comments" class="">Comments</label>
- <textarea id="comments" class="" name="comment" type="textarea"></textarea>
- </div>
- <h2>Select Box</h2>
- <div>
- <label for="select" class="">Comments</label>
- <select id="select" class="" name="comment" type="select">
- <option>Option 1</option>
- <option>Option 2</option>
- <option>Option 3</option>
- </select>
- </div>
- <h2>Radio Buttons</h2>
- <div>
- <input id="radio-1" class="radio-custom" name="radio-group-1" type="radio">
- <label for="radio-1" class="radio-custom-label">First Choice</label>
- </div>
- <div>
- <input id="radio-2" class="radio-custom" name="radio-group-2" type="radio">
- <label for="radio-2" class="radio-custom-label">Second Choice</label>
- </div>
- <div>
- <input id="radio-3" class="radio-custom" name="radio-group-3" type="radio">
- <label for="radio-3" class="radio-custom-label">Third Choice</label>
- </div>
-
- <h2>Checkboxes</h2>
- <div>
- <input id="checkbox-1" class="checkbox-custom" name="checkbox-1" type="checkbox">
- <label for="checkbox-1" class="checkbox-custom-label">First Choice</label>
- </div>
- <div>
- <input id="checkbox-2" class="checkbox-custom" name="checkbox-2" type="checkbox">
- <label for="checkbox-2" class="checkbox-custom-label">Second Choice tortor eget felis porttitor volutpat. Praesent sapien massa, tortor eget felis porttitor volutpat. Praesent sapien massa,</label>
- </div>
- <div>
- <input id="checkbox-3" class="checkbox-custom" name="checkbox-3" type="checkbox">
- <label for="checkbox-3" class="checkbox-custom-label">Third Choice</label>
- </div>
-
- <div class="alert__error"> Alert<button class="close" aria-label="close">×</button></div>
- <div class="alert__warning"> Warning<button class="close" aria-label="close">×</button></div>
- <div class="alert__message"> Message<button class="close" aria-label="close">×</button></div>
- </form>
-</div>
-</body>
-<script src="js/app.min.js"></script>
-</html>
\ No newline at end of file
diff --git a/src/footer.html b/src/footer.html
deleted file mode 100644
index ec52c82..0000000
--- a/src/footer.html
+++ /dev/null
@@ -1 +0,0 @@
-<header>This is an external footer file!</header>
\ No newline at end of file
diff --git a/src/index.html b/src/index.html
deleted file mode 100644
index e623cd9..0000000
--- a/src/index.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE html>
-<html lang="en" ng-app="app">
-<head>
- <base href="/">
- <meta charset="UTF-8">
- <title>openBMC</title>
- <link rel="icon" href="favicon.ico?v=2"/>
- <link rel="stylesheet" href="css/main.css">
- <script src="js/vendor/vendor.min.js"></script>
-</head>
-<body ng-style="dataService.bodyStyle" ng-attr-id="{{dataService.path == '/login' ? 'login': ''}}">
-
-<app-header ng-if="dataService.showNavigation" path="dataService.path"></app-header>
-<app-navigation ng-if="dataService.showNavigation" path="dataService.path" show-navigation="dataService.showNavigation"></app-navigation>
-
-<main ng-view ng-class="{'content__container': dataService.path != '/login', 'login__wrapper': dataService.path == '/login'}">
-</main>
-
-<script src="js/app.min.js"></script>
-</body>
-</html>
diff --git a/src/js/app.js b/src/js/app.js
deleted file mode 100644
index 7ba15cd..0000000
--- a/src/js/app.js
+++ /dev/null
@@ -1,84 +0,0 @@
-angular
- .module('app', [
- 'ngRoute',
- 'app.directives',
- 'app.services',
- 'app.controllers'
- ])
- .config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider){
- $locationProvider.hashPrefix('');
- $routeProvider
- .when('/login', {
- 'templateUrl': 'login.html',
- 'controller': 'loginController',
- authenticated: false
- })
- .when('/power-operations', {
- 'templateUrl': 'power-operations.html',
- 'controller': 'powerOperationsController',
- authenticated: true
- })
- .when('/system-overview', {
- 'templateUrl': 'system-overview.html',
- 'controller': 'systemOverviewController',
- authenticated: true
- })
- .when('/unit-id', {
- 'templateUrl': 'unit-id.html',
- 'controller': 'unitIDController',
- authenticated: true
- })
- .when('/bmc-reboot', {
- 'templateUrl': 'bmc-reboot.html',
- 'controller': 'bmcRebootController',
- authenticated: true
- })
- .otherwise({
- 'redirectTo': '/login'
- });
- }])
- .config(['$httpProvider', function($httpProvider){
- //console.log($httpProvider.interceptors);
- $httpProvider.interceptors.push('apiInterceptor');
- }])
- .run(['$rootScope', '$location', 'dataService', 'userModel',
- function($rootScope, $location, dataService, userModel){
- $rootScope.dataService = dataService;
- dataService.path = $location.path();
- $rootScope.$on('$routeChangeStart', function(event, next, current){
-
- if(next.$$route == null || next.$$route == undefined) return;
-
- if(next.$$route.authenticated){
- if(!userModel.isLoggedIn()){
- $location.path('/login');
- }
- }
-
- if(next.$$route.originalPath == '/' ||
- next.$$route.originalPath == '/login'){
- if(userModel.isLoggedIn()){
- if(current){
- $location.path(current.$$route.originalPath);
- }else{
- $location.path('/system-overview');
- }
- }
- }
- });
- $rootScope.$on('$locationChangeSuccess', function(event){
- var path = $location.path();
- dataService.path = path;
- if(['/','/login','/logout'].indexOf(path) == -1){
- dataService.showNavigation = true;
- }else{
- dataService.showNavigation = false;
- }
- });
-
- $rootScope.$on('timedout-user', function(){
- sessionStorage.removeItem('LOGIN_ID');
- $location.path('/login');
- });
- }
- ]);
diff --git a/src/js/controllers.js b/src/js/controllers.js
deleted file mode 100644
index 03318e4..0000000
--- a/src/js/controllers.js
+++ /dev/null
@@ -1,153 +0,0 @@
- angular
- .module('app.controllers', [])
- .controller('loginController', ['$scope', '$window', 'APIUtils', 'dataService', 'userModel', function($scope, $window, APIUtils, dataService, userModel){
- $scope.dataService = dataService;
-
- $scope.tryLogin = function(username, password, event){
- if(event.keyCode === 13){
- $scope.login(username, password);
- }
- };
- $scope.login = function(username, password){
- $scope.error = false;
-
- if(!username || username == "" ||
- !password || password == ""){
- return false;
- }else{
- userModel.login(username, password, function(status, unreachable){
- if(status){
- $scope.$emit('user-logged-in',{});
- $window.location.hash = '#/system-overview';
- }else{
- if(!unreachable){
- $scope.error = true;
- }
- };
- });
- }
- }
- }])
- .controller('dashboardController', ['$scope', 'dataService', function($scope, dataService){
- $scope.dataService = dataService;
- }])
- .controller('systemOverviewController', ['$scope', 'dataService', function($scope, dataService){
- $scope.dataService = dataService;
- }])
- .controller('unitIDController', ['$scope', 'dataService', function($scope, dataService){
- $scope.dataService = dataService;
- }])
- .controller('bmcRebootController', ['$scope', 'dataService', function($scope, dataService){
- $scope.dataService = dataService;
- }])
- .controller('powerOperationsController', ['$scope', 'APIUtils', 'dataService', '$timeout', function($scope, APIUtils, dataService, $timeout){
- $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;
-
- //@TODO: call api and get proper state
- $scope.toggleState = function(){
- dataService.server_state = (dataService.server_state == 'Running') ? 'Off': 'Running';
- }
-
- $scope.togglePower = function(){
- var method = (dataService.server_state == 'Running') ? 'hostPowerOff' : 'hostPowerOn';
- //@TODO: show progress or set class orange
- APIUtils[method](function(response){
- //update state based on response
- //error case?
- if(response == null){
- console.log("Failed request.");
- }else{
- //@TODO::need to get the server status
- if(dataService.server_state == 'Running'){
- dataService.setPowerOffState();
- }else{
- dataService.setPowerOnState();
- }
- }
- });
- }
- $scope.powerOnConfirm = function(){
- if($scope.confirm) {
- return;
- }
- $scope.confirm = true;
- $scope.power_confirm = true;
- };
- $scope.warmReboot = function(){
- //@TODO:show progress
- dataService.setBootingState();
- APIUtils.hostPowerOff(function(response){
- if(response){
- APIUtils.hostPowerOn(function(response){
- if(response){
- dataService.setPowerOnState();
- }else{
- //@TODO:show error message
- }
- });
- }else{
- }
- });
- };
- $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.warmReboot();
- };
- $scope.coldRebootConfirm = function(){
- if($scope.confirm) {
- return;
- }
- $scope.confirm = true;
- $scope.coldboot_confirm = true;
- };
-
- $scope.orderlyShutdown = function(){
- //@TODO:show progress
- APIUtils.hostPowerOff(function(response){
- if(response){
- dataService.setPowerOffState();
- }else{
- //@TODO:hide progress & show error message
- }
- });
- };
- $scope.orderlyShutdownConfirm = function(){
- if($scope.confirm) {
- return;
- }
- $scope.confirm = true;
- $scope.orderly_confirm = true;
- };
-
- $scope.immediateShutdown = function(){
- $scope.orderlyShutdown();
- };
- $scope.immediateShutdownConfirm = function(){
- if($scope.confirm) {
- return;
- }
- $scope.confirm = true;
- $scope.immediately_confirm = true;
- };
- }]);
diff --git a/src/js/directives.js b/src/js/directives.js
deleted file mode 100644
index 801f67d..0000000
--- a/src/js/directives.js
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-angular
- .module('app.directives', [])
- .directive('appHeader', ['APIUtils', function(APIUtils){
-
- return {
- 'restrict': 'E',
- 'templateUrl': 'header.html',
- 'scope': {
- 'path': '='
- },
- 'controller': ['$rootScope', '$scope','dataService', 'userModel', '$location', function($rootScope, $scope, dataService, userModel, $location){
- $scope.dataService = dataService;
-
- $scope.loadServerStatus = function(){
-
- APIUtils.getHostState(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.setBootingState();
- }
- });
- }
- $scope.loadServerStatus();
-
- $scope.logout = function(){
- userModel.logout(function(status, error){
- if(status){
- $location.path('/logout');
- }else{
- console.log(error);
- }
- });
- }
-
- $scope.refresh = function(){
- $scope.loadServerStatus();
- }
-
- var loginListener = $rootScope.$on('user-logged-in', function(event, arg){
- $scope.loadServerStatus();
- });
-
- $scope.$on('$destroy', function(){
- loginListener();
- });
- }]
- };
- }])
- .directive('appNavigation', function(){
-
- return {
- 'restrict': 'E',
- 'templateUrl': 'navigation.html',
- 'scope': {
- 'path': '=',
- 'showNavigation': '='
- },
- 'controller': ['$scope', 'dataService', function($scope, dataService){
- $scope.$watch('showNavigation', function(){
- var padingTop = 0;
- $scope.firstLevel = 'overview';
- $scope.secondLevel = 'system_overview';
- if($scope.showNavigation){
- paddingTop = document.getElementById('header__wrapper').offsetHeight;
- }
- dataService.bodyStyle = {'padding-top': paddingTop + 'px'};
- $scope.navStyle = {'top': paddingTop + 'px'};
- });
- }]
- };
- })
- .directive('confirm', ['$timeout', function($timeout){
-
- return {
- 'restrict': 'E',
- 'templateUrl': '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();
- }
- }],
- link: function(scope, e) {
- scope.$watch('confirm', function(){
- if(scope.confirm){
- $timeout(function(){
- angular.element(e[0].parentNode).css({'min-height': e[0].querySelector('.power__confirm').offsetHeight + 'px'});
- }, 0);
- }else{
- angular.element(e[0].parentNode).css({'min-height': 0+ 'px'});
- }
- });
- }
- };
- }]);
diff --git a/src/js/services.js b/src/js/services.js
deleted file mode 100644
index 23bfffb..0000000
--- a/src/js/services.js
+++ /dev/null
@@ -1,379 +0,0 @@
-/**
-chassis
-/org/openbmc/control/chassis0 —> PowerOn ..PowerOff
-
-host reboot
-/org/openbmc/control/host0 —>reboot
-
-shutdown
-/org/openbmc/control/host0 —> shutdown
-**/
-angular
- .module('app.services', [])
- .service('apiInterceptor', ['$q', '$rootScope', 'dataService', function($q, $rootScope, dataService){
- return {
- 'request': function(config){
- dataService.server_unreachable = false;
- dataService.loading = true;
- return config;
- },
- 'response': function(response){
- dataService.loading = false;
- dataService.last_updated = new Date();
-
- if(response == null){
- dataService.server_unreachable = true;
- }
-
- if(response && response.status == 'error' &&
- dataService.path != '/login'){
- $rootScope.$emit('timedout-user', {});
- }
-
- return response;
- },
- 'responseError': function(rejection){
- dataService.server_unreachable = true;
- dataService.loading = false;
- return $q.reject(rejection);
- }
- };
- }])
- .service('Constants', function(){
- return {
- LOGIN_CREDENTIALS: {
- username: "test",
- password: "testpass",
- },
- API_CREDENTIALS: {
- host: 'https://9.3.164.147'
- },
- API_RESPONSE: {
- ERROR_STATUS: 'error',
- ERROR_MESSAGE: '401 Unauthorized',
- SUCCESS_STATUS: 'ok',
- SUCCESS_MESSAGE: '200 OK'
- },
- CHASSIS_POWER_STATE: {
- on: 'On',
- off: 'Off'
- },
- HOST_STATE_TEXT: {
- on: 'Running',
- off: 'Off',
- booting: 'Quiesced',
- unreachable: 'Unreachable'
- },
- HOST_STATE: {
- on: 1,
- off: -1,
- booting: 0,
- unreachable: -2
- }
- };
- })
- .service('dataService', ['Constants', function(Constants){
- this.app_version = "openBMC V.0.0.1";
- this.server_health = 'Error';
- this.server_state = 'Unreachable';
- this.server_status = -2;
- this.chassis_state = 'On';
- this.server_id = "Server 9.3.164.147";
- this.last_updated = new Date();
-
- this.loading = false;
- this.server_unreachable = false;
- this.loading_message = "";
- this.showNavigation = false;
- this.bodyStyle = {};
- this.path = '';
-
- this.setPowerOnState = function(){
- this.server_state = Constants.HOST_STATE_TEXT.on;
- this.server_status = Constants.HOST_STATE.on;
- },
-
- this.setPowerOffState = function(){
- this.server_state = Constants.HOST_STATE_TEXT.off;
- this.server_status = Constants.HOST_STATE.off;
- },
-
- this.setBootingState = function(){
- this.server_state = Constants.HOST_STATE_TEXT.booting;
- this.server_status = Constants.HOST_STATE.booting;
- },
-
- this.setUnreachableState = function(){
- this.server_state = Constants.HOST_STATE_TEXT.unreachable;
- this.server_status = Constants.HOST_STATE.unreachable;
- }
- }])
- .factory('APIUtils', ['$http', 'Constants', function($http, Constants){
- var SERVICE = {
- LOGIN_CREDENTIALS: Constants.LOGIN_CREDENTIALS,
- API_CREDENTIALS: Constants.API_CREDENTIALS,
- API_RESPONSE: Constants.API_RESPONSE,
- CHASSIS_POWER_STATE: Constants.CHASSIS_POWER_STATE,
- HOST_STATE_TEXT: Constants.HOST_STATE,
- HOST_STATE: Constants.HOST_STATE,
- getChassisState: function(callback){
- $http({
- method: 'GET',
- url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/chassis0",
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true
- }).success(function(response){
- var json = JSON.stringify(response);
- var content = JSON.parse(json);
- callback(content.data.CurrentPowerState);
- }).error(function(error){
- console.log(error);
- });
- },
- getHostState: function(callback){
- $http({
- method: 'GET',
- url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0",
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true
- }).success(function(response){
- var json = JSON.stringify(response);
- var content = JSON.parse(json);
- callback(content.data.CurrentHostState);
- }).error(function(error){
- console.log(error);
- });
- },
- login: function(username, password, callback){
- $http({
- method: 'POST',
- url: SERVICE.API_CREDENTIALS.host + "/login",
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true,
- data: JSON.stringify({"data": [username, password]})
- }).success(function(response){
- if(callback){
- callback(response);
- }
- }).error(function(error){
- if(callback){
- callback(null, true);
- }
- console.log(error);
- });
- },
- logout: function(callback){
- $http({
- method: 'POST',
- url: SERVICE.API_CREDENTIALS.host + "/logout",
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true,
- data: JSON.stringify({"data": []})
- }).success(function(response){
- if(callback){
- callback(response);
- }
- }).error(function(error){
- if(callback){
- callback(null, error);
- }
- console.log(error);
- });
- },
- chassisPowerOn: function(callback){
- $http({
- method: 'POST',
- url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0",
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true,
- data: JSON.stringify({"data": []})
- }).success(function(response){
- var json = JSON.stringify(response);
- var content = JSON.parse(json);
- if(callback){
- return callback(content.data.CurrentPowerState);
- }
- }).error(function(error){
- if(callback){
- callback(error);
- }else{
- console.log(error);
- }
- });
- },
- chassisPowerOff: function(callback){
- $http({
- method: 'POST',
- url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0",
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true,
- data: JSON.stringify({"data": []})
- }).success(function(response){
- var json = JSON.stringify(response);
- var content = JSON.parse(json);
- if(callback){
- return callback(content.data.CurrentPowerState);
- }
- }).error(function(error){
- if(callback){
- callback(error);
- }else{
- console.log(error);
- }
- });
- },
- hostPowerOn: function(callback){
- /**
- curl -c cjar -b cjar -k -H "Content-Type: application/json" -d
- "{\"data\": \"xyz.openbmc_project.State.Host.Transition.Off\"}"
- -X PUT
- https://9.3.164.147/xyz/openbmc_project/state/host0/attr/RequestedHostTransition
- **/
- $http({
- method: 'PUT',
- url: SERVICE.API_CREDENTIALS.host + "/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"})
- }).success(function(response){
- var json = JSON.stringify(response);
- var content = JSON.parse(json);
- if(callback){
- return callback(content.status);
- }
- }).error(function(error){
- if(callback){
- callback(error);
- }else{
- console.log(error);
- }
- });
- },
- hostPowerOff: function(callback){
- $http({
- method: 'PUT',
- url: SERVICE.API_CREDENTIALS.host + "/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"})
- }).success(function(response){
- var json = JSON.stringify(response);
- var content = JSON.parse(json);
- if(callback){
- return callback(content.status);
- }
- }).error(function(error){
- if(callback){
- callback(error);
- }else{
- console.log(error);
- }
- });
- },
- hostReboot: function(callback){
- $http({
- method: 'POST',
- url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0",
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true,
- data: JSON.stringify({"data": []}),
- }).success(function(response){
- var json = JSON.stringify(response);
- var content = JSON.parse(json);
- if(callback){
- return callback(content);
- }
- }).error(function(error){
- if(callback){
- callback(error);
- }else{
- console.log(error);
- }
- });
- },
- hostShutdown: function(callback){
- $http({
- method: 'POST',
- url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0",
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- withCredentials: true,
- data: JSON.stringify({"data": []})
- }).success(function(response){
- var json = JSON.stringify(response);
- var content = JSON.parse(json);
- if(callback){
- return callback(content);
- }
- }).error(function(error){
- if(callback){
- callback(error);
- }else{
- console.log(error);
- }
- });
- }
- };
- return SERVICE;
- }])
- .factory('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){
- sessionStorage.setItem('LOGIN_ID', username);
- callback(true);
- }else{
- callback(false, error);
- }
- });
- },
- isLoggedIn : function(){
- if(sessionStorage.getItem('LOGIN_ID') === null){
- return false;
- }
- return true;
- },
- logout : function(callback){
- APIUtils.logout(function(response, error){
- if(response &&
- response.status == APIUtils.API_RESPONSE.SUCCESS_STATUS){
- sessionStorage.removeItem('LOGIN_ID');
- callback(true);
- }else{
- callback(false, error);
- }
- });
- }
- };
- }]);
diff --git a/src/scss/components/_all.scss b/src/scss/components/_all.scss
deleted file mode 100644
index 016900c..0000000
--- a/src/scss/components/_all.scss
+++ /dev/null
@@ -1,5 +0,0 @@
-@import "systemUser";
-@import "login";
-@import "power-ops";
-@import "bmc-reboot";
-@import "uid-light";
\ No newline at end of file
diff --git a/src/scss/components/_systemUser.scss b/src/scss/components/_systemUser.scss
deleted file mode 100644
index beb96f0..0000000
--- a/src/scss/components/_systemUser.scss
+++ /dev/null
@@ -1,20 +0,0 @@
-#app-user {
- position: absolute;
- top: 50%;
- right: .8em;
- transform: translateY(-50%);
- .app-user__name {
- display: inline-block;
- position: relative;
-
- }
- &::before {
- content: "";
- display: inline-block;
- background: $white;
- height:20px;
- width: 20px;
- border-radius: 10px;
- vertical-align: middle;
- }
-}
diff --git a/src/scss/main.scss b/src/scss/main.scss
deleted file mode 100755
index 30249cf..0000000
--- a/src/scss/main.scss
+++ /dev/null
@@ -1,8 +0,0 @@
-//Import SCSS files
-@import 'base/all';
-@import 'utils/all';
-@import 'layout/all';
-@import 'elements/all';
-@import 'components/all';
-@import 'vendor/all';
-
diff --git a/src/scss/vendor/_all.scss b/src/scss/vendor/_all.scss
deleted file mode 100644
index e69de29..0000000
--- a/src/scss/vendor/_all.scss
+++ /dev/null