Add image creation and suppression
This commit is contained in:
parent
664cddd4fa
commit
2856a776db
9 changed files with 107 additions and 47 deletions
|
@ -26,7 +26,7 @@
|
|||
<div ng-include="'./partials/home/machineDetails.html'"></div>
|
||||
<div ng-include="'./partials/home/machineCreation.html'"></div>
|
||||
<div ng-include="'./partials/loading.html'"></div>
|
||||
<div ng-include="'./partials/image/upload.html'"></div>
|
||||
<div ng-include="'./partials/image/create.html'"></div>
|
||||
<div ng-include="'./partials/image/edit.html'"></div>
|
||||
|
||||
|
||||
|
@ -97,7 +97,7 @@
|
|||
<script src="./js/controllers/home/machineCreation.js"></script>
|
||||
<script src="./js/controllers/network/network.js"></script>
|
||||
<script src="./js/controllers/image/image.js"></script>
|
||||
<script src="./js/controllers/image/upload.js"></script>
|
||||
<script src="./js/controllers/image/create.js"></script>
|
||||
<script src="./js/controllers/image/edit.js"></script>
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* @param {$scope} $scope The $scope service from angular
|
||||
*/
|
||||
mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity, upload)
|
||||
mainApp.controller('createImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload','$rootScope', function ($scope, Image, Loading, Identity, upload, $rootScope)
|
||||
{
|
||||
/*$scope.uploader = new FileUploader({
|
||||
"token" : Identity.getToken(),
|
||||
|
@ -22,11 +22,11 @@ mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity',
|
|||
*/
|
||||
|
||||
$scope.doUpload = function () {
|
||||
/* console.log($('#imageToUpload').prop('files')[0]);
|
||||
Image.uploadImage($('#imageToUpload').prop('files')[0], function () {
|
||||
alert("done");
|
||||
});*/
|
||||
Image.uploadImage("loic",function(){})
|
||||
/* console.log($('#imageToUpload').prop('files')[0]);
|
||||
Image.uploadImage($('#imageToUpload').prop('files')[0], function () {
|
||||
alert("done");
|
||||
});*/
|
||||
Image.uploadImage("loic", function () {})
|
||||
/*$("#drop-area-div").dmUploader({
|
||||
extraData: {
|
||||
"token" : Identity.getToken(),
|
||||
|
@ -59,10 +59,22 @@ mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity',
|
|||
|
||||
};
|
||||
// Manager logout event
|
||||
$scope.$on('showUploadImageModalEvent', function () {
|
||||
$scope.token = Identity.getToken();
|
||||
$scope.$on('showCreateImageModalEvent', function () {
|
||||
$scope.token = Identity.getToken();
|
||||
|
||||
$('#uploadImageModal').modal("show");
|
||||
$('#createImageModal').modal("show");
|
||||
});
|
||||
|
||||
var callMeAfterImageCreate = function (response) {
|
||||
$rootScope.$broadcast("updateImageEvent");
|
||||
Loading.stop();
|
||||
|
||||
}
|
||||
|
||||
$scope.doCreation = function () {
|
||||
$('#createImageModal').modal("hide");
|
||||
Loading.start();
|
||||
Image.createImage($scope.name, callMeAfterImageCreate)
|
||||
};
|
||||
|
||||
}]);
|
|
@ -9,7 +9,6 @@ mainApp.controller('editImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', '
|
|||
$scope.image = image;
|
||||
$scope.axioms = axioms;
|
||||
$('#editImageModal').modal('show');
|
||||
console.log(image)
|
||||
});
|
||||
$scope.data = {};
|
||||
$scope.data.visibility = "public";
|
||||
|
|
|
@ -22,13 +22,29 @@ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', '$roo
|
|||
}
|
||||
}
|
||||
|
||||
// Manager logout event
|
||||
$scope.$on('updateImageEvent', function () {
|
||||
// If user is login try to retrieve data
|
||||
if (Identity.isAlreadyLogin()) {
|
||||
Loading.start();
|
||||
Image.getImages(callMeAfterGetImage);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.edit = function (image) {
|
||||
$rootScope.$broadcast("editImageEvent", image, Image.getData().axioms);
|
||||
|
||||
}
|
||||
|
||||
$scope.showUploadImageModal = function () {
|
||||
$rootScope.$broadcast("showUploadImageModalEvent");
|
||||
$scope.showCreateImageModal = function () {
|
||||
$rootScope.$broadcast("showCreateImageModalEvent");
|
||||
|
||||
};
|
||||
|
||||
$scope.deleteImage = function (id) {
|
||||
Image.deleteImage(id, function () {
|
||||
$rootScope.$broadcast("updateImageEvent");
|
||||
|
||||
})
|
||||
}
|
||||
}]);
|
||||
|
|
|
@ -148,6 +148,23 @@ mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) {
|
|||
callback()
|
||||
});
|
||||
};
|
||||
var deleteImage = function (id,callback) {
|
||||
|
||||
|
||||
var result = $http.post('../server/index.php',
|
||||
$.param({"token": Identity.getToken(), "task": "image", 'action': 'deleteImage', "id":id}));
|
||||
|
||||
//var result=$http.post('../server/index.php',
|
||||
// $.param({"token" : Identity.getToken(), "task" : "image", 'action':'uploadImage', 'file_name':form_data, 'id':'6564'}));
|
||||
|
||||
// Wait and handle the response
|
||||
result.then(function (response) {
|
||||
callback()
|
||||
}, function (response) {
|
||||
alert(response.data)
|
||||
callback()
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -160,6 +177,7 @@ mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) {
|
|||
getImages: getImages,
|
||||
updateImage: updateImage,
|
||||
getData: getData,
|
||||
deleteImage:deleteImage,
|
||||
createImage: createImage,
|
||||
uploadImage: uploadImage
|
||||
};
|
||||
|
|
33
client/partials/image/create.html
Normal file
33
client/partials/image/create.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
<div class="modal fade" id="createImageModal" ng-controller="createImageCtrl">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content"></div>
|
||||
</div>
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>-->
|
||||
<h4 class="modal-title">Upload Image</h4>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal" role="form">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2">Name</label>
|
||||
<div class="col-sm-20">
|
||||
<input ng-model="name" type="text" value="" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<div class="modal-footer">
|
||||
<!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>-->
|
||||
|
||||
<a class="btn btn-lg btn-primary btn-block" id="loginButton" ng-click="doCreation()">Create</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -34,6 +34,19 @@
|
|||
</fieldset>
|
||||
|
||||
</form>
|
||||
<form action="../server/index.php" method="post">
|
||||
<input type="hidden" name="task" value="image" />
|
||||
<input type="hidden" name="token" value="{{ token}}" />
|
||||
<input type="hidden" name="action" value="uploadImage" />
|
||||
<input type="hidden" name="id" value="60ed9403-419e-4ea8-933f-dd1750d97360" />
|
||||
<input type="hidden" name="file_name" value="bob.iso" />
|
||||
<fieldset class="form-group">
|
||||
<label class="control-label col-sm-2">Upload</label>
|
||||
<input name="file" type="file" />
|
||||
<input type="submit" value="Upload" />
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
<div class="modal-footer">
|
||||
<!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>-->
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
<div class="btn-group btn-group-md" role="group" aria-label="...">
|
||||
<button type="button" class="btn btn-default" ng-click="showUploadImageModal()">Upload</button>
|
||||
<button type="button" class="btn btn-default" ng-click="showCreateImageModal()">Create Image</button>
|
||||
<button type="button" class="btn btn-default">Download</button>
|
||||
</div>
|
||||
<p></p>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<td>{{ (image.size / 1048576).toFixed(2)}} MB</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-primary" ng-click="edit(image)">Edit</button>
|
||||
<button type="button" class="btn btn-danger">Remove</button>
|
||||
<button type="button" class="btn btn-danger" ng-click="deleteImage(image.id)">Remove</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<div class="modal fade" id="uploadImageModal" ng-controller="uploadImageCtrl">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content"></div>
|
||||
</div>
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>-->
|
||||
<h4 class="modal-title">Upload Image</h4>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<form action="../server/index.php" method="post">
|
||||
<input type="hidden" name="task" value="image" />
|
||||
<input type="hidden" name="token" value="{{ token }}" />
|
||||
<input type="hidden" name="action" value="uploadImage" />
|
||||
<input type="hidden" name="id" value="60ed9403-419e-4ea8-933f-dd1750d97360" />
|
||||
<input type="hidden" name="file_name" value="bob.iso" />
|
||||
<input name="file" type="file" />
|
||||
<input type="submit" value="Upload" />
|
||||
</form>
|
||||
|
||||
<div class="modal-footer">
|
||||
<!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>-->
|
||||
|
||||
<a class="btn btn-lg btn-primary btn-block" id="loginButton" ng-click="doUpload()">Upload</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Add table
Reference in a new issue