Merge branch 'loic' into develop

This commit is contained in:
manzerbredes 2016-02-24 14:42:46 +01:00
commit 7676509fcd
4 changed files with 29 additions and 11 deletions

View file

@ -6,7 +6,6 @@
mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute)
{
var updatePage=function(){
// TODO Update graph etc...
}

View file

@ -20,7 +20,6 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s
$('#loadingLoginButton').hide();
$('#failedToLoginAlert').hide();
$scope.loginAction=function(){
// Begin login state for template

View file

@ -31,8 +31,8 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){
// Return services objects
return {
getMachines: getMachines
pullData: pullData
getMachines: getMachines,
pullData: pullData,
data:data
};

View file

@ -7,14 +7,17 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
var profile={};
profile.username=null;
profile.projectname=null;
profile.token=null;
var token={};
token.part_0=null;
token.part_1=null;
/**
* Save profile in cookies
*/
var saveCookieForSession=function(){
$cookies.putObject('profile', 5);
$cookies.putObject('profile', profile);
$cookies.putObject('token.part_0', token.part_0);
$cookies.putObject('token.part_1', token.part_1);
};
@ -23,10 +26,17 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
*/
var isAlreadyLogin=function(){
var profileInCookie=$cookies.getObject('profile');
console.log(profileInCookie);
var tokenPart_0InCookie=$cookies.getObject('token.part_0');
var tokenPart_1InCookie=$cookies.getObject('token.part_0');
if(typeof profileInCookie !== 'undefined'){
if(typeof profileInCookie !== 'undefined'
&& typeof tokenPart_0InCookie !== 'undefined'
&& typeof tokenPart_1InCookie !== 'undefined'
){
angular.extend(profile, profileInCookie);
token.part_0=tokenPart_0InCookie;
token.part_1=tokenPart_1InCookie;
return true;
}
@ -38,6 +48,8 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
*/
var logout=function(){
$cookies.remove('profile');
$cookies.remove('token.part_0');
$cookies.remove('token.part_1');
}
@ -56,7 +68,11 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
if (typeof response.data.token !== 'undefined') {
requestParserResult.status=0;
profile.token=response.data.token;
var middle=parseInt(response.data.token.length/2);
token.part_0=response.data.token.substring(0, middle);
token.part_1=response.data.token.substring(middle, response.data.token.length);
saveCookieForSession();
}
else if(failedToSendRequest){
@ -70,6 +86,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
};
var getToken=function(){
return token.part_0+token.part_1;
}
/**
* Function to connect to OpenStack
@ -104,7 +123,8 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
login: login,
profile: profile,
isAlreadyLogin: isAlreadyLogin,
logout:logout
logout:logout,
getToken:getToken
};