1/**
2 * Controller for bmc-reboot
3 *
4 * @module app/serverControl
5 * @exports bmcRebootController
6 * @name bmcRebootController
7 */
8
9window.angular && (function(angular) {
10  'use strict';
11
12  angular.module('app.serverControl').controller('bmcRebootController', [
13    '$scope', '$window', 'APIUtils', 'dataService',
14    function($scope, $window, APIUtils, dataService) {
15      $scope.dataService = dataService;
16      $scope.confirm = false;
17      APIUtils.getLastRebootTime().then(
18          function(data) {
19            $scope.reboot_time = data.data;
20          },
21          function(error) {
22            console.log(JSON.stringify(error));
23          });
24      $scope.rebootConfirm = function() {
25        if ($scope.confirm) {
26          return;
27        }
28        $scope.confirm = true;
29      };
30      $scope.reboot = function() {
31        dataService.setUnreachableState();
32        APIUtils.bmcReboot(function(response) {
33          //@NOTE: using common event to reload server status, may be a better
34          // event listener name?
35          $scope.$emit('user-logged-in', {});
36        });
37      };
38    }
39  ]);
40})(angular);
41