function renderClusterList(Y) {
Y.io("../php/frontend/listClusters.php", {
method: 'GET',
timeout : 10000,
on: {
success: function (x,o) {
Y.log("RAW JSON DATA: " + o.responseText);
// Process the JSON data returned from the server
try {
clusterListInfoJson = Y.JSON.parse(o.responseText);
}
catch (e) {
alert("JSON Parse failed!");
return;
}
Y.log("PARSED DATA: " + Y.Lang.dump(clusterListInfoJson));
if (clusterListInfoJson.result != 0) {
// Error!
alert("Got error!" + clusterListInfoJson.error);
return;
}
clusterListInfoJson = clusterListInfoJson.response;
var numClusters = clusterListInfoJson.length;
var clustersListMarkup;
var clusterId;
var multipleClustersSupported = false;
if (numClusters == 0) {
clustersListMarkup = "You don't have any installed cluster.";
} else {
if (multipleClustersSupported) {
clustersListMarkup = "
" +
"List of clusters" +
"Name of the cluster | Cluster status | Actions |
";
var i = 0;
for (clusterId in clusterListInfoJson) {
clustersListMarkup += "" + clusterId + " | " + clusterListInfoJson[clusterId] + " | Uninstall |
" ;
}
clustersListMarkup += "
";
} else {
var clusterName; var clusterInfo;
for (clusterId in clusterListInfoJson) {
clusterName = clusterId;
clusterInfo = clusterListInfoJson[clusterName];
}
clustersListMarkup = 'Cluster information
';
clustersListMarkup += '' +
'
' +
'' +
'' +
'
' +
'
' +
'' +
'' +
'
' +
'
' +
'
' +
'
';
}
}
var newClusterLinkHTML = "
Want to create a new cluster? Click here ";
if (multipleClustersSupported || numClusters == 0) {
clustersListMarkup += newClusterLinkHTML;
}
Y.one("#clustersListDivId").setContent( clustersListMarkup );
if (Y.one('#newClusterLinkDivId') != null) {
Y.one('#newClusterLinkDivId').on('click',function (e) {
/* Done with this stage, hide it. */
Y.one("#clustersListDivId").setStyle('display','none');
// Y.one("#installationWizardDivId").setStyle('display','block');
});
}
if(numClusters !=0) {
Y.one('#existingClusterLinkDivId').on('click',function (e) {
e.target.set('disabled', true);
/* Done with this stage, hide it. */
Y.one("#clustersListDivId").setStyle('display','none');
/* Render the next stage. */
getServicesStatus(Y, clusterId);
/* Show off our rendering. */
Y.one("#displayServiceStatusCoreDivId").setStyle('display','block');
});
}
},
failure: function (x,o) {
// e.target.set('disabled', false);
alert("Async call failed!");
}
}
});
}
// Create business logic in a YUI sandbox using the 'io' and 'json' modules
YUI().use("node", "io", "dump", "json", "arraysort", "panel", function (Y) {
Y.log( Y.one("#pageTitleId").get('innerHTML') );
// Y.one('#createClusterSubmitButtonId').on('click',function (e) {
renderClusterList(Y);
});