diff --git a/client/index.html b/client/index.html index 43659d0..d04955c 100755 --- a/client/index.html +++ b/client/index.html @@ -26,6 +26,7 @@
+
@@ -95,6 +96,8 @@ + + diff --git a/client/js/controllers/image/edit.js b/client/js/controllers/image/edit.js new file mode 100644 index 0000000..9bd4975 --- /dev/null +++ b/client/js/controllers/image/edit.js @@ -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(){}); + + }; + }]); diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index 28aeb55..d5034d3 100755 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -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); + + } }]); diff --git a/client/js/services/Image.js b/client/js/services/Image.js index 795f85e..90f3a48 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -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 }; diff --git a/client/partials/image/edit.html b/client/partials/image/edit.html new file mode 100644 index 0000000..4420f52 --- /dev/null +++ b/client/partials/image/edit.html @@ -0,0 +1,46 @@ + diff --git a/client/partials/image/image.html b/client/partials/image/image.html index 886a11d..9c17c2f 100644 --- a/client/partials/image/image.html +++ b/client/partials/image/image.html @@ -6,33 +6,36 @@
- -
- - -
-

- - - - - - - - - - - - - - - - -
NameSizeAction
{{ image.name }}{{ (image.size / 1048576).toFixed(2) }} MB
+ +
+ + +
+

+ + + + + + + + + + + + + + + + +
NameSizeAction
{{ image.name}}{{ (image.size / 1048576).toFixed(2)}} MB + + +
+ -
diff --git a/client/partials/image/upload.html b/client/partials/image/upload.html index 01c54b2..641646b 100644 --- a/client/partials/image/upload.html +++ b/client/partials/image/upload.html @@ -16,11 +16,12 @@ - + + - +