web: make ActionButton's method configurable

This commit is contained in:
Jens Langhammer 2021-02-09 16:08:43 +01:00
parent 552f8c6a9a
commit fa30755241
3 changed files with 6 additions and 5 deletions

View File

@ -64,8 +64,9 @@ class LDAPSourceViewSet(ModelViewSet):
@swagger_auto_schema(responses={200: LDAPSourceSyncStatusSerializer(many=False)}) @swagger_auto_schema(responses={200: LDAPSourceSyncStatusSerializer(many=False)})
@action(methods=["GET"], detail=True) @action(methods=["GET"], detail=True)
# pylint: disable=invalid-name # pylint: disable=unused-argument
def sync_status(self, request: Request, slug: str) -> Response: def sync_status(self, request: Request, slug: str) -> Response:
"""Get source's sync status"""
source = self.get_object() source = self.get_object()
last_sync = cache.get(source.state_cache_prefix("last_sync"), None) last_sync = cache.get(source.state_cache_prefix("last_sync"), None)
return Response( return Response(

View File

@ -1,8 +1,6 @@
"""authentik LDAP Models""" """authentik LDAP Models"""
from datetime import datetime
from typing import Optional, Type from typing import Optional, Type
from django.core.cache import cache
from django.db import models from django.db import models
from django.forms import ModelForm from django.forms import ModelForm
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@ -11,7 +9,6 @@ from rest_framework.serializers import Serializer
from authentik.core.models import Group, PropertyMapping, Source from authentik.core.models import Group, PropertyMapping, Source
from authentik.lib.models import DomainlessURLValidator from authentik.lib.models import DomainlessURLValidator
from authentik.lib.utils.template import render_to_string
class LDAPSource(Source): class LDAPSource(Source):

View File

@ -9,6 +9,9 @@ export class ActionButton extends SpinnerButton {
@property() @property()
url = ""; url = "";
@property()
method = "POST";
callAction(): void { callAction(): void {
if (this.isRunning === true) { if (this.isRunning === true) {
return; return;
@ -19,7 +22,7 @@ export class ActionButton extends SpinnerButton {
headers: { "X-CSRFToken": csrftoken }, headers: { "X-CSRFToken": csrftoken },
}); });
fetch(request, { fetch(request, {
method: "POST", method: this.method,
mode: "same-origin", mode: "same-origin",
}) })
.then((r) => { .then((r) => {