diff options
| author | root <root@kabir-PC> | 2016-03-02 15:11:56 +0100 |
|---|---|---|
| committer | root <root@kabir-PC> | 2016-03-02 15:11:56 +0100 |
| commit | dac5c28a6795984a32687fe21c41783de2e85d8b (patch) | |
| tree | bb5b719f923b33e31d5a0880d1d50dbe49543e45 /client/js/controllers/home | |
| parent | 70fcf3553abb4a25672ee198dafb89e430e2bd79 (diff) | |
| parent | b6d7d2c30efe5e9758072bb82ea3a947bda7fd1d (diff) | |
Merge branch 'develop' of https://github.com/manzerbredes/istic-openstack into othmane
Diffstat (limited to 'client/js/controllers/home')
| -rw-r--r-- | client/js/controllers/home/machineDetails.js | 41 | ||||
| -rw-r--r-- | client/js/controllers/home/main.js | 31 |
2 files changed, 66 insertions, 6 deletions
diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js new file mode 100644 index 0000000..24fac42 --- /dev/null +++ b/client/js/controllers/home/machineDetails.js @@ -0,0 +1,41 @@ +/** + * The home controller + * + * @param {$scope} $scope The $scope service from angular + */ +mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$timeout', function ($scope, Compute, $rootScope, $timeout) +{ + + $scope.machine={}; + $("#waitingForToggleMachine").hide(); + + $scope.$on('showMachineDetailsEvent', function(eventName ,machine, axioms){ + $scope.machine=machine; + $scope.axioms=axioms; + console.log(machine); + $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); + }); + + + $scope.toggleMachineState=function(){ + $("#waitingForToggleMachine").show(); + + // Fake timeout + $timeout(function(){ + $("#waitingForToggleMachine").hide(); + }, 3000); + $timeout(function(){ + $scope.machine.online=!$scope.machine.online; + + }, 3000); + + + }; + + $scope.applyModifications=function(){ + //Todo + } + + + +}]); diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index d25bfad..f84f625 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -3,15 +3,34 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) +mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', function ($scope, Compute, $rootScope, Loading, Identity) { + var callMeAfterPullData=function(data){ + $scope.machines=Compute.getData().machines; + Loading.stop(); + } - var updatePage=function(){ - // TODO Update graph etc... + ; + if(Compute.getData().machines == null && Identity.isAlreadyLogin()){ + Loading.start(); + Compute.pullData(callMeAfterPullData); } - // Retrieve all Data - Compute.pullData(updatePage); - + + + + $scope.raiseShowMachineDetailsEvent=function(id){ + + var callback=function(){ + Loading.stop(); + var data=Compute.getData(); + $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms); + + } + Loading.start(); + Compute.pullMachines(callback); + } + + }]); |
