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 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'client/index.html') 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 @@ + -- 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/index.html') 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/index.html') 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