nice update

This commit is contained in:
GroovieGermanikus 2023-10-13 23:42:35 +02:00
parent 9f6218947c
commit 1add2f37cf
No known key found for this signature in database
GPG Key ID: 5B6EB831A5CD2015
3 changed files with 111 additions and 80 deletions

38
app.py
View File

@ -1,16 +1,42 @@
from flask import Flask, render_template
from turbo_flask import Turbo
import transaction_database
import threading
import time
from random import shuffle
app = Flask(__name__)
# https://blog.miguelgrinberg.com/post/dynamically-update-your-flask-web-pages-using-turbo-flask
turbo = Turbo(app)
app.update_thread_started = False
@app.route('/dashboard')
def table():
def dashboard():
start_if_needed()
maprows = transaction_database.RunQuery()
print(maprows)
return render_template('table.html', transactions=maprows)
return render_template('dashboard.html', transactions=maprows)
@app.route('/<name>')
def hello(name=None):
return render_template('hello.html', name=name)
# refresh all clients
@app.route('/refresh')
def refresh():
# turbo.push(turbo.replace(render_template('table.html'), 'datatable'))
return 'ok'
def start_if_needed():
if app.update_thread_started:
return
app.update_thread_started = True
threading.Thread(target=update_load).start()
def update_load():
with app.app_context():
print('start update poller')
while True:
time.sleep(1)
maprows = transaction_database.RunQuery()
shuffle(maprows)
turbo.push(turbo.replace(render_template('table.html', transactions=maprows), 'datatable'))

40
templates/dashboard.html Normal file
View File

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Solana Transaction Errors</title>
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='a72bf4ce55ad4320.css') }}">
<link href='https://fonts.googleapis.com/css?family=Rubik' rel='stylesheet'>
<!-- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">-->
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>-->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style>
body {
font-family: 'Rubik';
--explorer-default-font: 'Rubik';
}
</style>
{{ turbo() }}
</head>
<body>
<div class="main-content pb-4">
<div class="container mt-n2">
<div class="card">
<div class="card-header align-items-center"><h3 class="card-header-title">Transactions Errors</h3>
</div>
<div class="table-responsive mb-0">
{% include "table.html" %}
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -1,78 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Solana Transaction Errors</title>
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='a72bf4ce55ad4320.css') }}">
<link href='https://fonts.googleapis.com/css?family=Rubik' rel='stylesheet'>
<!-- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">-->
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>-->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style>
body {
font-family: 'Rubik';
--explorer-default-font: 'Rubik';
}
</style>
{{ turbo() }}
</head>
<body data-turbo-suppress-warning>
<table id="datatable" class="table table-sm table-nowrap card-table">
<thead>
<tr>
<th class="text-muted c-pointer">#</th>
<th class="text-muted">Execution</th>
<th class="text-muted">Transaction Signature</th>
<th class="text-muted text-end c-pointer">CU requested</th>
<th class="text-muted text-end c-pointer">Prio Fees</th>
<th class="text-muted">Errors</th>
</tr>
</thead>
<tbody class="list">
{% for tx in transactions %}
<tr>
<td>{{ tx.pos }}</td>
<div id="load" class="load main-content pb-4">
<div class="containter mt-n2">
<div class="card">
<div class="card-header align-items-center"><h3 class="card-header-title">Transactions Errors</h3>
{% if tx.is_executed %}
<td><span class="badge bg-success-soft">Executed</span></td>
{% elif not tx.is_executed %}
<td><span class="badge bg-warning-soft">Failed</span></td>
{% endif %}
<td>
<div class="align-items-center" style="width:20em;text-overflow:ellipsis; overflow:hidden"><span class="font-size-tiny me-2"></span></span><span
class="font-monospace"><a class=""
href="https://explorer.solana.com/tx/{{ tx.signature }}">{{ tx.signature }}</a></span>
</div>
<div class="table-responsive mb-0">
<table class="table table-sm table-nowrap card-table">
<thead>
<tr>
<th class="text-muted c-pointer">#</th>
<th class="text-muted">Execution</th>
<th class="text-muted">Transaction Signature</th>
<th class="text-muted text-end c-pointer">CU requested</th>
<th class="text-muted text-end c-pointer">Prio Fees</th>
<th class="text-muted">Errors</th>
</tr>
</thead>
<tbody class="list">
{% for tx in transactions %}
<tr>
<td>{{ tx.pos }}</td>
{% if tx.is_executed %}
<td><span class="badge bg-success-soft">Executed</span></td>
{% elif not tx.is_executed %}
<td><span class="badge bg-warning-soft">Failed</span></td>
{% endif %}
<td>
<div class="align-items-center" style="width:20em;text-overflow:ellipsis; overflow:hidden"><span class="font-size-tiny me-2"></span></span><span
class="font-monospace"><a class=""
href="https://explorer.solana.com/tx/{{ tx.signature }}">{{ tx.signature }}</a></span>
</div>
</td>
<td class="text-end"><span class="font-monospace">{{ tx.cu_requested|default('no CU', True) }}</span></td>
<td class="text-end">{{ tx.prioritization_fees|default('no fees', True) }}</td>
<td>
{% for error in tx.errors_array %}
<div class="d-flex align-items-center">
<div class="d-flex align-items-center"><span class="font-size-tiny me-2"></span><span
class="font-monospace text-danger">{{ error }}</span>
</div>
</div>
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</td>
<td class="text-end"><span class="font-monospace">{{ tx.cu_requested|default('no CU', True) }}</span></td>
<td class="text-end">{{ tx.prioritization_fees|default('no fees', True) }}</td>
<td>
{% for error in tx.errors_array %}
<div class="d-flex align-items-center">
<div class="d-flex align-items-center"><span class="font-size-tiny me-2"></span><span
class="font-monospace text-danger">{{ error }}</span>
</div>
</div>
{% endfor %}
</td>
</tr>
{% endfor %}
</div>
</div>
</div>
</body>
</html>
</tbody>
</table>