From fa5a48bc3a76b109f6611620b6e56f3024def029 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 2 Mar 2016 17:41:04 +0100 Subject: Correct bugs --- client/js/controllers/login.js | 3 ++- client/js/controllers/status.js | 6 +++--- client/js/services/Identity.js | 6 +++++- client/partials/nav.html | 26 +++++++------------------- 4 files changed, 17 insertions(+), 24 deletions(-) (limited to 'client') diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 1a89563..63cb6d1 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -16,10 +16,11 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s // Manager logout event $scope.$on('logoutEvent', function(){ - Identity.logout(); $('#loginModal').modal({backdrop: 'static', keyboard: false}); }); + + // Hide loading button and message alert $('#loadingLoginButton').hide(); $('#failedToLoginAlert').hide(); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 940d794..6f398ad 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -11,10 +11,10 @@ mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($ // Give profile to model $scope.profile=Identity.getProfile(); - + // Function to logout - $scope.raiseLogoutEvent=function(){ - $rootScope.$broadcast('logoutEvent'); + $scope.logout=function(){ + Identity.logout(); }; }]); diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index da85ecd..e6a9daf 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', '$rootScope', function($http, $cookies, $rootScope){ /* 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/partials/nav.html b/client/partials/nav.html index b3ef76a..01b9079 100644 --- a/client/partials/nav.html +++ b/client/partials/nav.html @@ -8,7 +8,7 @@ - Status + Status @@ -18,24 +18,12 @@ - +
  • User : {{ profile.username }}
  • +
  • Project Name : {{ profile.projectname }}
  • + - - + + -- cgit v1.2.3 From e2be86814e8ac92778bfa9fc49e1d02946a7efbc Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 2 Mar 2016 20:46:24 +0100 Subject: Clean some things --- client/index.html | 27 +++++++++++++------------- client/js/controllers/home/machineDetails.js | 10 ++++++---- client/partials/home/machineDetails.html | 2 +- client/partials/nav.html | 29 ---------------------------- client/partials/status.html | 29 ++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 47 deletions(-) delete mode 100644 client/partials/nav.html create mode 100644 client/partials/status.html (limited to 'client') diff --git a/client/index.html b/client/index.html index 8ca2b9f..ca6bbe6 100644 --- a/client/index.html +++ b/client/index.html @@ -11,27 +11,28 @@ - + - + + +
    +
    +
    + + +
    - -
    - -
    -
    - - -
    + +
    @@ -56,7 +57,7 @@
    - + diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js index 24fac42..c015eaa 100644 --- a/client/js/controllers/home/machineDetails.js +++ b/client/js/controllers/home/machineDetails.js @@ -6,23 +6,25 @@ mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$timeout', function ($scope, Compute, $rootScope, $timeout) { + // Init scope $scope.machine={}; - $("#waitingForToggleMachine").hide(); + $scope.machineIsStarting=false; // For loading icon + $scope.$on('showMachineDetailsEvent', function(eventName ,machine, axioms){ $scope.machine=machine; $scope.axioms=axioms; - console.log(machine); $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); }); $scope.toggleMachineState=function(){ - $("#waitingForToggleMachine").show(); + // Display gif + $scope.machineIsStarting=true; // Fake timeout $timeout(function(){ - $("#waitingForToggleMachine").hide(); + $scope.machineIsStarting=false; }, 3000); $timeout(function(){ $scope.machine.online=!$scope.machine.online; diff --git a/client/partials/home/machineDetails.html b/client/partials/home/machineDetails.html index 47a65fb..c4c8a38 100644 --- a/client/partials/home/machineDetails.html +++ b/client/partials/home/machineDetails.html @@ -26,7 +26,7 @@   -   +   diff --git a/client/partials/nav.html b/client/partials/nav.html deleted file mode 100644 index 01b9079..0000000 --- a/client/partials/nav.html +++ /dev/null @@ -1,29 +0,0 @@ - diff --git a/client/partials/status.html b/client/partials/status.html new file mode 100644 index 0000000..01b9079 --- /dev/null +++ b/client/partials/status.html @@ -0,0 +1,29 @@ + -- cgit v1.2.3 From 824382b3ea5902d5e5343d2898232e1521565dff Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 2 Mar 2016 20:51:04 +0100 Subject: Clean file name --- client/index.html | 4 ++-- client/js/controllers/home/home.js | 36 ++++++++++++++++++++++++++++++++ client/js/controllers/home/main.js | 36 -------------------------------- client/js/controllers/network/main.js | 8 ------- client/js/controllers/network/network.js | 8 +++++++ client/js/services/Identity.js | 2 +- client/js/services/Loading.js | 15 ++++++------- 7 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 client/js/controllers/home/home.js delete mode 100644 client/js/controllers/home/main.js delete mode 100644 client/js/controllers/network/main.js create mode 100644 client/js/controllers/network/network.js (limited to 'client') diff --git a/client/index.html b/client/index.html index ca6bbe6..48ea4a0 100644 --- a/client/index.html +++ b/client/index.html @@ -86,9 +86,9 @@ - + - + diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js new file mode 100644 index 0000000..f84f625 --- /dev/null +++ b/client/js/controllers/home/home.js @@ -0,0 +1,36 @@ +/** + * The home controller + * + * @param {$scope} $scope The $scope service from angular + */ +mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', function ($scope, Compute, $rootScope, Loading, Identity) +{ + + var callMeAfterPullData=function(data){ + $scope.machines=Compute.getData().machines; + Loading.stop(); + } + + ; + if(Compute.getData().machines == null && Identity.isAlreadyLogin()){ + 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/controllers/home/main.js b/client/js/controllers/home/main.js deleted file mode 100644 index f84f625..0000000 --- a/client/js/controllers/home/main.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * The home controller - * - * @param {$scope} $scope The $scope service from angular - */ -mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', function ($scope, Compute, $rootScope, Loading, Identity) -{ - - var callMeAfterPullData=function(data){ - $scope.machines=Compute.getData().machines; - Loading.stop(); - } - - ; - if(Compute.getData().machines == null && Identity.isAlreadyLogin()){ - 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/controllers/network/main.js b/client/js/controllers/network/main.js deleted file mode 100644 index 7264aec..0000000 --- a/client/js/controllers/network/main.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * The network controller - * - * @param {$scope} $scope The $scope service from angular - */ -mainApp.controller('networkCtrl', function ($scope) -{ -}); \ No newline at end of file diff --git a/client/js/controllers/network/network.js b/client/js/controllers/network/network.js new file mode 100644 index 0000000..7264aec --- /dev/null +++ b/client/js/controllers/network/network.js @@ -0,0 +1,8 @@ +/** + * The network controller + * + * @param {$scope} $scope The $scope service from angular + */ +mainApp.controller('networkCtrl', function ($scope) +{ +}); \ No newline at end of file diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index e6a9daf..db93e97 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,5 +1,5 @@ -mainApp.factory('Identity',[ '$http', '$cookies', '$rootScope', function($http, $cookies, $rootScope){ +mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ /* Create profile structure to store informations * about current session 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 }; - - }]); -- cgit v1.2.3 From 3454c71f0523bd6957e10873d0b95bc191b2f283 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 6 Mar 2016 14:42:50 +0100 Subject: Test request --- client/js/controllers/home/home.js | 5 +++-- client/js/services/Image.js | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'client') diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js index f84f625..18133fa 100644 --- a/client/js/controllers/home/home.js +++ b/client/js/controllers/home/home.js @@ -3,7 +3,7 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', function ($scope, Compute, $rootScope, Loading, Identity) +mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', 'Image', function ($scope, Compute, $rootScope, Loading, Identity, Image) { var callMeAfterPullData=function(data){ @@ -17,7 +17,8 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I Compute.pullData(callMeAfterPullData); } - + + Image.getImages(function(){}); $scope.raiseShowMachineDetailsEvent=function(id){ diff --git a/client/js/services/Image.js b/client/js/services/Image.js index 23b33a8..eccd4af 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -4,16 +4,22 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ var parseUploadImageAnswer=function(response, failedToSendRequest){ - + console.log(response.data.Images[0]) }; 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)); + }); - }; @@ -21,7 +27,7 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ // Return services objects return { - uploadImage: uploadImage + getImages:getImages }; -- cgit v1.2.3 From 96094547dd793868092dda4c2699a839287fa175 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 6 Mar 2016 14:51:50 +0100 Subject: Add image view, controller. --- client/index.html | 1 + client/js/app.js | 8 ++++++-- client/js/controllers/image/image.js | 9 +++++++++ client/partials/home/home.html | 12 ++++++++++++ client/partials/home/main.html | 12 ------------ client/partials/image/image.html | 8 ++++++++ client/partials/menu.html | 3 ++- client/partials/network/main.html | 8 -------- client/partials/network/network.html | 8 ++++++++ 9 files changed, 46 insertions(+), 23 deletions(-) create mode 100644 client/js/controllers/image/image.js create mode 100644 client/partials/home/home.html delete mode 100644 client/partials/home/main.html create mode 100644 client/partials/image/image.html delete mode 100644 client/partials/network/main.html create mode 100644 client/partials/network/network.html (limited to 'client') diff --git a/client/index.html b/client/index.html index 48ea4a0..a06994c 100644 --- a/client/index.html +++ b/client/index.html @@ -89,6 +89,7 @@ + diff --git a/client/js/app.js b/client/js/app.js index e2d5b9b..1602e65 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -13,12 +13,16 @@ mainApp.config(['$routeProvider', function($routeProvider){ $routeProvider. when('/home',{ - templateUrl: 'partials/home/main.html', + templateUrl: 'partials/home/home.html', controller: 'homeCtrl' }). when('/network',{ - templateUrl: 'partials/network/main.html', + templateUrl: 'partials/network/network.html', controller: 'networkCtrl' + }). + when('/image',{ + templateUrl: 'partials/image/image.html', + controller: 'imageCtrl' }).otherwise({ redirectTo: '/home' }); diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js new file mode 100644 index 0000000..036dec3 --- /dev/null +++ b/client/js/controllers/image/image.js @@ -0,0 +1,9 @@ +/** + * The image controller + * + * @param {$scope} $scope The $scope service from angular + */ +mainApp.controller('imageCtrl', function ($scope) +{ + $scope.title="Test"; +}); diff --git a/client/partials/home/home.html b/client/partials/home/home.html new file mode 100644 index 0000000..f9f8878 --- /dev/null +++ b/client/partials/home/home.html @@ -0,0 +1,12 @@ +
    +
    + Home +
    +
    + + Pour charger les machines, recharger la page (temporaire)
    + Selectionner une machine: + + +
    +
    diff --git a/client/partials/home/main.html b/client/partials/home/main.html deleted file mode 100644 index f9f8878..0000000 --- a/client/partials/home/main.html +++ /dev/null @@ -1,12 +0,0 @@ -
    -
    - Home -
    -
    - - Pour charger les machines, recharger la page (temporaire)
    - Selectionner une machine: - - -
    -
    diff --git a/client/partials/image/image.html b/client/partials/image/image.html new file mode 100644 index 0000000..586f003 --- /dev/null +++ b/client/partials/image/image.html @@ -0,0 +1,8 @@ +
    +
    + Image +
    +
    + Main Content +
    +
    diff --git a/client/partials/menu.html b/client/partials/menu.html index dfd5842..a473fd8 100644 --- a/client/partials/menu.html +++ b/client/partials/menu.html @@ -1,4 +1,5 @@ \ No newline at end of file + Images + diff --git a/client/partials/network/main.html b/client/partials/network/main.html deleted file mode 100644 index 8b779be..0000000 --- a/client/partials/network/main.html +++ /dev/null @@ -1,8 +0,0 @@ -
    -
    - Network -
    -
    - Main Content -
    -
    diff --git a/client/partials/network/network.html b/client/partials/network/network.html new file mode 100644 index 0000000..8b779be --- /dev/null +++ b/client/partials/network/network.html @@ -0,0 +1,8 @@ +
    +
    + Network +
    +
    + Main Content +
    +
    -- cgit v1.2.3 From b0b2dc9a6451fc1a2d41b255600094da1ece6485 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 6 Mar 2016 15:04:47 +0100 Subject: Avalaible images can be display --- client/js/controllers/image/image.js | 10 +++++++--- client/js/services/Image.js | 29 +++++++++++++++++++++++++++-- client/partials/image/image.html | 8 +++++--- 3 files changed, 39 insertions(+), 8 deletions(-) (limited to 'client') diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index 036dec3..a8346b3 100644 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -3,7 +3,11 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('imageCtrl', function ($scope) +mainApp.controller('imageCtrl', ['$scope', 'Image', function ($scope, Image) { - $scope.title="Test"; -}); + var callbackTest=function(){ + $scope.images=Image.getData().images; + }; + + Image.getImages(callbackTest); +}]); diff --git a/client/js/services/Image.js b/client/js/services/Image.js index eccd4af..2e8c56f 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -1,10 +1,31 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ + var data={}; + data.images=null; var parseUploadImageAnswer=function(response, failedToSendRequest){ - console.log(response.data.Images[0]) + + // 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; }; @@ -24,10 +45,14 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ }; + var getData=function(response){ + return data; + }; // Return services objects return { - getImages:getImages + getImages:getImages, + getData:getData }; diff --git a/client/partials/image/image.html b/client/partials/image/image.html index 586f003..8af8af5 100644 --- a/client/partials/image/image.html +++ b/client/partials/image/image.html @@ -1,8 +1,10 @@ -
    +
    - Image + Images disponibles
    - Main Content +
    + {{image.name}} +
    -- cgit v1.2.3 From 3b569b6d008d5b1936ee04948cf5c1cc08790f39 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 6 Mar 2016 15:10:34 +0100 Subject: Make some test --- client/js/controllers/home/home.js | 5 +++++ client/js/controllers/image/image.js | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js index 18133fa..4402e62 100644 --- a/client/js/controllers/home/home.js +++ b/client/js/controllers/home/home.js @@ -16,6 +16,11 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I Loading.start(); Compute.pullData(callMeAfterPullData); } + else{ + if(Identity.isAlreadyLogin()){ + callMeAfterPullData(); + } + } Image.getImages(function(){}); diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index a8346b3..e298fcc 100644 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -3,11 +3,19 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('imageCtrl', ['$scope', 'Image', function ($scope, Image) +mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', function ($scope, Image, Loading) { var callbackTest=function(){ $scope.images=Image.getData().images; + Loading.stop(); }; - Image.getImages(callbackTest); + if(Image.getData().images==null){ + Loading.start(); + Image.getImages(callbackTest); + } + else{ + callbackTest(); + } + }]); -- cgit v1.2.3