web: make table pagination size user-configurable

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-10-14 12:48:52 +02:00
parent 8eddb4b95b
commit f341479732
39 changed files with 122 additions and 114 deletions

View File

@ -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<Event> {
@property()
targetModelName!: string;
apiEndpoint(page: number): Promise<AKResponse<Event>> {
async apiEndpoint(page: number): Promise<AKResponse<Event>> {
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(),

View File

@ -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<Event> {
@property()
targetUser!: string;
apiEndpoint(page: number): Promise<AKResponse<Event>> {
async apiEndpoint(page: number): Promise<AKResponse<Event>> {
return new EventsApi(DEFAULT_CONFIG).eventsEventsList({
page: page,
ordering: this.order,
pageSize: PAGE_SIZE / 2,
pageSize: (await uiConfig()).pagination.perPage / 2,
username: this.targetUser,
});
}

View File

@ -38,7 +38,7 @@ export class DeleteObjectsTable<T> extends Table<T> {
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
apiEndpoint(page: number): Promise<AKResponse<T>> {
async apiEndpoint(page: number): Promise<AKResponse<T>> {
return Promise.resolve({
pagination: {
count: this.objects.length,

View File

@ -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<ExpiringBaseGrantModel> {
@property({ type: Number })
userId?: number;
apiEndpoint(page: number): Promise<AKResponse<ExpiringBaseGrantModel>> {
async apiEndpoint(page: number): Promise<AKResponse<ExpiringBaseGrantModel>> {
return new Oauth2Api(DEFAULT_CONFIG).oauth2AuthorizationCodesList({
user: this.userId,
ordering: "expires",
page: page,
pageSize: PAGE_SIZE,
pageSize: (await uiConfig()).pagination.perPage,
});
}

View File

@ -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<RefreshTokenModel> {
return super.styles.concat(PFFlex);
}
apiEndpoint(page: number): Promise<AKResponse<RefreshTokenModel>> {
async apiEndpoint(page: number): Promise<AKResponse<RefreshTokenModel>> {
return new Oauth2Api(DEFAULT_CONFIG).oauth2RefreshTokensList({
user: this.userId,
ordering: "expires",
page: page,
pageSize: PAGE_SIZE,
pageSize: (await uiConfig()).pagination.perPage,
});
}

View File

@ -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<AuthenticatedSession> {
@property()
targetUser!: string;
apiEndpoint(page: number): Promise<AKResponse<AuthenticatedSession>> {
async apiEndpoint(page: number): Promise<AKResponse<AuthenticatedSession>> {
return new CoreApi(DEFAULT_CONFIG).coreAuthenticatedSessionsList({
userUsername: this.targetUser,
ordering: this.order,
page: page,
pageSize: PAGE_SIZE,
pageSize: (await uiConfig()).pagination.perPage,
});
}

View File

@ -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<UserConsent> {
@property({ type: Number })
userId?: number;
apiEndpoint(page: number): Promise<AKResponse<UserConsent>> {
async apiEndpoint(page: number): Promise<AKResponse<UserConsent>> {
return new CoreApi(DEFAULT_CONFIG).coreUserConsentList({
user: this.userId,
ordering: this.order,
page: page,
pageSize: PAGE_SIZE,
pageSize: (await uiConfig()).pagination.perPage,
});
}