From f43859d4dca696ba4cac224e0c7e87e4b2aad40f 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 --- 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 2f7b020c8a868..0c0a971f36e86 100644 --- a/src/pybind/mgr/dashboard/base.html +++ b/src/pybind/mgr/dashboard/base.html @@ -90,6 +90,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