Add login check witouth reloading page
This commit is contained in:
parent
3216a69b75
commit
3c336f00d2
284 changed files with 141 additions and 31 deletions
|
@ -1,5 +1,5 @@
|
|||
|
||||
mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
|
||||
mainApp.factory('Identity',[ '$http', '$cookies', '$rootScope', function($http, $cookies, $rootScope){
|
||||
|
||||
/* Create profile structure to store informations
|
||||
* about current session
|
||||
|
@ -27,17 +27,20 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
|
|||
&& typeof tokenPart_1InCookie !== 'undefined'
|
||||
){
|
||||
|
||||
if(token!==null){
|
||||
//if(token!==null){
|
||||
// If yes, put it into variables
|
||||
angular.extend(profile, profileInCookie);
|
||||
token=tokenPart_0InCookie+tokenPart_1InCookie;
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
// Return I'm Login
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Show the login overlay
|
||||
$rootScope.$broadcast("logoutEvent");
|
||||
|
||||
// Return I'm not Login
|
||||
return false;
|
||||
}
|
||||
|
@ -56,7 +59,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
|
|||
profile.projectname=null;
|
||||
|
||||
// Reload Page
|
||||
location.reload();
|
||||
//location.reload();
|
||||
$rootScope.$broadcast("logoutEvent");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,17 +45,42 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){
|
|||
};
|
||||
|
||||
var uploadImage=function(fileToUpload, callback) {
|
||||
var form_data = new FormData();
|
||||
form_data.append('file', fileToUpload);
|
||||
console.log(fileToUpload)
|
||||
form_data.append("task" , "image")
|
||||
form_data.append("token" , Identity.getToken())
|
||||
form_data.append('action',"uploadImage")
|
||||
form_data.append('id','6564')
|
||||
form_data.append('file_name', fileToUpload.name);
|
||||
|
||||
$.ajax({
|
||||
url: "../server/index.php", // Url to which the request is send
|
||||
type: "POST", // Type of request to be send, called as method
|
||||
data: form_data, // Data sent to server, a set of key/value pairs (i.e. form fields and values)
|
||||
file_name:fileToUpload.name,
|
||||
token : Identity.getToken(),
|
||||
task : "image",
|
||||
action:'uploadImage',
|
||||
id:'6564',
|
||||
contentType: false, // The content type used when sending data to the server.
|
||||
cache: false, // To unable request pages to be cached
|
||||
processData:false, // To send DOMDocument or non processed data file it is set to false
|
||||
success: function(data) // A function to be called if request succeeds
|
||||
{
|
||||
alert("success")
|
||||
}
|
||||
});
|
||||
|
||||
var result=$http.post('../server/index.php',
|
||||
$.param({"token" : Identity.getToken(), "task" : "image", 'action':'uploadImage', 'filename':fileToUpload, 'id':'6564'}));
|
||||
//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){
|
||||
/* result.then(function (response){
|
||||
callback(parseUploadImageAnswer(response, false));
|
||||
},function(response){
|
||||
callback(parseUploadImageAnswer(response, true));
|
||||
});
|
||||
});*/
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue