Added host power on/off functionality to button.

Change-Id: I8942444c7686851c1cf2db9a6125654a5fa399d9
Signed-off-by: Iftekharul Islam <iislam@us.ibm.com>
diff --git a/src/header.html b/src/header.html
index 94beff5..2019c0e 100644
--- a/src/header.html
+++ b/src/header.html
@@ -10,8 +10,8 @@
     <div class="logo__wrapper"><img src="img/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__good">{{dataService.server_health}}</span></a>
-        <a href="#/power-operations" class="header__server-power" role="button">Server power<span ng-class="{'status-light__error': server_status == -1, 'status-light__disabled': server_status == 0, 'status-light__good': server_status == 1}">{{dataService.server_state}}</span></a>
+        <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>
         <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>
     </div>
diff --git a/src/js/controllers.js b/src/js/controllers.js
index 1b5df0f..1c2dd82 100644
--- a/src/js/controllers.js
+++ b/src/js/controllers.js
@@ -1,185 +1,158 @@
-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 {
-                if (userModel.login(username, password)) {
-                    $window.location.hash = '#/system-overview';
-                } else {
-                    $scope.error = true;
-                }
+ 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{
+            if(userModel.login(username, password)){
+                $window.location.hash = '#/system-overview';
+            }else{
+                $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;
-        $scope.bmcReboot_confirm = false;
+    }
+ }])
+ .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;
 
