From 4cdc9c1abbddb14eb88bb2ccdbf35d01d38941fe Mon Sep 17 00:00:00 2001 From: Iakov Gan Date: Fri, 3 Nov 2023 16:47:00 +0100 Subject: [PATCH] better choice --- cid/common.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/cid/common.py b/cid/common.py index 25a984cb..1abe9691 100644 --- a/cid/common.py +++ b/cid/common.py @@ -389,25 +389,20 @@ def _deploy(self, dashboard_id: str=None, recursive=True, update=False, **kwargs standard_categories = ['Foundational', 'Advanced', 'Additional'] all_categories = set([f"{dashboard.get('category', 'Custom')}" for dashboard in self.resources.get('dashboards').values()]) non_standard_categories = [cat for cat in all_categories if cat not in standard_categories] - while True: - category_options = standard_categories + sorted(non_standard_categories) - category = get_parameter( - param_name='category', - message="Please select a category of dashboard to deploy", - choices=category_options, - ) - dashboard_options = {} + categories = standard_categories + sorted(non_standard_categories) + dashboard_options = {} + for category in categories: + dashboard_options[f'{category.upper()}'] = '[category]' for dashboard in self.resources.get('dashboards').values(): if dashboard.get('category', 'Custom') == category: - dashboard_options[f"[{dashboard.get('dashboardId')}] {dashboard.get('name')}"] = dashboard.get('dashboardId') - dashboard_options['<<< back'] = '<<< back' + dashboard_options[f" [{dashboard.get('dashboardId')}] {dashboard.get('name')}"] = dashboard.get('dashboardId') + while True: dashboard_id = get_parameter( param_name='dashboard-id', message="Please select a dashboard to deploy", choices=dashboard_options, ) - if dashboard_id == '<<< back': - unset_parameter('category') + if dashboard_id == '[category]': unset_parameter('dashboard-id') continue break