mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-06-07 20:44:31 +00:00
Added table to web
This commit is contained in:
7
Server/static/css/bootstrap.min.css
vendored
Normal file
7
Server/static/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
7
Server/static/css/main.css
Normal file
7
Server/static/css/main.css
Normal file
@@ -0,0 +1,7 @@
|
||||
html, body, .container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
3
Server/static/css/tabulator.min.css
vendored
Normal file
3
Server/static/css/tabulator.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
24
Server/static/js/main.js
Normal file
24
Server/static/js/main.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var tabledata = [];
|
||||
updateData();
|
||||
|
||||
function updateData() {
|
||||
let req = new XMLHttpRequest();
|
||||
req.open('POST', '/selfcheck/all', false);
|
||||
req.send();
|
||||
tabledata = JSON.parse(req.response);
|
||||
}
|
||||
|
||||
var table = new Tabulator("#example-table", {
|
||||
data: tabledata,
|
||||
reactiveData: true,
|
||||
layout: "fitColumns",
|
||||
columns: [ //Define Table Columns
|
||||
{title: "Name", field: "name"},
|
||||
{title: "IP", field: "ip"},
|
||||
{title: "Animation id", field: "anim_id"},
|
||||
{title: "Batt voltage", field: "batt_voltage"},
|
||||
{title: "Cell voltage", field: "cell_voltage"},
|
||||
{title: "Selfcheck", field: "selfcheck"},
|
||||
{title: "Time", field: "time"},
|
||||
]
|
||||
});
|
||||
11
Server/static/js/tabulator.min.js
vendored
Normal file
11
Server/static/js/tabulator.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -3,8 +3,18 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Main</title>
|
||||
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/static/css/tabulator.min.css">
|
||||
<link rel="stylesheet" href="/static/css/main.css">
|
||||
<script lang="js" src="/static/js/tabulator.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
{{ data }}
|
||||
<div class="container">
|
||||
<div class="table-container">
|
||||
<div id="example-table"></div>
|
||||
</div>
|
||||
<div class="command-container"></div>
|
||||
</div>
|
||||
<script lang="js" src="/static/js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,9 +1,9 @@
|
||||
import threading
|
||||
from web_server_models import WebCopter
|
||||
from server import *
|
||||
from flask import Flask, render_template, jsonify, request
|
||||
from flask import Flask, render_template, jsonify, request, send_from_directory
|
||||
|
||||
app = Flask(__name__)
|
||||
app = Flask(__name__, static_url_path='/static')
|
||||
copters = []
|
||||
|
||||
|
||||
@@ -55,20 +55,20 @@ def selfcheck_selected():
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
@app.route('/selfcheck/all')
|
||||
@app.route('/selfcheck/all', methods=["GET", "POST"])
|
||||
def selfcheck_all():
|
||||
data = dict()
|
||||
ip = request.args.get("ip")
|
||||
data = []
|
||||
for copter in copters:
|
||||
copter.refresh()
|
||||
data[copter.ip] = {
|
||||
data.append({
|
||||
'anim_id': copter.anim_id,
|
||||
'batt_voltage': copter.batt_voltage,
|
||||
'cell_voltage': copter.cell_voltage,
|
||||
'selfcheck': copter.selfcheck,
|
||||
'ip': copter.ip,
|
||||
'time': copter.time,
|
||||
'name': copter.name,
|
||||
}
|
||||
})
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
@@ -80,6 +80,6 @@ class ServerThread(threading.Thread):
|
||||
pass
|
||||
|
||||
|
||||
server_thread = ServerThread()
|
||||
server_thread.start()
|
||||
# server_thread = ServerThread()
|
||||
# server_thread.start()
|
||||
app.run(host='0.0.0.0', debug=False)
|
||||
|
||||
Reference in New Issue
Block a user