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)})
@action(methods=["GET"], detail=True)
# pylint: disable=invalid-name
# pylint: disable=unused-argument
def sync_status(self, request: Request, slug: str) -> Response:
"""Get source's sync status"""
source = self.get_object()
last_sync = cache.get(source.state_cache_prefix("last_sync"), None)
return Response(

View File

@ -1,8 +1,6 @@
"""authentik LDAP Models"""
from datetime import datetime
from typing import Optional, Type
from django.core.cache import cache
from django.db import models
from django.forms import ModelForm
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.lib.models import DomainlessURLValidator
from authentik.lib.utils.template import render_to_string
class LDAPSource(Source):

View File

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