From: John Spray Date: Wed, 27 Sep 2017 13:33:58 +0000 (+0100) Subject: mgr/dashboard: handle null in format_number X-Git-Tag: v12.2.2~37^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e14de28f9e524575c633dc98c6ebb9a234c8d1c5;p=ceph.git mgr/dashboard: handle null in format_number Fixes: http://tracker.ceph.com/issues/21570 Signed-off-by: John Spray (cherry picked from commit f43859d4dca696ba4cac224e0c7e87e4b2aad40f) --- diff --git a/src/pybind/mgr/dashboard/base.html b/src/pybind/mgr/dashboard/base.html index 146bd92d0c80..d3783873c204 100644 --- a/src/pybind/mgr/dashboard/base.html +++ b/src/pybind/mgr/dashboard/base.html @@ -94,6 +94,12 @@ var width=4; var unit = 0; + if (n == null) { + // People shouldn't really be passing null, but let's + // do something sensible instead of barfing. + return "-"; + } + while (Math.floor(n / (divisor**unit)).toString().length > width - 1) { unit = unit + 1; }