Merge branch 'loic-image-edition' into loic
This commit is contained in:
commit
9a93133272
7 changed files with 135 additions and 28 deletions
24
client/js/controllers/image/edit.js
Normal file
24
client/js/controllers/image/edit.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* The image controller
|
||||
*
|
||||
* @param {$scope} $scope The $scope service from angular
|
||||
*/
|
||||
mainApp.controller('editImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity, upload)
|
||||
{
|
||||
$scope.$on('editImageEvent', function (eventName, image, axioms) {
|
||||
$scope.image = image;
|
||||
$scope.axioms = axioms;
|
||||
$('#editImageModal').modal('show');
|
||||
console.log(image)
|
||||
});
|
||||
$scope.data = {};
|
||||
$scope.data.visibility = "public";
|
||||
$scope.data.protected = false;
|
||||
|
||||
$scope.applyEdition = function (image) {
|
||||
image.visibility = $scope.data.visibility;
|
||||
image.protected = $scope.data.protected;
|
||||
Image.updateImage(image, function(){});
|
||||
|
||||
};
|
||||
}]);
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* @param {$scope} $scope The $scope service from angular
|
||||
*/
|
||||
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', function ($scope, Image, Loading, Identity)
|
||||
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity','$rootScope', function ($scope, Image, Loading, Identity, $rootScope)
|
||||
{
|
||||
// Update view
|
||||
var callMeAfterGetImage = function () {
|
||||
|
@ -20,4 +20,9 @@ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', funct
|
|||
callMeAfterGetImage();
|
||||
}
|
||||
}
|
||||
|
||||
$scope.edit=function(image){
|
||||
$rootScope.$broadcast("editImageEvent", image, Image.getData().axioms);
|
||||
|
||||
}
|
||||
}]);
|
||||
|
|
|
@ -4,7 +4,9 @@ mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) {
|
|||
// Data object
|
||||
var data = {};
|
||||
data.images = null; // Images
|
||||
|
||||
data.axioms = {};
|
||||
data.axioms.protected = [true, false];
|
||||
data.axioms.visibility = ["public", "private"];
|
||||
/**
|
||||
* Parse uploadImage anwser
|
||||
* @param {type} response
|
||||
|
@ -53,6 +55,28 @@ mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Update image
|
||||
* @param {type} image
|
||||
* @param {type} callback
|
||||
* @returns {undefined}
|
||||
*/
|
||||
var updateImage = function (image, callback) {
|
||||
var result = $http.post('../server/index.php',
|
||||
$.param({"token": Identity.getToken(), "task": "image", 'action': 'updateImage', 'id': image.id, 'opt': image}));
|
||||
|
||||
// Wait and handle the response
|
||||
result.then(function (response) {
|
||||
callback();
|
||||
}, function (response) {
|
||||
alert(response)
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Upload an image
|
||||
* @param {type} fileToUpload
|
||||
|
@ -106,6 +130,7 @@ mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) {
|
|||
// Return services objects
|
||||
return {
|
||||
getImages: getImages,
|
||||
updateImage: updateImage,
|
||||
getData: getData,
|
||||
uploadImage: uploadImage
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue