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