Skip to content

Commit bc836db

Browse files
committed
Styling clean-up of document headers
1 parent cbab7e3 commit bc836db

File tree

6 files changed

+71
-30
lines changed

6 files changed

+71
-30
lines changed

cubedash/_filters.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import calendar
88
import logging
99
from datetime import datetime
10+
from typing import Mapping
1011

1112
import flask
1213
import rapidjson
@@ -106,6 +107,11 @@ def _dataset_created(dataset: Dataset):
106107
return utils.dataset_created(dataset)
107108

108109

110+
@bp.app_template_filter("all_values_none")
111+
def _all_values_none(d: Mapping):
112+
return all(v is None for v in d.values())
113+
114+
109115
@bp.app_template_filter("dataset_day_link")
110116
def _dataset_day_link(dataset: Dataset, timezone=None):
111117
t = dataset.center_time

cubedash/templates/dataset.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@
3131
{% block content %}
3232
{% from "layout/macros.html" import query_param_list, show_raw_document %}
3333
<div class="panel highlight">
34-
<h1><strong>{{ dataset | printable_dataset }}</strong></h1>
34+
<h2 class="followed"><strong>{{ dataset | printable_dataset }}</strong></h2>
35+
<div class="header-follow">
36+
dataset of product {{ dataset.type.name | product_link }}
37+
</div>
3538
<div class="sub-header">
3639
<span>
37-
{% if dataset_region_code %}Region <strong>{{ dataset_region_code }}</strong>, {% endif %}
3840
Indexed by <strong>{{ dataset.indexed_by }}</strong>
3941
{{ dataset.indexed_time | timesince }},
4042
created {{ dataset | dataset_created | timesince }}
@@ -49,8 +51,14 @@ <h1><strong>{{ dataset | printable_dataset }}</strong></h1>
4951
</span>
5052
</div>
5153
<div class="sub-header">
52-
{{ dataset.type.name | product_link }} of {{ dataset | dataset_day_link(grouping_timezone) }}
53-
({{ dataset.type.metadata_type.name }})
54+
{% if dataset_region_code %}
55+
Region
56+
<a href="{{ url_for('region_page', region_code=dataset_region_code, product_name=dataset.type.name)}}">
57+
{{- dataset_region_code -}}
58+
</a>
59+
{% endif %}
60+
for
61+
{{ dataset | dataset_day_link(grouping_timezone) }}
5462
</div>
5563
</div>
5664

cubedash/templates/metadata-type.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
{% from "layout/macros.html" import query_param_list, show_raw_document %}
1010

1111
<div class="panel highlight">
12-
<h2 class="followed"><span class="metadata-type-name">{{ metadata_type.name }}</span></h2>
12+
<h2 class="followed">
13+
<span class="metadata-type-name">
14+
<i class="fa fa-hdd-o" aria-hidden="true"></i>
15+
{{ metadata_type.name }}
16+
</span>
17+
</h2>
1318
<div class="header-follow">metadata type of {{ products_using_it | length }} products</div>
1419

1520
<div><em>

cubedash/templates/overview.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,19 @@ <h4>
144144
metadata:
145145
</h4>
146146

