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', 'toastService',
14    function($scope, $window, APIUtils, dataService, toastService) {
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        APIUtils.bmcReboot().then(
32            function(response) {
33              toastService.success('BMC is rebooting.')
34            },
35            function(error) {
36              console.log(JSON.stringify(error));
37              toastService.error('Unable to reboot BMC.');
38            });
39      };
40    }
41  ]);
42})(angular);
43