-        // BMC reboot
-        $scope.bmcReboot = function () {
-            //@TODO:show progress
-            APIUtils.bmcReboot(function (response) {
-                if (response) {
-                    //@TODO: set proper server state
-                } else {
-                    //@TODO:show error message
+    //@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();
                 }
-                //@TODO:hide progress
-            });
-        };
-        $scope.bmcRebootConfirm = function () {
-            if ($scope.confirm) {
-                return;
             }
-            $scope.confirm = true;
-            $scope.bmcReboot_confirm = true;
-        };
-    }])
-    .controller('powerOperationsController', ['$scope', 'APIUtils', 'dataService', function ($scope, APIUtils, dataService) {
-        $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 == 'On') ? 'Off' : 'On';
-        };
-
-        $scope.togglePower = function () {
-            var method = (dataService.server_state == 'On') ? 'chassisPowerOff' : 'chassisPowerOn';
-            //@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 {
-                    dataService.server_state = response;
-                }
-            });
+        });
+    }
+    $scope.powerOnConfirm = function(){
+        if($scope.confirm) {
+            return;
         }
-        $scope.powerOnConfirm = function () {
-            if ($scope.confirm) {
-                return;
+        $scope.confirm = true;
+        $scope.power_confirm = true;
+    };
+    $scope.warmReboot = function(){
+        //@TODO:show progress
+        dataService.loading = true;
+        APIUtils.hostPowerOff(function(response){
+            if(response){
+                dataService.setPowerOffState();
+                APIUtils.hostPowerOn(function(response){
+                    if(response){
+                        dataService.setPowerOnState();
+                    }else{
+                        //@TODO:show error message
+                    }
+                    //@TODO:hide progress, set proper server state
+                    dataService.loading = false;
+                });
+            }else{
+                //@TODO:hide progress & show error message
+                dataService.loading = false;
             }
-            $scope.confirm = true;
-            $scope.power_confirm = true;
-        };
-        $scope.warmReboot = function () {
-            //@TODO:show progress
-            APIUtils.hostPowerOff(function (response) {
-                if (response) {
-                    APIUtils.hostPowerOn(function (response) {
-                        if (response) {
+        });
+    };
+    $scope.testState = function(){
+        //@TODO:show progress
+        dataService.loading = true;
 
-                        } else {
-                            //@TODO:show error message
-                        }
-                        //@TODO:hide progress, set proper server state
-                    });
-                } else {
-                    //@TODO:hide progress & show error message
-                }
-            });
-        };
-        $scope.warmRebootConfirm = function () {
-            if ($scope.confirm) {
-                return;
+        $timeout(function(){
+            dataService.setPowerOffState();
+            $timeout(function(){
+                dataService.setPowerOnState();
+                dataService.loading = false;
+            }, 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
+        dataService.loading = true;
+        APIUtils.hostPowerOff(function(response){
+            if(response){
+                dataService.setPowerOffState();
+            }else{
+                //@TODO:hide progress & show error message
             }
-            $scope.confirm = true;
-            $scope.warmboot_confirm = true;
-        };
+            dataService.loading = false;
+        });
+    };
+    $scope.orderlyShutdownConfirm = function(){
+        if($scope.confirm) {
+            return;
+        }
+        $scope.confirm = true;
+        $scope.orderly_confirm = true;
+    };
 
-        $scope.coldReboot = function () {
-            //@TODO:show progress
-            APIUtils.chassisPowerOff(function (response) {
-                if (response) {
-                    APIUtils.chassisPowerOn(function (response) {
-                        if (response) {
-
-                        } else {
-                            //@TODO:show error message
-                        }
-                        //@TODO:hide progress, set proper server state
-                    });
-                } else {
-                    //@TODO:hide progress & show error message
-                }
-            });
-        };
-        $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) {
-                    APIUtils.chassisPowerOff(function (response) {
-                        if (response) {
-
-                        } else {
-                            //@TODO:show error message
-                        }
-                        //@TODO:hide progress, set proper server state
-                    });
-                } else {
-                    //@TODO:hide progress & show error message
-                }
-            });
-        };
-        $scope.orderlyShutdownConfirm = function () {
-            if ($scope.confirm) {
-                return;
-            }
-            $scope.confirm = true;
-            $scope.orderly_confirm = true;
-        };
-
-        $scope.immediateShutdown = function () {
-            //@TODO:show progress
-            APIUtils.chassisPowerOff(function (response) {
-                if (response) {
-                    //@TODO: set proper server state
-                } else {
-                    //@TODO:show error message
-                }
-                //@TODO:hide progress
-            });
-        };
-        $scope.immediateShutdownConfirm = function () {
-            if ($scope.confirm) {
-                return;
-            }
-            $scope.confirm = true;
-            $scope.immediately_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
index 79224f0..913d686 100644
--- a/src/js/directives.js
+++ b/src/js/directives.js
@@ -13,17 +13,23 @@
         'controller': ['$scope','dataService', 'userModel', '$location', function($scope, dataService, userModel, $location){
             $scope.server_status = 01;
             $scope.dataService = dataService;
-            APIUtils.login(function(){
-                APIUtils.getHostState(function(status){
-                    if(status == 'xyz.openbmc_project.State.Host.HostState.Off'){
-                        $scope.server_status = -1;
-                    }else if(status == 'xyz.openbmc_project.State.Host.HostState.Running'){
-                        $scope.server_status = 1;
-                    }else{
-                        $scope.server_status = 0;
-                    }
+
+            $scope.loadServerStatus = function(){
+                $scope.dataService.loading = true;
+                APIUtils.login(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();
+                        }
+                        dataService.loading = false;
+                    });
                 });
-            });
+            }
+            $scope.loadServerStatus();
 
             $scope.logout = function(){
                 userModel.logout();
@@ -31,7 +37,7 @@
             };
 
             $scope.refresh = function(){
-                console.log("--refresh status--");
+                $scope.loadServerStatus();
             }
         }]
     };
diff --git a/src/js/services.js b/src/js/services.js
index db44ae9..dbf8dc4 100644
--- a/src/js/services.js
+++ b/src/js/services.js
@@ -10,24 +10,46 @@
 **/
 angular
  .module('app.services', [])
