blob: ea50bf373f69a56767e4f7772161c4f35bc5bc8d [file] [log] [blame]
Iftekharul Islam99d199f2017-03-24 15:28:25 -05001/**
2 * Controller for bmc-reboot
3 *
Iftekharul Islamcd789502017-04-19 14:37:55 -05004 * @module app/serverControl
Iftekharul Islam99d199f2017-03-24 15:28:25 -05005 * @exports bmcRebootController
6 * @name bmcRebootController
Iftekharul Islam99d199f2017-03-24 15:28:25 -05007 */
8
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07009window.angular && (function(angular) {
10 'use strict';
Iftekharul Islam99d199f2017-03-24 15:28:25 -050011
Andrew Geisslerd27bb132018-05-24 11:07:27 -070012 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;
beccabroekbfc99902018-07-24 15:36:33 -050017 APIUtils.getLastRebootTime().then(
18 function(data) {
19 $scope.reboot_time = data.data;
20 },
21 function(error) {
22 console.log(JSON.stringify(error));
23 });
Andrew Geisslerd27bb132018-05-24 11:07:27 -070024 $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 ]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -050040})(angular);