From 501eb41b05c88a1e49afd30ff2371db14944964a Mon Sep 17 00:00:00 2001 From: seolmin Date: Tue, 7 Jan 2025 11:04:29 +0900 Subject: [PATCH] fix: add header fields when loading DataTable Signed-off-by: seolmin --- .../manager/data_table_manager/__init__.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/spaceone/dashboard/manager/data_table_manager/__init__.py b/src/spaceone/dashboard/manager/data_table_manager/__init__.py index 8e06aaa..0d49c23 100644 --- a/src/spaceone/dashboard/manager/data_table_manager/__init__.py +++ b/src/spaceone/dashboard/manager/data_table_manager/__init__.py @@ -188,13 +188,31 @@ def response_data(self, sort: list = None, page: dict = None) -> dict: self.apply_page_df(page) df = self.df.copy(deep=True) + data_info, labels_info = self.get_data_and_labels_info() + self.df = None - return { + results = { "results": df.to_dict(orient="records"), "total_count": total_count, } + if labels_info: + results["labels_info"] = labels_info + + if data_info: + results["data_info"] = data_info + + if self.data_keys: + if self.label_keys is None: + order = self.data_keys + else: + order = self.label_keys + self.data_keys + + results["order"] = order + + return results + def apply_sort_to_df(self, sort: list) -> None: if len(self.df) > 0: keys = []