Skip to content

Commit

Permalink
Add manual task stop to remote session
Browse files Browse the repository at this point in the history
  • Loading branch information
enzok committed Jan 18, 2024
1 parent 0b3fd06 commit 6accd5e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion web/guac/templates/guac/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<head>
<link rel="icon" href="{% static 'img/cape.png' %}">
<link href="{% static 'css/guac-main.css' %}" rel="stylesheet" type="text/css"/>
<script src="{% static 'js/crypto-js.min.js' %}"></script>
<script src="{% static 'js/guac-main.js' %}"></script>
<script src="{% static 'js/guacamole-1.4.0-all.min.js' %}"></script>
<script src="{% static 'js/jquery.js' %}"></script>
Expand All @@ -24,11 +25,14 @@
</div>
</div>
<script>
document.getElementById("stopTask").addEventListener("click", function () {
stopTask("{{task_id}}");
});
var task_url = location.origin + '/submit/status/{{task_id}}'
document.getElementById("taskStatus").addEventListener("click", function() {
location.replace(task_url);
}, false);
GuacMe("html", "{{guest_ip}}", {{vncport}}, "{{session_id}}", "{{recording_name}}");
GuacMe("html", "{{guest_ip}}","{{vncport}}", "{{session_id}}", "{{recording_name}}");
</script>
</div>
</body>
Expand Down
1 change: 1 addition & 0 deletions web/static/js/crypto-js.min.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions web/static/js/guac-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,26 @@ function GuacMe(element, guest_ip, vncport, session_id, recording_name) {

init();
}

function stopTask(taskId) {
var apiUrl = location.origin + "/apiv2/tasks/status/" + taskId + "/";

var postData = {
status: 'finish',
};

fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(postData),
})
.then(response => response.json())
.then(data => {
console.log('Response:', data);
})
.catch(error => {
console.error('Error:', error);
});
}

0 comments on commit 6accd5e

Please sign in to comment.