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

45 lines
942 B
JavaScript
Raw Normal View History

2016-02-06 12:10:04 +01:00
/**
* The home controller
*
* @param {$scope} $scope The $scope service from angular
2016-01-24 19:19:32 +01:00
*/
2016-03-06 14:42:50 +01:00
mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', 'Image', function ($scope, Compute, $rootScope, Loading, Identity, Image)
2016-01-24 19:19:32 +01:00
{
2016-03-01 22:50:37 +01:00
var callMeAfterPullData=function(data){
2016-03-01 20:51:08 +01:00
$scope.machines=Compute.getData().machines;
2016-03-20 11:23:06 +01:00
Loading.stop();
};
2016-03-06 14:42:50 +01:00
2016-02-28 20:30:57 +01:00
2016-03-01 20:51:08 +01:00
$scope.raiseShowMachineDetailsEvent=function(id){
2016-03-02 07:14:05 +01:00
2016-03-01 15:50:57 +01:00
var callback=function(){
2016-03-02 07:14:05 +01:00
Loading.stop();
2016-03-01 15:50:57 +01:00
var data=Compute.getData();
2016-03-01 22:50:37 +01:00
$rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms);
2016-03-20 11:23:06 +01:00
2016-03-01 15:50:57 +01:00
}
2016-03-02 07:14:05 +01:00
Loading.start();
2016-03-01 15:50:57 +01:00
Compute.pullMachines(callback);
2016-02-28 16:07:52 +01:00
}
2016-02-28 17:54:15 +01:00
2016-03-20 11:23:06 +01:00
if(Identity.isAlreadyLogin()){
2016-03-21 06:47:01 +01:00
if(Compute.getData().machines == null){
2016-03-20 11:23:06 +01:00
Loading.start();
Compute.pullData(callMeAfterPullData);
}
else{
if(Identity.isAlreadyLogin()){
callMeAfterPullData();
}
}
Image.getImages(function(){});
}
2016-02-18 18:06:06 +01:00
}]);