web: PBResponse -> AKResponse

This commit is contained in:
Jens Langhammer 2021-02-09 17:04:55 +01:00
parent 45f1d95bf9
commit f8bcdb26b3
29 changed files with 78 additions and 74 deletions

View File

@ -1,4 +1,4 @@
import { DefaultClient, PBResponse, QueryArguments } from "./Client";
import { DefaultClient, AKResponse, QueryArguments } from "./Client";
import { Provider } from "./Providers";
export class Application {
@ -22,8 +22,8 @@ export class Application {
return DefaultClient.fetch<Application>(["core", "applications", slug]);
}
static list(filter?: QueryArguments): Promise<PBResponse<Application>> {
return DefaultClient.fetch<PBResponse<Application>>(["core", "applications"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<Application>> {
return DefaultClient.fetch<AKResponse<Application>>(["core", "applications"], filter);
}
static adminUrl(rest: string): string {

View File

@ -94,7 +94,7 @@ export interface PBPagination {
end_index: number;
}
export interface PBResponse<T> {
export interface AKResponse<T> {
pagination: PBPagination;
results: Array<T>;

View File

@ -1,4 +1,4 @@
import { DefaultClient, QueryArguments, PBResponse } from "./Client";
import { DefaultClient, QueryArguments, AKResponse } from "./Client";
import { Event } from "./Events";
export class Notification {
@ -17,8 +17,8 @@ export class Notification {
return DefaultClient.fetch<Notification>(["events", "notifications", pk]);
}
static list(filter?: QueryArguments): Promise<PBResponse<Notification>> {
return DefaultClient.fetch<PBResponse<Notification>>(["events", "notifications"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<Notification>> {
return DefaultClient.fetch<AKResponse<Notification>>(["events", "notifications"], filter);
}
static markSeen(pk: string): Promise<{seen: boolean}> {

View File

@ -1,4 +1,4 @@
import { DefaultClient, QueryArguments, PBResponse } from "./Client";
import { DefaultClient, QueryArguments, AKResponse } from "./Client";
import { Group } from "./Groups";
export class Rule {
@ -16,8 +16,8 @@ export class Rule {
return DefaultClient.fetch<Rule>(["events", "rules", pk]);
}
static list(filter?: QueryArguments): Promise<PBResponse<Rule>> {
return DefaultClient.fetch<PBResponse<Rule>>(["events", "rules"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<Rule>> {
return DefaultClient.fetch<AKResponse<Rule>>(["events", "rules"], filter);
}
static adminUrl(rest: string): string {

View File

@ -1,4 +1,4 @@
import { DefaultClient, QueryArguments, PBResponse } from "./Client";
import { DefaultClient, QueryArguments, AKResponse } from "./Client";
export class Transport {
pk: string;
@ -15,8 +15,8 @@ export class Transport {
return DefaultClient.fetch<Transport>(["events", "transports", pk]);
}
static list(filter?: QueryArguments): Promise<PBResponse<Transport>> {
return DefaultClient.fetch<PBResponse<Transport>>(["events", "transports"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<Transport>> {
return DefaultClient.fetch<AKResponse<Transport>>(["events", "transports"], filter);
}
static adminUrl(rest: string): string {

View File

@ -1,4 +1,4 @@
import { DefaultClient, PBResponse, QueryArguments } from "./Client";
import { DefaultClient, AKResponse, QueryArguments } from "./Client";
export interface EventUser {
pk: number;
@ -28,8 +28,8 @@ export class Event {
return DefaultClient.fetch<Event>(["events", "events", pk]);
}
static list(filter?: QueryArguments): Promise<PBResponse<Event>> {
return DefaultClient.fetch<PBResponse<Event>>(["events", "events"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<Event>> {
return DefaultClient.fetch<AKResponse<Event>>(["events", "events"], filter);
}
// events/events/top_per_user/?filter_action=authorize_application

View File

@ -1,4 +1,4 @@
import { DefaultClient, PBResponse, QueryArguments } from "./Client";
import { DefaultClient, AKResponse, QueryArguments } from "./Client";
export enum FlowDesignation {
Authentication = "authentication",
@ -34,12 +34,12 @@ export class Flow {
return DefaultClient.fetch<{ diagram: string }>(["flows", "instances", slug, "diagram"]);
}
static list(filter?: QueryArguments): Promise<PBResponse<Flow>> {
return DefaultClient.fetch<PBResponse<Flow>>(["flows", "instances"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<Flow>> {
return DefaultClient.fetch<AKResponse<Flow>>(["flows", "instances"], filter);
}
static cached(): Promise<number> {
return DefaultClient.fetch<PBResponse<Flow>>(["flows", "cached"]).then(r => {
return DefaultClient.fetch<AKResponse<Flow>>(["flows", "cached"]).then(r => {
return r.pagination.count;
});
}
@ -76,8 +76,8 @@ export class FlowStageBinding {
return DefaultClient.fetch<FlowStageBinding>(["flows", "bindings", slug]);
}
static list(filter?: QueryArguments): Promise<PBResponse<FlowStageBinding>> {
return DefaultClient.fetch<PBResponse<FlowStageBinding>>(["flows", "bindings"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<FlowStageBinding>> {
return DefaultClient.fetch<AKResponse<FlowStageBinding>>(["flows", "bindings"], filter);
}
static adminUrl(rest: string): string {

View File

@ -1,4 +1,4 @@
import { DefaultClient, PBResponse, QueryArguments } from "./Client";
import { DefaultClient, AKResponse, QueryArguments } from "./Client";
import { Provider } from "./Providers";
export interface OutpostHealth {
@ -26,8 +26,8 @@ export class Outpost {
return DefaultClient.fetch<Outpost>(["outposts", "outposts", pk]);
}
static list(filter?: QueryArguments): Promise<PBResponse<Outpost>> {
return DefaultClient.fetch<PBResponse<Outpost>>(["outposts", "outposts"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<Outpost>> {
return DefaultClient.fetch<AKResponse<Outpost>>(["outposts", "outposts"], filter);
}
static health(pk: string): Promise<OutpostHealth[]> {

View File

@ -1,4 +1,4 @@
import { DefaultClient, BaseInheritanceModel, PBResponse, QueryArguments } from "./Client";
import { DefaultClient, BaseInheritanceModel, AKResponse, QueryArguments } from "./Client";
export class Policy implements BaseInheritanceModel {
pk: string;
@ -15,12 +15,12 @@ export class Policy implements BaseInheritanceModel {
return DefaultClient.fetch<Policy>(["policies", "all", pk]);
}
static list(filter?: QueryArguments): Promise<PBResponse<Policy>> {
return DefaultClient.fetch<PBResponse<Policy>>(["policies", "all"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<Policy>> {
return DefaultClient.fetch<AKResponse<Policy>>(["policies", "all"], filter);
}
static cached(): Promise<number> {
return DefaultClient.fetch<PBResponse<Policy>>(["policies", "cached"]).then(r => {
return DefaultClient.fetch<AKResponse<Policy>>(["policies", "cached"]).then(r => {
return r.pagination.count;
});
}

View File

@ -1,4 +1,4 @@
import { DefaultClient, PBResponse, QueryArguments } from "./Client";
import { DefaultClient, AKResponse, QueryArguments } from "./Client";
import { Policy } from "./Policies";
export class PolicyBinding {
@ -18,8 +18,8 @@ export class PolicyBinding {
return DefaultClient.fetch<PolicyBinding>(["policies", "bindings", pk]);
}
static list(filter?: QueryArguments): Promise<PBResponse<PolicyBinding>> {
return DefaultClient.fetch<PBResponse<PolicyBinding>>(["policies", "bindings"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<PolicyBinding>> {
return DefaultClient.fetch<AKResponse<PolicyBinding>>(["policies", "bindings"], filter);
}
static adminUrl(rest: string): string {

View File

@ -1,4 +1,4 @@
import { DefaultClient, PBResponse, QueryArguments } from "./Client";
import { DefaultClient, AKResponse, QueryArguments } from "./Client";
export class PropertyMapping {
pk: string;
@ -16,8 +16,8 @@ export class PropertyMapping {
return DefaultClient.fetch<PropertyMapping>(["propertymappings", "all", pk]);
}
static list(filter?: QueryArguments): Promise<PBResponse<PropertyMapping>> {
return DefaultClient.fetch<PBResponse<PropertyMapping>>(["propertymappings", "all"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<PropertyMapping>> {
return DefaultClient.fetch<AKResponse<PropertyMapping>>(["propertymappings", "all"], filter);
}
static adminUrl(rest: string): string {

View File

@ -1,4 +1,4 @@
import { BaseInheritanceModel, DefaultClient, PBResponse, QueryArguments } from "./Client";
import { BaseInheritanceModel, DefaultClient, AKResponse, QueryArguments } from "./Client";
export class Provider implements BaseInheritanceModel {
pk: number;
@ -20,8 +20,8 @@ export class Provider implements BaseInheritanceModel {
return DefaultClient.fetch<Provider>(["providers", "all", id.toString()]);
}
static list(filter?: QueryArguments): Promise<PBResponse<Provider>> {
return DefaultClient.fetch<PBResponse<Provider>>(["providers", "all"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<Provider>> {
return DefaultClient.fetch<AKResponse<Provider>>(["providers", "all"], filter);
}
static adminUrl(rest: string): string {

View File

@ -1,4 +1,4 @@
import { BaseInheritanceModel, DefaultClient, PBResponse, QueryArguments } from "./Client";
import { BaseInheritanceModel, DefaultClient, AKResponse, QueryArguments } from "./Client";
export class Source implements BaseInheritanceModel {
pk: string;
@ -19,8 +19,8 @@ export class Source implements BaseInheritanceModel {
return DefaultClient.fetch<Source>(["sources", "all", slug]);
}
static list(filter?: QueryArguments): Promise<PBResponse<Source>> {
return DefaultClient.fetch<PBResponse<Source>>(["sources", "all"], filter);
static list(filter?: QueryArguments): Promise<AKResponse<Source>> {
return DefaultClient.fetch<AKResponse<Source>>(["sources", "all"], filter);
}
static adminUrl(rest: string): string {

View File

@ -1,4 +1,4 @@
import { DefaultClient, PBResponse } from "./Client";
import { DefaultClient, AKResponse } from "./Client";
let _globalMePromise: Promise<User>;
@ -22,7 +22,7 @@ export class User {
}
static count(): Promise<number> {
return DefaultClient.fetch<PBResponse<User>>(["core", "users"], {
return DefaultClient.fetch<AKResponse<User>>(["core", "users"], {
"page_size": 1
}).then(r => {
return r.pagination.count;

View File

@ -1,6 +1,6 @@
import { gettext } from "django";
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
import { PBResponse } from "../../api/Client";
import { AKResponse } from "../../api/Client";
import { Notification } from "../../api/EventNotification";
import { COMMON_STYLES } from "../../common/styles";
@ -8,7 +8,7 @@ import { COMMON_STYLES } from "../../common/styles";
export class NotificationDrawer extends LitElement {
@property({attribute: false})
notifications?: PBResponse<Notification>;
notifications?: AKResponse<Notification>;
@property({type: Number})
unread = 0;

View File

@ -1,6 +1,6 @@
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { PBResponse } from "../../api/Client";
import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../../elements/table/Table";
import { PolicyBinding } from "../../api/PolicyBindings";
@ -14,7 +14,7 @@ export class BoundPoliciesList extends Table<PolicyBinding> {
@property()
target?: string;
apiEndpoint(page: number): Promise<PBResponse<PolicyBinding>> {
apiEndpoint(page: number): Promise<AKResponse<PolicyBinding>> {
return PolicyBinding.list({
target: this.target || "",
ordering: "order",

View File

@ -1,6 +1,6 @@
import { gettext } from "django";
import { CSSResult, html, LitElement, property, TemplateResult } from "lit-element";
import { PBResponse } from "../../api/Client";
import { AKResponse } from "../../api/Client";
import { COMMON_STYLES } from "../../common/styles";
import "./TablePagination";
@ -69,7 +69,7 @@ export class TableColumn {
}
export abstract class Table<T> extends LitElement {
abstract apiEndpoint(page: number): Promise<PBResponse<T>>;
abstract apiEndpoint(page: number): Promise<AKResponse<T>>;
abstract columns(): TableColumn[];
abstract row(item: T): TemplateResult[];
@ -84,7 +84,7 @@ export abstract class Table<T> extends LitElement {
}
@property({attribute: false})
data?: PBResponse<T>;
data?: AKResponse<T>;
@property({type: Number})
page = 1;

View File

@ -2,7 +2,7 @@ import { gettext } from "django";
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
import { ifDefined } from "lit-html/directives/if-defined";
import { Application } from "../api/Applications";
import { PBResponse } from "../api/Client";
import { AKResponse } from "../api/Client";
import { COMMON_STYLES } from "../common/styles";
import { loading, truncate } from "../utils";
@ -52,7 +52,7 @@ export class LibraryApplication extends LitElement {
@customElement("ak-library")
export class LibraryPage extends LitElement {
@property({attribute: false})
apps?: PBResponse<Application>;
apps?: AKResponse<Application>;
static get styles(): CSSResult[] {
return COMMON_STYLES;

View File

@ -1,13 +1,13 @@
import { gettext } from "django";
import { customElement } from "lit-element";
import { DefaultClient, PBResponse } from "../../../api/Client";
import { DefaultClient, AKResponse } from "../../../api/Client";
import { AdminStatus, AdminStatusCard } from "./AdminStatusCard";
@customElement("ak-admin-status-card-workers")
export class WorkersStatusCard extends AdminStatusCard<number> {
getPrimaryValue(): Promise<number> {
return DefaultClient.fetch<PBResponse<number>>(["admin", "workers"]).then((r) => {
return DefaultClient.fetch<AKResponse<number>>(["admin", "workers"]).then((r) => {
return r.pagination.count;
});
}

View File

@ -1,7 +1,7 @@
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { Application } from "../../api/Applications";
import { PBResponse } from "../../api/Client";
import { AKResponse } from "../../api/Client";
import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
@ -26,7 +26,7 @@ export class ApplicationListPage extends TablePage<Application> {
@property()
order = "name";
apiEndpoint(page: number): Promise<PBResponse<Application>> {
apiEndpoint(page: number): Promise<AKResponse<Application>> {
return Application.list({
ordering: this.order,
page: page,

View File

@ -1,6 +1,6 @@
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { PBResponse } from "../../api/Client";
import { AKResponse } from "../../api/Client";
import { Event } from "../../api/Events";
import { TableColumn } from "../../elements/table/Table";
import { TablePage } from "../../elements/table/TablePage";
@ -27,7 +27,7 @@ export class EventListPage extends TablePage<Event> {
@property()
order = "-created";
apiEndpoint(page: number): Promise<PBResponse<Event>> {
apiEndpoint(page: number): Promise<AKResponse<Event>> {
return Event.list({
ordering: this.order,
page: page,

View File

@ -1,6 +1,6 @@
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { PBResponse } from "../../api/Client";
import { AKResponse } from "../../api/Client";
import { TablePage } from "../../elements/table/TablePage";
import "../../elements/policies/BoundPoliciesList";
@ -29,7 +29,7 @@ export class RuleListPage extends TablePage<Rule> {
@property()
order = "name";
apiEndpoint(page: number): Promise<PBResponse<Rule>> {
apiEndpoint(page: number): Promise<AKResponse<Rule>> {
return Rule.list({
ordering: this.order,
page: page,

View File

@ -1,6 +1,6 @@
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { DefaultClient, PBResponse } from "../../api/Client";
import { DefaultClient, AKResponse } from "../../api/Client";
import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ActionButton";
@ -27,7 +27,7 @@ export class TransportListPage extends TablePage<Transport> {
@property()
order = "name";
apiEndpoint(page: number): Promise<PBResponse<Transport>> {
apiEndpoint(page: number): Promise<AKResponse<Transport>> {
return Transport.list({
ordering: this.order,
page: page,

View File

@ -1,6 +1,6 @@
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { PBResponse } from "../../api/Client";
import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../../elements/table/Table";
import "../../elements/Tabs";
@ -17,7 +17,7 @@ export class BoundStagesList extends Table<FlowStageBinding> {
@property()
target?: string;
apiEndpoint(page: number): Promise<PBResponse<FlowStageBinding>> {
apiEndpoint(page: number): Promise<AKResponse<FlowStageBinding>> {
return FlowStageBinding.list({
target: this.target || "",
ordering: "order",

View File

@ -1,7 +1,7 @@
import { gettext } from "django";
import { customElement, property } from "lit-element";
import { html, TemplateResult } from "lit-html";
import { PBResponse } from "../../api/Client";
import { AKResponse } from "../../api/Client";
import { Outpost } from "../../api/Outposts";
import { TableColumn } from "../../elements/table/Table";
import { TablePage } from "../../elements/table/TablePage";
@ -25,7 +25,7 @@ export class OutpostListPage extends TablePage<Outpost> {
searchEnabled(): boolean {
return true;
}
apiEndpoint(page: number): Promise<PBResponse<Outpost>> {
apiEndpoint(page: number): Promise<AKResponse<Outpost>> {
return Outpost.list({
ordering: this.order,
page: page,

View File

@ -1,7 +1,7 @@
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { PropertyMapping } from "../../api/PropertyMapping";
import { PBResponse } from "../../api/Client";
import { AKResponse } from "../../api/Client";
import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
@ -30,7 +30,7 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
@property({type: Boolean})
hideManaged = false;
apiEndpoint(page: number): Promise<PBResponse<PropertyMapping>> {
apiEndpoint(page: number): Promise<AKResponse<PropertyMapping>> {
return PropertyMapping.list({
ordering: this.order,
page: page,

View File

@ -1,7 +1,7 @@
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { Provider } from "../../api/Providers";
import { PBResponse } from "../../api/Client";
import { AKResponse } from "../../api/Client";
import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
@ -27,7 +27,7 @@ export class ProviderListPage extends TablePage<Provider> {
@property()
order = "name";
apiEndpoint(page: number): Promise<PBResponse<Provider>> {
apiEndpoint(page: number): Promise<AKResponse<Provider>> {
return Provider.list({
ordering: this.order,
page: page,

View File

@ -4,6 +4,7 @@ import { COMMON_STYLES } from "../../common/styles";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
import "../../elements/buttons/ActionButton";
import "../../elements/CodeMirror";
import "../../elements/Tabs";
import { Page } from "../../elements/Page";
@ -112,7 +113,7 @@ export class LDAPSourceViewPage extends Page {
return gettext("Not synced in the last hour, check System tasks.");
}
const syncDate = new Date(ls.last_sync * 1000);
return gettext(`Last sync: ${syncDate.toLocaleString()}`)
return gettext(`Last sync: ${syncDate.toLocaleString()}`);
}), "loading")}
</p>
</div>

View File

@ -1,10 +1,13 @@
import { gettext } from "django";
import { customElement, html, LitElement, property, TemplateResult } from "lit-element";
import { DefaultClient, PBResponse } from "../../api/Client";
import { customElement, html, property, TemplateResult } from "lit-element";
import { AKResponse } from "../../api/Client";
import { Source } from "../../api/Sources";
import { TableColumn } from "../../elements/table/Table";
import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
@customElement("ak-source-list")
export class SourceListPage extends TablePage<Source> {
pageTitle(): string {
@ -23,7 +26,7 @@ export class SourceListPage extends TablePage<Source> {
@property()
order = "name";
apiEndpoint(page: number): Promise<PBResponse<Source>> {
apiEndpoint(page: number): Promise<AKResponse<Source>> {
return Source.list({
ordering: this.order,
page: page,