HDFS-14334. RBF: Use human readable format for long numbers in the Router UI. Contributed by Inigo Goiri.

This commit is contained in:
Giovanni Matteo Fumarola 2019-03-05 11:01:11 -08:00 committed by Brahma Reddy Battula
parent d79685af04
commit c99f62fdad
2 changed files with 24 additions and 8 deletions

View File

@ -177,10 +177,10 @@
</div>
</div>
</td>
<td>{numOfFiles}</td>
<td>{numOfBlocks}</td>
<td>{numOfBlocksMissing}</td>
<td>{numOfBlocksUnderReplicated}</td>
<td>{numOfFiles|fmt_human_number}</td>
<td>{numOfBlocks|fmt_human_number}</td>
<td>{numOfBlocksMissing|fmt_human_number}</td>
<td>{numOfBlocksUnderReplicated|fmt_human_number}</td>
<td>{numOfActiveDatanodes}</td>
<td>{numOfDeadDatanodes}</td>
<td>{numOfDecommissioningDatanodes}</td>
@ -244,10 +244,10 @@
</div>
</div>
</td>
<td>{numOfFiles}</td>
<td>{numOfBlocks}</td>
<td>{numOfBlocksMissing}</td>
<td>{numOfBlocksUnderReplicated}</td>
<td>{numOfFiles|fmt_human_number}</td>
<td>{numOfBlocks|fmt_human_number}</td>
<td>{numOfBlocksMissing|fmt_human_number}</td>
<td>{numOfBlocksUnderReplicated|fmt_human_number}</td>
<td>{numOfActiveDatanodes}</td>
<td>{numOfDeadDatanodes}</td>
<td>{numOfDecommissioningDatanodes}</td>

View File

@ -96,6 +96,22 @@
'fmt_number': function (v) {
return v.toLocaleString();
},
'fmt_human_number': function (v) {
var UNITS = ['', 'K', 'M'];
var prev = 0, i = 0;
while (Math.floor(v) > 0 && i < UNITS.length) {
prev = v;
v /= 1000;
i += 1;
}
if (i > 0) {
v = prev;
i -= 1;
}
return Math.round(v * 100) / 100 + UNITS[i];
}
};
$.extend(dust.filters, filters);