From c511010ec41e57d99d1756780ee968269fa2b8fb Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 24 Feb 2016 14:39:47 +0100 Subject: Manager session cookie OK ! --- client/js/controllers/home/main.js | 1 - client/js/controllers/login.js | 1 - client/js/services/Compute.js | 4 ++-- client/js/services/Identity.js | 34 +++++++++++++++++++++++++++------- 4 files changed, 29 insertions(+), 11 deletions(-) (limited to 'client') diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index d25bfad..27de5f3 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -6,7 +6,6 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) { - var updatePage=function(){ // TODO Update graph etc... } diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 829fc1d..a37591c 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -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 diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index c5c8da9..70359ee 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -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 }; diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 8ee664c..0dfba47 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -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 }; -- cgit v1.2.3 From 211ebb0e432b5fee2031dd6e7338e659146867bb Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 24 Feb 2016 15:02:14 +0100 Subject: Simplify Identity --- client/js/controllers/login.js | 7 ++++++- client/js/controllers/status.js | 2 +- client/js/services/Identity.js | 46 +++++++++++++++++++++++++++-------------- 3 files changed, 37 insertions(+), 18 deletions(-) (limited to 'client') diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index a37591c..66d1793 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -13,13 +13,18 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s if(!Identity.isAlreadyLogin()){ $('#loginModal').modal({backdrop: 'static', keyboard: false}); } + + // Manager logout event $scope.$on('logoutEvent', function(){ $('#loginModal').modal({backdrop: 'static', keyboard: false}); }); - + + // Hide loading button and message alert $('#loadingLoginButton').hide(); $('#failedToLoginAlert').hide(); + + // Defined function for login $scope.loginAction=function(){ // Begin login state for template diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index e01df34..5ec6fa8 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -10,7 +10,7 @@ mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($ { // Give profile to model - $scope.profile=Identity.profile; + $scope.profile=Identity.getProfile(); // Function to logout $scope.logout=function(){ diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 0dfba47..2042efd 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -7,10 +7,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ var profile={}; profile.username=null; profile.projectname=null; - var token={}; - token.part_0=null; - token.part_1=null; + var token=null; + /** * Save profile in cookies */ @@ -27,7 +26,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ var isAlreadyLogin=function(){ var profileInCookie=$cookies.getObject('profile'); var tokenPart_0InCookie=$cookies.getObject('token.part_0'); - var tokenPart_1InCookie=$cookies.getObject('token.part_0'); + var tokenPart_1InCookie=$cookies.getObject('token.part_1'); if(typeof profileInCookie !== 'undefined' @@ -35,14 +34,29 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ && typeof tokenPart_1InCookie !== 'undefined' ){ angular.extend(profile, profileInCookie); - token.part_0=tokenPart_0InCookie; - token.part_1=tokenPart_1InCookie; + token=tokenPart_0InCookie+tokenPart_1InCookie; + return true; } return false; } + + /* + * Get the profile + */ + var getProfile=function(){ + return profile; + } + + /* + * Get the token + */ + var getToken=function(){ + return token; + } + /* * Destroy profile cookies */ @@ -67,13 +81,18 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ requestParserResult.failReason=null; if (typeof response.data.token !== 'undefined') { + // Set status code requestParserResult.status=0; + // Find the middle of the token to split it 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(); + + // Save profile + $cookies.putObject('profile', profile); + // Save first part of token + $cookies.putObject('token.part_0', response.data.token.substring(0, middle)); + // Save second part of token + $cookies.putObject('token.part_1', response.data.token.substring(middle, response.data.token.length)); } else if(failedToSendRequest){ requestParserResult.failReason="Failed to send request"; @@ -84,11 +103,6 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ return requestParserResult; }; - - - var getToken=function(){ - return token.part_0+token.part_1; - } /** * Function to connect to OpenStack @@ -121,7 +135,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ // Return services objects return { login: login, - profile: profile, + getProfile: getProfile, isAlreadyLogin: isAlreadyLogin, logout:logout, getToken:getToken -- cgit v1.2.3 From 5d8b904a328c87c533231ebf6ba68965256a035f Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 24 Feb 2016 15:22:10 +0100 Subject: Change logout event --- client/js/controllers/login.js | 1 + client/js/controllers/status.js | 4 +--- client/partials/nav.html | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 66d1793..1a89563 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -16,6 +16,7 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s // Manager logout event $scope.$on('logoutEvent', function(){ + Identity.logout(); $('#loginModal').modal({backdrop: 'static', keyboard: false}); }); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 5ec6fa8..940d794 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -13,10 +13,8 @@ mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($ $scope.profile=Identity.getProfile(); // Function to logout - $scope.logout=function(){ - Identity.logout(); + $scope.raiseLogoutEvent=function(){ $rootScope.$broadcast('logoutEvent'); - }; }]); diff --git a/client/partials/nav.html b/client/partials/nav.html index 3c72844..b3ef76a 100644 --- a/client/partials/nav.html +++ b/client/partials/nav.html @@ -32,7 +32,7 @@
  • Informations
  • Settings
  • -
  • Logout
  • +
  • Logout
  • -- cgit v1.2.3 From fa77d200c525d0c53118d5d4d60758880e9ca11c Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 24 Feb 2016 16:16:19 +0100 Subject: Add expire time and remove useless function --- client/js/services/Identity.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'client') diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 2042efd..7604230 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -9,17 +9,6 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ profile.projectname=null; var token=null; - - /** - * Save profile in cookies - */ - var saveCookieForSession=function(){ - $cookies.putObject('profile', profile); - $cookies.putObject('token.part_0', token.part_0); - $cookies.putObject('token.part_1', token.part_1); - }; - - /* * @returns {boolean} Return true if a cookie is found (and load it in profile) false else */ @@ -87,12 +76,16 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ // Find the middle of the token to split it var middle=parseInt(response.data.token.length/2); + // Create expire date (cookie expire in 55 mins) + var expireDate=new Date(); + expireDate.setMinutes(expireDate.getMinutes()+55); + // Save profile - $cookies.putObject('profile', profile); + $cookies.putObject('profile', profile, {'expires': expireDate}); // Save first part of token - $cookies.putObject('token.part_0', response.data.token.substring(0, middle)); + $cookies.putObject('token.part_0', response.data.token.substring(0, middle), {'expires': expireDate}); // Save second part of token - $cookies.putObject('token.part_1', response.data.token.substring(middle, response.data.token.length)); + $cookies.putObject('token.part_1', response.data.token.substring(middle, response.data.token.length), {'expires': expireDate}); } else if(failedToSendRequest){ requestParserResult.failReason="Failed to send request"; -- cgit v1.2.3 From 1f397cf0c6a4f177c9f66e4a0f4d2274f26ae5be Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 28 Feb 2016 16:07:52 +0100 Subject: Begin machine details overlay --- client/index.html | 5 ++++ client/js/controllers/home/machineDetails.js | 21 +++++++++++++++ client/js/controllers/home/main.js | 7 ++++- client/partials/home/machineDetails.html | 38 ++++++++++++++++++++++++++++ client/partials/home/main.html | 5 ++-- 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 client/js/controllers/home/machineDetails.js create mode 100644 client/partials/home/machineDetails.html (limited to 'client') diff --git a/client/index.html b/client/index.html index ba183df..8d81ac3 100644 --- a/client/index.html +++ b/client/index.html @@ -26,6 +26,9 @@
    + +
    +
    @@ -81,7 +84,9 @@ + + diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js new file mode 100644 index 0000000..43cfe07 --- /dev/null +++ b/client/js/controllers/home/machineDetails.js @@ -0,0 +1,21 @@ +/** + * The home controller + * + * @param {$scope} $scope The $scope service from angular + */ +mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', function ($scope, Compute, $rootScope) +{ + + + + + $scope.$on('showMachineDetailsEvent', function(eventName ,machine){ + $scope.machine=machine; + $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); + }); + + + + + +}]); diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index 27de5f3..3d57f8d 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -3,7 +3,7 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) +mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($scope, Compute, $rootScope) { var updatePage=function(){ @@ -12,5 +12,10 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) // Retrieve all Data Compute.pullData(updatePage); + + $scope.raiseShowMachineDetailsEvent=function(){ + var machine={name: "Machine 1"}; + $rootScope.$broadcast("showMachineDetailsEvent", machine); + } }]); diff --git a/client/partials/home/machineDetails.html b/client/partials/home/machineDetails.html new file mode 100644 index 0000000..9da131e --- /dev/null +++ b/client/partials/home/machineDetails.html @@ -0,0 +1,38 @@ + diff --git a/client/partials/home/main.html b/client/partials/home/main.html index 7a5045a..e3611e5 100644 --- a/client/partials/home/main.html +++ b/client/partials/home/main.html @@ -1,8 +1,9 @@ -
    +
    Home
    Main Content +
    -
    \ No newline at end of file +
    -- cgit v1.2.3 From 04b66da25740e569f9d66e21077a1e998b9f9d0f Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 28 Feb 2016 17:29:34 +0100 Subject: Edit machine details --- client/js/controllers/home/machineDetails.js | 24 +++++++++++++++--- client/js/controllers/home/main.js | 2 +- client/partials/home/machineDetails.html | 38 +++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 5 deletions(-) (limited to 'client') diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js index 43cfe07..3ee4625 100644 --- a/client/js/controllers/home/machineDetails.js +++ b/client/js/controllers/home/machineDetails.js @@ -3,11 +3,11 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', function ($scope, Compute, $rootScope) +mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$timeout', function ($scope, Compute, $rootScope, $timeout) { - - + $scope.machine={}; + $("#waitingForToggleMachine").hide(); $scope.$on('showMachineDetailsEvent', function(eventName ,machine){ $scope.machine=machine; @@ -15,6 +15,24 @@ mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', fu }); + $scope.toggleMachineState=function(){ + $("#waitingForToggleMachine").show(); + + // Fake timeout + $timeout(function(){ + $("#waitingForToggleMachine").hide(); + }, 1000); + $timeout(function(){ + $scope.machine.online=!$scope.machine.online; + + }, 1000); + + + }; + + $scope.applyModifications=function(){ + //Todo + } diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index 3d57f8d..6545c1a 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -14,7 +14,7 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($s Compute.pullData(updatePage); $scope.raiseShowMachineDetailsEvent=function(){ - var machine={name: "Machine 1"}; + var machine={name: "Machine 1", online:true}; $rootScope.$broadcast("showMachineDetailsEvent", machine); } diff --git a/client/partials/home/machineDetails.html b/client/partials/home/machineDetails.html index 9da131e..5e33a53 100644 --- a/client/partials/home/machineDetails.html +++ b/client/partials/home/machineDetails.html @@ -22,9 +22,45 @@
    Offline   - + + + +   + +
    +
    + + +
    + +
    + + +
    + + + + + + -- cgit v1.2.3 From 27a39a9448eac036d3af994b36d77093a2304e00 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 28 Feb 2016 17:32:32 +0100 Subject: Edit machine details --- client/partials/home/machineDetails.html | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'client') diff --git a/client/partials/home/machineDetails.html b/client/partials/home/machineDetails.html index 5e33a53..2a79f52 100644 --- a/client/partials/home/machineDetails.html +++ b/client/partials/home/machineDetails.html @@ -56,6 +56,15 @@ +
    + + +
    -- cgit v1.2.3 From 81c4c30c69f63a8605d5e7d2d317aa85fd7fdb05 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 28 Feb 2016 17:54:15 +0100 Subject: Add spin icon --- client/images/spin/128x128/Preloader_1.gif | Bin 0 -> 71831 bytes client/images/spin/128x128/Preloader_10.gif | Bin 0 -> 19793 bytes client/images/spin/128x128/Preloader_2.gif | Bin 0 -> 7879 bytes client/images/spin/128x128/Preloader_3.gif | Bin 0 -> 22053 bytes client/images/spin/128x128/Preloader_4.gif | Bin 0 -> 19963 bytes client/images/spin/128x128/Preloader_5.gif | Bin 0 -> 84698 bytes client/images/spin/128x128/Preloader_6.gif | Bin 0 -> 19299 bytes client/images/spin/128x128/Preloader_7.gif | Bin 0 -> 12651 bytes client/images/spin/128x128/Preloader_8.gif | Bin 0 -> 81985 bytes client/images/spin/128x128/Preloader_9.gif | Bin 0 -> 48009 bytes client/images/spin/32x32/Preloader_1.gif | Bin 0 -> 17796 bytes client/images/spin/32x32/Preloader_10.gif | Bin 0 -> 5943 bytes client/images/spin/32x32/Preloader_2.gif | Bin 0 -> 3551 bytes client/images/spin/32x32/Preloader_3.gif | Bin 0 -> 7980 bytes client/images/spin/32x32/Preloader_4.gif | Bin 0 -> 6852 bytes client/images/spin/32x32/Preloader_5.gif | Bin 0 -> 22755 bytes client/images/spin/32x32/Preloader_6.gif | Bin 0 -> 5965 bytes client/images/spin/32x32/Preloader_7.gif | Bin 0 -> 4217 bytes client/images/spin/32x32/Preloader_8.gif | Bin 0 -> 13706 bytes client/images/spin/32x32/Preloader_9.gif | Bin 0 -> 13661 bytes client/images/spin/64x64/Preloader_1.gif | Bin 0 -> 35166 bytes client/images/spin/64x64/Preloader_10.gif | Bin 0 -> 10015 bytes client/images/spin/64x64/Preloader_2.gif | Bin 0 -> 4799 bytes client/images/spin/64x64/Preloader_3.gif | Bin 0 -> 12080 bytes client/images/spin/64x64/Preloader_4.gif | Bin 0 -> 10456 bytes client/images/spin/64x64/Preloader_5.gif | Bin 0 -> 41405 bytes client/images/spin/64x64/Preloader_6.gif | Bin 0 -> 9959 bytes client/images/spin/64x64/Preloader_7.gif | Bin 0 -> 6225 bytes client/images/spin/64x64/Preloader_8.gif | Bin 0 -> 25056 bytes client/images/spin/64x64/Preloader_9.gif | Bin 0 -> 23767 bytes client/js/controllers/home/machineDetails.js | 4 ++-- client/js/controllers/home/main.js | 3 ++- client/partials/home/machineDetails.html | 2 +- client/partials/home/main.html | 2 ++ 34 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 client/images/spin/128x128/Preloader_1.gif create mode 100644 client/images/spin/128x128/Preloader_10.gif create mode 100644 client/images/spin/128x128/Preloader_2.gif create mode 100644 client/images/spin/128x128/Preloader_3.gif create mode 100644 client/images/spin/128x128/Preloader_4.gif create mode 100644 client/images/spin/128x128/Preloader_5.gif create mode 100644 client/images/spin/128x128/Preloader_6.gif create mode 100644 client/images/spin/128x128/Preloader_7.gif create mode 100644 client/images/spin/128x128/Preloader_8.gif create mode 100644 client/images/spin/128x128/Preloader_9.gif create mode 100644 client/images/spin/32x32/Preloader_1.gif create mode 100644 client/images/spin/32x32/Preloader_10.gif create mode 100644 client/images/spin/32x32/Preloader_2.gif create mode 100644 client/images/spin/32x32/Preloader_3.gif create mode 100644 client/images/spin/32x32/Preloader_4.gif create mode 100644 client/images/spin/32x32/Preloader_5.gif create mode 100644 client/images/spin/32x32/Preloader_6.gif create mode 100644 client/images/spin/32x32/Preloader_7.gif create mode 100644 client/images/spin/32x32/Preloader_8.gif create mode 100644 client/images/spin/32x32/Preloader_9.gif create mode 100644 client/images/spin/64x64/Preloader_1.gif create mode 100644 client/images/spin/64x64/Preloader_10.gif create mode 100644 client/images/spin/64x64/Preloader_2.gif create mode 100644 client/images/spin/64x64/Preloader_3.gif create mode 100644 client/images/spin/64x64/Preloader_4.gif create mode 100644 client/images/spin/64x64/Preloader_5.gif create mode 100644 client/images/spin/64x64/Preloader_6.gif create mode 100644 client/images/spin/64x64/Preloader_7.gif create mode 100644 client/images/spin/64x64/Preloader_8.gif create mode 100644 client/images/spin/64x64/Preloader_9.gif (limited to 'client') diff --git a/client/images/spin/128x128/Preloader_1.gif b/client/images/spin/128x128/Preloader_1.gif new file mode 100644 index 0000000..dafe17e Binary files /dev/null and b/client/images/spin/128x128/Preloader_1.gif differ diff --git a/client/images/spin/128x128/Preloader_10.gif b/client/images/spin/128x128/Preloader_10.gif new file mode 100644 index 0000000..cdfa680 Binary files /dev/null and b/client/images/spin/128x128/Preloader_10.gif differ diff --git a/client/images/spin/128x128/Preloader_2.gif b/client/images/spin/128x128/Preloader_2.gif new file mode 100644 index 0000000..3cb9003 Binary files /dev/null and b/client/images/spin/128x128/Preloader_2.gif differ diff --git a/client/images/spin/128x128/Preloader_3.gif b/client/images/spin/128x128/Preloader_3.gif new file mode 100644 index 0000000..7f7d415 Binary files /dev/null and b/client/images/spin/128x128/Preloader_3.gif differ diff --git a/client/images/spin/128x128/Preloader_4.gif b/client/images/spin/128x128/Preloader_4.gif new file mode 100644 index 0000000..78baff6 Binary files /dev/null and b/client/images/spin/128x128/Preloader_4.gif differ diff --git a/client/images/spin/128x128/Preloader_5.gif b/client/images/spin/128x128/Preloader_5.gif new file mode 100644 index 0000000..c9c1530 Binary files /dev/null and b/client/images/spin/128x128/Preloader_5.gif differ diff --git a/client/images/spin/128x128/Preloader_6.gif b/client/images/spin/128x128/Preloader_6.gif new file mode 100644 index 0000000..3203d7f Binary files /dev/null and b/client/images/spin/128x128/Preloader_6.gif differ diff --git a/client/images/spin/128x128/Preloader_7.gif b/client/images/spin/128x128/Preloader_7.gif new file mode 100644 index 0000000..2eb19be Binary files /dev/null and b/client/images/spin/128x128/Preloader_7.gif differ diff --git a/client/images/spin/128x128/Preloader_8.gif b/client/images/spin/128x128/Preloader_8.gif new file mode 100644 index 0000000..3ba8217 Binary files /dev/null and b/client/images/spin/128x128/Preloader_8.gif differ diff --git a/client/images/spin/128x128/Preloader_9.gif b/client/images/spin/128x128/Preloader_9.gif new file mode 100644 index 0000000..7018192 Binary files /dev/null and b/client/images/spin/128x128/Preloader_9.gif differ diff --git a/client/images/spin/32x32/Preloader_1.gif b/client/images/spin/32x32/Preloader_1.gif new file mode 100644 index 0000000..b810330 Binary files /dev/null and b/client/images/spin/32x32/Preloader_1.gif differ diff --git a/client/images/spin/32x32/Preloader_10.gif b/client/images/spin/32x32/Preloader_10.gif new file mode 100644 index 0000000..f9c462f Binary files /dev/null and b/client/images/spin/32x32/Preloader_10.gif differ diff --git a/client/images/spin/32x32/Preloader_2.gif b/client/images/spin/32x32/Preloader_2.gif new file mode 100644 index 0000000..f23998f Binary files /dev/null and b/client/images/spin/32x32/Preloader_2.gif differ diff --git a/client/images/spin/32x32/Preloader_3.gif b/client/images/spin/32x32/Preloader_3.gif new file mode 100644 index 0000000..bb7c60d Binary files /dev/null and b/client/images/spin/32x32/Preloader_3.gif differ diff --git a/client/images/spin/32x32/Preloader_4.gif b/client/images/spin/32x32/Preloader_4.gif new file mode 100644 index 0000000..117c756 Binary files /dev/null and b/client/images/spin/32x32/Preloader_4.gif differ diff --git a/client/images/spin/32x32/Preloader_5.gif b/client/images/spin/32x32/Preloader_5.gif new file mode 100644 index 0000000..7169708 Binary files /dev/null and b/client/images/spin/32x32/Preloader_5.gif differ diff --git a/client/images/spin/32x32/Preloader_6.gif b/client/images/spin/32x32/Preloader_6.gif new file mode 100644 index 0000000..9087ded Binary files /dev/null and b/client/images/spin/32x32/Preloader_6.gif differ diff --git a/client/images/spin/32x32/Preloader_7.gif b/client/images/spin/32x32/Preloader_7.gif new file mode 100644 index 0000000..0b1e633 Binary files /dev/null and b/client/images/spin/32x32/Preloader_7.gif differ diff --git a/client/images/spin/32x32/Preloader_8.gif b/client/images/spin/32x32/Preloader_8.gif new file mode 100644 index 0000000..6816be3 Binary files /dev/null and b/client/images/spin/32x32/Preloader_8.gif differ diff --git a/client/images/spin/32x32/Preloader_9.gif b/client/images/spin/32x32/Preloader_9.gif new file mode 100644 index 0000000..e38dd5a Binary files /dev/null and b/client/images/spin/32x32/Preloader_9.gif differ diff --git a/client/images/spin/64x64/Preloader_1.gif b/client/images/spin/64x64/Preloader_1.gif new file mode 100644 index 0000000..2004c5f Binary files /dev/null and b/client/images/spin/64x64/Preloader_1.gif differ diff --git a/client/images/spin/64x64/Preloader_10.gif b/client/images/spin/64x64/Preloader_10.gif new file mode 100644 index 0000000..944ec82 Binary files /dev/null and b/client/images/spin/64x64/Preloader_10.gif differ diff --git a/client/images/spin/64x64/Preloader_2.gif b/client/images/spin/64x64/Preloader_2.gif new file mode 100644 index 0000000..9821827 Binary files /dev/null and b/client/images/spin/64x64/Preloader_2.gif differ diff --git a/client/images/spin/64x64/Preloader_3.gif b/client/images/spin/64x64/Preloader_3.gif new file mode 100644 index 0000000..52b81ba Binary files /dev/null and b/client/images/spin/64x64/Preloader_3.gif differ diff --git a/client/images/spin/64x64/Preloader_4.gif b/client/images/spin/64x64/Preloader_4.gif new file mode 100644 index 0000000..3408b5d Binary files /dev/null and b/client/images/spin/64x64/Preloader_4.gif differ diff --git a/client/images/spin/64x64/Preloader_5.gif b/client/images/spin/64x64/Preloader_5.gif new file mode 100644 index 0000000..6f0585d Binary files /dev/null and b/client/images/spin/64x64/Preloader_5.gif differ diff --git a/client/images/spin/64x64/Preloader_6.gif b/client/images/spin/64x64/Preloader_6.gif new file mode 100644 index 0000000..c577f24 Binary files /dev/null and b/client/images/spin/64x64/Preloader_6.gif differ diff --git a/client/images/spin/64x64/Preloader_7.gif b/client/images/spin/64x64/Preloader_7.gif new file mode 100644 index 0000000..5f6dd5e Binary files /dev/null and b/client/images/spin/64x64/Preloader_7.gif differ diff --git a/client/images/spin/64x64/Preloader_8.gif b/client/images/spin/64x64/Preloader_8.gif new file mode 100644 index 0000000..b57e4d8 Binary files /dev/null and b/client/images/spin/64x64/Preloader_8.gif differ diff --git a/client/images/spin/64x64/Preloader_9.gif b/client/images/spin/64x64/Preloader_9.gif new file mode 100644 index 0000000..fc3ddb7 Binary files /dev/null and b/client/images/spin/64x64/Preloader_9.gif differ diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js index 3ee4625..f84a073 100644 --- a/client/js/controllers/home/machineDetails.js +++ b/client/js/controllers/home/machineDetails.js @@ -21,11 +21,11 @@ mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$ // Fake timeout $timeout(function(){ $("#waitingForToggleMachine").hide(); - }, 1000); + }, 3000); $timeout(function(){ $scope.machine.online=!$scope.machine.online; - }, 1000); + }, 3000); }; diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index 6545c1a..d93c376 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -17,5 +17,6 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($s var machine={name: "Machine 1", online:true}; $rootScope.$broadcast("showMachineDetailsEvent", machine); } - + + }]); diff --git a/client/partials/home/machineDetails.html b/client/partials/home/machineDetails.html index 2a79f52..1a4edde 100644 --- a/client/partials/home/machineDetails.html +++ b/client/partials/home/machineDetails.html @@ -25,7 +25,7 @@ -   +   diff --git a/client/partials/home/main.html b/client/partials/home/main.html index e3611e5..37638d3 100644 --- a/client/partials/home/main.html +++ b/client/partials/home/main.html @@ -5,5 +5,7 @@
    Main Content +
    +
    -- cgit v1.2.3 From 726562f0426d94c7822cf99d12cd35a9d913ca45 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 28 Feb 2016 18:13:27 +0100 Subject: Correct bug --- client/partials/home/machineDetails.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/partials/home/machineDetails.html b/client/partials/home/machineDetails.html index 1a4edde..606edcf 100644 --- a/client/partials/home/machineDetails.html +++ b/client/partials/home/machineDetails.html @@ -21,8 +21,9 @@
    - Offline   - + Online + Offline +     -- cgit v1.2.3 From d1991fca2b3e9517da9aff571494dbc1374344d9 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 28 Feb 2016 20:30:57 +0100 Subject: Erreur ! --- client/js/controllers/home/main.js | 2 ++ client/js/services/Compute.js | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index d93c376..4e3bcda 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -13,6 +13,8 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($s // Retrieve all Data Compute.pullData(updatePage); + Compute.getMachines(function(adzda){}); + $scope.raiseShowMachineDetailsEvent=function(){ var machine={name: "Machine 1", online:true}; $rootScope.$broadcast("showMachineDetailsEvent", machine); diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 70359ee..7e1764f 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -15,9 +15,18 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // Get Machine var getMachines=function(callback){ - + var result=$http.post('../server/index.php', - $.param({"token" : Identity.profile.token, "task" : "Compute"})); + $.param({"token" : Identity.getToken(), "task" : "compute", action:"getImage", serverID:"69d5bcc4-2fab-4634-b0d2-f455fee5b7bd"})); + + // Wait and handle the response + result.then(function (response){ + alert(response); + callback(parseGetMachinesAnswer(response, false)); + },function(response){ + alert(response.status); + callback(parseGetMachinesAnswer(response, true)); + }); }; -- cgit v1.2.3 From ef28780fba689daefdb9e770d370deed14f2447e Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 28 Feb 2016 20:45:21 +0100 Subject: Test --- client/js/services/Compute.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 7e1764f..43d13c4 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -17,7 +17,7 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ var getMachines=function(callback){ var result=$http.post('../server/index.php', - $.param({"token" : Identity.getToken(), "task" : "compute", action:"getImage", serverID:"69d5bcc4-2fab-4634-b0d2-f455fee5b7bd"})); + $.param({"token" : Identity.getToken(), "task" : "compute", "action":"getImage", "serverID":"69d5bcc4-2fab-4634-b0d2-f455fee5b7bd"})); // Wait and handle the response result.then(function (response){ -- cgit v1.2.3 From 829c7ba8f3b65cd43f6a93e44028ad5cfe354d50 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 28 Feb 2016 21:14:06 +0100 Subject: Test --- client/js/services/Compute.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 43d13c4..59f6291 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -17,11 +17,11 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ var getMachines=function(callback){ var result=$http.post('../server/index.php', - $.param({"token" : Identity.getToken(), "task" : "compute", "action":"getImage", "serverID":"69d5bcc4-2fab-4634-b0d2-f455fee5b7bd"})); + $.param({"token" : Identity.getToken(), "task" : "compute", "action":"listServers"})); // Wait and handle the response result.then(function (response){ - alert(response); + console.log(response.data.Servers); callback(parseGetMachinesAnswer(response, false)); },function(response){ alert(response.status); -- cgit v1.2.3 From 6a67f6ba9dce19b046a5fc86e7437fbaa873c1e8 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Mon, 29 Feb 2016 08:32:48 +0100 Subject: Test --- client/js/services/Compute.js | 2 +- client/js/services/Identity.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 59f6291..9f404c4 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -17,7 +17,7 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ var getMachines=function(callback){ var result=$http.post('../server/index.php', - $.param({"token" : Identity.getToken(), "task" : "compute", "action":"listServers"})); + $.param({"token" : Identity.getToken(), "task" : "compute", "action":"getServer", serverId:"69d5bcc4-2fab-4634-b0d2-f455fee5b7bd"})); // Wait and handle the response result.then(function (response){ diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 7604230..a13c457 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -117,9 +117,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ // Wait and handle the response result.then(function (response){ - callback(parseLoginAnswer(response), false); + callback(parseLoginAnswer(response, false)); },function(response){ - callback(parseLoginAnswer(response), true) + callback(parseLoginAnswer(response, true)); }); }; -- cgit v1.2.3 From 3656654077f505dd782678451760eba45b59707b Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Mon, 29 Feb 2016 08:54:04 +0100 Subject: Clean code --- client/js/services/Compute.js | 14 +++++++++++--- client/js/services/Identity.js | 42 ++++++++++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 19 deletions(-) (limited to 'client') diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 9f404c4..8148948 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -2,11 +2,12 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ - + // Create data var data={}; data.machines={}; + // Parser var parseGetMachinesAnswer=function(response, failedToSendRequest){ @@ -15,9 +16,16 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // Get Machine var getMachines=function(callback){ + + var params={ + "token" : Identity.getToken(), + "task" : "compute", + "action":"getServer", + "serverId":"69d5bcc4-2fab-4634-b0d2-f455fee5b7bd" + }; var result=$http.post('../server/index.php', - $.param({"token" : Identity.getToken(), "task" : "compute", "action":"getServer", serverId:"69d5bcc4-2fab-4634-b0d2-f455fee5b7bd"})); + $.param(params)); // Wait and handle the response result.then(function (response){ @@ -25,7 +33,7 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ callback(parseGetMachinesAnswer(response, false)); },function(response){ alert(response.status); - callback(parseGetMachinesAnswer(response, true)); + callback(parseGetMachinesAnswer(response, true)); }); diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index a13c457..b1d2a48 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -9,42 +9,37 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ profile.projectname=null; var token=null; + /* * @returns {boolean} Return true if a cookie is found (and load it in profile) false else */ var isAlreadyLogin=function(){ + + // Load cookies var profileInCookie=$cookies.getObject('profile'); var tokenPart_0InCookie=$cookies.getObject('token.part_0'); var tokenPart_1InCookie=$cookies.getObject('token.part_1'); + // Check if cookie is defined if(typeof profileInCookie !== 'undefined' && typeof tokenPart_0InCookie !== 'undefined' && typeof tokenPart_1InCookie !== 'undefined' ){ + + // If yes, put it into variables angular.extend(profile, profileInCookie); token=tokenPart_0InCookie+tokenPart_1InCookie; - + + // Return I'm Login return true; } + // Return I'm not Login return false; } - /* - * Get the profile - */ - var getProfile=function(){ - return profile; - } - - /* - * Get the token - */ - var getToken=function(){ - return token; - } /* * Destroy profile cookies @@ -64,7 +59,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ */ var parseLoginAnswer=function(response, failedToSendRequest){ - + // Defined return object var requestParserResult={}; requestParserResult.status=1; requestParserResult.failReason=null; @@ -96,6 +91,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ return requestParserResult; }; + /** * Function to connect to OpenStack @@ -113,7 +109,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ profile.projectname=projectname; var result=$http.post('../server/index.php', - $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); + $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); // Wait and handle the response result.then(function (response){ @@ -124,6 +120,20 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ }; + /* + * Get the profile + */ + var getProfile=function(){ + return profile; + } + + /* + * Get the token + */ + var getToken=function(){ + return token; + } + // Return services objects return { -- cgit v1.2.3 From 24773559e2d6e6c418baf97a6e9d41917d4cb244 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Mon, 29 Feb 2016 09:32:12 +0100 Subject: Test --- client/js/services/Compute.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 8148948..e0c28ae 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -21,7 +21,7 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ "token" : Identity.getToken(), "task" : "compute", "action":"getServer", - "serverId":"69d5bcc4-2fab-4634-b0d2-f455fee5b7bd" + "serverId":"a2926ce3-501b-4285-82ce-c6e451295599" }; var result=$http.post('../server/index.php', @@ -29,7 +29,7 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // Wait and handle the response result.then(function (response){ - console.log(response.data.Servers); + console.log(response.data.MyServer.image); callback(parseGetMachinesAnswer(response, false)); },function(response){ alert(response.status); -- cgit v1.2.3 From 575b8ea4b611a5bd06c92471ecb8fb31d45c1c45 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Tue, 1 Mar 2016 15:50:57 +0100 Subject: Test --- client/js/controllers/home/main.js | 14 +++++++++----- client/js/services/Compute.js | 36 +++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 12 deletions(-) (limited to 'client') diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index 4e3bcda..805bc63 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -10,14 +10,18 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($s // TODO Update graph etc... } - // Retrieve all Data - Compute.pullData(updatePage); - Compute.getMachines(function(adzda){}); + + $scope.raiseShowMachineDetailsEvent=function(){ - var machine={name: "Machine 1", online:true}; - $rootScope.$broadcast("showMachineDetailsEvent", machine); + var callback=function(){ + var data=Compute.getData(); + console.log(data.machines[Object.keys(data.machines)[0]]); + $rootScope.$broadcast("showMachineDetailsEvent", data.machines[Object.keys(data.machines)[0]]); + + } + Compute.pullMachines(callback); } diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index e0c28ae..7c9df26 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -10,18 +10,36 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // Parser var parseGetMachinesAnswer=function(response, failedToSendRequest){ + // Defined return object + var requestParserResult={}; + requestParserResult.status=1; + requestParserResult.failReason=null; + + if (typeof response.data.Servers !== 'undefined') { + // Set status code + requestParserResult.status=0; + data.machines=response.data.Servers; + } + else if(failedToSendRequest){ + requestParserResult.failReason="Failed to send request"; + } + else{ + requestParserResult.failReason="Error"; + } + + return requestParserResult; + }; // Get Machine - var getMachines=function(callback){ + var pullMachines=function(callback){ var params={ "token" : Identity.getToken(), "task" : "compute", - "action":"getServer", - "serverId":"a2926ce3-501b-4285-82ce-c6e451295599" + "action":"listServers" }; var result=$http.post('../server/index.php', @@ -29,7 +47,7 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // Wait and handle the response result.then(function (response){ - console.log(response.data.MyServer.image); + callback(parseGetMachinesAnswer(response, false)); },function(response){ alert(response.status); @@ -45,12 +63,16 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // TODO call getMachines etc... } - + + var getData=function(){ + return data; + } + // Return services objects return { - getMachines: getMachines, + pullMachines: pullMachines, pullData: pullData, - data:data + getData: getData }; -- cgit v1.2.3 From bb8b3dd14060bbad8d4c1295c8395b5cb1108e59 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Tue, 1 Mar 2016 16:55:36 +0100 Subject: test --- client/js/controllers/home/main.js | 1 - client/js/services/Compute.js | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index 805bc63..ee564b2 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -17,7 +17,6 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($s $scope.raiseShowMachineDetailsEvent=function(){ var callback=function(){ var data=Compute.getData(); - console.log(data.machines[Object.keys(data.machines)[0]]); $rootScope.$broadcast("showMachineDetailsEvent", data.machines[Object.keys(data.machines)[0]]); } diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 7c9df26..28f8a69 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -14,11 +14,12 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ var requestParserResult={}; requestParserResult.status=1; requestParserResult.failReason=null; - + console.log(response.data.Images[Object.keys(response.data.Images)[0]]) if (typeof response.data.Servers !== 'undefined') { // Set status code requestParserResult.status=0; data.machines=response.data.Servers; + } else if(failedToSendRequest){ requestParserResult.failReason="Failed to send request"; @@ -39,7 +40,7 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ var params={ "token" : Identity.getToken(), "task" : "compute", - "action":"listServers" + "action":"listImages" }; var result=$http.post('../server/index.php', -- cgit v1.2.3 From cdc3c2cdcb4fc863701afba9b48916857414208f Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Tue, 1 Mar 2016 19:08:30 +0100 Subject: test --- client/js/services/Compute.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 28f8a69..f4e8fa8 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -14,7 +14,7 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ var requestParserResult={}; requestParserResult.status=1; requestParserResult.failReason=null; - console.log(response.data.Images[Object.keys(response.data.Images)[0]]) + console.log(response.data.Servers[Object.keys(response.data.Servers)[0]]) if (typeof response.data.Servers !== 'undefined') { // Set status code requestParserResult.status=0; @@ -40,7 +40,7 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ var params={ "token" : Identity.getToken(), "task" : "compute", - "action":"listImages" + "action":"listServers" }; var result=$http.post('../server/index.php', -- cgit v1.2.3 From f1628e280abaf47bfdcabc7d463ce6ad5d0f0752 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Tue, 1 Mar 2016 20:20:05 +0100 Subject: Clean Identity service --- client/js/services/Identity.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index b1d2a48..da85ecd 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -48,6 +48,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ $cookies.remove('profile'); $cookies.remove('token.part_0'); $cookies.remove('token.part_1'); + token=null; + profile.username=null; + profile.projectname=null; } @@ -81,6 +84,10 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ $cookies.putObject('token.part_0', response.data.token.substring(0, middle), {'expires': expireDate}); // Save second part of token $cookies.putObject('token.part_1', response.data.token.substring(middle, response.data.token.length), {'expires': expireDate}); + + // Put token in var + token=response.data.token; + } else if(failedToSendRequest){ requestParserResult.failReason="Failed to send request"; @@ -102,7 +109,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ * @param {string} projectname The user project name * @param {function} function to call when data is avalaible */ - var login=function(username, password,projectname, callback){ + var login=function(username, password,projectname,callback){ // Set profile information (early) profile.username=username; @@ -120,6 +127,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ }; + + + /* * Get the profile */ @@ -133,6 +143,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ var getToken=function(){ return token; } + // Return services objects -- cgit v1.2.3 From 5ef1c9b8b1ab47b659f512db86e51dacf1bec860 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Tue, 1 Mar 2016 20:51:08 +0100 Subject: Edit machineDetails --- client/js/controllers/home/machineDetails.js | 1 + client/js/controllers/home/main.js | 9 +++-- client/js/services/Compute.js | 55 +++++++++++++++------------- client/partials/home/machineDetails.html | 14 +++---- client/partials/home/main.html | 9 +++-- 5 files changed, 48 insertions(+), 40 deletions(-) (limited to 'client') diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js index f84a073..7476c69 100644 --- a/client/js/controllers/home/machineDetails.js +++ b/client/js/controllers/home/machineDetails.js @@ -11,6 +11,7 @@ mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$ $scope.$on('showMachineDetailsEvent', function(eventName ,machine){ $scope.machine=machine; + console.log(machine); $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); }); diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index ee564b2..b44836b 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -6,18 +6,19 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($scope, Compute, $rootScope) { - var updatePage=function(){ - // TODO Update graph etc... + var callMeAfterGetMachines=function(data){ + $scope.machines=Compute.getData().machines; } + Compute.pullMachines(callMeAfterGetMachines); - $scope.raiseShowMachineDetailsEvent=function(){ + $scope.raiseShowMachineDetailsEvent=function(id){ var callback=function(){ var data=Compute.getData(); - $rootScope.$broadcast("showMachineDetailsEvent", data.machines[Object.keys(data.machines)[0]]); + $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id]); } Compute.pullMachines(callback); diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index f4e8fa8..e2fb3df 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -2,19 +2,27 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ - // Create data + // Init data var data={}; - data.machines={}; + data.machines=null; - // Parser - var parseGetMachinesAnswer=function(response, failedToSendRequest){ + + /** + * Retrieve machine list + * @param {response} the server response + * @param {boolean} false if the request as been send true else + * @return {requestParserResult} the result of parsing + */ + var parsePullMachinesAnswer=function(response, failedToSendRequest){ + // Defined return object var requestParserResult={}; requestParserResult.status=1; requestParserResult.failReason=null; - console.log(response.data.Servers[Object.keys(response.data.Servers)[0]]) + + if (typeof response.data.Servers !== 'undefined') { // Set status code requestParserResult.status=0; @@ -27,44 +35,41 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ else{ requestParserResult.failReason="Error"; } - return requestParserResult; - - }; - // Get Machine + /** + * Retrieve machine list + * @param {callback} function to call after request complete + */ var pullMachines=function(callback){ - - var params={ - "token" : Identity.getToken(), - "task" : "compute", - "action":"listServers" - }; - + // Send listServers request var result=$http.post('../server/index.php', - $.param(params)); + $.param({"token" : Identity.getToken(), "task" : "compute", "action":"listServers"})); // Wait and handle the response result.then(function (response){ - - callback(parseGetMachinesAnswer(response, false)); + callback(parsePullMachinesAnswer(response, false)); },function(response){ - alert(response.status); - callback(parseGetMachinesAnswer(response, true)); - }); - - + callback(parsePullMachinesAnswer(response, true)); + }); }; - + /** + * Retrieve all data + * @param {callback} function to call after request complete + */ var pullData=function(callback){ // TODO call getMachines etc... } + /** + * Get Data + * @return {data} return the data object + */ var getData=function(){ return data; } diff --git a/client/partials/home/machineDetails.html b/client/partials/home/machineDetails.html index 606edcf..28c9165 100644 --- a/client/partials/home/machineDetails.html +++ b/client/partials/home/machineDetails.html @@ -21,11 +21,11 @@
    - Online - Offline + Online + Offline   - - + +   @@ -34,7 +34,7 @@
    - + @@ -60,7 +60,7 @@
    - - - - - + + MB
    -- cgit v1.2.3 From 2d99f1ecf2164431b03eff5bcbaa7abe67287602 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 2 Mar 2016 07:14:05 +0100 Subject: Create loading service --- client/index.html | 4 +++- client/js/controllers/home/main.js | 8 ++++++-- client/js/services/Loading.js | 22 ++++++++++++++++++++++ client/partials/loading.html | 18 ++++++++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 client/js/services/Loading.js create mode 100644 client/partials/loading.html (limited to 'client') diff --git a/client/index.html b/client/index.html index 8d81ac3..8ca2b9f 100644 --- a/client/index.html +++ b/client/index.html @@ -28,8 +28,9 @@
    +
    - +
    @@ -79,6 +80,7 @@ + diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index 9d7ddfc..2e9c00b 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -3,24 +3,28 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($scope, Compute, $rootScope) +mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading', function ($scope, Compute, $rootScope, Loading) { var callMeAfterPullData=function(data){ $scope.machines=Compute.getData().machines; + Loading.stop(); } - + Loading.start(); Compute.pullData(callMeAfterPullData); $scope.raiseShowMachineDetailsEvent=function(id){ + var callback=function(){ + Loading.stop(); var data=Compute.getData(); $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms); } + Loading.start(); Compute.pullMachines(callback); } diff --git a/client/js/services/Loading.js b/client/js/services/Loading.js new file mode 100644 index 0000000..b12aaa0 --- /dev/null +++ b/client/js/services/Loading.js @@ -0,0 +1,22 @@ + +mainApp.factory('Loading',[ '$http', 'Identity', function($http, Identity){ + + + + + var start=function(){ + $('#loadingModal').modal({backdrop: 'static', keyboard: false}); + }; + + var stop=function(){ + $('#loadingModal').modal('hide'); + } + + + return { + start:start, + stop:stop + }; + + +}]); diff --git a/client/partials/loading.html b/client/partials/loading.html new file mode 100644 index 0000000..c978190 --- /dev/null +++ b/client/partials/loading.html @@ -0,0 +1,18 @@ + -- cgit v1.2.3 From b6d7d2c30efe5e9758072bb82ea3a947bda7fd1d Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 2 Mar 2016 07:25:28 +0100 Subject: Correct bug --- client/js/controllers/home/main.js | 10 +++++++--- client/partials/home/main.html | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index 2e9c00b..f84f625 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -3,7 +3,7 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading', function ($scope, Compute, $rootScope, Loading) +mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', function ($scope, Compute, $rootScope, Loading, Identity) { var callMeAfterPullData=function(data){ @@ -11,8 +11,12 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading', f Loading.stop(); } - Loading.start(); - Compute.pullData(callMeAfterPullData); + ; + if(Compute.getData().machines == null && Identity.isAlreadyLogin()){ + Loading.start(); + Compute.pullData(callMeAfterPullData); + } + diff --git a/client/partials/home/main.html b/client/partials/home/main.html index 77a9bc4..f9f8878 100644 --- a/client/partials/home/main.html +++ b/client/partials/home/main.html @@ -4,7 +4,7 @@
    - + Pour charger les machines, recharger la page (temporaire)
    Selectionner une machine: -- cgit v1.2.3