1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Merge pull request #1643 from benthomasson/network_ui_export_yaml_fix

Fixes timeout when exporting YAML from network UI
This commit is contained in:
Ben Thomasson 2018-05-02 11:15:31 -04:00 committed by GitHub
commit f6600872b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 12 deletions

View File

@ -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/"),
]

View File

@ -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'),
]

View File

@ -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)

View File

@ -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):

View File

@ -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