Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web/web/blueprints/attacks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def download(attack_id):
def create():
return render_template('attacks/create.html')

@attacks.route('/table')
def table():
return render_template('attacks/attacks_table.html', attacks=Attack.query.all())

@attacks.errorhandler(NotFound)
def handle_not_found_error(e):
if (request.referrer is None):
Expand Down
29 changes: 29 additions & 0 deletions web/web/blueprints/attacks/templates/attacks/attacks_table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<table class="table table-hover table-clickable-rows">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Created By</th>
<th scope="col">Created At</th>
<th scope="col">Teams currently passing</th>
</tr>
</thead>
<tbody>
{% for attack in attacks %}
<tr onclick="window.location='{{ url_for('attacks.show', attack_id=attack.id) }}';">
<th scope="row">{{ attack.name }}</th>
<td>{{ attack.team.name if attack.team else "" }}</td>
<td>{{ attack.created_at | formatdatetime }}</td>
<td>{{ attack.passing | length }}</td>
</tr>
{% endfor %}
<!--<tr onclick="window.location='{{ url_for('teams.show', team_id=2) }}';">
<th scope="row">Sloths</th>
<td>20/27
<div class="spinner-border spinner-border-sm" style="color:#888;" role="status">
<span class="sr-only">Running Tests...</span>
</div> <span style="color:#888;">Rescoring...</span></td>
<td>22/28</td>
<td>Fifteen seconds ago</td>
</tr>-->
</tbody>
</table>
66 changes: 36 additions & 30 deletions web/web/blueprints/attacks/templates/attacks/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,42 @@
{% block title %}Attacks{% endblock %}

{% block content %}
<button class="btn btn-primary mb-2" onclick="location.reload()">Reload results</button>
<button class="btn btn-primary mb-2" onclick="reloadTable()">Reload results</button>
<div class="form-check mb-2 me-sm-2">
<input class="form-check-input" type="checkbox" id="autorefresh-checkbox" onclick="autoRefreshClick(this);">
<label class="form-check-label" for="autorefresh-checkbox">
Automatically refresh results
</label>
</div>
<a class="btn btn-light mb-2" href="{{ url_for('attacks.create') }}">Submit an attack</a>
<table class="table table-hover table-clickable-rows">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Created By</th>
<th scope="col">Created At</th>
<th scope="col">Teams currently passing</th>
</tr>
</thead>
<tbody>
{% for attack in attacks %}
<tr onclick="window.location='{{ url_for('attacks.show', attack_id=attack.id) }}';">
<th scope="row">{{ attack.name }}</th>
<td>{{ attack.team.name if attack.team else "" }}</td>
<td>{{ attack.created_at | formatdatetime }}</td>
<td>{{ attack.passing | length }}</td>
</tr>
{% endfor %}
<!--<tr onclick="window.location='{{ url_for('teams.show', team_id=2) }}';">
<th scope="row">Sloths</th>
<td>20/27
<div class="spinner-border spinner-border-sm" style="color:#888;" role="status">
<span class="sr-only">Running Tests...</span>
</div> <span style="color:#888;">Rescoring...</span></td>
<td>22/28</td>
<td>Fifteen seconds ago</td>
</tr>-->
</tbody>
</table>
<div id="content">
{% include "attacks/attacks_table.html" %}
</div>
{% endblock %}

{% block scripts %}
<script>
async function reloadTable() {
let response = await fetch("{{ url_for('attacks.table') }}");
document.getElementById('content').innerHTML = await response.text();
}

$(function() {
setInterval(async function() {
if (document.getElementById('autorefresh-checkbox').checked) {
reloadTable();
}
}, 10000);
});

document.addEventListener('DOMContentLoaded', (event) => {
if (localStorage["autorefresh"] === 'true') {
document.getElementById('autorefresh-checkbox').checked = true
}
});

function autoRefreshClick(cb) {
localStorage["autorefresh"] = cb.checked
}
</script>
{% endblock %}