From e14de28f9e524575c633dc98c6ebb9a234c8d1c5 Mon Sep 17 00:00:00 2001 From: John Spray Date: Wed, 27 Sep 2017 14:33:58 +0100 Subject: [PATCH] mgr/dashboard: handle null in format_number Fixes: http://tracker.ceph.com/issues/21570 Signed-off-by: John Spray (cherry picked from commit f43859d4dca696ba4cac224e0c7e87e4b2aad40f) --- src/pybind/mgr/dashboard/base.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pybind/mgr/dashboard/base.html b/src/pybind/mgr/dashboard/base.html index 146bd92d0c807..d3783873c2046 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; } -- 2.39.5