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) license = getattr(CommandProcessor, "license", None)
if not license: if not license:
with open(Utils.local_path("LICENSE")) as f: with open(Utils.local_path("LICENSE")) as f:
CommandProcessor.license = license = f.read() CommandProcessor.license = f.read()
self.output(CommandProcessor.license) self.output(CommandProcessor.license)
def default(self, raw: str): def default(self, raw: str):

View File

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

View File

@ -42,7 +42,7 @@
} }
window.setTimeout(request_new, 1000); window.setTimeout(request_new, 1000);
window.setInterval(request_new, 3000); window.setInterval(request_new, 10000);
</script> </script>
</div> </div>
{% endblock %} {% 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 %} {% block head %}
{{ super() }}
<title>Multiworld Tracker for Room {{ room.id }}</title> <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="{{ static_autoversion("tracker.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>
<script> <script>
window.onload = () => { window.onload = () => {
let tables = $(".table").DataTable({ let tables = $(".table").DataTable({

View File

@ -1,9 +1,21 @@
{% extends 'layout.html' %} {% extends 'tablepage.html' %}
{% block head %} {% block head %}
{{ super() }}
<title>Upload Multidata</title> <title>Upload Multidata</title>
<link rel="stylesheet" type="text/css" href="{{ static_autoversion("uploads.css") }}" /> <link rel="stylesheet" type="text/css" href="{{ static_autoversion("uploads.css") }}" />
<script type="application/ecmascript" src="{{ static_autoversion("uploads.js") }}"></script> <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 %} {% endblock %}
{% block body %} {% block body %}
@ -21,14 +33,30 @@
{% if rooms %} {% if rooms %}
<p>Your Rooms:</p> <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 %} {% for room in rooms %}
<li> <tr>
Room: <a href="{{ url_for("host_room", room=room.id) }}">{{ room.id }}</a><br /> <td><a href="{{ url_for("view_seed", seed=room.seed.id) }}">{{ room.seed.id }}</a></td>
Seed: <a href="{{ url_for("view_seed", seed=room.seed.id) }}">{{ room.seed.id }}</a> <td><a href="{{ url_for("host_room", room=room.id) }}">{{ room.id }}</a></td>
</li> <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 %} {% endfor %}
</ul> </tbody>
</table>
{% else %} {% else %}
<p>No rooms owned by you were found. Upload a file to get started.</p> <p>No rooms owned by you were found. Upload a file to get started.</p>
{% endif %} {% endif %}

View File

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