Provide an initial datapoint on rendering index

This patch adds a single data point when rendering the
initial stats for the index page.
This commit is contained in:
Hemna 2021-03-30 10:18:56 -04:00
parent 6297ebeb67
commit fb979eda94
2 changed files with 11 additions and 3 deletions

View File

@ -43,7 +43,8 @@ class APRSDFlask(flask_classful.FlaskView):
@auth.login_required
def index(self):
return flask.render_template("index.html", message=self.stats())
stats = self._stats()
return flask.render_template("index.html", initial_stats=stats)
@auth.login_required
def messages(self):
@ -69,7 +70,7 @@ class APRSDFlask(flask_classful.FlaskView):
track.save()
return json.dumps({"messages": "saved"})
def stats(self):
def _stats(self):
stats_obj = stats.APRSDStats()
track = messaging.MsgTrack()
now = datetime.datetime.now()
@ -84,7 +85,11 @@ class APRSDFlask(flask_classful.FlaskView):
"memory_current": current,
"memory_peak": peak,
}
return json.dumps(result)
return result
def stats(self):
return json.dumps(self._stats())
def init_flask(config):

View File

@ -12,6 +12,8 @@
<script type="text/javascript"">
var initial_stats = {{ initial_stats|tojson|safe }};
var memory_chart = null
var message_chart = null
var color = Chart.helpers.color;
@ -166,6 +168,7 @@
$(document).ready(function() {
console.log(initial_stats);
start_update();
start_charts();