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