2017-10-24 02:56:27 +00:00
{% extends "base.html" %}
2022-12-31 20:52:57 +00:00
{% block title %}{{ database }}: {{ table }}: {% if count or count == 0 %}{{ "{:,}".format(count) }} row{% if count == 1 %}{% else %}s{% endif %}{% endif %}{% if human_description_en %} {{ human_description_en }}{% endif %}{% endblock %}
2017-10-24 02:56:27 +00:00
2017-11-11 05:55:50 +00:00
{% block extra_head %}
2021-11-27 20:08:42 +00:00
{{- super() -}}
2020-10-20 00:33:59 +00:00
< script src = "{{ urls.static('table.js') }}" defer > < / script >
2022-03-24 19:16:19 +00:00
< script > DATASETTE _ALLOW _FACET = { { datasette _allow _facet } } ; < / script >
2017-11-11 05:55:50 +00:00
< style >
@media only screen and (max-width: 576px) {
2020-10-27 19:01:44 +00:00
{% for column in display_columns -%}
2018-05-20 17:45:01 +00:00
.rows-and-columns td:nth-of-type({{ loop.index }}):before { content: "{{ column.name|escape_css_string }}"; }
2020-10-27 19:01:44 +00:00
{% endfor %}}
2017-11-11 05:55:50 +00:00
< / style >
{% endblock %}
2017-11-30 07:09:54 +00:00
{% block body_class %}table db-{{ database|to_css_class }} table-{{ table|to_css_class }}{% endblock %}
2022-10-13 21:42:52 +00:00
{% block crumbs %}
{{ crumbs.nav(request=request, database=database) }}
2019-07-05 20:34:41 +00:00
{% endblock %}
2017-10-24 02:56:27 +00:00
{% block content %}
2023-08-11 05:16:19 +00:00
< div class = "page-header" style = "border-color: #{{ database_color }}" >
2023-03-22 22:49:39 +00:00
< h1 > {{ metadata.get("title") or table }}{% if is_view %} (view){% endif %}{% if private %} 🔒{% endif %}< / h1 >
2024-02-25 20:54:16 +00:00
< / div >
2024-03-12 21:25:07 +00:00
{% set links = actions() %}{% if links %}
2024-02-25 20:54:16 +00:00
< div class = "page-action-menu" >
< details class = "actions-menu-links details-menu" >
< summary >
< div class = "icon-text" >
< svg class = "icon" aria-labelledby = "actions-menu-links-title" role = "img" style = "color: #fff" xmlns = "http://www.w3.org/2000/svg" width = "28" height = "28" viewBox = "0 0 28 28" fill = "none" stroke = "currentColor" stroke-width = "2" stroke-linecap = "round" stroke-linejoin = "round" >
2024-03-12 21:25:07 +00:00
< title id = "actions-menu-links-title" > {% if is_view %}View{% else %}Table{% endif %} actions< / title >
2024-02-25 20:54:16 +00:00
< circle cx = "12" cy = "12" r = "3" > < / circle >
< path d = "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" > < / path >
< / svg >
2024-03-12 21:25:07 +00:00
< span > {% if is_view %}View{% else %}Table{% endif %} actions< / span >
2020-10-30 05:16:41 +00:00
< / div >
2024-02-25 20:54:16 +00:00
< / summary >
< div class = "dropdown-menu" >
< div class = "hook" > < / div >
{% if links %}
< ul >
{% for link in links %}
2024-03-07 03:54:06 +00:00
< li > < a href = "{{ link.href }}" > {{ link.label }}
{% if link.description %}
< p class = "dropdown-description" > {{ link.description }}< / p >
{% endif %}< / a >
< / li >
2024-02-25 20:54:16 +00:00
{% endfor %}
< / ul >
{% endif %}
< / div >
< / details >
2020-10-30 05:16:41 +00:00
< / div >
2024-02-25 20:54:16 +00:00
{% endif %}
metadata.json support for per-table/per-database metadata
Also added support for descriptions and HTML descriptions.
Here's an example metadata.json file illustrating custom per-database and per-
table metadata:
{
"title": "Overall datasette title",
"description_html": "This is a <em>description with HTML</em>.",
"databases": {
"db1": {
"title": "First database",
"description": "This is a string description & has no HTML",
"license_url": "http://example.com/",
"license": "The example license",
"queries": {
"canned_query": "select * from table1 limit 3;"
},
"tables": {
"table1": {
"title": "Custom title for table1",
"description": "Tables can have descriptions too",
"source": "This has a custom source",
"source_url": "http://example.com/"
}
}
}
}
}
Closes #165, Refs #164
2017-12-07 16:42:54 +00:00
2024-01-31 03:54:03 +00:00
{{ top_table() }}
metadata.json support for per-table/per-database metadata
Also added support for descriptions and HTML descriptions.
Here's an example metadata.json file illustrating custom per-database and per-
table metadata:
{
"title": "Overall datasette title",
"description_html": "This is a <em>description with HTML</em>.",
"databases": {
"db1": {
"title": "First database",
"description": "This is a string description & has no HTML",
"license_url": "http://example.com/",
"license": "The example license",
"queries": {
"canned_query": "select * from table1 limit 3;"
},
"tables": {
"table1": {
"title": "Custom title for table1",
"description": "Tables can have descriptions too",
"source": "This has a custom source",
"source_url": "http://example.com/"
}
}
}
}
}
Closes #165, Refs #164
2017-12-07 16:42:54 +00:00
{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}
2017-11-11 20:36:20 +00:00
2023-03-22 22:49:39 +00:00
{% if metadata.get("columns") %}
2021-08-12 23:53:23 +00:00
< dl class = "column-descriptions" >
{% for column_name, column_description in metadata.columns.items() %}
< dt > {{ column_name }}< / dt > < dd > {{ column_description }}< / dd >
{% endfor %}
< / dl >
{% endif %}
2022-12-31 20:52:57 +00:00
{% if count or human_description_en %}
< h3 > {% if count or count == 0 %}{{ "{:,}".format(count) }} row{% if count == 1 %}{% else %}s{% endif %}{% endif %}
2018-04-09 05:07:18 +00:00
{% if human_description_en %}{{ human_description_en }}{% endif %}
2017-11-24 22:02:39 +00:00
< / h3 >
2017-11-11 20:36:20 +00:00
{% endif %}
2017-10-24 02:00:37 +00:00
2020-10-20 00:33:59 +00:00
< form class = "filters" action = "{{ urls.table(database, table) }}" method = "get" >
2017-11-24 22:22:57 +00:00
{% if supports_search %}
< div class = "search-row" > < label for = "_search" > Search:< / label > < input id = "_search" type = "search" name = "_search" value = "{{ search }}" > < / div >
{% endif %}
2017-11-23 04:33:55 +00:00
{% for column, lookup, value in filters.selections() %}
2017-11-23 15:58:55 +00:00
< div class = "filter-row" >
< div class = "select-wrapper" >
< select name = "_filter_column_{{ loop.index }}" >
2017-11-23 20:32:54 +00:00
< option value = "" > - remove filter -< / option >
2017-12-07 05:05:53 +00:00
{% for c in filter_columns %}
< option { % if c = = column % } selected { % endif % } > {{ c }}< / option >
2017-11-23 15:58:55 +00:00
{% endfor %}
< / select >
2017-11-23 20:05:51 +00:00
< / div > < div class = "select-wrapper filter-op" >
2017-11-23 15:58:55 +00:00
< select name = "_filter_op_{{ loop.index }}" >
{% for key, display, no_argument in filters.lookups() %}
< option value = "{{ key }}{% if no_argument %}__1{% endif %}" { % if key = = lookup % } selected { % endif % } > {{ display }}< / option >
{% endfor %}
< / select >
2017-11-23 20:05:51 +00:00
< / div > < input type = "text" name = "_filter_value_{{ loop.index }}" class = "filter-value" value = "{{ value }}" >
2017-11-23 15:58:55 +00:00
< / div >
{% endfor %}
< div class = "filter-row" >
< div class = "select-wrapper" >
< select name = "_filter_column" >
2017-11-23 20:05:51 +00:00
< option value = "" > - column -< / option >
2017-12-07 05:05:53 +00:00
{% for column in filter_columns %}
< option > {{ column }}< / option >
2017-11-23 04:33:55 +00:00
{% endfor %}
< / select >
2017-11-23 20:05:51 +00:00
< / div > < div class = "select-wrapper filter-op" >
2017-11-23 15:58:55 +00:00
< select name = "_filter_op" >
2017-11-23 04:33:55 +00:00
{% for key, display, no_argument in filters.lookups() %}
2023-03-22 22:49:39 +00:00
< option value = "{{ key }}{% if no_argument %}__1{% endif %}" > {{ display }}< / option >
2017-11-23 04:33:55 +00:00
{% endfor %}
< / select >
2017-11-23 20:05:51 +00:00
< / div > < input type = "text" name = "_filter_value" class = "filter-value" >
2018-04-10 00:30:44 +00:00
< / div >
< div class = "filter-row" >
{% if is_sortable %}
2018-05-31 14:43:06 +00:00
< div class = "select-wrapper small-screen-only" >
2018-04-10 00:30:44 +00:00
< select name = "_sort" id = "sort_by" >
< option value = "" > Sort...< / option >
{% for column in display_columns %}
{% if column.sortable %}
< option value = "{{ column.name }}" { % if column . name = = sort or column . name = = sort_desc % } selected { % endif % } > Sort by {{ column.name }}< / option >
{% endif %}
{% endfor %}
< / select >
< / div >
2018-05-31 14:43:06 +00:00
< label class = "sort_by_desc small-screen-only" > < input type = "checkbox" name = "_sort_by_desc" { % if sort_desc % } checked { % endif % } > descending< / label >
2018-04-10 00:30:44 +00:00
{% endif %}
2019-04-12 04:21:17 +00:00
{% for key, value in form_hidden_args %}
< input type = "hidden" name = "{{ key }}" value = "{{ value }}" >
{% endfor %}
2018-04-10 00:30:44 +00:00
< input type = "submit" value = "Apply" >
2017-11-23 15:58:55 +00:00
< / div >
2017-11-23 04:33:55 +00:00
< / form >
2019-04-13 01:37:22 +00:00
{% if extra_wheres_for_ui %}
< div class = "extra-wheres" >
< h3 > {{ extra_wheres_for_ui|length }} extra where clause{% if extra_wheres_for_ui|length != 1 %}s{% endif %}< / h3 >
< ul >
{% for extra_where in extra_wheres_for_ui %}
< li > < code > {{ extra_where.text }}< / code > [< a href = "{{ extra_where.remove_url }}" > remove< / a > ]< / li >
{% endfor %}
< / ul >
< / div >
{% endif %}
2020-06-09 00:05:44 +00:00
{% if query.sql and allow_execute_sql %}
2020-10-20 00:33:59 +00:00
< p > < a class = "not-underlined" title = "{{ query.sql }}" href = "{{ urls.database(database) }}?{{ {'sql': query.sql}|urlencode|safe }}{% if query.params %}&{{ query.params|urlencode|safe }}{% endif %}" > ✎ < span class = "underlined" > View and edit SQL< / span > < / a > < / p >
2017-11-24 22:02:39 +00:00
{% endif %}
2017-11-12 23:21:39 +00:00
2020-10-10 00:33:13 +00:00
< p class = "export-links" > This data as {% for name, url in renderers.items() %}< a href = "{{ url }}" > {{ name }}< / a > {{ ", " if not loop.last }}{% endfor %}{% if display_rows %}, < a href = "{{ url_csv }}" > CSV< / a > (< a href = "#export" > advanced< / a > ){% endif %}< / p >
2017-11-11 22:40:44 +00:00
2018-05-14 22:09:42 +00:00
{% if suggested_facets %}
2022-06-20 18:05:44 +00:00
{% include "_suggested_facets.html" %}
2018-05-14 22:09:42 +00:00
{% endif %}
2018-05-18 06:07:45 +00:00
{% if facets_timed_out %}
< p class = "facets-timed-out" > These facets timed out: {{ ", ".join(facets_timed_out) }}< / p >
{% endif %}
2018-05-16 05:06:05 +00:00
{% if facet_results %}
2022-06-20 18:05:44 +00:00
{% include "_facet_results.html" %}
2018-05-16 05:06:05 +00:00
{% endif %}
2018-05-12 22:29:06 +00:00
2019-07-03 00:50:45 +00:00
{% include custom_table_templates %}
2017-11-11 22:40:44 +00:00
2017-11-13 20:34:56 +00:00
{% if next_url %}
< p > < a href = "{{ next_url }}" > Next page< / a > < / p >
2017-11-10 20:41:14 +00:00
{% endif %}
2017-11-11 20:36:20 +00:00
2018-06-18 06:03:22 +00:00
{% if display_rows %}
< div id = "export" class = "advanced-export" >
< h3 > Advanced export< / h3 >
2019-01-28 01:40:23 +00:00
< p > JSON shape:
2020-10-10 00:33:13 +00:00
< a href = "{{ renderers['json'] }}" > default< / a > ,
< a href = "{{ append_querystring(renderers['json'], '_shape=array') }}" > array< / a > ,
< a href = "{{ append_querystring(renderers['json'], '_shape=array&_nl=on') }}" > newline-delimited< / a > {% if primary_keys %},
< a href = "{{ append_querystring(renderers['json'], '_shape=object') }}" > object< / a >
2019-01-28 01:40:23 +00:00
{% endif %}
< / p >
2018-06-18 06:03:22 +00:00
< form action = "{{ url_csv_path }}" method = "get" >
< p >
CSV options:
< label > < input type = "checkbox" name = "_dl" > download file< / label >
2018-06-20 16:15:33 +00:00
{% if expandable_columns %}< label > < input type = "checkbox" name = "_labels" checked > expand labels< / label > {% endif %}
2021-08-13 01:10:36 +00:00
{% if next_url and settings.allow_csv_stream %}< label > < input type = "checkbox" name = "_stream" > stream all rows< / label > {% endif %}
2018-06-18 06:03:22 +00:00
< input type = "submit" value = "Export CSV" >
2019-01-03 02:43:56 +00:00
{% for key, value in url_csv_hidden_args %}
< input type = "hidden" name = "{{ key }}" value = "{{ value }}" >
2018-06-18 06:03:22 +00:00
{% endfor %}
< / p >
< / form >
< / div >
{% endif %}
2017-11-12 21:16:59 +00:00
{% if table_definition %}
2019-07-07 20:21:50 +00:00
< pre class = "wrapped-sql" > {{ table_definition }}< / pre >
2017-11-12 21:16:59 +00:00
{% endif %}
2017-11-12 21:25:34 +00:00
{% if view_definition %}
2019-07-07 20:21:50 +00:00
< pre class = "wrapped-sql" > {{ view_definition }}< / pre >
2017-11-12 21:25:34 +00:00
{% endif %}
2017-10-24 02:56:27 +00:00
{% endblock %}