mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 02:42:26 -05:00
Make dashboard stats update dynamically
https://www.pivotaltracker.com/story/show/115874485 This uses the same component as on the jobs page to make a partial section of the page update itself periodically.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from flask import (
|
||||
render_template,
|
||||
session,
|
||||
flash
|
||||
flash,
|
||||
jsonify
|
||||
)
|
||||
|
||||
from flask_login import login_required
|
||||
@@ -41,6 +42,20 @@ def service_dashboard(service_id):
|
||||
service_id=str(service_id))
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/dashboard.json")
|
||||
@login_required
|
||||
def service_dashboard_updates(service_id):
|
||||
|
||||
statistics = statistics_api_client.get_statistics_for_service(service_id)['data']
|
||||
|
||||
return jsonify(**{
|
||||
'today': render_template(
|
||||
'views/dashboard/today.html',
|
||||
statistics=expand_statistics(statistics),
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
def expand_statistics(statistics, danger_zone=25):
|
||||
|
||||
if not statistics or not statistics[0]:
|
||||
|
||||
@@ -13,7 +13,15 @@
|
||||
{% if not jobs %}
|
||||
{% include 'views/dashboard/get-started.html' %}
|
||||
{% else %}
|
||||
{% include 'views/dashboard/today.html' %}
|
||||
|
||||
<div
|
||||
data-module="update-content"
|
||||
data-resource="{{url_for(".service_dashboard_updates", service_id=service_id)}}"
|
||||
data-key="today"
|
||||
>
|
||||
{% include 'views/dashboard/today.html' %}
|
||||
</div>
|
||||
|
||||
{% include 'views/dashboard/jobs.html' %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user