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-05-05 13:51:18 +02:00
|
|
|
// Init scope
|
2016-04-17 18:50:05 +02:00
|
|
|
$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-05 13:51:18 +02:00
|
|
|
// console.log(machine.flavor)
|
2016-04-17 18:50:05 +02:00
|
|
|
$scope.axioms = axioms;
|
|
|
|
$('#machineDetailsModal').modal({backdrop: false, keyboard: true});
|
|
|
|
});
|
|
|
|
// Try to stop or start a machine
|
|
|
|
$scope.toggleMachineState = function () {
|
|
|
|
// Display gif
|
|
|
|
$scope.machineIsStarting = true;
|
|
|
|
// Fake timeout
|
|
|
|
$timeout(function () {
|
|
|
|
$scope.machineIsStarting = false;
|
|
|
|
}, 3000);
|
|
|
|
$timeout(function () {
|
|
|
|
$scope.machine.online = !$scope.machine.online;
|
|
|
|
}, 3000);
|
|
|
|
};
|
|
|
|
// Apply modifications
|
|
|
|
$scope.applyModifications = function () {
|
|
|
|
//Todo
|
|
|
|
};
|
2016-05-05 13:51:18 +02:00
|
|
|
$scope.deleteMachine = function () {
|
|
|
|
var call = function () {
|
|
|
|
Compute.pullData(function () {
|
|
|
|
$rootScope.$broadcast("updateGraphEvent");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-28 17:29:34 +01:00
|
|
|
|
2016-05-05 13:51:18 +02:00
|
|
|
Compute.deleteMachine(call, $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
|
|
|
}]);
|