mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
#6834: Add title, favicon to GraphiQL view
This commit is contained in:
@ -12,6 +12,8 @@ class GraphQLView(GraphQLView_):
|
|||||||
"""
|
"""
|
||||||
Extends graphene_django's GraphQLView to support DRF's token-based authentication.
|
Extends graphene_django's GraphQLView to support DRF's token-based authentication.
|
||||||
"""
|
"""
|
||||||
|
graphiql_template = 'graphiql.html'
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
|
||||||
# Enforce GRAPHQL_ENABLED
|
# Enforce GRAPHQL_ENABLED
|
||||||
|
BIN
netbox/project-static/img/graphql.ico
Normal file
BIN
netbox/project-static/img/graphql.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
59
netbox/templates/graphiql.html
Normal file
59
netbox/templates/graphiql.html
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
{% comment %}
|
||||||
|
This template derives from the graphene-django project:
|
||||||
|
https://github.com/graphql-python/graphene-django/blob/main/graphene_django/templates/graphene/graphiql.html
|
||||||
|
{% endcomment %}
|
||||||
|
<!--
|
||||||
|
The request to this GraphQL server provided the header "Accept: text/html"
|
||||||
|
and as a result has been presented GraphiQL - an in-browser IDE for
|
||||||
|
exploring GraphQL.
|
||||||
|
If you wish to receive JSON, provide the header "Accept: application/json" or
|
||||||
|
add "&raw" to the end of the URL within a browser.
|
||||||
|
-->
|
||||||
|
{% load static %}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
html, body, #editor {
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/graphiql@{{graphiql_version}}/graphiql.min.css"
|
||||||
|
integrity="{{graphiql_css_sri}}"
|
||||||
|
rel="stylesheet"
|
||||||
|
crossorigin="anonymous" />
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/whatwg-fetch@{{whatwg_fetch_version}}/dist/fetch.umd.js"
|
||||||
|
integrity="{{whatwg_fetch_sri}}"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/react@{{react_version}}/umd/react.production.min.js"
|
||||||
|
integrity="{{react_sri}}"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/react-dom@{{react_version}}/umd/react-dom.production.min.js"
|
||||||
|
integrity="{{react_dom_sri}}"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/graphiql@{{graphiql_version}}/graphiql.min.js"
|
||||||
|
integrity="{{graphiql_sri}}"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/subscriptions-transport-ws@{{subscriptions_transport_ws_version}}/browser/client.js"
|
||||||
|
integrity="{{subscriptions_transport_ws_sri}}"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<link rel="icon" type="image/png" href="{% static 'graphql.ico' %}" />
|
||||||
|
<title>GraphiQL | NetBox</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="editor"></div>
|
||||||
|
{% csrf_token %}
|
||||||
|
<script type="application/javascript">
|
||||||
|
window.GRAPHENE_SETTINGS = {
|
||||||
|
{% if subscription_path %}
|
||||||
|
subscriptionPath: "{{subscription_path}}",
|
||||||
|
{% endif %}
|
||||||
|
graphiqlHeaderEditorEnabled: {{ graphiql_header_editor_enabled|yesno:"true,false" }},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="{% static 'graphene_django/graphiql.js' %}"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user