solutions table
This commit is contained in:
44
templates/solutions.html
Normal file
44
templates/solutions.html
Normal file
@@ -0,0 +1,44 @@
|
||||
{% extends 'base_main.html' %}
|
||||
|
||||
{% block scripts %}
|
||||
var page = 1;
|
||||
function setPage(number) {
|
||||
page = number;
|
||||
}
|
||||
function doPoll() {
|
||||
jQuery.get('/solutions_table?task_id={{ task.id }}&page=' + page.toString(), function(data) {
|
||||
document.getElementById('solutions').innerHTML = data;
|
||||
const name = "page_num_" + page.toString();
|
||||
document.getElementById(name).className = "btn btn-dark";
|
||||
setTimeout(function() {doPoll()}, 2000);
|
||||
})
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block onload %}doPoll(){% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<h2>Решения</h2>
|
||||
<h4>Фильтр</h4>
|
||||
<div>
|
||||
<select name="set_id" style="width: 33%">
|
||||
<option value="0">Все сеты</option>
|
||||
{% for set in user.userinfo.available_sets %}
|
||||
<option value="{{ set.id }}" {% if set.id == set_id %}selected{% endif %}>{{ set.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<select name="set_id" style="width: 33%">
|
||||
<option value="0">Все таски</option>
|
||||
{% for task in user.userinfo.available_tasks %}
|
||||
<option value="{{ task.id }}" {% if task.id == task_id %}selected{% endif %}>{{ task.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<select name="set_id" style="width: 33%">
|
||||
<option value="0">Все пользователи</option>
|
||||
{% for u in users %}
|
||||
<option value="{{ user.username }}" {% if user.username == username %}selected{% endif %}>{{ user.userinfo }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div id="solutions"></div>
|
||||
{% endblock %}
|
@@ -1,8 +1,24 @@
|
||||
<table class="table" style="margin-top: 30px;">
|
||||
<thead>
|
||||
<th scope="col">id</th>
|
||||
<th scope="col">Пользователь</th>
|
||||
<th scope="col">Задача</th>
|
||||
<th scope="col">Время отправки</th>
|
||||
<th scope="col">Язык</th>
|
||||
<th scope="col">Результат</th>
|
||||
</thead>
|
||||
<tbody id="solutions">
|
||||
{% for solution in solutions %}
|
||||
<tr>
|
||||
<td>
|
||||
<b><a href="/solution?solution_id={{ solution.id }}">{{ solution.id }}</a></b>
|
||||
</td>
|
||||
<td>
|
||||
<img src="{{ solution.user.userinfo.profile_pic_url }}" width="30px" height="30px" style="border-radius: 50%; margin-right: 10px;"><a href="/account?username={{ solution.user.username }}">{{ solution.user }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/task?task_id={{ solution.task.id }}">{{ solution.task.name }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ solution.time_sent }}
|
||||
</td>
|
||||
@@ -16,4 +32,17 @@
|
||||
</h4>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if need_pagination %}
|
||||
<div style="display: flex; justify-content: flex-end">
|
||||
<table>
|
||||
<tr>
|
||||
{% for num in count_pages %}
|
||||
<td><button class="btn btn-light" id="page_num_{{ num }}" onclick="setPage({{ num }})">{{ num }}</button></td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
@@ -19,26 +19,20 @@
|
||||
document.getElementById('file-upload').value = null;
|
||||
document.getElementById('input0').value = "";
|
||||
}
|
||||
var page = 1;
|
||||
function setPage(number) {
|
||||
page = number;
|
||||
}
|
||||
function doPoll() {
|
||||
jQuery.get('/solutions_table?task_id={{ task.id }}', function(data) {
|
||||
jQuery.get('/solutions_table?task_id={{ task.id }}&username={{ user.username }}&page=' + page.toString(), function(data) {
|
||||
document.getElementById('solutions').innerHTML = data;
|
||||
const name = "page_num_" + page.toString();
|
||||
document.getElementById(name).className = "btn btn-dark";
|
||||
jQuery.get('/task_runtime?task_id={{ task.id }}', function(data1) {
|
||||
if (data == 'done' && data1 == 'done')
|
||||
return
|
||||
if (data != 'done') {
|
||||
document.getElementById('solutions').innerHTML = data;
|
||||
}
|
||||
if (data1 != 'done') {
|
||||
document.getElementById('runtime').innerHTML = data1;
|
||||
}
|
||||
document.getElementById('runtime').innerHTML = data1;
|
||||
setTimeout(function() {doPoll()}, 2000);
|
||||
})
|
||||
})
|
||||
jQuery.get('/solutions_table?id={{ task.id }}&render=true', function(data) {
|
||||
document.getElementById('solutions').innerHTML = data;
|
||||
})
|
||||
jQuery.get('/task_runtime?id={{ task.id }}&render=true', function(data) {
|
||||
document.getElementById('runtime').innerHTML = data;
|
||||
})
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
@@ -134,15 +128,5 @@
|
||||
</form>
|
||||
<hr>
|
||||
<h2>Решения</h2>
|
||||
<table class="table" style="margin-top: 30px;">
|
||||
<thead>
|
||||
<th scope="col">id</th>
|
||||
<th scope="col">Время отправки</th>
|
||||
<th scope="col">Язык</th>
|
||||
<th scope="col">Результат</th>
|
||||
</thead>
|
||||
<tbody id="solutions">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="solutions"></div>
|
||||
{% endblock %}
|
@@ -44,6 +44,6 @@
|
||||
</tr>
|
||||
</table>
|
||||
{% for task in tasks %}
|
||||
<a href="/task?task_id={{ task.id }}">{{ task.name }}</a> {% if task.creator == user %}<a href="/admin/task?task_id={{ task.id }}"><i class="fa fa-pencil"></i> </a>{% endif %}<br>
|
||||
<a href="/task?task_id={{ task.id }}">{{ task.name }}</a> {% if task.creator == user %}<a href="/admin/task?task_id={{ task.id }}"><i class="fa fa-pencil"></i> </a><a href="/solutions?task_id={{ task.id }}&page=1"><i class="fa fa-stack-overflow"></i> </a>{% endif %}<br>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
Reference in New Issue
Block a user