summaryrefslogtreecommitdiff
path: root/client/js/controllers/home/machineCreation.js
blob: aa488af5f94294283f395c58d7619a444fb57d8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
 * The home controller
 * 
 * @param {$scope} $scope The $scope service from angular
 */
mainApp.controller('machineCreationCtrl', ['$scope', 'Compute', '$rootScope', '$timeout', 'Identity', function ($scope, Compute, $rootScope, $timeout, Identity)
    {

        $scope.name = "";
        $('#pleaseChooseAnImage').hide();
        // When we need to show details of machine
        $scope.$on('showMachineCreationEvent', function (eventName, axioms) {
            $scope.axioms = axioms;
            $('#machineCreationModal').modal({backdrop: false, keyboard: true});
        });

        var callMeAfterMachineCreation=function(response){
            Compute.pullData(function(){$rootScope.$broadcast("updateGraphEvent")});
        };

        $scope.createMachine = function () {
            if ($scope.selectedImage == null) {
                $('#pleaseChooseAnImage').show();
            } else {
                $('#pleaseChooseAnImage').hide();
                $('#machineCreationModal').modal("hide");

                machine = {}
                machine.name = $scope.name
                machine.flavorId = 1
                machine.imageId = $scope.selectedImage

                
                Compute.createMachine(callMeAfterMachineCreation, machine)
                $scope.name="";

            }
        };

    }]);