summaryrefslogtreecommitdiff
path: root/client/js/services
diff options
context:
space:
mode:
authorYoggzo <yogg@epsina.com>2016-03-08 17:30:26 +0100
committerYoggzo <yogg@epsina.com>2016-03-08 17:30:26 +0100
commit89f2c4ac8cd6b0f7766170d588eae2407124f8fc (patch)
tree6275b180b1c1f45caba3e84437119f784f5ebfba /client/js/services
parent66baa3ffc8bd119558eeb1e87cb05c6008df9d6f (diff)
parent3b569b6d008d5b1936ee04948cf5c1cc08790f39 (diff)
Merge branch 'develop' into Evan
Diffstat (limited to 'client/js/services')
-rw-r--r--client/js/services/Identity.js6
-rw-r--r--client/js/services/Image.js37
-rw-r--r--client/js/services/Loading.js15
3 files changed, 47 insertions, 11 deletions
diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js
index da85ecd..db93e97 100644
--- a/client/js/services/Identity.js
+++ b/client/js/services/Identity.js
@@ -1,5 +1,5 @@
-mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
+mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
/* Create profile structure to store informations
* about current session
@@ -51,6 +51,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
token=null;
profile.username=null;
profile.projectname=null;
+
+ // Reload Page
+ location.reload();
}
@@ -95,6 +98,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
else{
requestParserResult.failReason="Please check your username, password and project name !";
}
+
return requestParserResult;
};
diff --git a/client/js/services/Image.js b/client/js/services/Image.js
index 23b33a8..2e8c56f 100644
--- a/client/js/services/Image.js
+++ b/client/js/services/Image.js
@@ -1,27 +1,58 @@
mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){
+ var data={};
+ data.images=null;
var parseUploadImageAnswer=function(response, failedToSendRequest){
+
+ // Defined return object
+ var requestParserResult={};
+ requestParserResult.status=1;
+ requestParserResult.failReason=null;
+
+ if (typeof response.data.Images !== 'undefined') {
+ // Set status code
+ requestParserResult.status=0;
+ data.images=response.data.Images;
+
+ }
+ else if(failedToSendRequest){
+ requestParserResult.failReason="Failed to send request";
+ }
+ else{
+ requestParserResult.failReason="Error";
+ }
+ return requestParserResult;
};
var getImages=function(callback){
var result=$http.post('../server/index.php',
- $.param({"token" : Identity.profile.token, "task" : "Image"}));
+ $.param({"token" : Identity.getToken(), "task" : "image", 'action':'listImage'}));
+
+ // Wait and handle the response
+ result.then(function (response){
+ callback(parseUploadImageAnswer(response, false));
+ },function(response){
+ callback(parseUploadImageAnswer(response, true));
+ });
-
};
+ var getData=function(response){
+ return data;
+ };
// Return services objects
return {
- uploadImage: uploadImage
+ getImages:getImages,
+ getData:getData
};
diff --git a/client/js/services/Loading.js b/client/js/services/Loading.js
index b12aaa0..db06194 100644
--- a/client/js/services/Loading.js
+++ b/client/js/services/Loading.js
@@ -1,22 +1,23 @@
-mainApp.factory('Loading',[ '$http', 'Identity', function($http, Identity){
-
-
-
-
+mainApp.factory('Loading',[ function(){
+ /**
+ * Display Loading modal
+ */
var start=function(){
$('#loadingModal').modal({backdrop: 'static', keyboard: false});
};
+ /**
+ * Hide Loading modal
+ */
var stop=function(){
$('#loadingModal').modal('hide');
}
+ // Service returns
return {
start:start,
stop:stop
};
-
-
}]);