From dbfcce44aa4a4ef6010b955c8394dc5314e60ac1 Mon Sep 17 00:00:00 2001 From: Victor Marmol Date: Mon, 5 Jan 2015 15:23:20 -0800 Subject: [PATCH] Limit to 5 FS gauges in a stable way. The first 5 gauges on the list may not be the same as the first 5 gauges being displayed. --- pages/static/containers_js.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pages/static/containers_js.go b/pages/static/containers_js.go index dac3fd68..a2681d74 100644 --- a/pages/static/containers_js.go +++ b/pages/static/containers_js.go @@ -1635,16 +1635,21 @@ function drawOverallUsage(elementId, machineInfo, containerInfo) { var numGauges = gauges.length; if (cur.filesystem) { - // Limit the number of filesystem gauges displayed to 5. - // 'Filesystem details' section still shows information for all filesystems. - for (var i = 0; i < cur.filesystem.length && i < 5; i++) { + for (var i = 0; i < cur.filesystem.length; i++) { var data = cur.filesystem[i]; var totalUsage = Math.floor((data.usage * 100.0) / data.capacity); var els = window.cadvisor.fsUsage.elements[data.device]; - // Update the gauges. + // Update the gauges in the right order. gauges[numGauges + els.index] = ['FS #' + (els.index + 1), totalUsage]; } + + // Limit the number of filesystem gauges displayed to 5. + // 'Filesystem details' section still shows information for all filesystems. + var max_gauges = numGauges + 5; + if (gauges.length > max_gauges) { + gauges = gauges.slice(0, max_gauges); + } } drawGauges(elementId, gauges);