Add status to image
This commit is contained in:
parent
43e76785f0
commit
664cddd4fa
6 changed files with 279 additions and 236 deletions
|
@ -4,7 +4,7 @@
|
|||
* @param {$scope} $scope The $scope service from angular
|
||||
*/
|
||||
mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'Identity', 'Image', function ($scope, Compute, $rootScope, Loading, Identity, Image)
|
||||
{
|
||||
{
|
||||
|
||||
graph = new joint.dia.Graph;
|
||||
paper = new joint.dia.Paper({
|
||||
|
@ -61,7 +61,7 @@ mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'I
|
|||
var cells = buildGraphFromAdjacencyList(vmList);
|
||||
|
||||
this.graph.addCells(cells);
|
||||
console.log(this.graph);
|
||||
//console.log(this.graph);
|
||||
var test = joint.layout.DirectedGraph.layout(this.graph, {
|
||||
etLinkVertices: false,
|
||||
//Top to bottom generation
|
||||
|
@ -199,4 +199,4 @@ mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'I
|
|||
});
|
||||
}
|
||||
}
|
||||
}]);
|
||||
}]);
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* @param {$scope} $scope The $scope service from angular
|
||||
*/
|
||||
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity','$rootScope', function ($scope, Image, Loading, Identity, $rootScope)
|
||||
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', '$rootScope', function ($scope, Image, Loading, Identity, $rootScope)
|
||||
{
|
||||
|
||||
// Update view
|
||||
|
@ -22,8 +22,13 @@ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity','$root
|
|||
}
|
||||
}
|
||||
|
||||
$scope.edit=function(image){
|
||||
$scope.edit = function (image) {
|
||||
$rootScope.$broadcast("editImageEvent", image, Image.getData().axioms);
|
||||
|
||||
}
|
||||
|
||||
$scope.showUploadImageModal = function () {
|
||||
$rootScope.$broadcast("showUploadImageModalEvent");
|
||||
|
||||
};
|
||||
}]);
|
||||
|
|
|
@ -22,10 +22,11 @@ mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity',
|
|||
*/
|
||||
|
||||
$scope.doUpload = function () {
|
||||
console.log($('#imageToUpload').prop('files')[0]);
|
||||
/* console.log($('#imageToUpload').prop('files')[0]);
|
||||
Image.uploadImage($('#imageToUpload').prop('files')[0], function () {
|
||||
alert("done")
|
||||
})
|
||||
alert("done");
|
||||
});*/
|
||||
Image.uploadImage("loic",function(){})
|
||||
/*$("#drop-area-div").dmUploader({
|
||||
extraData: {
|
||||
"token" : Identity.getToken(),
|
||||
|
@ -57,6 +58,11 @@ mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity',
|
|||
|
||||
|
||||
};
|
||||
|
||||
// Manager logout event
|
||||
$scope.$on('showUploadImageModalEvent', function () {
|
||||
$scope.token = Identity.getToken();
|
||||
|
||||
$('#uploadImageModal').modal("show");
|
||||
});
|
||||
|
||||
}]);
|
||||
|
|
|
@ -84,7 +84,7 @@ mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) {
|
|||
* @returns {undefined}
|
||||
*/
|
||||
var uploadImage = function (fileToUpload, callback) {
|
||||
var form_data = new FormData();
|
||||
/*var form_data = new FormData();
|
||||
form_data.append('file', fileToUpload);
|
||||
console.log(fileToUpload);
|
||||
form_data.append("task", "image");
|
||||
|
@ -109,19 +109,47 @@ mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) {
|
|||
{
|
||||
alert("success");
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
alert("send")
|
||||
var result = $http.post('../server/index.php',
|
||||
$.param({"token": Identity.getToken(), "task": "image", 'action': 'createImage', "opt": {"name": "loic"}}));
|
||||
|
||||
//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(parseUploadImageAnswer(response, false));
|
||||
},function(response){
|
||||
callback(parseUploadImageAnswer(response, true));
|
||||
});*/
|
||||
result.then(function (response) {
|
||||
//callback(parseUploadImageAnswer(response, false));
|
||||
alert(response.data)
|
||||
console.log(response.data)
|
||||
callback()
|
||||
}, function (response) {
|
||||
alert(response.data)
|
||||
callback()
|
||||
//callback(parseUploadImageAnswer(response, true));
|
||||
});
|
||||
};
|
||||
|
||||
var createImage = function (name,callback) {
|
||||
|
||||
|
||||
var result = $http.post('../server/index.php',
|
||||
$.param({"token": Identity.getToken(), "task": "image", 'action': 'createImage', "opt": {"name": name}}));
|
||||
|
||||
//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()
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
var getData = function (response) {
|
||||
return data;
|
||||
|
@ -132,6 +160,7 @@ mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) {
|
|||
getImages: getImages,
|
||||
updateImage: updateImage,
|
||||
getData: getData,
|
||||
createImage: createImage,
|
||||
uploadImage: uploadImage
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
<div class="btn-group btn-group-md" role="group" aria-label="...">
|
||||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#uploadImageModal">Upload</button>
|
||||
<button type="button" class="btn btn-default" ng-click="showUploadImageModal()">Upload</button>
|
||||
<button type="button" class="btn btn-default">Download</button>
|
||||
</div>
|
||||
<p></p>
|
||||
|
@ -16,6 +16,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Status</th>
|
||||
<th>Size</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
|
@ -23,6 +24,9 @@
|
|||
<tbody>
|
||||
<tr ng-repeat="image in images">
|
||||
<td>{{ image.name}}</td>
|
||||
<td ng-if="image.status == 'queued'"><font color="red">{{ image.status}}</font></td>
|
||||
<td ng-if="image.status != 'queued'"><font color="green">{{ image.status}}</font></td>
|
||||
|
||||
<td>{{ (image.size / 1048576).toFixed(2)}} MB</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-primary" ng-click="edit(image)">Edit</button>
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
</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 }}" />
|
||||
|
|
Loading…
Add table
Reference in a new issue