Kinda working
This commit is contained in:
		
							
								
								
									
										13
									
								
								dashboard.py
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								dashboard.py
									
									
									
									
									
								
							| @@ -12,7 +12,7 @@ root_content_path = 'dashboard_static' | |||||||
| # the action will be called with the context and the event | # the action will be called with the context and the event | ||||||
| @event('init') | @event('init') | ||||||
| def setup(ctx, e): | def setup(ctx, e): | ||||||
|     start_offline_tweets('sports1.txt', event_name="sample") |     start_offline_tweets('sports1.txt', event_name="tweet") | ||||||
|     ctx.count = 0 |     ctx.count = 0 | ||||||
|     # fire('sample', {'previous': 0.0}) |     # fire('sample', {'previous': 0.0}) | ||||||
|  |  | ||||||
| @@ -21,21 +21,22 @@ def setup(ctx, e): | |||||||
| def clip(lower, value, upper): | def clip(lower, value, upper): | ||||||
|     return max(lower, min(value, upper)) |     return max(lower, min(value, upper)) | ||||||
|  |  | ||||||
| @event('sample') | @event('tweet') | ||||||
| def generate_sample(ctx, e): | def generate_tweet(ctx, e): | ||||||
|     ctx.count += 1 |     ctx.count += 1 | ||||||
|     if ctx.count % 50 == 0: |     if ctx.count % 50 == 0: | ||||||
|         emit('debug', {'text': 'Log message #'+str(ctx.count)+'!'}) |         emit('debug', {'text': 'Log message #'+str(ctx.count)+'!'}) | ||||||
|  |         print('Log message #'+str(ctx.count)+'!') | ||||||
|     tweet = e.data |     tweet = e.data | ||||||
|     print(tweet) |     print(tweet) | ||||||
|     # base sample on previous one |     # base sample on previous one | ||||||
|     # sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100) |     # sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100) | ||||||
|     # emit to outside world |     # emit to outside world | ||||||
|     emit('sample',{ |     emit('tweet', { | ||||||
|         'action': 'add', |         'action': 'add', | ||||||
|         'value': tweet |         'value': tweet | ||||||
|     }) |     }) | ||||||
|  |  | ||||||
|     # chain event |     # # chain event | ||||||
|     fire('sample', {'previous': tweet}, delay=0.05) |     # fire('tweet', {'previous': tweet}, delay=0.05) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -13,6 +13,7 @@ | |||||||
|     <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" /> |     <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" /> | ||||||
|     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> |     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> | ||||||
|     <link rel="icon" type="image/x-icon" href="./media/logo.png"> |     <link rel="icon" type="image/x-icon" href="./media/logo.png"> | ||||||
|  |      | ||||||
| </head> | </head> | ||||||
| <body> | <body> | ||||||
|     <div class="container"> |     <div class="container"> | ||||||
| @@ -86,13 +87,23 @@ | |||||||
|             </div> |             </div> | ||||||
|             --> |             --> | ||||||
|             <div class = "maintable"> |             <div class = "maintable"> | ||||||
|                 <div class = "leftcol"></div> |                 <div class = "leftcol"> | ||||||
|  |                     <div id="tweet"> | ||||||
|  |  | ||||||
|  |                     </div> | ||||||
|  |                 </div> | ||||||
|                 <div class="centercol"></div> |                 <div class="centercol"></div> | ||||||
|                 <div class = "searchbar"></div> |                 <div class = "searchbar"></div> | ||||||
|                 <div class = "popchart"></div> |                 <div class = "popchart"></div> | ||||||
|             </div> |             </div> | ||||||
|         </div>  |         </div>  | ||||||
|     </div> |     </div> | ||||||
|  |     <script src="/lib/jquery-2.1.1.min.js"></script> | ||||||
|  |     <script src="/lib/jquery.flot.min.js"></script> | ||||||
|  |     <script src="/lib/core.js"></script> | ||||||
|  |     <script src="/lib/charts.js"></script> | ||||||
|  |     <script src="/lib/log.js"></script> | ||||||
|  |     <script src="./lib/tweets.js"></script> | ||||||
|     <script src="./js/code.js"></script> |     <script src="./js/code.js"></script> | ||||||
|     <script src="./js/connection.js"></script> |     <script src="./js/connection.js"></script> | ||||||
| </body> | </body> | ||||||
|   | |||||||
| @@ -27,3 +27,8 @@ function tweetCell(tweet, parent) { | |||||||
|     cell.innerHTML = |     cell.innerHTML = | ||||||
|         "<div>" |         "<div>" | ||||||
| } | } | ||||||
|  | (function($, block) { | ||||||
|  |     block("#tweet").tweets({ | ||||||
|  |         memory: 20 | ||||||
|  |     }); | ||||||
|  | })(jQuery, block); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user