2016-03-06 14:51:50 +01:00
|
|
|
/**
|
|
|
|
* The image controller
|
|
|
|
*
|
|
|
|
* @param {$scope} $scope The $scope service from angular
|
|
|
|
*/
|
2016-05-06 14:06:56 +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-05-06 14:06:56 +02:00
|
|
|
|
|
|
|
$scope.edit = function (image) {
|
2016-04-18 13:16:50 +02:00
|
|
|
$rootScope.$broadcast("editImageEvent", image, Image.getData().axioms);
|
2016-05-06 14:06:56 +02:00
|
|
|
|
2016-04-17 20:43:41 +02:00
|
|
|
}
|
2016-05-06 14:06:56 +02:00
|
|
|
|
|
|
|
$scope.showUploadImageModal = function () {
|
|
|
|
$rootScope.$broadcast("showUploadImageModalEvent");
|
|
|
|
|
|
|
|
};
|
2016-04-17 18:50:05 +02:00
|
|
|
}]);
|