|
| 1 | +{% set multiple_databases = database_chips|length > 1 %} |
| 2 | +{# A filter group is only useful with a choice in it, or one already applied #} |
| 3 | +{% set useful_facets = [] %} |
| 4 | +{% for facet in facets %}{% if facet["items"]|length > 1 or facet["items"]|selectattr("active")|list %}{% set _ = useful_facets.append(facet) %}{% endif %}{% endfor %} |
| 5 | +{% if database_chips or useful_facets %} |
| 6 | +<div class="query-list-filters"> |
| 7 | + {% if database_chips %} |
| 8 | + <nav class="homepage-databases" aria-labelledby="query-list-databases-label"> |
| 9 | + <span class="homepage-databases-label" id="query-list-databases-label">Databases</span> |
| 10 | + <a href="{{ all_queries_href }}" class="homepage-database{% if not database %} selected{% endif %}"{% if not database %} aria-current="true"{% endif %}>All</a> |
| 11 | + {% for chip in database_chips %} |
| 12 | + <a href="{{ chip.href }}" class="homepage-database{% if chip.selected %} selected{% endif %}{% if not chip.count %} empty{% endif %}" style="--db-color: #{{ chip.color }}"{% if chip.selected %} aria-current="true"{% endif %}> |
| 13 | + <span class="db-swatch" aria-hidden="true"></span>{{ chip.name }} |
| 14 | + <span class="homepage-database-count">{{ "{:,}".format(chip.count) }}</span> |
| 15 | + </a> |
| 16 | + {% endfor %} |
| 17 | + </nav> |
| 18 | + {% endif %} |
| 19 | + {% if useful_facets %} |
| 20 | + <nav class="homepage-databases query-list-facets" aria-label="Query filters"> |
| 21 | + {% for facet in useful_facets %} |
| 22 | + <span class="homepage-databases-label">{{ facet.title }}</span> |
| 23 | + {% for item in facet["items"] %} |
| 24 | + {% if item.href %}<a class="homepage-database{% if item.active %} selected{% endif %}" href="{{ item.href }}"{% if item.active %} aria-current="true"{% endif %}>{% else %}<span class="homepage-database empty">{% endif %}{{ item.label }} <span class="homepage-database-count">{{ "{:,}".format(item.count) }}</span>{% if item.href %}</a>{% else %}</span>{% endif %} |
| 25 | + {% endfor %} |
| 26 | + {% endfor %} |
| 27 | + </nav> |
| 28 | + {% endif %} |
| 29 | +</div> |
| 30 | +{% endif %} |
| 31 | + |
| 32 | +<section class="homepage-queries" aria-label="Queries"> |
| 33 | +{% if queries %} |
| 34 | + <ul class="query-list"> |
| 35 | + {% for query in queries %} |
| 36 | + <li class="query-row"> |
| 37 | + <a class="query-row-name" href="{{ urls.query(query.database, query.name) }}{% if query.fragment %}#{{ query.fragment }}{% endif %}">{{ query.title or query.name }}</a> |
| 38 | + {%- if query.private %} 🔒{% endif %} |
| 39 | + {% if actor_id and query.owner_id == actor_id %}<span class="type-tag type-tag-mine">yours</span>{% endif %} |
| 40 | + {% if query.is_write %}<span class="type-tag type-tag-write">writes</span>{% endif %} |
| 41 | + {% if query.is_private %}<span class="type-tag type-tag-private" title="Only the owner can view this query">private</span>{% endif %} |
| 42 | + {% if query.is_trusted and query.source != "config" %}<span class="type-tag type-tag-trusted" title="Runs without the usual SQL and write permission checks">trusted</span>{% endif %} |
| 43 | + {% if multiple_databases and not database %}<span class="db-tag" style="--db-color: #{{ (database_chips|selectattr('name', 'equalto', query.database)|first or {}).color }}">{{ query.database }}</span>{% endif %} |
| 44 | + <span class="query-row-detail"> |
| 45 | + {%- if query.description %}{{ query.description }}{% elif not query.hide_sql %}<code>{{ query.sql|truncate(120) }}</code>{% endif -%} |
| 46 | + {%- set parameters = query_parameters[(query.database, query.name)] %} |
| 47 | + {%- if parameters %} · inputs: {% for p in parameters %}<code>{{ p }}</code>{% if not loop.last %}, {% endif %}{% endfor %}{% endif -%} |
| 48 | + {%- if query.owner_id and query.owner_id != actor_id %} · by <span class="query-row-owner">{{ query.owner_id }}</span>{% endif -%} |
| 49 | + </span> |
| 50 | + </li> |
| 51 | + {% endfor %} |
| 52 | + </ul> |
| 53 | + {% if next_url %} |
| 54 | + <nav class="page-position page-position-footer" aria-label="Query pagination"> |
| 55 | + <span class="page-position-text">Showing <strong>{{ queries|length }}</strong> of <strong>{{ "{:,}".format(total) }}</strong></span> |
| 56 | + <span class="page-position-links"><a class="page-position-next" href="{{ next_url }}" rel="next"> |
| 57 | + Next |
| 58 | + <svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6"/></svg> |
| 59 | + </a></span> |
| 60 | + </nav> |
| 61 | + {% endif %} |
| 62 | +{% elif filters.q %} |
| 63 | + <p class="homepage-empty">No queries match “{{ filters.q }}”. <a href="{{ query_list_path }}">Clear search</a></p> |
| 64 | +{% else %} |
| 65 | + <p class="homepage-empty">No queries found.</p> |
| 66 | +{% endif %} |
| 67 | +</section> |
0 commit comments