[879b32]: / qiita_pet / templates / compute_wait.html

Download this file

46 lines (39 with data), 1.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{% extends sitebase.html%}
{%block head%}
<script type="text/javascript">
$(document).ready(function() {
var socket_protocol = window.location.protocol == "https:" ? 'wss://' : 'ws://'
var host = socket_protocol + window.location.host + '{% raw qiita_config.portal_dir %}/consumer/';
var websocket = new WebSocket(host);
// When the socket is opened, send a message from the client to the
// server that indicates the current user. This is likely not secure.
websocket.onopen = function() {
websocket.send(JSON.stringify({'user': '{{user.id}}'}));
};
// When the web socket receives an event
websocket.onmessage = function(evt) {
// ...convert the event's data to JSON
message = JSON.parse(evt.data);
// ...and if the message has the job ID we currently care about
if(message.job_id == "{{job_id}}") {
// ...o something based on its status.
switch(message.status_msg) {
case 'Success':
case 'Failed':
window.location.replace('{{completion_redirect}}');
break;
default:
status_msg = document.getElementById('status-msg');
status_msg.innerHTML = message.status_msg + '<br/><b>You can move out of this page at any time, your job is running.</b>';
break;
}
}
};
websocket.onerror = function(evt) { };
});
</script>
{% end %}
{% block content %}
<h1>Waiting on {{title}}</h1>
<p>Current status: <span id=status-msg>Queued</span></p>
{% end %}