Test
This commit is contained in:
parent
8eafc905a9
commit
575b8ea4b6
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...
|
// TODO Update graph etc...
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve all Data
|
|
||||||
Compute.pullData(updatePage);
|
|
||||||
|
|
||||||
Compute.getMachines(function(adzda){});
|
|
||||||
|
|
||||||
|
|
||||||
$scope.raiseShowMachineDetailsEvent=function(){
|
$scope.raiseShowMachineDetailsEvent=function(){
|
||||||
var machine={name: "Machine 1", online:true};
|
var callback=function(){
|
||||||
$rootScope.$broadcast("showMachineDetailsEvent", machine);
|
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
|
// Parser
|
||||||
var parseGetMachinesAnswer=function(response, failedToSendRequest){
|
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
|
// Get Machine
|
||||||
var getMachines=function(callback){
|
var pullMachines=function(callback){
|
||||||
|
|
||||||
var params={
|
var params={
|
||||||
"token" : Identity.getToken(),
|
"token" : Identity.getToken(),
|
||||||
"task" : "compute",
|
"task" : "compute",
|
||||||
"action":"getServer",
|
"action":"listServers"
|
||||||
"serverId":"a2926ce3-501b-4285-82ce-c6e451295599"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var result=$http.post('../server/index.php',
|
var result=$http.post('../server/index.php',
|
||||||
|
@ -29,7 +47,7 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){
|
||||||
|
|
||||||
// Wait and handle the response
|
// Wait and handle the response
|
||||||
result.then(function (response){
|
result.then(function (response){
|
||||||
console.log(response.data.MyServer.image);
|
|
||||||
callback(parseGetMachinesAnswer(response, false));
|
callback(parseGetMachinesAnswer(response, false));
|
||||||
},function(response){
|
},function(response){
|
||||||
alert(response.status);
|
alert(response.status);
|
||||||
|
@ -45,12 +63,16 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){
|
||||||
// TODO call getMachines etc...
|
// TODO call getMachines etc...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var getData=function(){
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
// Return services objects
|
// Return services objects
|
||||||
return {
|
return {
|
||||||
getMachines: getMachines,
|
pullMachines: pullMachines,
|
||||||
pullData: pullData,
|
pullData: pullData,
|
||||||
data:data
|
getData: getData
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue