istic-openstack/client/js/controllers/home/machineDetails.js

49 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-02-28 16:07:52 +01:00
/**
* The home controller
*
* @param {$scope} $scope The $scope service from angular
*/
2016-04-17 18:50:05 +02:00
mainApp.controller('machineDetailsCtrl', ['$scope', 'Compute', '$rootScope', '$timeout', 'Identity', function ($scope, Compute, $rootScope, $timeout, Identity)
{
2016-02-28 16:07:52 +01:00
2016-03-20 11:23:06 +01:00
2016-04-17 18:50:05 +02:00
// Init scope
$scope.machine = {};
$scope.machineIsStarting = false; // For loading icon
2016-03-02 20:46:24 +01:00
2016-04-17 18:50:05 +02:00
// When we need to show details of machine
$scope.$on('showMachineDetailsEvent', function (eventName, machine, axioms) {
$scope.machine = machine;
2016-05-04 16:17:09 +02:00
// console.log(machine.flavor)
2016-04-17 18:50:05 +02:00
$scope.axioms = axioms;
$('#machineDetailsModal').modal({backdrop: false, keyboard: true});
});
2016-02-28 16:07:52 +01:00
2016-04-17 18:50:05 +02:00
// Try to stop or start a machine
$scope.toggleMachineState = function () {
// Display gif
$scope.machineIsStarting = true;
2016-02-28 16:07:52 +01:00
2016-04-17 18:50:05 +02:00
// Fake timeout
$timeout(function () {
$scope.machineIsStarting = false;
}, 3000);
$timeout(function () {
$scope.machine.online = !$scope.machine.online;
2016-02-28 16:07:52 +01:00
2016-04-17 18:50:05 +02:00
}, 3000);
2016-02-28 17:29:34 +01:00
2016-04-17 18:50:05 +02:00
};
2016-02-28 17:29:34 +01:00
2016-04-17 18:50:05 +02:00
// Apply modifications
$scope.applyModifications = function () {
//Todo
};
2016-02-28 17:29:34 +01:00
2016-05-04 20:19:06 +02:00
$scope.deleteMachine=function(){
2016-05-04 22:54:14 +02:00
Compute.deleteMachine(function(){Compute.pullData(function(){$rootScope.$broadcast("updateGraphEvent")});},$scope.machine.id);
2016-05-04 20:19:06 +02:00
}
2016-02-28 16:07:52 +01:00
2016-04-17 18:50:05 +02:00
}]);