diff --git a/src/views/graphs.html b/src/views/graphs.html index 98470b694..a662342e5 100644 --- a/src/views/graphs.html +++ b/src/views/graphs.html @@ -52,8 +52,8 @@

This {{ disk.type }} disk contains:

diff --git a/src/views/graphs.js b/src/views/graphs.js index fea175156..41fa4c5dd 100644 --- a/src/views/graphs.js +++ b/src/views/graphs.js @@ -120,7 +120,7 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati const apps = Object.keys(result.apps).filter(function (appId) { return result.apps[appId] === disk.filesystem; }); apps.forEach(function (appId) { - disk.contains.push({ app: Client.getCachedAppSync(appId), id: appId }); + disk.contains.push({ app: Client.getCachedAppSync(appId), id: appId, usage: 0 }); }); }); @@ -149,11 +149,17 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati return 'absolute(collectd.localhost.du-' + content.id + '.capacity-usage)'; }); - Client.graphs(graphiteQueries, '-1min', {}, function (error, data) { + Client.graphs(graphiteQueries, '-2days', { noNullPoints: true }, function (error, data) { if (error) return console.error(error); - disk.contains.forEach(function (content, index) { - content.usage = bytesToGigaBytes(data[index].datapoints[0][1]); + data.forEach(function (d) { + var content = disk.contains.find(function (content) { return d.target.indexOf(content.id) !== -1; }); + if (!content) { + content.usage = 'no data available yet'; + } else { + var tmp = d.datapoints[d.datapoints.length-1][0]; + content.usage = tmp < 1000000 ? (bytesToMegaBytes(tmp) + ' MB') : (bytesToGigaBytes(tmp) + ' GB'); + } }); }); });