metrics: fix danglish infinite scrolling bug

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2015-09-29 15:22:57 +05:30
parent 983520342f
commit 50c7894533
1 changed files with 184 additions and 176 deletions

View File

@ -113,92 +113,94 @@
data: data,
success: function(json) {
var items = json.listzonesresponse.zone;
$.each(items, function(idx, zone) {
items[idx].clusters = 0;
items[idx].cpuusedavg = 0.0;
items[idx].cpumaxdev = 0.0;
items[idx].cpuallocated = 0.0;
items[idx].maxCpuUsed = 0;
items[idx].memusedavg = 0.0;
items[idx].memmaxdev = 0.0;
items[idx].memallocated = 0.0;
items[idx].maxMemUsed = 0;
if (items) {
$.each(items, function(idx, zone) {
items[idx].clusters = 0;
items[idx].cpuusedavg = 0.0;
items[idx].cpumaxdev = 0.0;
items[idx].cpuallocated = 0.0;
items[idx].maxCpuUsed = 0;
items[idx].memusedavg = 0.0;
items[idx].memmaxdev = 0.0;
items[idx].memallocated = 0.0;
items[idx].maxMemUsed = 0;
$.ajax({
url: createURL('listClusters'),
data: {zoneid: zone.id},
success: function(json) {
items[idx].clusters += parseInt(json.listclustersresponse.count);
var maxCpuUsed = 0.0;
var maxMemUsed = 0;
$.each(json.listclustersresponse.cluster, function(i, cluster) {
if (cluster.hasOwnProperty('cpuused')) {
items[idx].cpuusedavg += cluster.cpuused;
if (cluster.cpuused > items[idx].maxCpuUsed) {
items[idx].maxCpuUsed = cluster.cpuused;
$.ajax({
url: createURL('listClusters'),
data: {zoneid: zone.id},
success: function(json) {
items[idx].clusters += parseInt(json.listclustersresponse.count);
var maxCpuUsed = 0.0;
var maxMemUsed = 0;
$.each(json.listclustersresponse.cluster, function(i, cluster) {
if (cluster.hasOwnProperty('cpuused')) {
items[idx].cpuusedavg += cluster.cpuused;
if (cluster.cpuused > items[idx].maxCpuUsed) {
items[idx].maxCpuUsed = cluster.cpuused;
}
}
}
if (cluster.hasOwnProperty('cpuallocated')) {
items[idx].cpuallocated += parseFloat(cluster.cpuallocated.replace('%', ''));
}
if (cluster.hasOwnProperty('memused')) {
items[idx].memusedavg += parseFloat(cluster.memused);
if (cluster.memused > items[idx].maxMemUsed) {
items[idx].maxMemUsed = cluster.memused;
if (cluster.hasOwnProperty('cpuallocated')) {
items[idx].cpuallocated += parseFloat(cluster.cpuallocated.replace('%', ''));
}
}
if (cluster.hasOwnProperty('memoryallocated')) {
items[idx].memallocated += parseFloat(100.0 * parseFloat(cluster.memoryallocated)/parseFloat(cluster.memorytotal));
}
if (cluster.hasOwnProperty('memused')) {
items[idx].memusedavg += parseFloat(cluster.memused);
if (cluster.memused > items[idx].maxMemUsed) {
items[idx].maxMemUsed = cluster.memused;
}
}
});
if (cluster.hasOwnProperty('memoryallocated')) {
items[idx].memallocated += parseFloat(100.0 * parseFloat(cluster.memoryallocated)/parseFloat(cluster.memorytotal));
}
},
async: false
});
},
async: false
});
$.ajax({
url: createURL('listCapacity'),
data: {zoneid: zone.id},
success: function(json) {
$.each(json.listcapacityresponse.capacity, function(i, capacity) {
// CPU
if (capacity.type == 1) {
items[idx].cputotal = (parseInt(capacity.capacitytotal)/(1000.0)).toFixed(2) + "Ghz";
}
// Memory
if (capacity.type == 0) {
items[idx].memtotal = (parseInt(capacity.capacitytotal)/(1024.0*1024.0*1024.0)).toFixed(2) + "GB";
}
});
},
async: false
});
items[idx].cpuusedavg = (100.0 * items[idx].cpuusedavg / items[idx].clusters);
items[idx].cpumaxdev = (items[idx].maxCpuUsed - items[idx].cpuusedavg);
items[idx].cpuallocated = (items[idx].cpuallocated / items[idx].clusters).toFixed(2) + "%";
items[idx].memusedavg = (100.0 * items[idx].memusedavg / items[idx].clusters);
items[idx].memmaxdev = (items[idx].maxMemUsed - items[idx].memusedavg);
items[idx].memallocated = (items[idx].memallocated / items[idx].clusters).toFixed(2) + "%";
items[idx].state = items[idx].allocationstate;
if (items[idx].managedstate == 'Unmanaged') {
items[idx].state = 'Unmanaged';
}
if (items[idx].managedstate == 'Managed' && items[idx].allocationstate == 'Enabled') {
items[idx].state = 'Enabled';
}
if (items[idx].managedstate == 'Managed' && items[idx].allocationstate == 'Disabled') {
items[idx].state = 'Disabled';
}
});
$.ajax({
url: createURL('listCapacity'),
data: {zoneid: zone.id},
success: function(json) {
$.each(json.listcapacityresponse.capacity, function(i, capacity) {
// CPU
if (capacity.type == 1) {
items[idx].cputotal = (parseInt(capacity.capacitytotal)/(1000.0)).toFixed(2) + "Ghz";
}
// Memory
if (capacity.type == 0) {
items[idx].memtotal = (parseInt(capacity.capacitytotal)/(1024.0*1024.0*1024.0)).toFixed(2) + "GB";
}
});
},
async: false
});
items[idx].cpuusedavg = (100.0 * items[idx].cpuusedavg / items[idx].clusters);
items[idx].cpumaxdev = (items[idx].maxCpuUsed - items[idx].cpuusedavg);
items[idx].cpuallocated = (items[idx].cpuallocated / items[idx].clusters).toFixed(2) + "%";
items[idx].memusedavg = (100.0 * items[idx].memusedavg / items[idx].clusters);
items[idx].memmaxdev = (items[idx].maxMemUsed - items[idx].memusedavg);
items[idx].memallocated = (items[idx].memallocated / items[idx].clusters).toFixed(2) + "%";
items[idx].state = items[idx].allocationstate;
if (items[idx].managedstate == 'Unmanaged') {
items[idx].state = 'Unmanaged';
}
if (items[idx].managedstate == 'Managed' && items[idx].allocationstate == 'Enabled') {
items[idx].state = 'Enabled';
}
if (items[idx].managedstate == 'Managed' && items[idx].allocationstate == 'Disabled') {
items[idx].state = 'Disabled';
}
});
}
args.response.success({
data: items
});
@ -301,92 +303,94 @@
data: data,
success: function(json) {
var items = json.listclustersresponse.cluster;
$.each(items, function(idx, cluster) {
items[idx].hosts = 0;
items[idx].cpuusedavg = 0.0;
items[idx].cpumaxdev = 0.0;
items[idx].cpuallocated = 0.0;
items[idx].maxCpuUsed = 0;
items[idx].memusedavg = 0.0;
items[idx].memmaxdev = 0.0;
items[idx].memallocated = 0.0;
items[idx].maxMemUsed = 0;
if (items) {
$.each(items, function(idx, cluster) {
items[idx].hosts = 0;
items[idx].cpuusedavg = 0.0;
items[idx].cpumaxdev = 0.0;
items[idx].cpuallocated = 0.0;
items[idx].maxCpuUsed = 0;
items[idx].memusedavg = 0.0;
items[idx].memmaxdev = 0.0;
items[idx].memallocated = 0.0;
items[idx].maxMemUsed = 0;
$.ajax({
url: createURL('listHosts'),
data: {clusterid: cluster.id},
success: function(json) {
items[idx].hosts += parseInt(json.listhostsresponse.count);
var maxCpuUsed = 0.0;
var maxMemUsed = 0;
$.each(json.listhostsresponse.host, function(i, host) {
if (host.hasOwnProperty('cpuused')) {
items[idx].cpuusedavg += host.cpuused;
if (host.cpuused > items[idx].maxCpuUsed) {
items[idx].maxCpuUsed = host.cpuused;
$.ajax({
url: createURL('listHosts'),
data: {clusterid: cluster.id},
success: function(json) {
items[idx].hosts += parseInt(json.listhostsresponse.count);
var maxCpuUsed = 0.0;
var maxMemUsed = 0;
$.each(json.listhostsresponse.host, function(i, host) {
if (host.hasOwnProperty('cpuused')) {
items[idx].cpuusedavg += host.cpuused;
if (host.cpuused > items[idx].maxCpuUsed) {
items[idx].maxCpuUsed = host.cpuused;
}
}
}
if (host.hasOwnProperty('cpuallocated')) {
items[idx].cpuallocated += parseFloat(host.cpuallocated.replace('%', ''));
}
if (host.hasOwnProperty('memused')) {
items[idx].memusedavg += parseFloat(host.memused);
if (host.memused > items[idx].maxMemUsed) {
items[idx].maxMemUsed = host.memused;
if (host.hasOwnProperty('cpuallocated')) {
items[idx].cpuallocated += parseFloat(host.cpuallocated.replace('%', ''));
}
}
if (host.hasOwnProperty('memoryallocated')) {
items[idx].memallocated += parseFloat(100.0 * parseFloat(host.memoryallocated)/parseFloat(host.memorytotal));
}
if (host.hasOwnProperty('memused')) {
items[idx].memusedavg += parseFloat(host.memused);
if (host.memused > items[idx].maxMemUsed) {
items[idx].maxMemUsed = host.memused;
}
}
});
if (host.hasOwnProperty('memoryallocated')) {
items[idx].memallocated += parseFloat(100.0 * parseFloat(host.memoryallocated)/parseFloat(host.memorytotal));
}
},
async: false
});
},
async: false
});
$.ajax({
url: createURL('listCapacity'),
data: {clusterid: cluster.id},
success: function(json) {
$.each(json.listcapacityresponse.capacity, function(i, capacity) {
// CPU
if (capacity.type == 1) {
items[idx].cputotal = (parseInt(capacity.capacitytotal)/(1000.0)).toFixed(2) + "Ghz";
}
// Memory
if (capacity.type == 0) {
items[idx].memtotal = (parseInt(capacity.capacitytotal)/(1024.0*1024.0*1024.0)).toFixed(2) + "GB";
}
});
},
async: false
});
items[idx].cpuusedavg = (100.0 * items[idx].cpuusedavg / items[idx].hosts);
items[idx].cpumaxdev = (items[idx].maxCpuUsed - items[idx].cpuusedavg);
items[idx].cpuallocated = (items[idx].cpuallocated / items[idx].hosts).toFixed(2) + "%";
items[idx].memusedavg = (100.0 * items[idx].memusedavg / items[idx].hosts);
items[idx].memmaxdev = (items[idx].maxMemUsed - items[idx].memusedavg);
items[idx].memallocated = (items[idx].memallocated / items[idx].hosts).toFixed(2) + "%";
items[idx].state = items[idx].allocationstate;
if (items[idx].managedstate == 'Unmanaged') {
items[idx].state = 'Unmanaged';
}
if (items[idx].managedstate == 'Managed' && items[idx].allocationstate == 'Enabled') {
items[idx].state = 'Enabled';
}
if (items[idx].managedstate == 'Managed' && items[idx].allocationstate == 'Disabled') {
items[idx].state = 'Disabled';
}
});
$.ajax({
url: createURL('listCapacity'),
data: {clusterid: cluster.id},
success: function(json) {
$.each(json.listcapacityresponse.capacity, function(i, capacity) {
// CPU
if (capacity.type == 1) {
items[idx].cputotal = (parseInt(capacity.capacitytotal)/(1000.0)).toFixed(2) + "Ghz";
}
// Memory
if (capacity.type == 0) {
items[idx].memtotal = (parseInt(capacity.capacitytotal)/(1024.0*1024.0*1024.0)).toFixed(2) + "GB";
}
});
},
async: false
});
items[idx].cpuusedavg = (100.0 * items[idx].cpuusedavg / items[idx].hosts);
items[idx].cpumaxdev = (items[idx].maxCpuUsed - items[idx].cpuusedavg);
items[idx].cpuallocated = (items[idx].cpuallocated / items[idx].hosts).toFixed(2) + "%";
items[idx].memusedavg = (100.0 * items[idx].memusedavg / items[idx].hosts);
items[idx].memmaxdev = (items[idx].maxMemUsed - items[idx].memusedavg);
items[idx].memallocated = (items[idx].memallocated / items[idx].hosts).toFixed(2) + "%";
items[idx].state = items[idx].allocationstate;
if (items[idx].managedstate == 'Unmanaged') {
items[idx].state = 'Unmanaged';
}
if (items[idx].managedstate == 'Managed' && items[idx].allocationstate == 'Enabled') {
items[idx].state = 'Enabled';
}
if (items[idx].managedstate == 'Managed' && items[idx].allocationstate == 'Disabled') {
items[idx].state = 'Disabled';
}
});
}
args.response.success({
data: items
});
@ -484,17 +488,19 @@
data: data,
success: function(json) {
var items = json.listhostsresponse.host;
$.each(items, function(idx, host) {
items[idx].cores = 0;
items[idx].cputotal = 0;
items[idx].cpuusedavg = 0.0;
items[idx].cpuallocated = 0.0;
items[idx].memtotal = 0;
items[idx].memallocated = 0.0;
items[idx].memusedavg = 0.0;
items[idx].networkread = 0.0;
items[idx].networkwrite = 0.0;
});
if (items) {
$.each(items, function(idx, host) {
items[idx].cores = 0;
items[idx].cputotal = 0;
items[idx].cpuusedavg = 0.0;
items[idx].cpuallocated = 0.0;
items[idx].memtotal = 0;
items[idx].memallocated = 0.0;
items[idx].memusedavg = 0.0;
items[idx].networkread = 0.0;
items[idx].networkwrite = 0.0;
});
}
args.response.success({
data: items
});
@ -601,15 +607,17 @@
data: data,
success: function(json) {
var items = json.listvirtualmachinesresponse.virtualmachine;
$.each(items, function(idx, host) {
items[idx].cores = 0;
items[idx].cputotal = 0;
items[idx].cpuused = 0.0;
items[idx].memallocated = 0.0;
items[idx].memused = 0.0;
items[idx].networkread = 0.0;
items[idx].networkwrite = 0.0;
});
if (items) {
$.each(items, function(idx, host) {
items[idx].cores = 0;
items[idx].cputotal = 0;
items[idx].cpuused = 0.0;
items[idx].memallocated = 0.0;
items[idx].memused = 0.0;
items[idx].networkread = 0.0;
items[idx].networkwrite = 0.0;
});
}
args.response.success({
data: items
});