From f3414797325a173ee2d919a573268e44e589b1ff Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 14 Oct 2021 12:48:52 +0200 Subject: [PATCH] web: make table pagination size user-configurable Signed-off-by: Jens Langhammer --- web/src/{user => common}/config.ts | 33 ++++++++++++------- web/src/constants.ts | 1 - web/src/elements/events/ObjectChangelog.ts | 6 ++-- web/src/elements/events/UserEvents.ts | 6 ++-- web/src/elements/forms/DeleteBulkForm.ts | 2 +- web/src/elements/oauth/UserCodeList.ts | 6 ++-- web/src/elements/oauth/UserRefreshList.ts | 6 ++-- web/src/elements/user/SessionList.ts | 6 ++-- web/src/elements/user/UserConsentList.ts | 6 ++-- web/src/interfaces/UserInterface.ts | 2 +- .../pages/applications/ApplicationListPage.ts | 6 ++-- .../crypto/CertificateKeyPairListPage.ts | 6 ++-- web/src/pages/events/EventListPage.ts | 6 ++-- web/src/pages/events/RuleListPage.ts | 6 ++-- web/src/pages/events/TransportListPage.ts | 6 ++-- web/src/pages/flows/BoundStagesList.ts | 6 ++-- web/src/pages/flows/FlowListPage.ts | 6 ++-- web/src/pages/groups/GroupListPage.ts | 6 ++-- web/src/pages/groups/MemberSelectModal.ts | 6 ++-- web/src/pages/outposts/OutpostListPage.ts | 6 ++-- .../outposts/ServiceConnectionListPage.ts | 6 ++-- web/src/pages/policies/BoundPoliciesList.ts | 6 ++-- web/src/pages/policies/PolicyListPage.ts | 6 ++-- .../reputation/IPReputationListPage.ts | 6 ++-- .../reputation/UserReputationListPage.ts | 6 ++-- .../PropertyMappingListPage.ts | 6 ++-- web/src/pages/providers/ProviderListPage.ts | 6 ++-- web/src/pages/sources/SourcesListPage.ts | 6 ++-- web/src/pages/stages/StageListPage.ts | 6 ++-- .../stages/invitation/InvitationListPage.ts | 6 ++-- web/src/pages/stages/prompt/PromptListPage.ts | 6 ++-- .../pages/system-tasks/SystemTaskListPage.ts | 2 +- web/src/pages/tenants/TenantListPage.ts | 6 ++-- web/src/pages/tokens/TokenListPage.ts | 6 ++-- web/src/pages/users/GroupSelectModal.ts | 6 ++-- web/src/pages/users/UserListPage.ts | 6 ++-- web/src/user/LibraryApplication.ts | 2 +- web/src/user/LibraryPage.ts | 2 +- .../user-settings/tokens/UserTokenList.ts | 6 ++-- 39 files changed, 122 insertions(+), 114 deletions(-) rename web/src/{user => common}/config.ts (64%) diff --git a/web/src/user/config.ts b/web/src/common/config.ts similarity index 64% rename from web/src/user/config.ts rename to web/src/common/config.ts index 3b1f3e799..9ab8c8176 100644 --- a/web/src/user/config.ts +++ b/web/src/common/config.ts @@ -26,6 +26,9 @@ export interface UIConfig { background: string; cardBackground: string; }; + pagination: { + perPage: number; + }; } export class DefaultUIConfig implements UIConfig { @@ -43,20 +46,26 @@ export class DefaultUIConfig implements UIConfig { background: "", cardBackground: "", }; + pagination = { + perPage: 20, + }; } -export function parseConfig(raw: string): UIConfig { - const c = JSON.parse(raw); - return Object.assign(new DefaultUIConfig(), c); -} +let globalUiConfig: Promise; export function uiConfig(): Promise { - return me().then((user) => { - const settings = user.user.settings; - let config = new DefaultUIConfig(); - if ("userInterface" in settings) { - config = parseConfig(settings.userInterface); - } - return config; - }); + if (!globalUiConfig) { + globalUiConfig = me().then((user) => { + const settings = user.user.settings; + let config = new DefaultUIConfig(); + if (!settings) { + return config; + } + if ("userInterface" in settings) { + config = Object.assign(new DefaultUIConfig(), settings.userInterface); + } + return config; + }); + } + return globalUiConfig; } diff --git a/web/src/constants.ts b/web/src/constants.ts index 8c8c67342..a63ca3651 100644 --- a/web/src/constants.ts +++ b/web/src/constants.ts @@ -4,7 +4,6 @@ export const ERROR_CLASS = "pf-m-danger"; export const PROGRESS_CLASS = "pf-m-in-progress"; export const CURRENT_CLASS = "pf-m-current"; export const VERSION = "2021.9.8"; -export const PAGE_SIZE = 20; export const TITLE_DEFAULT = "authentik"; export const ROUTE_SEPARATOR = ";"; diff --git a/web/src/elements/events/ObjectChangelog.ts b/web/src/elements/events/ObjectChangelog.ts index 0aff068c7..84c24c97f 100644 --- a/web/src/elements/events/ObjectChangelog.ts +++ b/web/src/elements/events/ObjectChangelog.ts @@ -8,7 +8,7 @@ import { Event, EventsApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; import { EventWithContext } from "../../api/Events"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../pages/events/EventInfo"; import "../Tabs"; import "../buttons/Dropdown"; @@ -32,12 +32,12 @@ export class ObjectChangelog extends Table { @property() targetModelName!: string; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new EventsApi(DEFAULT_CONFIG).eventsEventsList({ action: "model_", page: page, ordering: this.order, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, contextModelApp: this.targetModelApp, contextModelName: this.targetModelName, contextModelPk: this.targetModelPk.toString(), diff --git a/web/src/elements/events/UserEvents.ts b/web/src/elements/events/UserEvents.ts index d19f658e9..5a1cbbfae 100644 --- a/web/src/elements/events/UserEvents.ts +++ b/web/src/elements/events/UserEvents.ts @@ -8,7 +8,7 @@ import { Event, EventsApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; import { EventWithContext } from "../../api/Events"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../pages/events/EventInfo"; import "../Tabs"; import "../buttons/Dropdown"; @@ -26,11 +26,11 @@ export class ObjectChangelog extends Table { @property() targetUser!: string; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new EventsApi(DEFAULT_CONFIG).eventsEventsList({ page: page, ordering: this.order, - pageSize: PAGE_SIZE / 2, + pageSize: (await uiConfig()).pagination.perPage / 2, username: this.targetUser, }); } diff --git a/web/src/elements/forms/DeleteBulkForm.ts b/web/src/elements/forms/DeleteBulkForm.ts index 8ecf1f61e..4f7ba945e 100644 --- a/web/src/elements/forms/DeleteBulkForm.ts +++ b/web/src/elements/forms/DeleteBulkForm.ts @@ -38,7 +38,7 @@ export class DeleteObjectsTable extends Table { } // eslint-disable-next-line @typescript-eslint/no-unused-vars - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return Promise.resolve({ pagination: { count: this.objects.length, diff --git a/web/src/elements/oauth/UserCodeList.ts b/web/src/elements/oauth/UserCodeList.ts index b66de5b85..399d3f0cf 100644 --- a/web/src/elements/oauth/UserCodeList.ts +++ b/web/src/elements/oauth/UserCodeList.ts @@ -7,7 +7,7 @@ import { ExpiringBaseGrantModel, Oauth2Api } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../forms/DeleteBulkForm"; import { Table, TableColumn } from "../table/Table"; @@ -16,12 +16,12 @@ export class UserOAuthCodeList extends Table { @property({ type: Number }) userId?: number; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new Oauth2Api(DEFAULT_CONFIG).oauth2AuthorizationCodesList({ user: this.userId, ordering: "expires", page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, }); } diff --git a/web/src/elements/oauth/UserRefreshList.ts b/web/src/elements/oauth/UserRefreshList.ts index 8f3f9b17a..3d797d191 100644 --- a/web/src/elements/oauth/UserRefreshList.ts +++ b/web/src/elements/oauth/UserRefreshList.ts @@ -9,7 +9,7 @@ import { RefreshTokenModel, Oauth2Api, ExpiringBaseGrantModel } from "@goauthent import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../forms/DeleteBulkForm"; import { Table, TableColumn } from "../table/Table"; @@ -24,12 +24,12 @@ export class UserOAuthRefreshList extends Table { return super.styles.concat(PFFlex); } - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new Oauth2Api(DEFAULT_CONFIG).oauth2RefreshTokensList({ user: this.userId, ordering: "expires", page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, }); } diff --git a/web/src/elements/user/SessionList.ts b/web/src/elements/user/SessionList.ts index 08999f542..48a9d9fdf 100644 --- a/web/src/elements/user/SessionList.ts +++ b/web/src/elements/user/SessionList.ts @@ -7,7 +7,7 @@ import { CoreApi, AuthenticatedSession } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../forms/DeleteBulkForm"; import { Table, TableColumn } from "../table/Table"; @@ -16,12 +16,12 @@ export class AuthenticatedSessionList extends Table { @property() targetUser!: string; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreAuthenticatedSessionsList({ userUsername: this.targetUser, ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, }); } diff --git a/web/src/elements/user/UserConsentList.ts b/web/src/elements/user/UserConsentList.ts index feaca37af..94e152ea4 100644 --- a/web/src/elements/user/UserConsentList.ts +++ b/web/src/elements/user/UserConsentList.ts @@ -7,7 +7,7 @@ import { CoreApi, UserConsent } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../forms/DeleteBulkForm"; import { Table, TableColumn } from "../table/Table"; @@ -16,12 +16,12 @@ export class UserConsentList extends Table { @property({ type: Number }) userId?: number; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreUserConsentList({ user: this.userId, ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, }); } diff --git a/web/src/interfaces/UserInterface.ts b/web/src/interfaces/UserInterface.ts index c3308825d..a92f6b023 100644 --- a/web/src/interfaces/UserInterface.ts +++ b/web/src/interfaces/UserInterface.ts @@ -20,6 +20,7 @@ import { CurrentTenant, EventsApi } from "@goauthentik/api"; import { DEFAULT_CONFIG, tenant } from "../api/Config"; import { configureSentry } from "../api/Sentry"; import { me } from "../api/Users"; +import { uiConfig, UserDisplay } from "../common/config"; import { WebsocketClient } from "../common/ws"; import { EVENT_API_DRAWER_TOGGLE, @@ -34,7 +35,6 @@ import "../elements/sidebar/Sidebar"; import { DefaultTenant } from "../elements/sidebar/SidebarBrand"; import "../elements/sidebar/SidebarItem"; import { ROUTES } from "../routesUser"; -import { uiConfig, UserDisplay } from "../user/config"; import { first } from "../utils"; import "./locale"; diff --git a/web/src/pages/applications/ApplicationListPage.ts b/web/src/pages/applications/ApplicationListPage.ts index 078512301..da386da6b 100644 --- a/web/src/pages/applications/ApplicationListPage.ts +++ b/web/src/pages/applications/ApplicationListPage.ts @@ -9,7 +9,7 @@ import { Application, CoreApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; import "../../elements/forms/ModalForm"; @@ -37,11 +37,11 @@ export class ApplicationListPage extends TablePage { @property() order = "name"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreApplicationsList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", superuserFullList: true, }); diff --git a/web/src/pages/crypto/CertificateKeyPairListPage.ts b/web/src/pages/crypto/CertificateKeyPairListPage.ts index 878c5889b..0a25f1de6 100644 --- a/web/src/pages/crypto/CertificateKeyPairListPage.ts +++ b/web/src/pages/crypto/CertificateKeyPairListPage.ts @@ -9,7 +9,7 @@ import { CryptoApi, CertificateKeyPair } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; import "../../elements/forms/ModalForm"; @@ -43,11 +43,11 @@ export class CertificateKeyPairListPage extends TablePage { return super.styles.concat(PFDescriptionList); } - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/events/EventListPage.ts b/web/src/pages/events/EventListPage.ts index 9d3b33dda..8e5d74cda 100644 --- a/web/src/pages/events/EventListPage.ts +++ b/web/src/pages/events/EventListPage.ts @@ -8,7 +8,7 @@ import { Event, EventsApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; import { EventWithContext } from "../../api/Events"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import { TableColumn } from "../../elements/table/Table"; import { TablePage } from "../../elements/table/TablePage"; import "./EventInfo"; @@ -34,11 +34,11 @@ export class EventListPage extends TablePage { @property() order = "-created"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new EventsApi(DEFAULT_CONFIG).eventsEventsList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/events/RuleListPage.ts b/web/src/pages/events/RuleListPage.ts index f6b1cf085..35fb56d44 100644 --- a/web/src/pages/events/RuleListPage.ts +++ b/web/src/pages/events/RuleListPage.ts @@ -7,7 +7,7 @@ import { EventsApi, NotificationRule } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; import "../../elements/forms/ModalForm"; @@ -37,11 +37,11 @@ export class RuleListPage extends TablePage { @property() order = "name"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new EventsApi(DEFAULT_CONFIG).eventsRulesList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/events/TransportListPage.ts b/web/src/pages/events/TransportListPage.ts index ecfc186eb..e10b826a1 100644 --- a/web/src/pages/events/TransportListPage.ts +++ b/web/src/pages/events/TransportListPage.ts @@ -7,7 +7,7 @@ import { EventsApi, NotificationTransport } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/ActionButton"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; @@ -36,11 +36,11 @@ export class TransportListPage extends TablePage { @property() order = "name"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new EventsApi(DEFAULT_CONFIG).eventsTransportsList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/flows/BoundStagesList.ts b/web/src/pages/flows/BoundStagesList.ts index ed14bbd98..3acecb62d 100644 --- a/web/src/pages/flows/BoundStagesList.ts +++ b/web/src/pages/flows/BoundStagesList.ts @@ -9,7 +9,7 @@ import { FlowsApi, FlowStageBinding, StagesApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/Tabs"; import "../../elements/buttons/Dropdown"; import "../../elements/buttons/SpinnerButton"; @@ -28,12 +28,12 @@ export class BoundStagesList extends Table { @property() target?: string; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new FlowsApi(DEFAULT_CONFIG).flowsBindingsList({ target: this.target || "", ordering: "order", page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, }); } diff --git a/web/src/pages/flows/FlowListPage.ts b/web/src/pages/flows/FlowListPage.ts index c43206733..e8a529f70 100644 --- a/web/src/pages/flows/FlowListPage.ts +++ b/web/src/pages/flows/FlowListPage.ts @@ -7,7 +7,7 @@ import { Flow, FlowsApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/ConfirmationForm"; import "../../elements/forms/DeleteBulkForm"; @@ -39,11 +39,11 @@ export class FlowListPage extends TablePage { @property() order = "slug"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new FlowsApi(DEFAULT_CONFIG).flowsInstancesList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/groups/GroupListPage.ts b/web/src/pages/groups/GroupListPage.ts index 013ee07cb..cb74ed99e 100644 --- a/web/src/pages/groups/GroupListPage.ts +++ b/web/src/pages/groups/GroupListPage.ts @@ -7,7 +7,7 @@ import { CoreApi, Group } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; import "../../elements/forms/ModalForm"; @@ -34,11 +34,11 @@ export class GroupListPage extends TablePage { @property() order = "slug"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreGroupsList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/groups/MemberSelectModal.ts b/web/src/pages/groups/MemberSelectModal.ts index 49554fda8..a87e495a0 100644 --- a/web/src/pages/groups/MemberSelectModal.ts +++ b/web/src/pages/groups/MemberSelectModal.ts @@ -7,7 +7,7 @@ import { CoreApi, User } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/SpinnerButton"; import { TableColumn } from "../../elements/table/Table"; import { TableModal } from "../../elements/table/TableModal"; @@ -27,11 +27,11 @@ export class MemberSelectTable extends TableModal { order = "username"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreUsersList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE / 2, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/outposts/OutpostListPage.ts b/web/src/pages/outposts/OutpostListPage.ts index 2b32f43e2..8da62a1dd 100644 --- a/web/src/pages/outposts/OutpostListPage.ts +++ b/web/src/pages/outposts/OutpostListPage.ts @@ -12,7 +12,7 @@ import { Outpost, OutpostsApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import { PFSize } from "../../elements/Spinner"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; @@ -40,11 +40,11 @@ export class OutpostListPage extends TablePage { searchEnabled(): boolean { return true; } - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/outposts/ServiceConnectionListPage.ts b/web/src/pages/outposts/ServiceConnectionListPage.ts index fb5d3c828..4f28742d0 100644 --- a/web/src/pages/outposts/ServiceConnectionListPage.ts +++ b/web/src/pages/outposts/ServiceConnectionListPage.ts @@ -9,7 +9,7 @@ import { OutpostsApi, ServiceConnection } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import { PFColor } from "../../elements/Label"; import "../../elements/buttons/Dropdown"; import "../../elements/buttons/SpinnerButton"; @@ -39,11 +39,11 @@ export class OutpostServiceConnectionListPage extends TablePage> { + async apiEndpoint(page: number): Promise> { return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/policies/BoundPoliciesList.ts b/web/src/pages/policies/BoundPoliciesList.ts index 7860e3e71..e8681bfc8 100644 --- a/web/src/pages/policies/BoundPoliciesList.ts +++ b/web/src/pages/policies/BoundPoliciesList.ts @@ -9,7 +9,7 @@ import { PoliciesApi, PolicyBinding } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import { PFSize } from "../../elements/Spinner"; import "../../elements/Tabs"; import "../../elements/buttons/Dropdown"; @@ -32,12 +32,12 @@ export class BoundPoliciesList extends Table { checkbox = true; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new PoliciesApi(DEFAULT_CONFIG).policiesBindingsList({ target: this.target || "", ordering: "order", page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, }); } diff --git a/web/src/pages/policies/PolicyListPage.ts b/web/src/pages/policies/PolicyListPage.ts index 54d8cd63f..069823488 100644 --- a/web/src/pages/policies/PolicyListPage.ts +++ b/web/src/pages/policies/PolicyListPage.ts @@ -9,7 +9,7 @@ import { PoliciesApi, Policy } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/Dropdown"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/ConfirmationForm"; @@ -48,11 +48,11 @@ export class PolicyListPage extends TablePage { @property() order = "name"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new PoliciesApi(DEFAULT_CONFIG).policiesAllList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/policies/reputation/IPReputationListPage.ts b/web/src/pages/policies/reputation/IPReputationListPage.ts index f0e19b3fe..f5bbaf4bc 100644 --- a/web/src/pages/policies/reputation/IPReputationListPage.ts +++ b/web/src/pages/policies/reputation/IPReputationListPage.ts @@ -7,7 +7,7 @@ import { IPReputation, PoliciesApi } from "@goauthentik/api"; import { AKResponse } from "../../../api/Client"; import { DEFAULT_CONFIG } from "../../../api/Config"; -import { PAGE_SIZE } from "../../../constants"; +import { uiConfig } from "../../../common/config"; import "../../../elements/buttons/ModalButton"; import "../../../elements/buttons/SpinnerButton"; import "../../../elements/forms/DeleteBulkForm"; @@ -35,11 +35,11 @@ export class IPReputationListPage extends TablePage { checkbox = true; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new PoliciesApi(DEFAULT_CONFIG).policiesReputationIpsList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/policies/reputation/UserReputationListPage.ts b/web/src/pages/policies/reputation/UserReputationListPage.ts index 5dd56b80b..abaa0cd6e 100644 --- a/web/src/pages/policies/reputation/UserReputationListPage.ts +++ b/web/src/pages/policies/reputation/UserReputationListPage.ts @@ -7,7 +7,7 @@ import { UserReputation, PoliciesApi } from "@goauthentik/api"; import { AKResponse } from "../../../api/Client"; import { DEFAULT_CONFIG } from "../../../api/Config"; -import { PAGE_SIZE } from "../../../constants"; +import { uiConfig } from "../../../common/config"; import "../../../elements/buttons/ModalButton"; import "../../../elements/buttons/SpinnerButton"; import "../../../elements/forms/DeleteBulkForm"; @@ -35,11 +35,11 @@ export class UserReputationListPage extends TablePage { @property() order = "username"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new PoliciesApi(DEFAULT_CONFIG).policiesReputationUsersList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/property-mappings/PropertyMappingListPage.ts b/web/src/pages/property-mappings/PropertyMappingListPage.ts index 526e6df24..f038b66d2 100644 --- a/web/src/pages/property-mappings/PropertyMappingListPage.ts +++ b/web/src/pages/property-mappings/PropertyMappingListPage.ts @@ -9,7 +9,7 @@ import { PropertyMapping, PropertymappingsApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/Dropdown"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; @@ -47,11 +47,11 @@ export class PropertyMappingListPage extends TablePage { @property({ type: Boolean }) hideManaged = false; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", managedIsnull: this.hideManaged ? true : undefined, }); diff --git a/web/src/pages/providers/ProviderListPage.ts b/web/src/pages/providers/ProviderListPage.ts index 8900e4784..348d5ccb5 100644 --- a/web/src/pages/providers/ProviderListPage.ts +++ b/web/src/pages/providers/ProviderListPage.ts @@ -9,7 +9,7 @@ import { Provider, ProvidersApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/Dropdown"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; @@ -43,11 +43,11 @@ export class ProviderListPage extends TablePage { @property() order = "name"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new ProvidersApi(DEFAULT_CONFIG).providersAllList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/sources/SourcesListPage.ts b/web/src/pages/sources/SourcesListPage.ts index a11bb2aa5..64a81ad8f 100644 --- a/web/src/pages/sources/SourcesListPage.ts +++ b/web/src/pages/sources/SourcesListPage.ts @@ -9,7 +9,7 @@ import { Source, SourcesApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/Dropdown"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; @@ -42,11 +42,11 @@ export class SourceListPage extends TablePage { @property() order = "name"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new SourcesApi(DEFAULT_CONFIG).sourcesAllList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/stages/StageListPage.ts b/web/src/pages/stages/StageListPage.ts index 9cf39e13d..c71868ad4 100644 --- a/web/src/pages/stages/StageListPage.ts +++ b/web/src/pages/stages/StageListPage.ts @@ -9,7 +9,7 @@ import { Stage, StagesApi } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/Dropdown"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; @@ -58,11 +58,11 @@ export class StageListPage extends TablePage { @property() order = "name"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new StagesApi(DEFAULT_CONFIG).stagesAllList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/stages/invitation/InvitationListPage.ts b/web/src/pages/stages/invitation/InvitationListPage.ts index a3b2654d5..4357ea647 100644 --- a/web/src/pages/stages/invitation/InvitationListPage.ts +++ b/web/src/pages/stages/invitation/InvitationListPage.ts @@ -7,7 +7,7 @@ import { Invitation, StagesApi } from "@goauthentik/api"; import { AKResponse } from "../../../api/Client"; import { DEFAULT_CONFIG } from "../../../api/Config"; -import { PAGE_SIZE } from "../../../constants"; +import { uiConfig } from "../../../common/config"; import "../../../elements/buttons/ModalButton"; import "../../../elements/buttons/SpinnerButton"; import "../../../elements/forms/DeleteBulkForm"; @@ -39,11 +39,11 @@ export class InvitationListPage extends TablePage { @property() order = "expires"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new StagesApi(DEFAULT_CONFIG).stagesInvitationInvitationsList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/stages/prompt/PromptListPage.ts b/web/src/pages/stages/prompt/PromptListPage.ts index a855b4796..fc7525d31 100644 --- a/web/src/pages/stages/prompt/PromptListPage.ts +++ b/web/src/pages/stages/prompt/PromptListPage.ts @@ -7,7 +7,7 @@ import { Prompt, StagesApi } from "@goauthentik/api"; import { AKResponse } from "../../../api/Client"; import { DEFAULT_CONFIG } from "../../../api/Config"; -import { PAGE_SIZE } from "../../../constants"; +import { uiConfig } from "../../../common/config"; import "../../../elements/buttons/ModalButton"; import "../../../elements/buttons/SpinnerButton"; import "../../../elements/forms/DeleteBulkForm"; @@ -37,11 +37,11 @@ export class PromptListPage extends TablePage { @property() order = "order"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/system-tasks/SystemTaskListPage.ts b/web/src/pages/system-tasks/SystemTaskListPage.ts index 2998fc330..77548f73a 100644 --- a/web/src/pages/system-tasks/SystemTaskListPage.ts +++ b/web/src/pages/system-tasks/SystemTaskListPage.ts @@ -40,7 +40,7 @@ export class SystemTaskListPage extends TablePage { return super.styles.concat(PFDescriptionList); } - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new AdminApi(DEFAULT_CONFIG).adminSystemTasksList().then((tasks) => { return { pagination: { diff --git a/web/src/pages/tenants/TenantListPage.ts b/web/src/pages/tenants/TenantListPage.ts index a7b612772..f848fb61c 100644 --- a/web/src/pages/tenants/TenantListPage.ts +++ b/web/src/pages/tenants/TenantListPage.ts @@ -7,7 +7,7 @@ import { CoreApi, Tenant } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/SpinnerButton"; import "../../elements/forms/DeleteBulkForm"; import "../../elements/forms/ModalForm"; @@ -35,11 +35,11 @@ export class TenantListPage extends TablePage { @property() order = "domain"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreTenantsList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/tokens/TokenListPage.ts b/web/src/pages/tokens/TokenListPage.ts index 8a658f93d..bdb7541dd 100644 --- a/web/src/pages/tokens/TokenListPage.ts +++ b/web/src/pages/tokens/TokenListPage.ts @@ -7,7 +7,7 @@ import { CoreApi, IntentEnum, Token } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/Dropdown"; import "../../elements/buttons/TokenCopyButton"; import "../../elements/forms/DeleteBulkForm"; @@ -49,11 +49,11 @@ export class TokenListPage extends TablePage { @property() order = "expires"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreTokensList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } diff --git a/web/src/pages/users/GroupSelectModal.ts b/web/src/pages/users/GroupSelectModal.ts index da6b552f7..5eb2bb321 100644 --- a/web/src/pages/users/GroupSelectModal.ts +++ b/web/src/pages/users/GroupSelectModal.ts @@ -7,7 +7,7 @@ import { CoreApi, Group } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/SpinnerButton"; import { TableColumn } from "../../elements/table/Table"; import { TableModal } from "../../elements/table/TableModal"; @@ -26,11 +26,11 @@ export class GroupSelectModal extends TableModal { order = "name"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreGroupsList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE / 2, + pageSize: (await uiConfig()).pagination.perPage / 2, search: this.search || "", }); } diff --git a/web/src/pages/users/UserListPage.ts b/web/src/pages/users/UserListPage.ts index ac5b8c383..21f045042 100644 --- a/web/src/pages/users/UserListPage.ts +++ b/web/src/pages/users/UserListPage.ts @@ -10,7 +10,7 @@ import { CoreApi, User } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG, tenant } from "../../api/Config"; -import { PAGE_SIZE } from "../../constants"; +import { uiConfig } from "../../common/config"; import "../../elements/buttons/ActionButton"; import "../../elements/forms/DeleteBulkForm"; import "../../elements/forms/ModalForm"; @@ -52,11 +52,11 @@ export class UserListPage extends TablePage { return super.styles.concat(PFDescriptionList); } - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreUsersList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", attributes: this.hideServiceAccounts ? JSON.stringify({ diff --git a/web/src/user/LibraryApplication.ts b/web/src/user/LibraryApplication.ts index 8376e8615..a08d786e0 100644 --- a/web/src/user/LibraryApplication.ts +++ b/web/src/user/LibraryApplication.ts @@ -14,8 +14,8 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css"; import { Application } from "@goauthentik/api"; import { me } from "../api/Users"; +import { uiConfig } from "../common/config"; import { truncate } from "../utils"; -import { uiConfig } from "./config"; @customElement("ak-library-app") export class LibraryApplication extends LitElement { diff --git a/web/src/user/LibraryPage.ts b/web/src/user/LibraryPage.ts index 8a5769359..a7d18eb83 100644 --- a/web/src/user/LibraryPage.ts +++ b/web/src/user/LibraryPage.ts @@ -18,9 +18,9 @@ import { Application, CoreApi } from "@goauthentik/api"; import { AKResponse } from "../api/Client"; import { DEFAULT_CONFIG } from "../api/Config"; +import { UIConfig, uiConfig } from "../common/config"; import { loading } from "../utils"; import "./LibraryApplication"; -import { UIConfig, uiConfig } from "./config"; @customElement("ak-library") export class LibraryPage extends LitElement { diff --git a/web/src/user/user-settings/tokens/UserTokenList.ts b/web/src/user/user-settings/tokens/UserTokenList.ts index 99b699910..a316feb12 100644 --- a/web/src/user/user-settings/tokens/UserTokenList.ts +++ b/web/src/user/user-settings/tokens/UserTokenList.ts @@ -9,7 +9,7 @@ import { CoreApi, IntentEnum, Token } from "@goauthentik/api"; import { AKResponse } from "../../../api/Client"; import { DEFAULT_CONFIG } from "../../../api/Config"; -import { PAGE_SIZE } from "../../../constants"; +import { uiConfig } from "../../../common/config"; import "../../../elements/buttons/Dropdown"; import "../../../elements/buttons/ModalButton"; import "../../../elements/buttons/TokenCopyButton"; @@ -31,11 +31,11 @@ export class UserTokenList extends Table { @property() order = "expires"; - apiEndpoint(page: number): Promise> { + async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreTokensList({ ordering: this.order, page: page, - pageSize: PAGE_SIZE, + pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", managed: "", });