summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic GUEGAN <loic@Manzerbredes.home>2016-05-04 16:31:29 +0200
committerLoic GUEGAN <loic@Manzerbredes.home>2016-05-04 16:31:29 +0200
commita0056da90605f2fb4c2479cae310f12a81a9a3e7 (patch)
tree450092a2cf2b80dfb352e0969c5a685901cdbaa3
parentf4d12bf72a943d6a8965f21a11eefbb05d2a5483 (diff)
parentf4f2f50f21292a002e0becf6fcea7a22b7514e32 (diff)
Merge branch 'loic'
-rwxr-xr-xclient/js/controllers/home/home.js49
-rw-r--r--client/js/controllers/home/machineDetails.js1
-rw-r--r--client/js/services/Compute.js5
-rwxr-xr-xserver/core/Compute.php2
4 files changed, 53 insertions, 4 deletions
diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js
index 2e3cada..287e63a 100755
--- a/client/js/controllers/home/home.js
+++ b/client/js/controllers/home/home.js
@@ -5,6 +5,51 @@
*/
mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', 'Image', function ($scope, Compute, $rootScope, Loading, Identity, Image)
{
+ // 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();
+
+
var displayMachine = function(){
var machineNames = [];
var i = 0;
@@ -158,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/home/machineDetails.js b/client/js/controllers/home/machineDetails.js
index 9c8c602..cd7bb57 100644
--- a/client/js/controllers/home/machineDetails.js
+++ b/client/js/controllers/home/machineDetails.js
@@ -14,6 +14,7 @@ mainApp.controller('machineDetailsCtrl', ['$scope', 'Compute', '$rootScope', '$t
// When we need to show details of machine
$scope.$on('showMachineDetailsEvent', function (eventName, machine, axioms) {
$scope.machine = machine;
+ // console.log(machine.flavor)
$scope.axioms = axioms;
$('#machineDetailsModal').modal({backdrop: false, keyboard: true});
});
diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js
index 5e95f22..712b9a2 100644
--- a/client/js/services/Compute.js
+++ b/client/js/services/Compute.js
@@ -40,8 +40,9 @@ mainApp.factory('Compute', ['$http', 'Identity', function ($http, Identity) {
/**
- * Retrieve machine list
- * @param {callback} function to call after request complete
+ * Retrieve machine list
+ * @param {type} callback function to call after request complete
+ * @returns {undefined}
*/
var pullMachines = function (callback) {
// Send listServers request
diff --git a/server/core/Compute.php b/server/core/Compute.php
index 1db21bf..7783fde 100755
--- a/server/core/Compute.php
+++ b/server/core/Compute.php
@@ -65,9 +65,9 @@ class compute implements Core
$servers = Array();
foreach($serverList as $server){
$servers[$server->id] = Array();
+ $server->retrieve();
$server->flavor->retrieve();
$server->image->retrieve();
- $server->retrieve();
$servers[$server->id]["id"] = $server->id;
$servers[$server->id]["name"] = $server->name;
$servers[$server->id]["image"] = $server->image;