diff --git a/Makefile b/Makefile index 58fd4e3..ae3dbba 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +ROOT_DIR = $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) +PYTHON = $(ROOT_DIR)venv/bin/python + format: @./venv/bin/black mumui/*.py deployment/*.py @@ -24,6 +27,10 @@ build: $(MAKE) nginx-local $(MAKE) django +.PHONY: static +static: + $(PYTHON) manage.py collectstatic --no-input + run: docker compose up diff --git a/deployment/static/deployment/js/event_source.js b/deployment/static/deployment/js/event_source.js index 6763514..ecd2e6d 100644 --- a/deployment/static/deployment/js/event_source.js +++ b/deployment/static/deployment/js/event_source.js @@ -1,5 +1,11 @@ +var es = null; + var start = function (url) { - var es = new ReconnectingEventSource(url); + if (es) { + console.log("closing es", es); + es.close(); + } + es = new ReconnectingEventSource(url); console.log("url: " + url); @@ -60,4 +66,18 @@ var start = function (url) { } } }, false); -}; \ No newline at end of file +}; + +document.querySelectorAll(".btn-details").forEach(btn => { + btn.addEventListener("click", function(e) { + const durl = e.currentTarget.getAttribute("durl"); + console.log("details url:", durl); + + if (es) { + window.es.close() + console.log("closing sse...."); + }; + + window.location = durl; + }); +}); \ No newline at end of file diff --git a/deployment/static/deployment/js/event_source_details.js b/deployment/static/deployment/js/event_source_details.js index ef985c1..bfef663 100644 --- a/deployment/static/deployment/js/event_source_details.js +++ b/deployment/static/deployment/js/event_source_details.js @@ -1,5 +1,11 @@ var start = function (url) { - var es = new ReconnectingEventSource(url); + if (window.es) { + console.log("closing es", window.es); + window.es.close(); + } + + es = new ReconnectingEventSource(url); + window.es = es; console.log("url: " + url); diff --git a/templates/deployment/board.html b/templates/deployment/board.html index 96f5295..8a223dc 100644 --- a/templates/deployment/board.html +++ b/templates/deployment/board.html @@ -4,16 +4,6 @@ {% block title %} Deployments board {% endblock %} -{% block headscript %} - - - -{% endblock %} - -{% block bodyattr %} - onload="start('{{ url|safe }}');" -{% endblock %} - {% block content %}