From 7e5db6b5420755a76c1efcd87bf2a61b111b4c09 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 17 Feb 2016 14:01:13 +0100 Subject: Use angular-cookirs --- client/js/controllers/.#status.js | 1 + client/js/controllers/login.js | 16 +++++++++++----- client/js/controllers/status.js | 11 ++++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) create mode 120000 client/js/controllers/.#status.js (limited to 'client/js/controllers') diff --git a/client/js/controllers/.#status.js b/client/js/controllers/.#status.js new file mode 120000 index 0000000..e6c258f --- /dev/null +++ b/client/js/controllers/.#status.js @@ -0,0 +1 @@ +loic@Manzerbredes.home.30343:1455008378 \ No newline at end of file diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 6358a6d..829fc1d 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -9,14 +9,20 @@ */ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) { - // Define default states - $('#loginModal').modal({backdrop: 'static', keyboard: false}); + // Check for login and define default states + if(!Identity.isAlreadyLogin()){ + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + } + $scope.$on('logoutEvent', function(){ + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + }); + $('#loadingLoginButton').hide(); $('#failedToLoginAlert').hide(); - $('#loginButton').click(function(){ - + $scope.loginAction=function(){ + // Begin login state for template $('#loginButton').hide(); $('#loadingLoginButton').show(); @@ -49,6 +55,6 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s // Try to login Identity.login(username, password, projectname, responseCallback); - }); + }; }]); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 2930e34..6bc602a 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -6,9 +6,14 @@ * @param {$scope} $scope The $scope service from angular * @param {Identity} The Identity service */ -mainApp.controller('statusCtrl', ['$scope','Identity', function ($scope, Identity) +mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope) { $scope.profile=Identity.profile; - - + + $scope.logout=function(){ + Identity.logout(); + $rootScope.$broadcast('logoutEvent'); + + }; + }]); -- cgit v1.2.3 From d3047bb539a2256cf357784ff49e0ad58e638500 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Thu, 18 Feb 2016 18:06:06 +0100 Subject: Add compute service --- client/index.html | 3 ++- client/js/controllers/home/main.js | 4 ++-- client/js/services/Compute.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 client/js/services/Compute.js (limited to 'client/js/controllers') diff --git a/client/index.html b/client/index.html index 26430f9..ba183df 100644 --- a/client/index.html +++ b/client/index.html @@ -75,7 +75,8 @@ - + + diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index e629779..d42e413 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -3,8 +3,8 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('homeCtrl', function ($scope) +mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) { -}); \ No newline at end of file +}]); diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js new file mode 100644 index 0000000..748510e --- /dev/null +++ b/client/js/services/Compute.js @@ -0,0 +1,30 @@ + +mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ + + + + // Parser + var parseGetMachinesAnswer=function(response, failedToSendRequest){ + + }; + + + // Get Machine + var getMachines=function(callback){ + + var result=$http.post('../server/index.php', + $.param({"token" : Identity.profile.token, "task" : "Compute"})); + + + + }; + + + + // Return services objects + return { + getMachines: getMachines + }; + + +}]); -- cgit v1.2.3 From ff1832adcfe10fadb6cbf738c874611f77f6dd43 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Mon, 22 Feb 2016 17:30:25 +0100 Subject: Edit Compute service and home controller --- client/js/controllers/.#status.js | 1 - client/js/controllers/home/main.js | 9 ++++++++- client/js/controllers/status.js | 5 ++++- client/js/services/Compute.js | 14 ++++++++++++-- 4 files changed, 24 insertions(+), 5 deletions(-) delete mode 120000 client/js/controllers/.#status.js (limited to 'client/js/controllers') diff --git a/client/js/controllers/.#status.js b/client/js/controllers/.#status.js deleted file mode 120000 index e6c258f..0000000 --- a/client/js/controllers/.#status.js +++ /dev/null @@ -1 +0,0 @@ -loic@Manzerbredes.home.30343:1455008378 \ No newline at end of file diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index d42e413..d25bfad 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -5,6 +5,13 @@ */ mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) { - + + + var updatePage=function(){ + // TODO Update graph etc... + } + + // Retrieve all Data + Compute.pullData(updatePage); }]); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 6bc602a..e01df34 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -8,8 +8,11 @@ */ mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope) { + + // Give profile to model $scope.profile=Identity.profile; - + + // Function to logout $scope.logout=function(){ Identity.logout(); $rootScope.$broadcast('logoutEvent'); diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 748510e..c5c8da9 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -2,6 +2,10 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ + + var data={}; + data.machines={}; + // Parser var parseGetMachinesAnswer=function(response, failedToSendRequest){ @@ -13,17 +17,23 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ var getMachines=function(callback){ var result=$http.post('../server/index.php', - $.param({"token" : Identity.profile.token, "task" : "Compute"})); + $.param({"token" : Identity.profile.token, "task" : "Compute"})); - }; + + + var pullData=function(callback){ + // TODO call getMachines etc... + } // Return services objects return { getMachines: getMachines + pullData: pullData + data:data }; -- cgit v1.2.3