{# Shared template macros. Import with: {% from "_macros.html" import crumbs %} #} {# Breadcrumb trail. `items` is a list of (label, href) pairs, ordered root→current. Intermediate items with a truthy href render as links; the last item (or any item with an empty href) renders as plain current text. #} {% macro crumbs(items) -%} {%- endmacro %} {# A state as a labelled badge: up, down, stale, firing, pending, acknowledged, no_data, ok, warn, crit, resolved, inactive (formatting.STATES). `state` may be a string or an enum; `label` replaces the standard wording. #} {% macro status_badge(state, label=none, title=none) -%} {%- set tone, text = status_info(state) -%} {{ label or text }} {%- endmacro %} {# A state as a coloured dot. The dot is never the only signal: its label is read out to a screen reader, and shown beside it when `show_label`. #} {% macro status_dot(state, label=none, show_label=false) -%} {%- set tone, text = status_info(state) -%} {%- if show_label %}{{ label or text }}{% else %}{{ label or text }}{% endif %} {%- endmacro %} {# Threshold colouring: `threshold_style(value, kind)` (an inline style) and `status_class(value, kind)` ('ok' / 'warn' / 'crit' / 'unknown') are jinja globals reading the cutoffs from Settings → Thresholds. #} {# One headline number. `state` (a STATES name, or a status_class result) colours the value; `href` makes the whole tile a link. #} {% macro stat_tile(label, value, state=none, hint=none, href=none) -%} {%- set tone = status_info(state)[0] if state else none -%} {%- set body -%} {{ label }} {{ value }} {%- if hint %}{{ hint }}{% endif %} {%- endset -%} {%- if href -%} {{ body }} {%- else -%}
{{ body }}
{%- endif -%} {%- endmacro %} {# What a list shows when it has nothing in it, with an optional next step. #} {% macro empty_state(message, action_label=none, action_href=none) -%}

{{ message }}

{%- if action_label and action_href %}{{ action_label }}{% endif %}
{%- endmacro %} {# The page's

, with its actions to the right: {% call page_header("Alerts") %}New rule{% endcall %} #} {% macro page_header(title, subtitle=none) -%} {%- endmacro %} {# A button that shows only an icon. The label is required: it is the button's accessible name and its tooltip, and rendering one without it raises. #} {% macro icon_button(icon, label, href=none, cls="btn-ghost") -%} {%- set name = required(label, "icon_button label") -%} {%- if href -%} {{ icon }} {%- else -%} {%- endif -%} {%- endmacro %} {# A list that continues itself (#5211, pref 172; static/scroll-more.js). scroll_more ends a page while there are more rows: it fetches `url` (the next page, built with core.paging's cursor) when it comes near the viewport, and is replaced by that page's rows. scroll_end ends the last page. Pass `cols` inside a table body, to render as a full-width row. #} {% macro scroll_more(url, cols=none) -%} {%- if cols %} {%- else %}
{% endif -%} Loading more… {%- if cols %}{% else %}
{% endif %} {%- endmacro %} {% macro scroll_end(cols=none, text="End of the list.") -%} {%- if cols %}{{ text }} {%- else %}

{{ text }}

{% endif %} {%- endmacro %}