diff --git a/awx/network_ui/routing.py b/awx/network_ui/routing.py index 66553e23d2..0a9d07635d 100644 --- a/awx/network_ui/routing.py +++ b/awx/network_ui/routing.py @@ -3,7 +3,7 @@ from channels.routing import route from awx.network_ui.consumers import ws_connect, ws_message, ws_disconnect channel_routing = [ - route("websocket.connect", ws_connect, path=r"^/network_ui/topology"), - route("websocket.receive", ws_message, path=r"^/network_ui/topology"), - route("websocket.disconnect", ws_disconnect, path=r"^/network_ui/topology"), + route("websocket.connect", ws_connect, path=r"^/network_ui/topology/"), + route("websocket.receive", ws_message, path=r"^/network_ui/topology/"), + route("websocket.disconnect", ws_disconnect, path=r"^/network_ui/topology/"), ] diff --git a/awx/network_ui/urls.py b/awx/network_ui/urls.py index d08b0a448a..2101eff59f 100644 --- a/awx/network_ui/urls.py +++ b/awx/network_ui/urls.py @@ -5,6 +5,6 @@ from awx.network_ui import views app_name = 'network_ui' urlpatterns = [ - url(r'^topology.json$', views.json_topology_data, name='json_topology_data'), - url(r'^topology.yaml$', views.yaml_topology_data, name='yaml_topology_data'), + url(r'^topology.json/?$', views.json_topology_data, name='json_topology_data'), + url(r'^topology.yaml/?$', views.yaml_topology_data, name='yaml_topology_data'), ] diff --git a/awx/network_ui/views.py b/awx/network_ui/views.py index e80f03c320..577b8c004f 100644 --- a/awx/network_ui/views.py +++ b/awx/network_ui/views.py @@ -82,7 +82,10 @@ class TopologyForm(forms.Form): def json_topology_data(request): form = TopologyForm(request.GET) if form.is_valid(): - return JsonResponse(topology_data(form.cleaned_data['topology_id'])) + response = JsonResponse(topology_data(form.cleaned_data['topology_id']), + content_type='application/force-download') + response['Content-Disposition'] = 'attachment; filename="{}"'.format('topology.json') + return response else: return HttpResponseBadRequest(form.errors) @@ -90,9 +93,11 @@ def json_topology_data(request): def yaml_topology_data(request): form = TopologyForm(request.GET) if form.is_valid(): - return HttpResponse(yaml.safe_dump(topology_data(form.cleaned_data['topology_id']), - default_flow_style=False), - content_type='application/yaml') + response = HttpResponse(yaml.safe_dump(topology_data(form.cleaned_data['topology_id']), + default_flow_style=False), + content_type='application/force-download') + response['Content-Disposition'] = 'attachment; filename="{}"'.format('topology.yaml') + return response else: return HttpResponseBadRequest(form.errors) diff --git a/docs/networking.md b/docs/networking.md index 79accfef9b..1334b45395 100644 --- a/docs/networking.md +++ b/docs/networking.md @@ -615,7 +615,7 @@ and for interaction performance on the UI. Messages -------- -JSON messages are passed over the `/network_ui/topology` websocket between the +JSON messages are passed over the `/network_ui/topology/` websocket between the test client and the test server. The protocol that is used for all messages is in ABNF (RFC5234): diff --git a/tools/docker-compose/nginx.vh.default.conf b/tools/docker-compose/nginx.vh.default.conf index e8c26e732a..5e31bce2ee 100644 --- a/tools/docker-compose/nginx.vh.default.conf +++ b/tools/docker-compose/nginx.vh.default.conf @@ -30,7 +30,7 @@ server { sendfile off; } - location ~ ^/(websocket|network_ui) { + location ~ ^/(websocket|network_ui/topology/) { # Pass request to the upstream alias proxy_pass http://daphne; # Require http version 1.1 to allow for upgrade requests @@ -90,7 +90,7 @@ server { sendfile off; } - location ~ ^/(websocket|network_ui) { + location ~ ^/(websocket|network_ui/topology/) { # Pass request to the upstream alias proxy_pass http://daphne; # Require http version 1.1 to allow for upgrade requests