function loadDatacenterData() { var requestUrl = app_url+"/openoapi/resmgr/v1/datacenters"; $.ajax({ type: "GET", url: requestUrl, contentType: "application/json", success: function (jsonobj) { $.each(jsonobj.datacenters, function (n, v) { printCharts(v.usedCPU, v.totalCPU, v.usedMemory, v.totalMemory, v.usedDisk, v.totalDisk,v.name); }); }, error: function (xhr, ajaxOptions, thrownError) { bootbox.alert("Error on getting site data : " + xhr.responseText); printCharts(11, 12, 21, 22, 31, 32,1); } }); } function loadVimData() { var requestUrl = app_url+"/v1/resmanage/vim/vimInfo"; $.ajax({ type: "GET", url: requestUrl, contentType: "application/json", success: function (jsonobj) { printCharts(jsonobj.data[0].used.cpu, jsonobj.data[0].total.cpu, jsonobj.data[0].used.memory, jsonobj.data[0].total.memory, jsonobj.data[0].used.disk, jsonobj.data[0].total.disk,1); }, error: function (xhr, ajaxOptions, thrownError) { bootbox.alert("Error on getting data (here display the test data) : " + xhr.responseText); printCharts(11, 12, 21, 22, 31, 32,1); } }); } function addHtmlTemplate(dc_id){ var htmlTemplate= '

DataCenter[ '+dc_id+' ]



'; $('#chartArea').append(htmlTemplate); } function printCharts(v11, v12, v21, v22, v31, v32,dc_id) { addHtmlTemplate(dc_id); var cpuChart = new Chart($("#cpuChart_"+dc_id+""), { type: 'doughnut', data: { labels: ["used", "available"], datasets: [{ data: [v11, v12-v11], backgroundColor: ["#FFCE56", "#36A2EB"], hoverBackgroundColor: ["#FFCE56", "#36A2EB"] }] }, options: { animation: { animateScale: true, animateRotate: true } } }); var memoryChart = new Chart($("#memoryChart_"+dc_id+""), { type: 'doughnut', data: { labels: ["used", "available"], datasets: [{ data: [v21, v22-v21], backgroundColor: ["#FFCE56", "#36A2EB"], hoverBackgroundColor: ["#FFCE56", "#36A2EB"] }] }, options: { animation: { animateScale: true, animateRotate: true } } }); var diskChart = new Chart($("#diskChart_"+dc_id+""), { type: 'doughnut', data: { labels: ["used", "available"], datasets: [{ data: [v31, v32-v31], backgroundColor: ["#FFCE56", "#36A2EB"], hoverBackgroundColor: ["#FFCE56", "#36A2EB"] }] }, options: { animation: { animateScale: true, animateRotate: true } } }); } $(function () { loadDatacenterData(); })