From fe1d63675d66f75ffc3973017eda72c5fccbb878 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 28 Jun 2016 08:59:08 +0100 Subject: [PATCH] Refactor dashboard templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously the structure was ``` dashboard.html |_ today.html |_ some random html |_ a few things split into partials ``` This commit simplifies the structure to just be: ``` dashboard.html |_ partial |_ partial |_ … ``` --- app/templates/views/dashboard/_totals.html | 25 ++++++ app/templates/views/dashboard/_usage.html | 23 +++++ app/templates/views/dashboard/dashboard.html | 51 ++++++++++- app/templates/views/dashboard/today.html | 90 -------------------- 4 files changed, 98 insertions(+), 91 deletions(-) create mode 100644 app/templates/views/dashboard/_totals.html create mode 100644 app/templates/views/dashboard/_usage.html delete mode 100644 app/templates/views/dashboard/today.html diff --git a/app/templates/views/dashboard/_totals.html b/app/templates/views/dashboard/_totals.html new file mode 100644 index 000000000..7ddc9d4eb --- /dev/null +++ b/app/templates/views/dashboard/_totals.html @@ -0,0 +1,25 @@ +{% from "components/big-number.html" import big_number_with_status %} +{% from "components/message-count-label.html" import message_count_label %} + +
+ {{ big_number_with_status( + statistics.emails_requested, + message_count_label(statistics.emails_requested, 'email', suffix=''), + statistics.emails_failed, + statistics.get('emails_failure_rate', 0.0), + statistics.get('emails_failure_rate', 0)|float > 3, + failure_link=url_for(".view_notifications", service_id=current_service.id, message_type='email', status='failed'), + link=url_for(".view_notifications", service_id=current_service.id, message_type='email', status='sending,delivered,failed') + ) }} +
+
+ {{ big_number_with_status( + statistics.sms_requested, + message_count_label(statistics.sms_requested, 'sms', suffix=''), + statistics.sms_failed, + statistics.get('sms_failure_rate', 0.0), + statistics.get('sms_failure_rate', 0)|float > 3, + failure_link=url_for(".view_notifications", service_id=current_service.id, message_type='sms', status='failed'), + link=url_for(".view_notifications", service_id=current_service.id, message_type='sms', status='sending,delivered,failed') + ) }} +
diff --git a/app/templates/views/dashboard/_usage.html b/app/templates/views/dashboard/_usage.html new file mode 100644 index 000000000..066dae104 --- /dev/null +++ b/app/templates/views/dashboard/_usage.html @@ -0,0 +1,23 @@ +{% from "components/big-number.html" import big_number %} + +
+
+
+ {{ big_number("Unlimited", 'free email allowance', smaller=True) }} +
+
+
+
+ {% if sms_chargeable %} + {{ big_number( + (sms_chargeable * sms_rate), + 'spent on text messages', + currency="£", + smaller=True + ) }} + {% else %} + {{ big_number(sms_allowance_remaining, 'free text messages left', smaller=True) }} + {% endif %} +
+
+
diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index e79f0d8e6..9906e2377 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -1,5 +1,10 @@ {% extends "withnav_template.html" %} +{% from "components/big-number.html" import big_number, big_number_with_status %} +{% from "components/show-more.html" import show_more %} +{% from "components/message-count-label.html" import message_count_label %} +{% from "components/table.html" import list_table, field, right_aligned_field_heading, hidden_field_heading %} + {% block page_title %} {{ current_service.name }} – GOV.UK Notify {% endblock %} @@ -23,7 +28,51 @@

In the last 7 days

- {% include 'views/dashboard/today.html' %} + +
+
+ {% include 'views/dashboard/_totals.html' %} +
+ {{ show_more( + url_for('.weekly', service_id=current_service.id), + 'Compare to previous weeks' + ) }} +
+
+ + {% if template_statistics|length %} + {% include 'views/dashboard/template-statistics.html' %} + {{ show_more( + url_for('.template_history', service_id=current_service.id), + 'See all templates used this year' + ) }} + {% endif %} + + {% if jobs %} + {% include 'views/dashboard/_jobs.html' %} + {{ show_more( + url_for('.view_jobs', service_id=current_service.id), + 'See all uploaded files' + ) }} + {% endif %} + + {% if current_user.has_permissions(['manage_settings'], admin_override=True) %} +

This year

+ {% include 'views/dashboard/_jobs.html' %} + {{ show_more( + url_for(".usage", service_id=current_service['id']), + 'See usage breakdown' + ) }} + {% endif %} + +
+ diff --git a/app/templates/views/dashboard/today.html b/app/templates/views/dashboard/today.html deleted file mode 100644 index 409c4e58a..000000000 --- a/app/templates/views/dashboard/today.html +++ /dev/null @@ -1,90 +0,0 @@ -{% from "components/big-number.html" import big_number, big_number_with_status %} -{% from "components/show-more.html" import show_more %} -{% from "components/message-count-label.html" import message_count_label %} -{% from "components/table.html" import list_table, field, right_aligned_field_heading, hidden_field_heading %} - -
-
-
- {{ big_number_with_status( - statistics.emails_requested, - message_count_label(statistics.emails_requested, 'email', suffix=''), - statistics.emails_failed, - statistics.get('emails_failure_rate', 0.0), - statistics.get('emails_failure_rate', 0)|float > 3, - failure_link=url_for(".view_notifications", service_id=current_service.id, message_type='email', status='failed'), - link=url_for(".view_notifications", service_id=current_service.id, message_type='email', status='sending,delivered,failed') - ) }} -
-
- {{ big_number_with_status( - statistics.sms_requested, - message_count_label(statistics.sms_requested, 'sms', suffix=''), - statistics.sms_failed, - statistics.get('sms_failure_rate', 0.0), - statistics.get('sms_failure_rate', 0)|float > 3, - failure_link=url_for(".view_notifications", service_id=current_service.id, message_type='sms', status='failed'), - link=url_for(".view_notifications", service_id=current_service.id, message_type='sms', status='sending,delivered,failed') - ) }} -
-
- {{ show_more( - url_for('.weekly', service_id=current_service.id), - 'Compare to previous weeks' - ) }} -
-
- - {% if template_statistics|length %} - {% include 'views/dashboard/template-statistics.html' %} - {{ show_more( - url_for('.template_history', service_id=current_service.id), - 'See all templates used this year' - ) }} - {% endif %} - - {% if jobs %} - {% include 'views/dashboard/_jobs.html' %} - {{ show_more( - url_for('.view_jobs', service_id=current_service.id), - 'See all uploaded files' - ) }} - {% endif %} - - {% if current_user.has_permissions(['manage_settings'], admin_override=True) %} -

This year

- -
-
-
- {{ big_number("Unlimited", 'free email allowance', smaller=True) }} -
-
-
-
- {% if sms_chargeable %} - {{ big_number( - (sms_chargeable * sms_rate), - 'spent on text messages', - currency="£", - smaller=True - ) }} - {% else %} - {{ big_number(sms_allowance_remaining, 'free text messages left', smaller=True) }} - {% endif %} -
-
-
- {{ show_more( - url_for(".usage", service_id=current_service['id']), - 'See usage breakdown' - ) }} - {% endif %} - -