Merge branch 'loic' into develop
This commit is contained in:
commit
d013e9ff44
2 changed files with 38 additions and 12 deletions
|
@ -10,14 +10,18 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($s
|
|||
// TODO Update graph etc...
|
||||
}
|
||||
|
||||
// Retrieve all Data
|
||||
Compute.pullData(updatePage);
|
||||
|
||||
Compute.getMachines(function(adzda){});
|
||||
|
||||
|
||||
|
||||
$scope.raiseShowMachineDetailsEvent=function(){
|
||||
var machine={name: "Machine 1", online:true};
|
||||
$rootScope.$broadcast("showMachineDetailsEvent", machine);
|
||||
var callback=function(){
|
||||
var data=Compute.getData();
|
||||
console.log(data.machines[Object.keys(data.machines)[0]]);
|
||||
$rootScope.$broadcast("showMachineDetailsEvent", data.machines[Object.keys(data.machines)[0]]);
|
||||
|
||||
}
|
||||
Compute.pullMachines(callback);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,18 +10,36 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){
|
|||
|
||||
// Parser
|
||||
var parseGetMachinesAnswer=function(response, failedToSendRequest){
|
||||
// Defined return object
|
||||
var requestParserResult={};
|
||||
requestParserResult.status=1;
|
||||
requestParserResult.failReason=null;
|
||||
|
||||
if (typeof response.data.Servers !== 'undefined') {
|
||||
// Set status code
|
||||
requestParserResult.status=0;
|
||||
data.machines=response.data.Servers;
|
||||
}
|
||||
else if(failedToSendRequest){
|
||||
requestParserResult.failReason="Failed to send request";
|
||||
}
|
||||
else{
|
||||
requestParserResult.failReason="Error";
|
||||
}
|
||||
|
||||
return requestParserResult;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Get Machine
|
||||
var getMachines=function(callback){
|
||||
var pullMachines=function(callback){
|
||||
|
||||
var params={
|
||||
"token" : Identity.getToken(),
|
||||
"task" : "compute",
|
||||
"action":"getServer",
|
||||
"serverId":"a2926ce3-501b-4285-82ce-c6e451295599"
|
||||
"action":"listServers"
|
||||
};
|
||||
|
||||
var result=$http.post('../server/index.php',
|
||||
|
@ -29,7 +47,7 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){
|
|||
|
||||
// Wait and handle the response
|
||||
result.then(function (response){
|
||||
console.log(response.data.MyServer.image);
|
||||
|
||||
callback(parseGetMachinesAnswer(response, false));
|
||||
},function(response){
|
||||
alert(response.status);
|
||||
|
@ -45,12 +63,16 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){
|
|||
// TODO call getMachines etc...
|
||||
}
|
||||
|
||||
|
||||
|
||||
var getData=function(){
|
||||
return data;
|
||||
}
|
||||
|
||||
// Return services objects
|
||||
return {
|
||||
getMachines: getMachines,
|
||||
pullMachines: pullMachines,
|
||||
pullData: pullData,
|
||||
data:data
|
||||
getData: getData
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue