def horizon_nav(context): if 'request' not in context: return {} current_dashboard = context['request'].horizon.get('dashboard', None) current_panel = context['request'].horizon.get('panel', None) dashboards = [] for dash in Horizon.get_dashboards(): panel_groups = dash.get_panel_groups() non_empty_groups = [] for group in panel_groups.values(): allowed_panels = [] for panel in group: if callable(panel.nav) and panel.nav(context): allowed_panels.append(panel) elif not callable(panel.nav) and panel.nav: allowed_panels.append(panel) if allowed_panels: non_empty_groups.append((group.name, allowed_panels)) if callable(dash.nav) and dash.nav(context): dashboards.append((dash, SortedDict(non_empty_groups))) elif not callable(dash.nav) and dash.nav: dashboards.append((dash, SortedDict(non_empty_groups))) return {'components': dashboards, 'user': context['request'].user, 'current': current_dashboard, 'current_panel': current_panel.slug if current_panel else '', 'request': context['request']}
def horizon_nav(context): if "request" not in context: return {} current_dashboard = context["request"].horizon.get("dashboard", None) current_panel = context["request"].horizon.get("panel", None) dashboards = [] for dash in Horizon.get_dashboards(): panel_groups = dash.get_panel_groups() non_empty_groups = [] for group in panel_groups.values(): allowed_panels = [] for panel in group: if callable(panel.nav) and panel.nav(context): allowed_panels.append(panel) elif not callable(panel.nav) and panel.nav: allowed_panels.append(panel) if allowed_panels: non_empty_groups.append((group.name, allowed_panels)) if callable(dash.nav) and dash.nav(context): dashboards.append((dash, SortedDict(non_empty_groups))) elif not callable(dash.nav) and dash.nav: dashboards.append((dash, SortedDict(non_empty_groups))) return { "components": dashboards, "user": context["request"].user, "current": current_dashboard, "current_panel": current_panel.slug if current_panel else "", "request": context["request"], }
def horizon_nav(context): if 'request' not in context: return {} current_dashboard = context['request'].horizon.get('dashboard', None) current_panel = context['request'].horizon.get('panel', None) dashboards = [] for dash in Horizon.get_dashboards(): panel_groups = dash.get_panel_groups() non_empty_groups = [] for group in panel_groups.values(): allowed_panels = [] for panel in group: if callable(panel.nav) and panel.nav(context) and \ panel.can_access(context): allowed_panels.append(panel) elif not callable(panel.nav) and panel.nav and \ panel.can_access(context): allowed_panels.append(panel) if allowed_panels: non_empty_groups.append((group.name, allowed_panels)) if callable(dash.nav) and dash.nav(context) and \ dash.can_access(context): dashboards.append((dash, SortedDict(non_empty_groups))) elif not callable(dash.nav) and dash.nav and \ dash.can_access(context): dashboards.append((dash, SortedDict(non_empty_groups))) return { 'components': dashboards, 'user': context['request'].user, 'current': current_dashboard, 'current_panel': current_panel.slug if current_panel else '', 'request': context['request'] }
def horizon_all_nav(context): """ Generates top-level dashboard navigation entries. """ if 'request' not in context: return {} current_dashboard = context['request'].horizon.get('dashboard') paneldashboard = context['request'].horizon['dashboard'] panel_groups = paneldashboard.get_panel_groups() non_empty_groups = [] dashboards = [] allowed_panels = [] for dash in Horizon.get_dashboards(): if callable(dash.nav) and dash.nav(context): dashboards.append(dash) elif dash.nav: dashboards.append(dash) for group in panel_groups.values(): allowed_panels = [] for panel in group: if callable(panel.nav) and panel.nav(context): allowed_panels.append(panel) elif not callable(panel.nav) and panel.nav: allowed_panels.append(panel) if allowed_panels: non_empty_groups.append((paneldashboard.name, allowed_panels)) return {'components': dashboards, 'groups':SortedDict(non_empty_groups), 'user': context['request'].user, 'current': current_dashboard, 'request': context['request']}
def horizon_main_nav(context): """ Generates top-level dashboard navigation entries. """ if 'request' not in context: return {} current_dashboard = context['request'].horizon.get('dashboard', None) dashboards = [] for dash in Horizon.get_dashboards(): if callable(dash.nav) and dash.nav(context): dashboards.append(dash) elif dash.nav: dashboards.append(dash) return {'components': dashboards, 'user': context['request'].user, 'current': getattr(current_dashboard, 'slug', None)}
def horizon_main_nav(context): """ Generates top-level dashboard navigation entries. """ if 'request' not in context: return {} current_dashboard = context['request'].horizon.get('dashboard', None) dashboards = [] for dash in Horizon.get_dashboards(): if callable(dash.nav) and dash.nav(context): dashboards.append(dash) elif dash.nav: dashboards.append(dash) return {'components': dashboards, 'user': context['request'].user, 'current': current_dashboard, 'request': context['request']}
def horizon_main_nav(context): """ Generates top-level dashboard navigation entries. """ if "request" not in context: return {} current_dashboard = context["request"].horizon.get("dashboard", None) dashboards = [] for dash in Horizon.get_dashboards(): if callable(dash.nav) and dash.nav(context): dashboards.append(dash) elif dash.nav: dashboards.append(dash) return { "components": dashboards, "user": context["request"].user, "current": getattr(current_dashboard, "slug", None), }
def horizon_nav(context): if 'request' not in context: return {} current_dashboard = context['request'].horizon.get('dashboard', None) current_panel_group = None current_panel = context['request'].horizon.get('panel', None) dashboards = [] try: Horizon.get_project_id(context) except: pass for dash in Horizon.get_dashboards(): panel_groups = dash.get_panel_groups() non_empty_groups = [] for group in panel_groups.values(): allowed_panels = [] for panel in group: if (callable(panel.nav) and panel.nav(context) and panel.can_access(context)): allowed_panels.append(panel) elif (not callable(panel.nav) and panel.nav and panel.can_access(context)): allowed_panels.append(panel) if panel == current_panel: current_panel_group = group.slug if allowed_panels: non_empty_groups.append((group, allowed_panels)) if (callable(dash.nav) and dash.nav(context) and dash.can_access(context)): dashboards.append((dash, OrderedDict(non_empty_groups))) elif (not callable(dash.nav) and dash.nav and dash.can_access(context)): dashboards.append((dash, OrderedDict(non_empty_groups))) return { 'components': dashboards, 'user': context['request'].user, 'current': current_dashboard, 'current_panel_group': current_panel_group, 'current_panel': current_panel.slug if current_panel else '', 'request': context['request'] }