Merge branch 'master' into dependabot/pip/boto3-1.14.17

This commit is contained in:
Jens L 2020-07-07 13:14:07 +02:00 committed by GitHub
commit f56332c954
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 124 additions and 49 deletions

View file

@ -10,29 +10,33 @@
</section> </section>
<section class="pf-c-page__main-section"> <section class="pf-c-page__main-section">
<div class="pf-l-gallery pf-m-gutter"> <div class="pf-l-gallery pf-m-gutter">
<a href="{% url 'passbook_admin:applications' %}" class="pf-c-card pf-m-hoverable pf-m-compact"> <a href="{% url 'passbook_admin:applications' %}" class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact">
<div class="pf-c-card__header"> <div class="pf-c-card__header">
<div class="pf-c-card__header-main"> <div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-applications"></i> {% trans 'Applications' %} <i class="pf-icon pf-icon-applications"></i> {% trans 'Applications' %}
</div> </div>
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
<i class="pf-icon pf-icon-ok"></i> {{ application_count }} <p class="aggregate-status">
<i class="fa fa-check-circle"></i> {{ application_count }}
</p>
</div> </div>
</a> </a>
<a href="{% url 'passbook_admin:sources' %}" class="pf-c-card pf-m-hoverable pf-m-compact"> <a href="{% url 'passbook_admin:sources' %}" class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact">
<div class="pf-c-card__header"> <div class="pf-c-card__header">
<div class="pf-c-card__header-main"> <div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-middleware"></i> {% trans 'Sources' %} <i class="pf-icon pf-icon-middleware"></i> {% trans 'Sources' %}
</div> </div>
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
<i class="pf-icon pf-icon-ok"></i> {{ source_count }} <p class="aggregate-status">
<i class="fa fa-check-circle"></i> {{ source_count }}
</p>
</div> </div>
</a> </a>
<a href="{% url 'passbook_admin:providers' %}" class="pf-c-card pf-m-hoverable pf-m-compact"> <a href="{% url 'passbook_admin:providers' %}" class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact">
<div class="pf-c-card__header"> <div class="pf-c-card__header">
<div class="pf-c-card__header-main"> <div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-plugged"></i> {% trans 'Providers' %} <i class="pf-icon pf-icon-plugged"></i> {% trans 'Providers' %}
@ -40,15 +44,19 @@
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
{% if providers_without_application.exists %} {% if providers_without_application.exists %}
<i class="pf-icon pf-icon-warning-triangle"></i> {{ provider_count }} <p class="aggregate-status">
<i class="fa fa-exclamation-triangle"></i> {{ provider_count }}
</p>
<p>{% trans 'Warning: At least one Provider has no application assigned.' %}</p> <p>{% trans 'Warning: At least one Provider has no application assigned.' %}</p>
{% else %} {% else %}
<i class="pf-icon pf-icon-ok"></i> {{ provider_count }} <p class="aggregate-status">
<i class="fa fa-check-circle"></i> {{ provider_count }}
</p>
{% endif %} {% endif %}
</div> </div>
</a> </a>
<a href="{% url 'passbook_admin:stages' %}" class="pf-c-card pf-m-hoverable pf-m-compact"> <a href="{% url 'passbook_admin:stages' %}" class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact">
<div class="pf-c-card__header"> <div class="pf-c-card__header">
<div class="pf-c-card__header-main"> <div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-plugged"></i> {% trans 'Stages' %} <i class="pf-icon pf-icon-plugged"></i> {% trans 'Stages' %}
@ -56,26 +64,32 @@
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
{% if stage_count < 1 %} {% if stage_count < 1 %}
<p class="aggregate-status">
<i class="pficon-error-circle-o"></i> {{ stage_count }} <i class="pficon-error-circle-o"></i> {{ stage_count }}
</p>
<p>{% trans 'No Stages configured. No Users will be able to login.' %}"></p> <p>{% trans 'No Stages configured. No Users will be able to login.' %}"></p>
{% else %} {% else %}
<i class="pf-icon pf-icon-ok"></i> {{ stage_count }} <p class="aggregate-status">
<i class="fa fa-check-circle"></i> {{ stage_count }}
</p>
{% endif %} {% endif %}
</div> </div>
</a> </a>
<a href="{% url 'passbook_admin:stages' %}" class="pf-c-card pf-m-hoverable pf-m-compact"> <a href="{% url 'passbook_admin:stages' %}" class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact">
<div class="pf-c-card__header"> <div class="pf-c-card__header">
<div class="pf-c-card__header-main"> <div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-topology"></i> {% trans 'Flows' %} <i class="pf-icon pf-icon-topology"></i> {% trans 'Flows' %}
</div> </div>
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
<i class="pf-icon pf-icon-ok"></i> {{ flow_count }} <p class="aggregate-status">
<i class="fa fa-check-circle"></i> {{ flow_count }}
</p>
</div> </div>
</a> </a>
<a href="{% url 'passbook_admin:policies' %}" class="pf-c-card pf-m-hoverable pf-m-compact"> <a href="{% url 'passbook_admin:policies' %}" class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact">
<div class="pf-c-card__header"> <div class="pf-c-card__header">
<div class="pf-c-card__header-main"> <div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-infrastructure"></i> {% trans 'Policies' %} <i class="pf-icon pf-icon-infrastructure"></i> {% trans 'Policies' %}
@ -83,58 +97,71 @@
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
{% if policies_without_binding %} {% if policies_without_binding %}
<i class="pf-icon pf-icon-warning-triangle"></i> {{ policy_count }} <p class="aggregate-status">
<i class="fa fa-exclamation-triangle"></i> {{ policy_count }}
</p>
<p>{% trans 'Policies without binding exist.' %}</p> <p>{% trans 'Policies without binding exist.' %}</p>
{% else %} {% else %}
<i class="pf-icon pf-icon-ok"></i> {{ policy_count }} <p class="aggregate-status">
<i class="fa fa-check-circle"></i> {{ policy_count }}
</p>
{% endif %} {% endif %}
</div> </div>
</a> </a>
<a href="{% url 'passbook_admin:stage-invitations' %}" class="pf-c-card pf-m-hoverable pf-m-compact"> <a href="{% url 'passbook_admin:stage-invitations' %}" class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact">
<div class="pf-c-card__header"> <div class="pf-c-card__header">
<div class="pf-c-card__header-main"> <div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-migration"></i> {% trans 'Invitation' %} <i class="pf-icon pf-icon-migration"></i> {% trans 'Invitation' %}
</div> </div>
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
<i class="pf-icon pf-icon-ok"></i> {{ invitation_count }} <p class="aggregate-status">
<i class="fa fa-check-circle"></i> {{ invitation_count }}
</p>
</div> </div>
</a> </a>
<a href="{% url 'passbook_admin:users' %}" class="pf-c-card pf-m-hoverable pf-m-compact"> <a href="{% url 'passbook_admin:users' %}" class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact">
<div class="pf-c-card__header"> <div class="pf-c-card__header">
<div class="pf-c-card__header-main"> <div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-user"></i> {% trans 'Users' %} <i class="pf-icon pf-icon-user"></i> {% trans 'Users' %}
</div> </div>
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
<i class="pf-icon pf-icon-ok"></i> {{ user_count }} <p class="aggregate-status">
<i class="fa fa-check-circle"></i> {{ user_count }}
</p>
</div> </div>
</a> </a>
<div class="pf-c-card pf-m-hoverable pf-m-compact"> <div class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact">
<div class="pf-c-card__header"> <div class="pf-c-card__header">
<div class="pf-c-card__header-main"> <div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-bundle"></i> {% trans 'Version' %} <i class="pf-icon pf-icon-bundle"></i> {% trans 'Version' %}
</div> </div>
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
<p class="aggregate-status">
{% if version >= version_latest %} {% if version >= version_latest %}
<i class="pf-icon pf-icon-ok"></i> <i class="fa fa-check-circle"></i> {{ version }}
{% blocktrans with version=version %} {% else %}
{{ version }} (Up-to-date!) <i class="fa fa-exclamation-triangle"></i> {{ version }}
{% endif %}
</p>
{% if version >= version_latest %}
{% blocktrans %}
Up-to-date!
{% endblocktrans %} {% endblocktrans %}
{% else %} {% else %}
<i class="pf-icon pf-icon-warning-triangle"></i> {% blocktrans with latest=version_latest %}
{% blocktrans with version=version latest=version_latest %} {{ latest }} is available!
{{ version }} ({{ latest }} is available!)
{% endblocktrans %} {% endblocktrans %}
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div class="pf-c-card pf-m-hoverable pf-m-compact"> <div class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact">
<div class="pf-c-card__header"> <div class="pf-c-card__header">
<div class="pf-c-card__header-main"> <div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-server"></i> {% trans 'Workers' %} <i class="pf-icon pf-icon-server"></i> {% trans 'Workers' %}
@ -142,15 +169,19 @@
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
{% if worker_count < 1 %} {% if worker_count < 1 %}
<i class="pf-icon pf-icon-warning-triangle"></i> {{ worker_count }} <p class="aggregate-status">
<i class="fa fa-exclamation-triangle"></i> {{ worker_count }}
</p>
<p>{% trans 'No workers connected.' %}</p> <p>{% trans 'No workers connected.' %}</p>
{% else %} {% else %}
<i class="pf-icon pf-icon-ok"></i> {{ worker_count }} <p class="aggregate-status">
<i class="fa fa-check-circle"></i> {{ worker_count }}
</p>
{% endif %} {% endif %}
</div> </div>
</div> </div>
<a class="pf-c-card pf-m-hoverable pf-m-compact" data-target="modal" data-modal="clearCacheModalRoot"> <a class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact" data-target="modal" data-modal="clearCacheModalRoot">
<div class="pf-c-card__header"> <div class="pf-c-card__header">
<div class="pf-c-card__header-main"> <div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-server"></i> {% trans 'Cached Policies' %} <i class="pf-icon pf-icon-server"></i> {% trans 'Cached Policies' %}
@ -158,13 +189,37 @@
</div> </div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
{% if cached_policies < 1 %} {% if cached_policies < 1 %}
<i class="pf-icon pf-icon-warning-triangle"></i> {{ cached_policies }} <p class="aggregate-status">
<i class="fa fa-exclamation-triangle"></i> {{ cached_policies }}
</p>
<p>{% trans 'No policies cached. Users may experience slow response times.' %}</p> <p>{% trans 'No policies cached. Users may experience slow response times.' %}</p>
{% else %} {% else %}
<i class="pf-icon pf-icon-ok"></i> {{ cached_policies }} <p class="aggregate-status">
<i class="fa fa-check-circle"></i> {{ cached_policies }}
</p>
{% endif %} {% endif %}
</div> </div>
</a> </a>
<div class="pf-c-card pf-c-card-aggregate pf-m-hoverable pf-m-compact">
<div class="pf-c-card__header">
<div class="pf-c-card__header-main">
<i class="pf-icon pf-icon-server"></i> {% trans 'Cached Flows' %}
</div>
</div>
<div class="pf-c-card__body">
{% if cached_flows < 1 %}
<p class="aggregate-status">
<span class="fa fa-exclamation-triangle"></span> {{ cached_flows }}
</p>
<p>{% trans 'No flows cached.' %}</p>
{% else %}
<p class="aggregate-status">
<i class="fa fa-check-circle"></i> {{ cached_flows }}
</p>
{% endif %}
</div>
</div>
</section> </section>
</div> </div>
<div class="pf-c-backdrop" id="clearCacheModalRoot" hidden> <div class="pf-c-backdrop" id="clearCacheModalRoot" hidden>
@ -173,7 +228,9 @@
<button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog"> <button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog">
<i class="fas fa-times" aria-hidden="true"></i> <i class="fas fa-times" aria-hidden="true"></i>
</button> </button>
<div class="pf-c-modal-box__header">
<h1 class="pf-c-title pf-m-2xl" id="modal-title">{% trans 'Clear Cache' %}?</h1> <h1 class="pf-c-title pf-m-2xl" id="modal-title">{% trans 'Clear Cache' %}?</h1>
</div>
<div class="pf-c-modal-box__body" id="modal-description"> <div class="pf-c-modal-box__body" id="modal-description">
<form method="post" id="clearForm"> <form method="post" id="clearForm">
{% csrf_token %} {% csrf_token %}

