From bafa1ceead07440a6b64109a135a09c7506ec5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Hn=C3=A1t?= Date: Tue, 1 Nov 2022 13:38:17 +0100 Subject: [PATCH] Kinda working --- dashboard.py | 13 +++++++------ dashboard_static/index.html | 13 ++++++++++++- dashboard_static/js/code.js | 7 ++++++- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/dashboard.py b/dashboard.py index 5574203..307e603 100644 --- a/dashboard.py +++ b/dashboard.py @@ -12,7 +12,7 @@ root_content_path = 'dashboard_static' # the action will be called with the context and the event @event('init') def setup(ctx, e): - start_offline_tweets('sports1.txt', event_name="sample") + start_offline_tweets('sports1.txt', event_name="tweet") ctx.count = 0 # fire('sample', {'previous': 0.0}) @@ -21,21 +21,22 @@ def setup(ctx, e): def clip(lower, value, upper): return max(lower, min(value, upper)) -@event('sample') -def generate_sample(ctx, e): +@event('tweet') +def generate_tweet(ctx, e): ctx.count += 1 if ctx.count % 50 == 0: emit('debug', {'text': 'Log message #'+str(ctx.count)+'!'}) + print('Log message #'+str(ctx.count)+'!') tweet = e.data print(tweet) # base sample on previous one # sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100) # emit to outside world - emit('sample',{ + emit('tweet', { 'action': 'add', 'value': tweet }) - # chain event - fire('sample', {'previous': tweet}, delay=0.05) + # # chain event + # fire('tweet', {'previous': tweet}, delay=0.05) diff --git a/dashboard_static/index.html b/dashboard_static/index.html index bc976ac..7446894 100644 --- a/dashboard_static/index.html +++ b/dashboard_static/index.html @@ -13,6 +13,7 @@ +
@@ -86,13 +87,23 @@
-->
-
+
+
+ +
+
+ + + + + + diff --git a/dashboard_static/js/code.js b/dashboard_static/js/code.js index d71171d..7492605 100644 --- a/dashboard_static/js/code.js +++ b/dashboard_static/js/code.js @@ -26,4 +26,9 @@ function tweetCell(tweet, parent) { var cell = document.createElement("div") cell.innerHTML = "
" -} \ No newline at end of file +} +(function($, block) { + block("#tweet").tweets({ + memory: 20 + }); +})(jQuery, block);