summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic GUEGAN <loic@Manzerbredes.home>2016-04-20 09:10:02 +0200
committerLoic GUEGAN <loic@Manzerbredes.home>2016-04-20 09:10:02 +0200
commit7a587387aab354e8101dc04ee54c78ab4b036617 (patch)
tree3edaa3f4da03ad0999d258402ab4d4813c2494ce
parent5b5f526aa0cce998657c0c4569686ba356ddb77d (diff)
Debug
-rw-r--r--client/js/controllers/image/edit.js14
-rw-r--r--client/js/services/Image.js30
-rw-r--r--client/partials/image/edit.html8
3 files changed, 43 insertions, 9 deletions
diff --git a/client/js/controllers/image/edit.js b/client/js/controllers/image/edit.js
index bab4064..14c1949 100644
--- a/client/js/controllers/image/edit.js
+++ b/client/js/controllers/image/edit.js
@@ -5,10 +5,20 @@
*/
mainApp.controller('editImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity, upload)
{
- $scope.$on('editImageEvent', function (eventName, image,axioms) {
+ $scope.$on('editImageEvent', function (eventName, image, axioms) {
$scope.image = image;
- $scope.axioms=axioms;
+ $scope.axioms = axioms;
$('#editImageModal').modal('show');
console.log(image)
});
+ $scope.data = {};
+ $scope.data.visibility = "public";
+ $scope.data.protected = false;
+
+ $scope.updateImage = function (image) {
+ image.visibility = $scope.data.visibility;
+ image.protected = $scope.data.protected;
+ Image.updateImage(image, function(){});
+
+ };
}]);
diff --git a/client/js/services/Image.js b/client/js/services/Image.js
index 190bbb6..4dc835e 100644
--- a/client/js/services/Image.js
+++ b/client/js/services/Image.js
@@ -4,9 +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"];
+ data.axioms = {};
+ data.axioms.protected = [true, false];
+ data.axioms.visibility = ["public", "private"];
/**
* Parse uploadImage anwser
* @param {type} response
@@ -56,6 +56,29 @@ 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
* @param {type} callback
@@ -108,6 +131,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
index 1200bcd..32c6958 100644
--- a/client/partials/image/edit.html
+++ b/client/partials/image/edit.html
@@ -15,20 +15,20 @@
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="control-label col-sm-2">Name</label>
- <div class="col-sm-10">
+ <div class="col-sm-20">
<p class="form-control-static">{{ image.name}}</p>
</div>
</div>
<fieldset class="form-group">
<label class="control-label col-sm-2">Visibility</label>
- <select class="col-sm-20" id="visibilitySelected">
+ <select class="col-sm-20" id="visibilitySelected" ng-model="data.visibility">
<option ng-repeat="visibility in axioms.visibility" ng-selected="image.visibility == visibility">{{ visibility}}</option>
</select>
</fieldset>
<fieldset class="form-group">
<label class="control-label col-sm-2">Protected</label>
- <select class="col-sm-20" id="protectedSelected">
+ <select class="col-sm-20" id="protectedSelected" ng-model="data.protected">
<option ng-repeat="protected in axioms.protected" ng-selected="image.protected == protected">{{ protected}}</option>
</select>
</fieldset>
@@ -37,7 +37,7 @@
<div class="modal-footer">
<!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>-->
- <a class="btn btn-lg btn-primary btn-block" data-dismiss="modal" >Apply</a>
+ <a class="btn btn-lg btn-primary btn-block" ng-click="updateImage(image)" >Apply</a>
</div>
</div>