diff options
| author | Loic GUEGAN <loic@Manzerbredes.home> | 2016-05-04 16:20:11 +0200 |
|---|---|---|
| committer | Loic GUEGAN <loic@Manzerbredes.home> | 2016-05-04 16:20:11 +0200 |
| commit | f4f2f50f21292a002e0becf6fcea7a22b7514e32 (patch) | |
| tree | 5e2921e5be667cc32d02b30f89ea41a346dca2bf | |
| parent | b0f54743069f265c5417e0e6e11fe0184d9ed22f (diff) | |
| parent | d88851c8a691a2f12bbb932fb025883457b100c8 (diff) | |
Test
| -rwxr-xr-x | client/js/controllers/home/home.js | 49 | ||||
| -rwxr-xr-x | client/js/controllers/image/image.js | 1 |
2 files changed, 50 insertions, 0 deletions
diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js index 2aed337..287e63a 100755 --- a/client/js/controllers/home/home.js +++ b/client/js/controllers/home/home.js @@ -49,6 +49,7 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I // Try to retrieve data for the first time tryToRetrieveData(); + var displayMachine = function(){ var machineNames = []; var i = 0; @@ -112,6 +113,52 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I $scope.raiseShowMachineDetailsEvent($(this).attr('model-id')); }); } + + // Function to call after pull all data about machines + var callMeAfterPullData=function(data){ + //$scope.machines=Compute.getData().machines; + Loading.stop(); + displayMachine(); + }; + + var tryToRetrieveData = function () { + // If no data retrieve about machine and user is logged + if (Compute.getData().machines == null && Identity.isAlreadyLogin()) { + Loading.start(); // Show loading gif + Compute.pullData(callMeAfterPullData); // Retrieve data and call the callback + } else { + // Else if user is logged and data is already retrieve + // simply display data + if (Identity.isAlreadyLogin()) { + callMeAfterPullData(); // Display data + } + } + }; + + // On user login + $scope.$on('loginEvent', function () { + tryToRetrieveData(); + }); + + // Function to call from view to display the details of a machine + $scope.raiseShowMachineDetailsEvent = function (id) { + + // Stop loading gif and display overlay + var callback = function () { + Loading.stop(); + var data = Compute.getData(); + + $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms); + + }; + Loading.start(); // Show loading gif + Compute.pullMachines(callback); // Retrieve machine info and display overlay + }; + + // Try to retrieve data for the first time + tryToRetrieveData(); + + //Read the adjacencyList and build the elements and the links according to it function buildGraphFromAdjacencyList(adjacencyList) { @@ -156,7 +203,9 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I var width = 130; var height = 80; var data = Compute.getData(); + //console.log(data.machines[vm[1]]); + if(data.machines[vm[1]].status == "ACTIVE"){ return new joint.shapes.org.Member({ id: vm[1], diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index d5034d3..4142946 100755 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -5,6 +5,7 @@ */ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity','$rootScope', function ($scope, Image, Loading, Identity, $rootScope) { + console.log("test"); // Update view var callMeAfterGetImage = function () { $scope.images = Image.getData().images; |
