2021-03-19 17:51:25 +01:00
|
|
|
{% extends "main.html" %}
|
|
|
|
|
2022-01-14 15:58:06 +01:00
|
|
|
{% from 'bootstrap5/utils.html' import render_messages %}
|
2022-11-29 15:57:13 +01:00
|
|
|
{% from "macros.html" import shorten_string %}
|
2021-03-19 17:51:25 +01:00
|
|
|
|
|
|
|
{% block title %}Captures{% endblock %}
|
|
|
|
|
|
|
|
{% block scripts %}
|
|
|
|
{{ super() }}
|
|
|
|
<script type="text/javascript">
|
|
|
|
$('#table').DataTable( {
|
|
|
|
"order": [[ 0, "desc" ]],
|
|
|
|
"pageLength": 50,
|
|
|
|
"searching": false,
|
|
|
|
"paging": false
|
|
|
|
});
|
|
|
|
</script>
|
2022-11-21 16:49:35 +01:00
|
|
|
<script>
|
|
|
|
async function update_status() {
|
|
|
|
let capture_status = document.getElementsByClassName('capture_status');
|
2022-11-29 15:24:35 +01:00
|
|
|
let capture_error = document.getElementsByClassName('capture_error');
|
2022-11-21 16:49:35 +01:00
|
|
|
let keep_going = false;
|
|
|
|
for (let i = 0; i < capture_status.length; i++) {
|
2022-11-29 15:24:35 +01:00
|
|
|
await fetch(`/json/${capture_status[i].id}/status?with_error=1`)
|
2022-11-21 16:49:35 +01:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(cs => {
|
|
|
|
if ((cs.status_code == 0) || (cs.status_code == 2)) {
|
|
|
|
capture_status[i].innerHTML = "Capture ongoing, please wait...";
|
|
|
|
}
|
|
|
|
else if (cs.status_code == 1){
|
|
|
|
capture_status[i].innerHTML = "Capture done.";
|
2022-11-29 15:24:35 +01:00
|
|
|
if ('error' in cs ){
|
|
|
|
capture_error[i].innerHTML = cs.error;
|
|
|
|
}
|
2022-11-21 16:49:35 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
capture_status[i].innerHTML = "Unknown capture.";
|
|
|
|
};
|
|
|
|
if (cs.status_code != 1) {
|
|
|
|
keep_going = true;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
if (!keep_going) {
|
|
|
|
window.clearInterval(update_status_interval);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
let update_status_interval = window.setInterval(update_status, 5000);
|
|
|
|
</script>
|
2021-03-19 17:51:25 +01:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
{% block content %}
|
|
|
|
<center>
|
|
|
|
<h4>Ongoing captures</h4>
|
2022-03-18 10:48:09 +01:00
|
|
|
<button onclick="window.history.back();" class="btn btn-primary" type="button">Go Back</button>
|
2021-03-19 17:51:25 +01:00
|
|
|
</center>
|
|
|
|
<div>The captures below are queued, it will take a few minutes before the links are working</div>
|
|
|
|
<div class="table-responsive">
|
|
|
|
<table id="table" class="table" style="width:96%">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>URL</th>
|
|
|
|
<th>Link</th>
|
2022-11-21 16:49:35 +01:00
|
|
|
<th>Status</th>
|
2022-11-29 15:24:35 +01:00
|
|
|
<th>Error message</th>
|
2021-03-19 17:51:25 +01:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for uuid, captured_url in bulk_captures %}
|
|
|
|
<tr>
|
|
|
|
<td>
|
2022-11-29 15:57:13 +01:00
|
|
|
{{ shorten_string(captured_url, 50, with_title=True) }}
|
2021-03-19 17:51:25 +01:00
|
|
|
</td>
|
|
|
|
<td><a href="{{ url_for('tree', tree_uuid=uuid) }}">Show capture</a></td>
|
2022-11-21 16:49:35 +01:00
|
|
|
<td id="{{uuid}}" class="capture_status">Please wait...</td>
|
2022-11-29 15:24:35 +01:00
|
|
|
<td id="{{uuid}}" class="capture_error"></td>
|
2021-03-19 17:51:25 +01:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
{% endblock %}
|