From ffdc050bdcb2f4a2bddfb4f707a95739ee00f1f5 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Fri, 22 Dec 2017 15:18:21 +0800 Subject: [PATCH] rgw/dashboard: move some logic from JS to Python side, some cleanups Signed-off-by: Chang Liu --- src/pybind/mgr/dashboard/module.py | 12 ++- src/pybind/mgr/dashboard/rgw_detail.html | 116 +++++++++-------------- 2 files changed, 51 insertions(+), 77 deletions(-) diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 4d18b3c979851..9e50d2acc1a49 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -66,6 +66,9 @@ def recurse_refs(root, path): def get_prefixed_url(url): return global_instance().url_prefix + url +def to_sorted_array(data): + assert isinstance(data, dict) + return sorted(data.iteritems()) class StandbyModule(MgrStandbyModule): @@ -997,7 +1000,7 @@ class Module(MgrModule): global_instance().log.error("Failed to load histogram for OSD {}".format(osd_id)) else: histogram = json.loads(outb) - + # TODO(chang liu): use to_sorted_array to simpify javascript code return { "osd": osd, "osd_metadata": osd_metadata, @@ -1160,8 +1163,7 @@ class Module(MgrModule): @cherrypy.tools.json_out() def rgw_daemons_data(self): return self._rgw_daemons() - - + def _rgw(self, rgw_id): daemons = self.rgw_daemons_data() rgw_metadata = {} @@ -1176,8 +1178,8 @@ class Module(MgrModule): return { "rgw_id": rgw_id, - "rgw_metadata": rgw_metadata, - "rgw_status": rgw_status, + "rgw_metadata": to_sorted_array(rgw_metadata), + "rgw_status": to_sorted_array(rgw_status), } @cherrypy.expose diff --git a/src/pybind/mgr/dashboard/rgw_detail.html b/src/pybind/mgr/dashboard/rgw_detail.html index f367c4d77c37c..986dc90da0796 100644 --- a/src/pybind/mgr/dashboard/rgw_detail.html +++ b/src/pybind/mgr/dashboard/rgw_detail.html @@ -10,91 +10,63 @@ var refresh = function() { $.get("{{ url_prefix }}/rgw/rgw_data/" + content_data.rgw_id + "/", function(data) { content_data = data; - setTimeout(refresh, 3000); + setTimeout(refresh, 5000); }); }; setTimeout(refresh, 5000); - var post_load = function() { - content_data.rgw_metadata_list = []; - content_data.rgw_status_list = []; - _.each(content_data.rgw_metadata, function(v, k) { - content_data.rgw_metadata_list.push({ - key: k, - value: v - }); - }); - _.each(content_data.rgw_status, function(v, k) { - content_data.rgw_status_list.push({ - key: k, - value: v - }); - }); - - if (content_data.rgw_status_list.length() == 0) { - content_data.rgw_status_show = false; - } else { - content_data.rgw_status_show = true; - } - }; - rivets.bind($("#content"), content_data); - post_load(); });
-

- rgw.{rgw_id} -

+

-
-
-

Status

-
-
- - - - - - - - - - - - - -
KeyValue
{meta_item.key}{meta_item.value}
-
-
+
+
+
+

Status

+
+
+ + + + + + + + + + + + +
KeyValue
{item}
+
+
+
+
+

Metadata

+
+
+ + + + + + + + + + + + +
KeyValue
{item}
+
+
- -
-
-

Metadata

-
-
- - - - - - - - - - - - - -
KeyValue
{meta_item.key}{meta_item.value}
-
-
- +
-- 2.39.5