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

30 lines
881 B
JavaScript
Raw Normal View History

2016-03-06 14:51:50 +01:00
/**
* The image controller
*
* @param {$scope} $scope The $scope service from angular
*/
2016-04-17 20:43:41 +02:00
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity','$rootScope', function ($scope, Image, Loading, Identity, $rootScope)
2016-04-17 18:50:05 +02:00
{
2016-04-27 19:18:34 +02:00
2016-04-17 18:50:05 +02:00
// Update view
var callMeAfterGetImage = function () {
$scope.images = Image.getData().images;
Loading.stop();
};
2016-03-06 15:04:47 +01:00
2016-04-17 18:50:05 +02:00
// If user is login try to retrieve data
if (Identity.isAlreadyLogin()) {
if (Image.getData().images == null) {
Loading.start();
Image.getImages(callMeAfterGetImage);
} else {
callMeAfterGetImage();
}
}
2016-04-17 20:43:41 +02:00
$scope.edit=function(image){
2016-04-18 13:16:50 +02:00
$rootScope.$broadcast("editImageEvent", image, Image.getData().axioms);
2016-04-17 20:43:41 +02:00
}
2016-04-17 18:50:05 +02:00
}]);