From 00fae2353ca5a6b7f858fec9549b85672ce7e2d3 Mon Sep 17 00:00:00 2001 From: Jens L Date: Sat, 5 Aug 2023 15:37:06 +0200 Subject: [PATCH] api: optimise pagination in API schema (#6478) --- authentik/api/pagination.py | 73 +- authentik/api/schema.py | 32 +- schema.yml | 2101 +---------------- .../admin/system-tasks/SystemTaskListPage.ts | 2 + web/src/elements/forms/DeleteBulkForm.ts | 2 + web/src/elements/table/Table.ts | 3 +- web/src/elements/table/TablePagination.ts | 12 +- web/src/elements/user/UserDevicesList.ts | 2 + .../user/user-settings/mfa/MFADevicesPage.ts | 2 + 9 files changed, 177 insertions(+), 2052 deletions(-) diff --git a/authentik/api/pagination.py b/authentik/api/pagination.py index fab9c625c..7125c8968 100644 --- a/authentik/api/pagination.py +++ b/authentik/api/pagination.py @@ -2,6 +2,43 @@ from rest_framework import pagination from rest_framework.response import Response +PAGINATION_COMPONENT_NAME = "Pagination" +PAGINATION_SCHEMA = { + "type": "object", + "properties": { + "next": { + "type": "number", + }, + "previous": { + "type": "number", + }, + "count": { + "type": "number", + }, + "current": { + "type": "number", + }, + "total_pages": { + "type": "number", + }, + "start_index": { + "type": "number", + }, + "end_index": { + "type": "number", + }, + }, + "required": [ + "next", + "previous", + "count", + "current", + "total_pages", + "start_index", + "end_index", + ], +} + class Pagination(pagination.PageNumberPagination): """Pagination which includes total pages and current page""" @@ -35,41 +72,7 @@ class Pagination(pagination.PageNumberPagination): return { "type": "object", "properties": { - "pagination": { - "type": "object", - "properties": { - "next": { - "type": "number", - }, - "previous": { - "type": "number", - }, - "count": { - "type": "number", - }, - "current": { - "type": "number", - }, - "total_pages": { - "type": "number", - }, - "start_index": { - "type": "number", - }, - "end_index": { - "type": "number", - }, - }, - "required": [ - "next", - "previous", - "count", - "current", - "total_pages", - "start_index", - "end_index", - ], - }, + "pagination": {"$ref": f"#/components/schemas/{PAGINATION_COMPONENT_NAME}"}, "results": schema, }, "required": ["pagination", "results"], diff --git a/authentik/api/schema.py b/authentik/api/schema.py index 1b2663be6..8e27c4037 100644 --- a/authentik/api/schema.py +++ b/authentik/api/schema.py @@ -1,5 +1,6 @@ """Error Response schema, from https://github.com/axnsan12/drf-yasg/issues/224""" from django.utils.translation import gettext_lazy as _ +from drf_spectacular.generators import SchemaGenerator from drf_spectacular.plumbing import ( ResolvedComponent, build_array_type, @@ -9,6 +10,8 @@ from drf_spectacular.plumbing import ( from drf_spectacular.settings import spectacular_settings from drf_spectacular.types import OpenApiTypes +from authentik.api.pagination import PAGINATION_COMPONENT_NAME, PAGINATION_SCHEMA + def build_standard_type(obj, **kwargs): """Build a basic type with optional add owns.""" @@ -36,7 +39,19 @@ VALIDATION_ERROR = build_object_type( ) -def postprocess_schema_responses(result, generator, **kwargs): # noqa: W0613 +def create_component(generator: SchemaGenerator, name, schema, type_=ResolvedComponent.SCHEMA): + """Register a component and return a reference to it.""" + component = ResolvedComponent( + name=name, + type=type_, + schema=schema, + object=name, + ) + generator.registry.register_on_missing(component) + return component + + +def postprocess_schema_responses(result, generator: SchemaGenerator, **kwargs): # noqa: W0613 """Workaround to set a default response for endpoints. Workaround suggested at @@ -44,19 +59,10 @@ def postprocess_schema_responses(result, generator, **kwargs): # noqa: W0613 . """ - def create_component(name, schema, type_=ResolvedComponent.SCHEMA): - """Register a component and return a reference to it.""" - component = ResolvedComponent( - name=name, - type=type_, - schema=schema, - object=name, - ) - generator.registry.register_on_missing(component) - return component + create_component(generator, PAGINATION_COMPONENT_NAME, PAGINATION_SCHEMA) - generic_error = create_component("GenericError", GENERIC_ERROR) - validation_error = create_component("ValidationError", VALIDATION_ERROR) + generic_error = create_component(generator, "GenericError", GENERIC_ERROR) + validation_error = create_component(generator, "ValidationError", VALIDATION_ERROR) for path in result["paths"].values(): for method in path.values(): diff --git a/schema.yml b/schema.yml index dcd8b0814..ed4172c04 100644 --- a/schema.yml +++ b/schema.yml @@ -17070,6 +17070,7 @@ paths: - br - bs - ca + - ckb - cs - cy - da @@ -32965,30 +32966,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33000,30 +32978,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33035,30 +32990,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33070,30 +33002,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33105,30 +33014,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33140,30 +33026,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33175,30 +33038,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33210,30 +33050,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33245,30 +33062,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33280,30 +33074,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33315,30 +33086,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33350,30 +33098,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33385,30 +33110,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33420,30 +33122,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33455,30 +33134,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33490,30 +33146,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33525,30 +33158,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33560,30 +33170,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33595,30 +33182,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33630,30 +33194,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33665,30 +33206,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33700,30 +33218,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33735,30 +33230,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33770,30 +33242,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33805,30 +33254,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33840,30 +33266,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33875,30 +33278,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33910,30 +33290,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33945,30 +33302,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -33980,30 +33314,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34015,30 +33326,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34050,30 +33338,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34085,30 +33350,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34120,30 +33362,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34155,30 +33374,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34190,30 +33386,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34225,30 +33398,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34260,30 +33410,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34295,30 +33422,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34330,30 +33434,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34365,30 +33446,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34400,30 +33458,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34435,30 +33470,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34470,30 +33482,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34505,30 +33494,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34540,30 +33506,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34575,30 +33518,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34610,30 +33530,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34645,30 +33542,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34680,30 +33554,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34715,30 +33566,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34750,30 +33578,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34785,30 +33590,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34820,30 +33602,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34855,30 +33614,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34890,30 +33626,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34925,30 +33638,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34960,30 +33650,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -34995,30 +33662,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35030,30 +33674,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35065,30 +33686,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35100,30 +33698,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35135,30 +33710,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35170,30 +33722,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35205,30 +33734,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35240,30 +33746,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35275,30 +33758,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35310,30 +33770,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35345,30 +33782,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35380,30 +33794,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35415,30 +33806,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35450,30 +33818,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35485,30 +33830,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35520,30 +33842,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35555,30 +33854,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35590,30 +33866,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35625,30 +33878,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35660,30 +33890,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35695,30 +33902,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35730,30 +33914,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35765,30 +33926,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35800,30 +33938,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35835,30 +33950,7 @@ components: type: object properties: pagination: - type: object - properties: - next: - type: number - previous: - type: number - count: - type: number - current: - type: number - total_pages: - type: number - start_index: - type: number - end_index: - type: number - required: - - next - - previous - - count - - current - - total_pages - - start_index - - end_index + $ref: '#/components/schemas/Pagination' results: type: array items: @@ -35866,6 +33958,31 @@ components: required: - pagination - results + Pagination: + type: object + properties: + next: + type: number + previous: + type: number + count: + type: number + current: + type: number + total_pages: + type: number + start_index: + type: number + end_index: + type: number + required: + - next + - previous + - count + - current + - total_pages + - start_index + - end_index PasswordChallenge: type: object description: Password challenge UI fields diff --git a/web/src/admin/system-tasks/SystemTaskListPage.ts b/web/src/admin/system-tasks/SystemTaskListPage.ts index 0d73fa90c..f180f63cc 100644 --- a/web/src/admin/system-tasks/SystemTaskListPage.ts +++ b/web/src/admin/system-tasks/SystemTaskListPage.ts @@ -49,6 +49,8 @@ export class SystemTaskListPage extends TablePage { startIndex: 1, endIndex: tasks.length, current: page, + next: 0, + previous: 0, }, results: tasks, }; diff --git a/web/src/elements/forms/DeleteBulkForm.ts b/web/src/elements/forms/DeleteBulkForm.ts index 097c782c4..5d56f19c0 100644 --- a/web/src/elements/forms/DeleteBulkForm.ts +++ b/web/src/elements/forms/DeleteBulkForm.ts @@ -47,6 +47,8 @@ export class DeleteObjectsTable extends Table { totalPages: 1, startIndex: 1, endIndex: this.objects.length, + next: 0, + previous: 0, }, results: this.objects, }); diff --git a/web/src/elements/table/Table.ts b/web/src/elements/table/Table.ts index 5e4d52474..f671e7b37 100644 --- a/web/src/elements/table/Table.ts +++ b/web/src/elements/table/Table.ts @@ -7,7 +7,6 @@ import "@goauthentik/elements/chips/Chip"; import "@goauthentik/elements/chips/ChipGroup"; import { getURLParam, updateURLParams } from "@goauthentik/elements/router/RouteMatch"; import "@goauthentik/elements/table/TablePagination"; -import { Pagination } from "@goauthentik/elements/table/TablePagination"; import "@goauthentik/elements/table/TableSearch"; import { msg } from "@lit/localize"; @@ -24,6 +23,8 @@ import PFToolbar from "@patternfly/patternfly/components/Toolbar/toolbar.css"; import PFBullseye from "@patternfly/patternfly/layouts/Bullseye/bullseye.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; +import { Pagination } from "@goauthentik/api"; + export class TableColumn { title: string; orderBy?: string; diff --git a/web/src/elements/table/TablePagination.ts b/web/src/elements/table/TablePagination.ts index 6cc0a9ebe..d53c5a03d 100644 --- a/web/src/elements/table/TablePagination.ts +++ b/web/src/elements/table/TablePagination.ts @@ -8,17 +8,7 @@ import PFButton from "@patternfly/patternfly/components/Button/button.css"; import PFPagination from "@patternfly/patternfly/components/Pagination/pagination.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; -export interface Pagination { - next?: number; - previous?: number; - - count: number; - current: number; - totalPages: number; - - startIndex: number; - endIndex: number; -} +import { Pagination } from "@goauthentik/api"; @customElement("ak-table-pagination") export class TablePagination extends AKElement { diff --git a/web/src/elements/user/UserDevicesList.ts b/web/src/elements/user/UserDevicesList.ts index 97e517cfa..3e43d5547 100644 --- a/web/src/elements/user/UserDevicesList.ts +++ b/web/src/elements/user/UserDevicesList.ts @@ -28,6 +28,8 @@ export class UserDeviceList extends MFADevicesPage { totalPages: 1, startIndex: 1, endIndex: res.length, + next: 0, + previous: 0, }, results: res, }; diff --git a/web/src/user/user-settings/mfa/MFADevicesPage.ts b/web/src/user/user-settings/mfa/MFADevicesPage.ts index 1f4cef613..510fae335 100644 --- a/web/src/user/user-settings/mfa/MFADevicesPage.ts +++ b/web/src/user/user-settings/mfa/MFADevicesPage.ts @@ -49,6 +49,8 @@ export class MFADevicesPage extends Table { totalPages: 1, startIndex: 1, endIndex: devices.length, + next: 0, + previous: 0, }, results: devices, };