- .service('dataService', function(){
+ .service('dataService', ['APIUtils', function(APIUtils){
     this.app_version = "openBMC V.0.0.1";
-    this.server_health = 'Good';
-    this.server_state = 'On';
+    this.server_health = 'Error';
+    this.server_state = 'Unreachable';
+    this.server_status = -2;
     this.chassis_state = 'On';
-    this.server_id = "Server BLZ_109284.209.01";
+    this.server_id = "Server 9.3.164.147";
     this.last_updated = new Date();
-
+    
+    this.loading = false;
+    this.loading_message = "";
     this.showNavigation = false;
     this.bodyStyle = {};
     this.path = '';
 
- })
+    this.setPowerOnState = function(){
+        this.server_state = APIUtils.HOST_STATE_TEXT.on;
+        this.server_status = APIUtils.HOST_STATE.on;
+    },
+
+    this.setPowerOffState = function(){
+        this.server_state = APIUtils.HOST_STATE_TEXT.off;
+        this.server_status = APIUtils.HOST_STATE.off;
+    },
+
+    this.setBootingState = function(){
+        this.server_state = APIUtils.HOST_STATE_TEXT.booting;
+        this.server_status = APIUtils.HOST_STATE.booting;
+    },
+
+    this.setUnreachableState = function(){
+        this.server_state = APIUtils.HOST_STATE_TEXT.unreachable;
+        this.server_status = APIUtils.HOST_STATE.unreachable;
+    }
+ }])
  .factory('APIUtils', ['$http', function($http){
     var SERVICE = {
         LOGIN_CREDENTIALS: {
-            username: "test",
-            password: "testpass",
+            username: "root",
+            password: "0penBmc",
         },
         API_CREDENTIALS: {
             user: 'root',
@@ -38,10 +60,17 @@
             on: 'On',
             off: 'Off'
         },
-        HOST_STATE: {
+        HOST_STATE_TEXT: {
             on: 'Running',
             off: 'Off',
-            booting: 'Quiesced'
+            booting: 'Quiesced',
+            unreachable: 'Unreachable'
+        },
+        HOST_STATE: {
+            on: 1,
+            off: -1,
+            booting: 0,
+            unreachable: -2
         },
         getChassisState: function(callback){
           $http({
@@ -144,20 +173,26 @@
           });
         },
         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: 'POST',
-            url: SERVICE.API_CREDENTIALS.host + "xyz/openbmc_project/state/host0/attr/RequestedHostTransition",
+            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"})
+            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.data.CurrentHostState);
+                    return callback(content.status);
                 }
           }).error(function(error){
             if(callback){
@@ -169,19 +204,19 @@
         },
         hostPowerOff: function(callback){
           $http({
-            method: 'POST',
-            url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/state/host0",
+            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": []}),
+            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.data.CurrentHostState);
+                    return callback(content.status);
                 }
           }).error(function(error){
             if(callback){
diff --git a/src/login.html b/src/login.html
index bad16f7..3525a61 100644
--- a/src/login.html
+++ b/src/login.html
@@ -10,12 +10,11 @@
         <div class="columns large-6 login__desc">
             <h1>OpenBMC Advanced System Management</h1>
             <ul class="login__server-info">
-                <li><p class="login__info-label">Build version</p><p>1.00.102</p></li>
-                <li><p class="login__info-label">Server ID</p><p>29000000166668</p></li>
-                <li><p class="login__info-label">Server model</p><p>Power SL-22LC</p></li>
-Add a comment to this line
+                <li><p class="login__info-label">Build version</p><p>X.XX.XXX</p></li>
+                <li><p class="login__info-label">Server ID</p><p>XXXXXXXXXXXXXXXX</p></li>
+                <li><p class="login__info-label">Server model</p><p>Power XX-XXXXX</p></li>
                 <!-- ping server to see if powered on. Change status-light and txt accordingly. Status message is planned to be hardcoded message were isplay via local JS.  -->
-                <li><p class="login__info-label">Server power</p><p class="status-light__good">On</p></li>
+                <li><p class="login__info-label">Server power</p><p class="status-light__disabled">Indeterminate</p></li>
                 <li><p class="login__info-label">Status message</p><!--<p>BMC was reset by user</p>--></li>
             </ul>
         </div>
diff --git a/src/power-operations.html b/src/power-operations.html
index a692ca5..adcdd0e 100644
--- a/src/power-operations.html
+++ b/src/power-operations.html
@@ -12,7 +12,7 @@
         </div>
     </div>
     <div class="row column">
-        <div id="power-indicator-bar" class="power__indicator-bar " ng-class="{'power__state-on': dataService.server_state == 'On', 'power__state-off': dataService.server_state == 'Off', 'power__state-indet' : dataService.server_state == 'Booting' }">
+        <div id="power-indicator-bar" class="power__indicator-bar" ng-class="{'power__state-on': dataService.server_state == 'Running', 'power__state-off': dataService.server_state == 'Off', 'power__state-indet': dataService.server_state == 'Quiesced'}">
             <p class="inline">{{dataService.server_id}}</p>
             <h3 class="power__state inline float-right h3"><span>{{dataService.server_state}}</span></h3>
         </div>
@@ -23,33 +23,33 @@
         </div>
 
         <!-- Power on displays only when server is shutdown -->
-        <div class="row column power-option" ng-hide="dataService.server_state == 'On'" ng-class="{disabled: confirm && !power_confirm, transitionAll: confirm && power_confirm}">
-            <button id="power__power-on" class="btn-secondary" ng-click="powerOnConfirm()" role="button"><img src="img/icon-power.svg" />Power On</button>
+        <div class="row column power-option" ng-hide="dataService.server_state == 'Running'" ng-class="{disabled: (confirm && !power_confirm) || dataService.loading, transitionAll: confirm && power_confirm}">
+            <button id="power__power-on" class="btn-secondary" ng-click="togglePower()" role="button">Power On</button>
             <p>Attempts to power on the server</p>
 
-            <confirm title="power on" message="Power on the server" confirm="power_confirm" callback="togglePower"></confirm>
+            <!---<confirm title="power off" message="Power off the server" confirm="power_confirm" ng-show="power_confirm" callback="togglePower"></confirm>-->
         </div>
 
         <!-- Power reboot/shutdown options : when server is off all of these are hidden. When one option is selected, the others are disabled. -->
-        <div class="row column power-option" ng-hide="dataService.server_state == 'Off'" ng-class="{disabled: confirm && !warmboot_confirm, transitionAll: confirm && warmboot_confirm}">
+        <div class="row column power-option" ng-hide="dataService.server_state == 'Off'" ng-class="{disabled: (confirm && !warmboot_confirm) || dataService.loading, transitionAll: confirm && warmboot_confirm}">
             <button id="power__warm-boot" class="btn-secondary" ng-click="warmRebootConfirm()" role="button"><i>&#x21BB</i> Warm reboot</button>
             <p>Attempts to perform an orderly shutdown before restarting the server</p>
-            <confirm title="Warm Reboot" message="perform an orderly shutdown" confirm="warmboot_confirm" callback="warmReboot"></confirm>
+            <confirm title="Warm Reboot" message="perform an orderly shutdown" confirm="warmboot_confirm" ng-show="warmboot_confirm" callback="warmReboot"></confirm>
         </div>
-        <div class="row column power-option" ng-hide="dataService.server_state == 'Off'" ng-class="{disabled: confirm && !coldboot_confirm, transitionAll: confirm && coldboot_confirm}">
+        <div class="row column power-option" ng-hide="dataService.server_state == 'Off'" ng-class="{disabled: (confirm && !coldboot_confirm) || dataService.loading, transitionAll: confirm && coldboot_confirm}">
             <button id="power__cold-boot" class="btn-secondary" ng-click="coldRebootConfirm()" role="button"><i>&#x21BB</i> Cold reboot</button>
             <p>Shuts down the server immediately, then restarts it</p>
-            <confirm title="Cold Reboot" message="Shutdown server immediately." confirm="coldboot_confirm" cancel="coldbootCancel" callback="toggleState"></confirm>
+            <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, transitionAll: confirm && orderly_confirm}">
+        <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>
             <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" cancel="orderlyShutdownCancel" callback="toggleState"></confirm>
+            <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, transitionAll: confirm && immediately_confirm}">
+        <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>
             <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" cancel="immediatelyShutdownCancel" callback="toggleState"></confirm>
+            <confirm title="Immediate shutdown" message="Removes power from the server immediately." confirm="immediately_confirm" ng-show="immediately_confirm" cancel="immediatelyShutdownCancel" callback="immediateShutdown"></confirm>
         </div>
     </div>
 </div>
\ No newline at end of file