View file

@ -1,6 +1,4 @@
"""passbook administration overview""" """passbook administration overview"""
from functools import lru_cache
from django.core.cache import cache from django.core.cache import cache
from django.shortcuts import redirect, reverse from django.shortcuts import redirect, reverse
from django.views.generic import TemplateView from django.views.generic import TemplateView
@ -15,18 +13,21 @@ from passbook.policies.models import Policy
from passbook.root.celery import CELERY_APP from passbook.root.celery import CELERY_APP
from passbook.stages.invitation.models import Invitation from passbook.stages.invitation.models import Invitation
VERSION_CACHE_KEY = "passbook_latest_version"
@lru_cache
def latest_version() -> Version: def latest_version() -> Version:
"""Get latest release from GitHub, cached""" """Get latest release from GitHub, cached"""
if not cache.get(VERSION_CACHE_KEY):
try: try:
data = get( data = get(
"https://api.github.com/repos/beryju/passbook/releases/latest" "https://api.github.com/repos/beryju/passbook/releases/latest"
).json() ).json()
tag_name = data.get("tag_name") tag_name = data.get("tag_name")
return parse(tag_name.split("/")[1]) cache.set(VERSION_CACHE_KEY, tag_name.split("/")[1], 30)
except RequestException: except (RequestException, IndexError):
return parse("0.0.0") cache.set(VERSION_CACHE_KEY, "0.0.0", 30)
return parse(cache.get(VERSION_CACHE_KEY))
class AdministrationOverviewView(AdminRequiredMixin, TemplateView): class AdministrationOverviewView(AdminRequiredMixin, TemplateView):
@ -60,4 +61,5 @@ class AdministrationOverviewView(AdminRequiredMixin, TemplateView):
Policy.objects.filter(bindings__isnull=True) Policy.objects.filter(bindings__isnull=True)
) )
kwargs["cached_policies"] = len(cache.keys("policy_*")) kwargs["cached_policies"] = len(cache.keys("policy_*"))
kwargs["cached_flows"] = len(cache.keys("flow_*"))
return super().get_context_data(**kwargs) return super().get_context_data(**kwargs)