147-
{{ query_param_list(product.fields,
147+
{% if (product.fields | all_values_none) and (product_summary.fixed_metadata == {}) %}
148+
<em>No common values</em>
149+
{% else %}
150+
{{ query_param_list(product.fields,
148151
show_nulls=false,
149152
descriptions=product.metadata_type.dataset_fields,
150153
fallback_dict=product_summary.fixed_metadata or {}) }}
151-
154+
{% if product_summary.fixed_metadata is none %}
155+
<em class="muted" title="Generated summaries are out of date">
156+
Unknown (needs refresh)
157+
</em>
158+
{% endif %}
159+
{% endif %}
152160

153161
{% if product_summary.derived_products %}
154162
<h4>Derived</h4>

cubedash/templates/product-audit.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
{% endblock %}
2020
{% block content %}
2121
{% from "layout/macros.html" import query_param_list, show_raw_document %}
22-
<div class="panel highlight">
23-
<h1 class="followed">Product Audit
22+
<div class="panel">
23+
<h2 class="followed">Product Audit
2424
{%- if sentry_public_dsn and sentry_public_args.environment %} ({{ sentry_public_args.environment }})
2525
{%- endif -%}
26-
</h1>
26+
</h2>
2727
<div class="header-follow">{{ products_summarised|length }} products with summaries.
2828
{{ (products_missing | length) or 'None' }} without{% if products_missing %}:{% else %}.{% endif %}
2929
{% for name in products_missing %}

cubedash/templates/product.html

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,54 @@ <h2 class="followed">{{ product.name }}</h2>
1818
</div>
1919
<div>
2020
<em>{{ product.definition['description'] }}</em>
21-
2221
</div>
2322
<p>
24-
25-
<a href="{{ url_for('overview_page', product_name=product.name) }}">
26-
{%- if product_summary.time_earliest -%}
27-
{{ product_summary.time_earliest.strftime('%B %Y') }} to
28-
{{ product_summary.time_latest.strftime('%B %Y') }}
29-
{%- endif -%}
30-
</a>,
31-
<a href="{{ url_for('search_page', product_name=product.name) }}">
32-
{{ product_summary.dataset_count or '0' }} datasets
33-
</a>
23+
<i class="fa fa-globe" aria-hidden="true"></i>
24+
<a href="{{ url_for('overview_page', product_name=product.name) }}">
25+
{% if product_summary.time_earliest -%}
26+
{{ product_summary.time_earliest.strftime('%B %Y') }} to
27+
{{ product_summary.time_latest.strftime('%B %Y') }}
28+
{%- endif -%}
29+
</a><br/>
30+
<i class="fa fa-list" aria-hidden="true"></i>
31+
<a href="{{ url_for('search_page', product_name=product.name) }}">
32+
{{ product_summary.dataset_count or '0' }} datasets
33+
</a>
3434
</p>
3535
</div>
3636
<div class="panel">
3737

3838
<h3>Metadata</h3>
39-
{{ query_param_list(
40-
product.fields,
41-
wide=true,
42-
show_nulls=false,
43-
descriptions=product.metadata_type.dataset_fields,
44-
fallback_dict=fixed_metadata)
45-
}}
39+
40+
{% if (product.fields | all_values_none) and (product_summary.fixed_metadata == {}) %}
41+
<em>No common values</em>
42+
{% else %}
43+
{{ query_param_list(product.fields,
44+
show_nulls=false,
45+
wide=true,
46+
descriptions=product.metadata_type.dataset_fields,
47+
fallback_dict=product_summary.fixed_metadata or {}) }}
48+
{% if product_summary.fixed_metadata is none %}
49+
<em title="Generated summaries are out of date">
50+
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
51+
Unknown fixed fields
52+
</em>
53+
{% endif %}
54+
{% endif %}
4655
</div>
4756
<div class="panel odd">
4857
<h3>Searchable fields</h3>
4958
{% for key, value in product.fields | dictsort if (value is none and key not in fixed_metadata) %}
5059
<div>
5160
{% set field = product.metadata_type.dataset_fields[key] %}
5261
{{ key }}
53-
{% if field.indexed is true %}<span title="indexed"></span>{% endif %}
54-
<span class="badge">{{ field.type_name }}</span>
62+
63+
<span class="badge">
64+
{{- field.type_name -}}
65+
{%- if field.indexed is true %}
66+
<span title="indexed"><i class="fa fa-square" aria-hidden="true"></i></span>
67+
{%- endif -%}
68+
</span>
5569
{% if field.description and ('TODO' not in field.description) %}
5670
<span class="muted">{{ field.description }}</span>
5771
{% endif %}

0 commit comments

Comments
 (0)