def show(self): dashboard.load_dashboards() def render_topic(topic, s, foldable=True): first = True for t, title, name, _is_view in s: if t == topic: if first: if foldable: html.begin_foldable_container("dashboards", topic, False, topic, indent=True) else: html.open_ul() first = False bulletlink( title, 'dashboard.py?name=%s' % name, onclick="return cmk.sidebar.wato_views_clicked(this)") if not first: # at least one item rendered if foldable: html.end_foldable_container() else: html.open_ul() by_topic = visuals_by_topic(dashboard.permitted_dashboards().items(), default_order=[_('Overview')]) topics = [topic for topic, _entry in by_topic] if len(topics) < 2: render_topic(by_topic[0][0], by_topic[0][1], foldable=False) else: for topic, s in by_topic: render_topic(topic, s) links = [] if config.user.may("general.edit_dashboards"): if config.debug: links.append((_("Export"), "export_dashboards.py")) links.append((_("Edit"), "edit_dashboards.py")) footnotelinks(links)
def get_view_menu_items(): # type: () -> Dict[Text, List[ViewMenuItem]] # TODO: One bright day drop this whole visuals stuff and only use page_types page_type_topics = { } # type: Dict[Text, List[Tuple[Text, Text, str, bool]]] for page_type in pagetypes.all_page_types().values(): if issubclass(page_type, pagetypes.PageRenderer): for t, title, url in page_type.sidebar_links(): page_type_topics.setdefault(t, []).append( (t, title, url, False)) visuals_topics_with_entries = visuals_by_topic( list(views.get_permitted_views().items()) + list(dashboard.get_permitted_dashboards().items())) all_topics_with_entries = [] for topic, entries in visuals_topics_with_entries: if topic in page_type_topics: entries = entries + page_type_topics[topic] del page_type_topics[topic] all_topics_with_entries.append((topic, entries)) all_topics_with_entries += page_type_topics.items() # Filter hidden / not permitted entries by_topic = OrderedDict() # type: Dict[Text, List[ViewMenuItem]] for topic, entries in all_topics_with_entries: for t, title, name, is_view in entries: if is_view and config.visible_views and name not in config.visible_views: continue if is_view and config.hidden_views and name in config.hidden_views: continue if t != topic: continue url = view_menu_url(name, is_view) by_topic.setdefault(topic, []).append( ViewMenuItem(title=title, name=name, is_view=is_view, url=url)) return by_topic
def show(self): if not watolib.is_wato_slave_site(): if not config.wato_enabled: html.write_text(_("WATO is disabled.")) return False user_folders = compute_foldertree() # # Render link target selection # selected_topic, selected_target = config.user.load_file( "foldertree", (_('Hosts'), 'allhosts')) topic_views = visuals_by_topic( views.get_permitted_views().items() + dashboard.get_permitted_dashboards().items()) topics = [(t, t) for t, _s in topic_views] html.open_table() html.open_tr() html.td(_('Topic:'), class_="label") html.open_td() html.dropdown("topic", topics, deflt=selected_topic, onchange='cmk.sidebar.wato_tree_topic_changed(this)') html.close_td() html.close_tr() html.open_tr() html.td(_("View:"), class_="label") html.open_td() for topic, view_list in topic_views: targets = [] for t, title, name, is_view in view_list: if config.visible_views and name not in config.visible_views: continue if config.hidden_views and name in config.hidden_views: continue if t == topic: if not is_view: name = 'dashboard|' + name targets.append((name, title)) if topic != selected_topic: default, style = '', 'display:none' else: default, style = selected_target, None html.dropdown( "target_%s" % topic, targets, deflt=default, onchange='cmk.sidebar.wato_tree_target_changed(this)', style=style) html.close_td() html.close_tr() html.close_table() # Now render the whole tree if user_folders: render_tree_folder("wato-hosts", list(user_folders.values())[0], 'cmk.sidebar.wato_tree_click')
def show(self): dashboard.load_dashboards() def render_topic(topic, entries): first = True for t, title, name, is_view in entries: if is_view and config.visible_views and name not in config.visible_views: continue if is_view and config.hidden_views and name in config.hidden_views: continue if t == topic: if first: html.begin_foldable_container("views", topic, False, topic, indent=True) first = False if is_view: bulletlink( title, "view.py?view_name=%s" % name, onclick= "return cmk.sidebar.wato_views_clicked(this)") elif "?name=" in name: bulletlink(title, name) else: bulletlink( title, 'dashboard.py?name=%s' % name, onclick= "return cmk.sidebar.wato_views_clicked(this)") # TODO: One day pagestypes should handle the complete snapin. # for page_type in pagetypes.all_page_types().values(): # if issubclass(page_type, pagetypes.PageRenderer): # for t, title, url in page_type.sidebar_links(): # if t == topic: # bulletlink(title, url) if not first: # at least one item rendered html.end_foldable_container() # TODO: One bright day drop this whole visuals stuff and only use page_types page_type_topics = {} for page_type in pagetypes.all_page_types().values(): if issubclass(page_type, pagetypes.PageRenderer): for t, title, url in page_type.sidebar_links(): page_type_topics.setdefault(t, []).append( (t, title, url, False)) visuals_topics_with_entries = visuals_by_topic( views.get_permitted_views().items() + dashboard.permitted_dashboards().items()) all_topics_with_entries = [] for topic, entries in visuals_topics_with_entries: if topic in page_type_topics: entries = entries + page_type_topics[topic] del page_type_topics[topic] all_topics_with_entries.append((topic, entries)) all_topics_with_entries += sorted(page_type_topics.items()) for topic, entries in all_topics_with_entries: render_topic(topic, entries) links = [] if config.user.may("general.edit_views"): if config.debug: links.append((_("Export"), "export_views.py")) links.append((_("Edit"), "edit_views.py")) footnotelinks(links)