View file

@ -21,7 +21,9 @@
<button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog"> <button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog">
<i class="fas fa-times" aria-hidden="true"></i> <i class="fas fa-times" aria-hidden="true"></i>
</button> </button>
<div class="pf-c-modal-box__header">
<h1 class="pf-c-title pf-m-2xl">{% trans 'Setup with docker-compose' %}</h1> <h1 class="pf-c-title pf-m-2xl">{% trans 'Setup with docker-compose' %}</h1>
</div>
<div class="pf-c-modal-box__body"> <div class="pf-c-modal-box__body">
{% trans 'Add the following snippet to your docker-compose file.' %} {% trans 'Add the following snippet to your docker-compose file.' %}
<textarea class="codemirror" readonly data-cm-mode="yaml">{% include 'app_gw/docker-compose.yml' %}</textarea> <textarea class="codemirror" readonly data-cm-mode="yaml">{% include 'app_gw/docker-compose.yml' %}</textarea>
@ -39,7 +41,9 @@
<button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog"> <button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog">
<i class="fas fa-times" aria-hidden="true"></i> <i class="fas fa-times" aria-hidden="true"></i>
</button> </button>
<div class="pf-c-modal-box__header">
<h1 class="pf-c-title pf-m-2xl">{% trans 'Setup with Kubernetes' %}</h1> <h1 class="pf-c-title pf-m-2xl">{% trans 'Setup with Kubernetes' %}</h1>
</div>
<div class="pf-c-modal-box__body"> <div class="pf-c-modal-box__body">
<p>{% trans 'Download the manifest to create the Gatekeeper deployment and service:' %}</p> <p>{% trans 'Download the manifest to create the Gatekeeper deployment and service:' %}</p>
<a href="{% url 'passbook_providers_app_gw:k8s-manifest' provider=provider.pk %}">{% trans 'Here' %}</a> <a href="{% url 'passbook_providers_app_gw:k8s-manifest' provider=provider.pk %}">{% trans 'Here' %}</a>

View file

@ -7,7 +7,9 @@
<button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog"> <button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog">
<i class="fas fa-times" aria-hidden="true"></i> <i class="fas fa-times" aria-hidden="true"></i>
</button> </button>
<div class="pf-c-modal-box__header">
<h1 class="pf-c-title pf-m-2xl" id="modal-title">{% trans 'Setup URLs' %}</h1> <h1 class="pf-c-title pf-m-2xl" id="modal-title">{% trans 'Setup URLs' %}</h1>
</div>
<div class="pf-c-modal-box__body" id="modal-description"> <div class="pf-c-modal-box__body" id="modal-description">
<form class="pf-c-form"> <form class="pf-c-form">
<div class="pf-c-form__group"> <div class="pf-c-form__group">

View file

@ -8,7 +8,9 @@
<button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog"> <button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog">
<i class="fas fa-times" aria-hidden="true"></i> <i class="fas fa-times" aria-hidden="true"></i>
</button> </button>
<div class="pf-c-modal-box__header">
<h1 class="pf-c-title pf-m-2xl" id="modal-title">{% trans 'Setup URLs' %}</h1> <h1 class="pf-c-title pf-m-2xl" id="modal-title">{% trans 'Setup URLs' %}</h1>
</div>
<div class="pf-c-modal-box__body" id="modal-description"> <div class="pf-c-modal-box__body" id="modal-description">
<form class="pf-c-form"> <form class="pf-c-form">
<div class="pf-c-form__group"> <div class="pf-c-form__group">

