Skip to content
Snippets Groups Projects
Commit 54630b45 authored by Tim Fechner's avatar Tim Fechner
Browse files

Fix broken websockets

parent 8cd1af1b
Branches
No related tags found
No related merge requests found
Pipeline #
......@@ -2,7 +2,7 @@ $(function() {
// ATTENTION: set the token before importing this script
var socket = new WebSocket('ws://localhost:8002/all_events/' + token);
var socket = new WebSocket('wss://' + host + ':' + port + '/all_events/' + token);
// Get Salt's "real time" event stream.
socket.onopen = function() {
......
......@@ -33,7 +33,7 @@ SESSION_COOKIE_NAME = "cookie_session_salt_observer"
SALT_API = {
'cherrypy': {
'host': 'localhost',
'port': 8989,
'port': 8001,
'protocol': 'http',
},
'tornado': {
......
$(function(){function t(t){var e=$("#event-template").clone();e.removeAttr("id"),e.find(".icon").html('<i class="fa fa-fw fa-2x fa-bug"></i>'),e.find(".title").text(t.data.id),e.find(".message").html("<pre>"+JSON.stringify(t.data)+"</pre>"),e.find(".tag").text(t.tag),e.find(".minion-id").text(t.data.id),$("#eventholder").prepend(e),setTimeout(function(){e.remove()},3e5)}function e(t){var e=$("#job-template").clone();e.removeAttr("id"),e.find(".timestamp").text(t.data._stamp),e.find(".tag").text(t.tag),$("#jobholder").prepend(e),setTimeout(function(){e.remove()},6e4)}var n=new WebSocket("ws://localhost:8002/all_events/"+token);n.onopen=function(){n.send("websocket client ready"),console.log("Connected!"),$("#conn_status").html('<i class="fa fa-fw fa-check"></i> Connected!')},n.onerror=function(t){console.debug("Error!",t),$("#conn_status").html('<i class="fa fa-fw fa-times"></i> Connection failed!')},n.onmessage=function(n){console.log(n);var o=JSON.parse(n.data.substring(6));o.tag.startsWith("salt/job/")?e(o):t(o)}});
\ No newline at end of file
$(function(){function t(t){var e=$("#event-template").clone();e.removeAttr("id"),e.find(".icon").html('<i class="fa fa-fw fa-2x fa-bug"></i>'),e.find(".title").text(t.data.id),e.find(".message").html("<pre>"+JSON.stringify(t.data)+"</pre>"),e.find(".tag").text(t.tag),e.find(".minion-id").text(t.data.id),$("#eventholder").prepend(e),setTimeout(function(){e.remove()},3e5)}function e(t){var e=$("#job-template").clone();e.removeAttr("id"),e.find(".timestamp").text(t.data._stamp),e.find(".tag").text(t.tag),$("#jobholder").prepend(e),setTimeout(function(){e.remove()},6e4)}var n=new WebSocket("wss://"+host+":"+port+"/all_events/"+token);n.onopen=function(){n.send("websocket client ready"),console.log("Connected!"),$("#conn_status").html('<i class="fa fa-fw fa-check"></i> Connected!')},n.onerror=function(t){console.debug("Error!",t),$("#conn_status").html('<i class="fa fa-fw fa-times"></i> Connection failed!')},n.onmessage=function(n){console.log(n);var o=JSON.parse(n.data.substring(6));o.tag.startsWith("salt/job/")?e(o):t(o)}});
\ No newline at end of file
......@@ -11,6 +11,8 @@
{% block post-script %}
<script>
var host = "{{ tornado_host }}";
var port = "{{ tornado_port }}";
var token = "{{ request.session.salt_tornado_token }}";
</script>
<script src="{% static 'js/events.min.js' %}"></script>
......
......@@ -158,3 +158,11 @@ class DomainEdit(MarkdownEditMixin, UpdateView, DomainDetail):
class EventView(TemplateView):
template_name = 'events.html'
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context.update({
'tornado_host': settings.SALT_API['tornado']['host'],
'tornado_port': settings.SALT_API['tornado']['port'],
})
return context
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment