diff --git a/proxstar/__init__.py b/proxstar/__init__.py index 5d5e1a6..54e04b4 100644 --- a/proxstar/__init__.py +++ b/proxstar/__init__.py @@ -568,6 +568,8 @@ def settings(): templates=templates, ignored_pools=db_ignored_pools, allowed_users=db_allowed_users, + vnc_cleanup_token=app.config['VNC_CLEANUP_TOKEN'], + server_name=app.config['SERVER_NAME'] ) else: return abort(403) diff --git a/proxstar/static/js/script.js b/proxstar/static/js/script.js index 53bd1cd..2234fe1 100644 --- a/proxstar/static/js/script.js +++ b/proxstar/static/js/script.js @@ -627,6 +627,59 @@ $(".add-ignored-pool").click(function(){ }); }); +// TODO: Move these tasks so they're callable via JS? +/* +$("#generate-pool-cache-task-button").click(function(){ +}); + +$("#process-expiring-vms-task-button").click(function(){ +}); +*/ + +$("#cleanup-vnc-task-button").click(function(){ + const vncCleanupToken = $(this).data('vnc_cleanup_token'); + + swal({ + title: "Are you sure you want to clear VNC tokens?", + text: "This will clear the websockify targets file, and remove all entries from Redis. Ongoing VNC sessions may be disrupted.", + icon: "warning", + buttons: { + cancel: true, + action: { + text: "Cleanup VNC Sessions", + closeModal: false, + className: "swal-button--danger", + } + }, + dangerMode: true, + }) + .then((willComplete) => { + if (willComplete) { + var formData = new FormData(); + formData.append('token', vncCleanupToken); + fetch(`/console/cleanup`, { + method: 'post', + credentials: 'same-origin', + body: formData + }).then((response) => { + return swal("VNC Sessions have been cleared", { + icon: "success", + }); + }).then(() => { + window.location = location; + }).catch(err => { + if (err) { + swal("Uh oh...", "Unable to clear VNC sessions", "error"); + } else { + swal.stopLoading(); + swal.close(); + } + }); + } + }); +}); + + function change_for_template(obj) { var template_element = obj; var selected = template_element.options[template_element.selectedIndex].value; @@ -653,7 +706,6 @@ $("#console-vm").click(function(){ return response.json() }).then((vnc_params) => { // TODO (willnilges): encrypt=true - // TODO (willnilges): set host and port to an env variable window.open(`/static/noVNC/vnc.html?autoconnect=true&password=${vnc_params.password}&host=${vnc_params.host}&port=${vnc_params.port}&path=path?token=${vnc_params.token}`, '_blank'); }).catch(err => { if (err) { diff --git a/proxstar/templates/settings.html b/proxstar/templates/settings.html index 1df687f..cef6537 100644 --- a/proxstar/templates/settings.html +++ b/proxstar/templates/settings.html @@ -113,6 +113,14 @@

Allowed Users

+
+ + + +