From a3ae8278395ac76f54c6c611f92f732d9924156e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 21 Feb 2020 21:02:03 +0100 Subject: [PATCH] ui: centrally load CodeMirror and init via data tag --- .../admin/templates/administration/base.html | 13 ++++++++++ passbook/admin/templates/generic/form.html | 5 ---- .../app_gw/templates/app_gw/setup_modal.html | 24 ++----------------- .../saml/idp/admin_metadata_modal.html | 21 +--------------- passbook/static/static/passbook/pf.js | 15 ++++++++++++ 5 files changed, 31 insertions(+), 47 deletions(-) diff --git a/passbook/admin/templates/administration/base.html b/passbook/admin/templates/administration/base.html index e4892177f..25953a71a 100644 --- a/passbook/admin/templates/administration/base.html +++ b/passbook/admin/templates/administration/base.html @@ -1 +1,14 @@ {% extends "overview/base.html" %} + +{% load static %} + +{% block head %} +{{ block.super }} + + + + + + + +{% endblock %} diff --git a/passbook/admin/templates/generic/form.html b/passbook/admin/templates/generic/form.html index dc77bb231..e42819d94 100644 --- a/passbook/admin/templates/generic/form.html +++ b/passbook/admin/templates/generic/form.html @@ -16,11 +16,6 @@ - - - - - {% endblock %} {% block content %} diff --git a/passbook/providers/app_gw/templates/app_gw/setup_modal.html b/passbook/providers/app_gw/templates/app_gw/setup_modal.html index 6eb2d3521..db8000332 100644 --- a/passbook/providers/app_gw/templates/app_gw/setup_modal.html +++ b/passbook/providers/app_gw/templates/app_gw/setup_modal.html @@ -1,12 +1,5 @@ {% load i18n %} {% load static %} - - - - - - -
@@ -51,7 +44,7 @@

{% trans 'Download the manifest to create the Gatekeeper deployment and service:' %}

{% trans 'Here' %}

{% trans 'Afterwards, add the following annotations to the Ingress you want to secure:' %}

- @@ -62,16 +55,3 @@ nginx.ingress.kubernetes.io/auth-signin: "https://{{ provider.external_host }}/o
- - diff --git a/passbook/providers/saml/templates/saml/idp/admin_metadata_modal.html b/passbook/providers/saml/templates/saml/idp/admin_metadata_modal.html index 1d08f3e39..c52518970 100644 --- a/passbook/providers/saml/templates/saml/idp/admin_metadata_modal.html +++ b/passbook/providers/saml/templates/saml/idp/admin_metadata_modal.html @@ -1,12 +1,5 @@ {% load i18n %} {% load static %} - - - - - - - - - diff --git a/passbook/static/static/passbook/pf.js b/passbook/static/static/passbook/pf.js index f29f3aa6a..1e75d5850 100644 --- a/passbook/static/static/passbook/pf.js +++ b/passbook/static/static/passbook/pf.js @@ -21,3 +21,18 @@ document.querySelectorAll(".pf-c-modal-box [data-modal-close]").forEach((b) => { parentContainer.setAttribute("hidden", true); }); }); + +// CodeMirror +document.querySelectorAll(".codemirror").forEach((cm) => { + let cmMode = 'xml'; + if ('data-cm-mode' in cm.attributes) { + cmMode = cm.attributes['data-cm-mode'].value; + } + CodeMirror.fromTextArea(cm, { + mode: cmMode, + theme: 'monokai', + lineNumbers: false, + readOnly: cm.readOnly, + autoRefresh: true, + }); +});