Clean code, add comment etc..
This commit is contained in:
parent
968eda48cc
commit
bb1598713c
7 changed files with 251 additions and 232 deletions
|
@ -4,23 +4,21 @@
|
|||
* @param {$scope} $scope The $scope service from angular
|
||||
*/
|
||||
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', function ($scope, Image, Loading, Identity)
|
||||
{
|
||||
{
|
||||
|
||||
var callbackTest=function(){
|
||||
$scope.images=Image.getData().images;
|
||||
Loading.stop();
|
||||
};
|
||||
// Update view
|
||||
var callMeAfterGetImage = function () {
|
||||
$scope.images = Image.getData().images;
|
||||
Loading.stop();
|
||||
};
|
||||
|
||||
|
||||
if(Identity.isAlreadyLogin()){
|
||||
|
||||
if(Image.getData().images==null){
|
||||
Loading.start();
|
||||
Image.getImages(callbackTest);
|
||||
}
|
||||
else{
|
||||
callbackTest();
|
||||
}
|
||||
|
||||
}
|
||||
}]);
|
||||
// If user is login try to retrieve data
|
||||
if (Identity.isAlreadyLogin()) {
|
||||
if (Image.getData().images == null) {
|
||||
Loading.start();
|
||||
Image.getImages(callMeAfterGetImage);
|
||||
} else {
|
||||
callMeAfterGetImage();
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
|
|
@ -3,58 +3,60 @@
|
|||
*
|
||||
* @param {$scope} $scope The $scope service from angular
|
||||
*/
|
||||
mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity,upload)
|
||||
{
|
||||
mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity, upload)
|
||||
{
|
||||
/*$scope.uploader = new FileUploader({
|
||||
"token" : Identity.getToken(),
|
||||
"task" : "image",
|
||||
'action':'uploadImage',
|
||||
'id':'6564'
|
||||
});
|
||||
$scope.uploader.url='../server/index.php'
|
||||
$scope.uploader.alias='file_name'
|
||||
$scope.uploader.formData={
|
||||
"token" : Identity.getToken(),
|
||||
"task" : "image",
|
||||
'action':'uploadImage',
|
||||
'id':'6564'
|
||||
}
|
||||
*/
|
||||
"token" : Identity.getToken(),
|
||||
"task" : "image",
|
||||
'action':'uploadImage',
|
||||
'id':'6564'
|
||||
});
|
||||
$scope.uploader.url='../server/index.php'
|
||||
$scope.uploader.alias='file_name'
|
||||
$scope.uploader.formData={
|
||||
"token" : Identity.getToken(),
|
||||
"task" : "image",
|
||||
'action':'uploadImage',
|
||||
'id':'6564'
|
||||
}
|
||||
*/
|
||||
|
||||
$scope.doUpload = function () {
|
||||
console.log($('#imageToUpload').prop('files')[0]);
|
||||
Image.uploadImage($('#imageToUpload').prop('files')[0], function(){alert("done")})
|
||||
/*$("#drop-area-div").dmUploader({
|
||||
extraData: {
|
||||
"token" : Identity.getToken(),
|
||||
"task" : "image",
|
||||
'action':'uploadImage',
|
||||
'id':'6564'},
|
||||
url:"../server/index.php"
|
||||
});
|
||||
*/
|
||||
|
||||
/*upload({
|
||||
url: '../server/index.php',
|
||||
method: 'POST',
|
||||
data: {
|
||||
"token" : Identity.getToken(),
|
||||
"task" : "image",
|
||||
'action':'uploadImage',
|
||||
'id':'6564',
|
||||
"file_name": $scope.myFile, // a jqLite type="file" element, upload() will extract all the files from the input and put them into the FormData object before sending.
|
||||
}
|
||||
}).then(
|
||||
function (response) {
|
||||
console.log(response.data); // will output whatever you choose to return from the server on a successful upload
|
||||
},
|
||||
function (response) {
|
||||
console.error(response); // Will return if status code is above 200 and lower than 300, same as $http
|
||||
}
|
||||
);*/
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.token=Identity.getToken();
|
||||
}]);
|
||||
$scope.doUpload = function () {
|
||||
console.log($('#imageToUpload').prop('files')[0]);
|
||||
Image.uploadImage($('#imageToUpload').prop('files')[0], function () {
|
||||
alert("done")
|
||||
})
|
||||
/*$("#drop-area-div").dmUploader({
|
||||
extraData: {
|
||||
"token" : Identity.getToken(),
|
||||
"task" : "image",
|
||||
'action':'uploadImage',
|
||||
'id':'6564'},
|
||||
url:"../server/index.php"
|
||||
});
|
||||
*/
|
||||
|
||||
/*upload({
|
||||
url: '../server/index.php',
|
||||
method: 'POST',
|
||||
data: {
|
||||
"token" : Identity.getToken(),
|
||||
"task" : "image",
|
||||
'action':'uploadImage',
|
||||
'id':'6564',
|
||||
"file_name": $scope.myFile, // a jqLite type="file" element, upload() will extract all the files from the input and put them into the FormData object before sending.
|
||||
}
|
||||
}).then(
|
||||
function (response) {
|
||||
console.log(response.data); // will output whatever you choose to return from the server on a successful upload
|
||||
},
|
||||
function (response) {
|
||||
console.error(response); // Will return if status code is above 200 and lower than 300, same as $http
|
||||
}
|
||||
);*/
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.token = Identity.getToken();
|
||||
}]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue