mirror of
https://github.com/craigerl/aprsd.git
synced 2025-03-07 11:58:43 -05:00
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:
parent
6297ebeb67
commit
fb979eda94
@ -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):
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user