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:
Chris Hill-Scott
2016-03-23 08:43:45 +00:00
parent bb08589875
commit 5c57f5b588
2 changed files with 25 additions and 2 deletions

View File

@@ -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]: