Add image name edition
This commit is contained in:
parent
c5e909da1b
commit
19d62a8cbf
3 changed files with 25 additions and 13 deletions
|
@ -3,25 +3,33 @@
|
||||||
*
|
*
|
||||||
* @param {$scope} $scope The $scope service from angular
|
* @param {$scope} $scope The $scope service from angular
|
||||||
*/
|
*/
|
||||||
mainApp.controller('editImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity, upload)
|
mainApp.controller('editImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', '$rootScope', function ($scope, Image, Loading, Identity, upload, $rootScope)
|
||||||
{
|
{
|
||||||
$scope.$on('editImageEvent', function (eventName, image, axioms) {
|
$scope.$on('editImageEvent', function (eventName, image, axioms) {
|
||||||
$scope.image = image;
|
$scope.image = image;
|
||||||
|
$scope.data = {};
|
||||||
|
$scope.data.id = image.id;
|
||||||
|
|
||||||
|
$scope.data.name = image.name;
|
||||||
|
$scope.data.visibility = image.visibility;
|
||||||
|
$scope.data.protected = image.protected;
|
||||||
|
|
||||||
$scope.axioms = axioms;
|
$scope.axioms = axioms;
|
||||||
$('#editImageModal').modal('show');
|
$('#editImageModal').modal('show');
|
||||||
});
|
});
|
||||||
$scope.data = {};
|
$scope.data = {};
|
||||||
$scope.data.visibility = "public";
|
|
||||||
$scope.data.protected = false;
|
|
||||||
|
$scope.applyEdition = function (id) {
|
||||||
$scope.applyEdition = function (image) {
|
Image.updateImage($scope.data, function () {
|
||||||
image.visibility = $scope.data.visibility;
|
$rootScope.$broadcast("updateImageEvent");
|
||||||
image.protected = $scope.data.protected;
|
$('#editImageModal').modal('hide');
|
||||||
Image.updateImage(image, function(){});
|
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.getToken=function(){
|
$scope.getToken = function () {
|
||||||
return Identity.getToken();
|
return Identity.getToken();
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
|
@ -63,11 +63,15 @@ mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) {
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
*/
|
*/
|
||||||
var updateImage = function (image, callback) {
|
var updateImage = function (image, callback) {
|
||||||
|
console.log(image)
|
||||||
|
|
||||||
|
|
||||||
var result = $http.post('../server/index.php',
|
var result = $http.post('../server/index.php',
|
||||||
$.param({"token": Identity.getToken(), "task": "image", 'action': 'updateImage', 'id': image.id, 'opt': image}));
|
$.param({"token": Identity.getToken(), "task": "image", 'action': 'updateImage', 'id': image.id, 'opt': {'name': image.name}}));
|
||||||
|
|
||||||
// Wait and handle the response
|
// Wait and handle the response
|
||||||
result.then(function (response) {
|
result.then(function (response) {
|
||||||
|
console.log(response.data.Images)
|
||||||
callback();
|
callback();
|
||||||
}, function (response) {
|
}, function (response) {
|
||||||
alert(response);
|
alert(response);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-sm-2">Name</label>
|
<label class="control-label col-sm-2">Name</label>
|
||||||
<div class="col-sm-20">
|
<div class="col-sm-20">
|
||||||
<input type="text" value="{{ image.name}}" />
|
<input type="text" ng-model="data.name" value="{{ image.name}}"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>-->
|
<!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>-->
|
||||||
|
|
||||||
<a class="btn btn-lg btn-primary btn-block" ng-click="applyEdition(image)" >Apply</a>
|
<a class="btn btn-lg btn-primary btn-block" ng-click="applyEdition(image.id)" >Apply</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue