Split the JSON responses into one key per section

Previously, the AJAX update for the dashboard was returning a big blob
of JSON with one key.

This commit splits it up to return:

- one key for each section of the page
- each containing a smaller chunk of HTML rendered from a partial

The jobs page was already working this way (pretty much) but just needed
a little tweaking to get it the same.
This commit is contained in:
Chris Hill-Scott
2016-06-28 09:07:04 +01:00
parent fe1d63675d
commit c761d57d1d
9 changed files with 135 additions and 131 deletions

View File

@@ -57,11 +57,24 @@ def service_dashboard(service_id):
@login_required
@user_has_permissions('view_activity', admin_override=True)
def service_dashboard_updates(service_id):
dashboard_statistics = get_dashboard_statistics_for_service(service_id)
return jsonify(**{
'today': render_template(
'views/dashboard/today.html',
**get_dashboard_statistics_for_service(service_id)
)
'totals': render_template(
'views/dashboard/_totals.html',
**dashboard_statistics
),
'template-statistics': render_template(
'views/dashboard/template-statistics.html',
**dashboard_statistics
),
'jobs': render_template(
'views/dashboard/_jobs.html',
**dashboard_statistics
),
'usage': render_template(
'views/dashboard/_usage.html',
**dashboard_statistics
),
})