WebHost: List Rooms in a sortable table

This commit is contained in:
Fabian Dill 2020-07-21 23:15:19 +02:00
parent b7d45ae663
commit 78c85cce14
8 changed files with 52 additions and 17 deletions

View File

@ -621,7 +621,7 @@ class CommandProcessor(metaclass=CommandMeta):
license = getattr(CommandProcessor, "license", None)
if not license:
with open(Utils.local_path("LICENSE")) as f:
CommandProcessor.license = license = f.read()
CommandProcessor.license = f.read()
self.output(CommandProcessor.license)
def default(self, raw: str):

View File

@ -36,9 +36,11 @@ def int32_as_bytes(value):
def pc_to_snes(value):
return ((value<<1) & 0x7F0000)|(value & 0x7FFF)|0x8000
def snes_to_pc(value):
return ((value & 0x7F0000)>>1)|(value & 0x7FFF)
def parse_player_names(names, players, teams):
names = tuple(n for n in (n.strip() for n in names.split(",")) if n)
ret = []
@ -52,9 +54,11 @@ def parse_player_names(names, players, teams):
names = names[players:]
return ret
def is_bundled():
def is_bundled() -> bool:
return getattr(sys, 'frozen', False)
def local_path(path):
if local_path.cached_path:
return os.path.join(local_path.cached_path, path)

View File

@ -42,7 +42,7 @@
}
window.setTimeout(request_new, 1000);
window.setInterval(request_new, 3000);
window.setInterval(request_new, 10000);
</script>
</div>
{% endblock %}

View File

@ -0,0 +1,6 @@
{% extends "layout.html" %}
{% block head %}
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4-4.1.1/jq-3.3.1/dt-1.10.21/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4-4.1.1/jq-3.3.1/dt-1.10.21/datatables.min.js"></script>
<script src="{{ static_autoversion("jquery.scrollsync.js") }}"></script>
{% endblock %}

View File

@ -1,11 +1,8 @@
{% extends 'layout.html' %}
{% extends 'tablepage.html' %}
{% block head %}
{{ super() }}
<title>Multiworld Tracker for Room {{ room.id }}</title>
<link rel="stylesheet" type="text/css" href="{{ static_autoversion("static.css") }}"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4-4.1.1/jq-3.3.1/dt-1.10.21/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4-4.1.1/jq-3.3.1/dt-1.10.21/datatables.min.js"></script>
<script src="{{ static_autoversion("jquery.scrollsync.js") }}"></script>
<link rel="stylesheet" type="text/css" href="{{ static_autoversion("tracker.css") }}"/>
<script>
window.onload = () => {
let tables = $(".table").DataTable({

View File

@ -1,9 +1,21 @@
{% extends 'layout.html' %}
{% extends 'tablepage.html' %}
{% block head %}
{{ super() }}
<title>Upload Multidata</title>
<link rel="stylesheet" type="text/css" href="{{ static_autoversion("uploads.css") }}" />
<script type="application/ecmascript" src="{{ static_autoversion("uploads.js") }}"></script>
<script>
window.onload = () => {
let tables = $(".table").DataTable({
"paging": false,
"ordering": true,
"order": [[ 3, "desc" ]],
"info": false,
"dom": "t",
});
}
</script>
{% endblock %}
{% block body %}
@ -21,14 +33,30 @@
{% if rooms %}
<p>Your Rooms:</p>
<ul id="room-list">
<table class="table table-striped table-bordered table-hover table-sm">
<thead>
<tr>
<th>Seed</th>
<th>Room</th>
<th>Players</th>
<th>Created</th>
<th>Last Activity</th>
</tr>
</thead>
<tbody>
{% for room in rooms %}
<li>
Room: <a href="{{ url_for("host_room", room=room.id) }}">{{ room.id }}</a><br />
Seed: <a href="{{ url_for("view_seed", seed=room.seed.id) }}">{{ room.seed.id }}</a>
</li>
<tr>
<td><a href="{{ url_for("view_seed", seed=room.seed.id) }}">{{ room.seed.id }}</a></td>
<td><a href="{{ url_for("host_room", room=room.id) }}">{{ room.id }}</a></td>
<td>{{ room.seed.multidata.names[0]|length }} Total:
{{ room.seed.multidata.names[0]|join(", ")|truncate(256, False, " ...") }}</td>
<td>{{ room.creation_time.strftime("%Y-%m-%d %H:%M") }}</td>
<td>{{ room.last_activity.strftime("%Y-%m-%d %H:%M") }}</td>
</tr>
{% endfor %}
</ul>
</tbody>
</table>
{% else %}
<p>No rooms owned by you were found. Upload a file to get started.</p>
{% endif %}

View File

@ -242,7 +242,7 @@ def get_static_room_data(room: Room):
use_door_tracker = False
if "tags" in multidata:
use_door_tracker = "DR" in multidata.tags
use_door_tracker = "DR" in multidata["tags"]
result = locations, names, use_door_tracker
_multidata_cache[room.seed.id] = result
return result