View file

@ -8,7 +8,9 @@
<button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog"> <button data-modal-close class="pf-c-button pf-m-plain" type="button" aria-label="Close dialog">
<i class="fas fa-times" aria-hidden="true"></i> <i class="fas fa-times" aria-hidden="true"></i>
</button> </button>
<div class="pf-c-modal-box__header">
<h1 class="pf-c-title pf-m-2xl" id="modal-title">{% trans 'Metadata' %}</h1> <h1 class="pf-c-title pf-m-2xl" id="modal-title">{% trans 'Metadata' %}</h1>
</div>
<div class="pf-c-modal-box__body" id="modal-description"> <div class="pf-c-modal-box__body" id="modal-description">
<form method="post"> <form method="post">
<textarea class="codemirror" readonly data-cm-mode="xml">{{ metadata }}</textarea> <textarea class="codemirror" readonly data-cm-mode="xml">{{ metadata }}</textarea>

View file

@ -241,3 +241,9 @@ input[data-is-monospace] {
white-space: nowrap !important; white-space: nowrap !important;
padding: var(--pf-c-table--cell--PaddingTop) var(--pf-c-table--cell--PaddingRight) var(--pf-c-table--cell--PaddingBottom) var(--pf-c-table--cell--PaddingLeft) !important; padding: var(--pf-c-table--cell--PaddingTop) var(--pf-c-table--cell--PaddingRight) var(--pf-c-table--cell--PaddingBottom) var(--pf-c-table--cell--PaddingLeft) !important;
} }
/* Aggregate Cards */
.pf-c-card.pf-c-card-aggregate > .pf-c-card__body > .aggregate-status {
font-size: var(--pf-global--icon--FontSize--lg);
text-align: center;
}