mirror of
https://github.com/FAUSheppy/tmnf-replay-server.git
synced 2025-12-05 22:51:37 +01:00
wip: todo
This commit is contained in:
36
server.py
36
server.py
@@ -204,6 +204,34 @@ class DataTable():
|
||||
|
||||
return self.__build(results, total, filtered)
|
||||
|
||||
def get_all_maps(self):
|
||||
|
||||
filtered = 0
|
||||
total = 0
|
||||
|
||||
# base query
|
||||
query = db.session.query(Map)
|
||||
total = query.count()
|
||||
if self.searchValue:
|
||||
|
||||
# search string (search for all substrings individually #
|
||||
filterQuery = query
|
||||
|
||||
for substr in self.searchValue.split(" "):
|
||||
searchSubstr = "%{}%".format(substr.strip())
|
||||
filterQuery = filterQuery.filter(Map.mapname.like(searchSubstr))
|
||||
|
||||
filtered = filterQuery.count()
|
||||
results = filterQuery.offset(self.start).limit(self.length).all()
|
||||
|
||||
else:
|
||||
|
||||
query = query.order_by(self.orderAscDbClassReverse(Map.mapname))
|
||||
results = query.offset(self.start).limit(self.length).all()
|
||||
filtered = total
|
||||
|
||||
return self.__build(results, total, filtered)
|
||||
|
||||
def replay_from_path(fullpath, uploader=None):
|
||||
|
||||
if not fullpath.endswith(".gbx"):
|
||||
@@ -311,6 +339,14 @@ def source(map_uid):
|
||||
jsonDict = dt.get(map_uid=map_uid)
|
||||
return flask.Response(json.dumps(jsonDict), 200, mimetype='application/json')
|
||||
|
||||
@app.route("/data-source-index", methods=["POST"])
|
||||
def index_source(map_uid):
|
||||
|
||||
cols = ["mapname", "personal_"]
|
||||
dt = DataTable(flask.request.form.to_dict(), )
|
||||
jsonDict = dt.get(map_uid=map_uid)
|
||||
return flask.Response(json.dumps(jsonDict), 200, mimetype='application/json')
|
||||
|
||||
@app.route("/upload", methods = ['GET', 'POST'])
|
||||
def upload():
|
||||
|
||||
|
||||
63
templates/datatable-overview.html
Normal file
63
templates/datatable-overview.html
Normal file
@@ -0,0 +1,63 @@
|
||||
<div style="font-size: 16px; font-weight: 300;" class="mt-5 mb-3 ml-2 mr-2" role="main">
|
||||
<table id="tableMain" class="table table-striped table-bordered table-sm"
|
||||
cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
{% for item in header_col %}
|
||||
<th class="th-sm font-weighIt-bold">{{ item }}</th>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- tbody serverside processing -->
|
||||
</table>
|
||||
<script defer>
|
||||
var dt = null
|
||||
$(document).ready(function () {
|
||||
dt = $('#tableMain').DataTable({
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: '/data-source-index',
|
||||
type: 'POST'
|
||||
},
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": 2,
|
||||
"render": function ( data, type, full, meta ) {
|
||||
const dateString = data
|
||||
const dateObj = new Date(dateString);
|
||||
const options = { day: '2-digit',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit' };
|
||||
const formattedDate = dateObj.toLocaleString('de-DE', options);
|
||||
return formattedDate
|
||||
}
|
||||
},
|
||||
{
|
||||
"targets": 3,
|
||||
"render": function ( data, type, full, meta ) {
|
||||
return '<a href=\"/static/'+data+'\" download>Download</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
"targets": 0,
|
||||
"render": function ( data, type, full, meta ) {
|
||||
const regex = /^([^/]+)/;
|
||||
const match = data.match(regex);
|
||||
const prefix = match ? match[1] : '';
|
||||
const ip4regex = /\b(?:\d{1,3}\.){3}\d{1,3}(?::\d+)?\b/;
|
||||
const containsIPv4 = ip4regex.test(data);
|
||||
if(containsIPv4){
|
||||
return prefix
|
||||
}else{
|
||||
return data
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
$('.dataTables_length').addClass('bs-select');
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
Reference in New Issue
Block a user