From 3b7bba5a6211c2fd1cb2c386df0e5562e6bdef63 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 16 Dec 2020 23:02:43 +0100 Subject: [PATCH] web: make sure naming matches backend --- .../api/{application.ts => Applications.ts} | 2 +- web/src/api/{errors.ts => Error.ts} | 0 web/src/api/{flow.ts => Flows.ts} | 2 +- web/src/api/Policies.ts | 24 +++++++++++++++++ web/src/api/{policy.ts => PolicyBindings.ts} | 26 ++----------------- web/src/api/{provider.ts => Providers.ts} | 2 +- web/src/api/{source.ts => Sources.ts} | 2 +- web/src/api/{token.ts => Tokens.ts} | 2 +- web/src/api/{user.ts => Users.ts} | 2 +- web/src/api/{version.ts => Versions.ts} | 2 +- web/src/api/client.ts | 2 +- web/src/api/config.ts | 2 +- web/src/api/events.ts | 2 +- web/src/elements/buttons/TokenCopyButton.ts | 2 +- web/src/elements/messages/MessageContainer.ts | 2 +- .../elements/policies/BoundPoliciesList.ts | 4 +-- web/src/elements/sidebar/SidebarBrand.ts | 2 +- web/src/elements/sidebar/SidebarUser.ts | 2 +- web/src/elements/table/Table.ts | 2 +- web/src/elements/table/TablePagination.ts | 2 +- web/src/interfaces/AdminInterface.ts | 2 +- web/src/pages/LibraryPage.ts | 4 +-- .../pages/admin-overview/AdminOverviewPage.ts | 4 +-- .../admin-overview/TopApplicationsTable.ts | 2 +- .../cards/FlowCacheStatusCard.ts | 2 +- .../cards/PolicyCacheStatusCard.ts | 2 +- .../cards/PolicyUnboundStatusCard.ts | 2 +- .../cards/ProviderStatusCard.ts | 2 +- .../admin-overview/cards/VersionStatusCard.ts | 2 +- .../admin-overview/cards/WorkerStatusCard.ts | 2 +- .../pages/applications/ApplicationListPage.ts | 4 +-- .../pages/applications/ApplicationViewPage.ts | 4 +-- web/src/pages/flows/BoundStagesList.ts | 4 +-- web/src/pages/flows/FlowViewPage.ts | 2 +- web/src/pages/sources/SourceViewPage.ts | 2 +- 35 files changed, 64 insertions(+), 62 deletions(-) rename web/src/api/{application.ts => Applications.ts} (90%) rename web/src/api/{errors.ts => Error.ts} (100%) rename web/src/api/{flow.ts => Flows.ts} (96%) create mode 100644 web/src/api/Policies.ts rename web/src/api/{policy.ts => PolicyBindings.ts} (50%) rename web/src/api/{provider.ts => Providers.ts} (87%) rename web/src/api/{source.ts => Sources.ts} (88%) rename web/src/api/{token.ts => Tokens.ts} (85%) rename web/src/api/{user.ts => Users.ts} (92%) rename web/src/api/{version.ts => Versions.ts} (88%) diff --git a/web/src/api/application.ts b/web/src/api/Applications.ts similarity index 90% rename from web/src/api/application.ts rename to web/src/api/Applications.ts index 005bed0d9..38379c605 100644 --- a/web/src/api/application.ts +++ b/web/src/api/Applications.ts @@ -1,4 +1,4 @@ -import { DefaultClient, PBResponse, QueryArguments } from "./client"; +import { DefaultClient, PBResponse, QueryArguments } from "./Client"; export class Application { pk: string; diff --git a/web/src/api/errors.ts b/web/src/api/Error.ts similarity index 100% rename from web/src/api/errors.ts rename to web/src/api/Error.ts diff --git a/web/src/api/flow.ts b/web/src/api/Flows.ts similarity index 96% rename from web/src/api/flow.ts rename to web/src/api/Flows.ts index 2a376fc07..c78df9d80 100644 --- a/web/src/api/flow.ts +++ b/web/src/api/Flows.ts @@ -1,4 +1,4 @@ -import { DefaultClient, PBResponse, QueryArguments } from "./client"; +import { DefaultClient, PBResponse, QueryArguments } from "./Client"; export enum FlowDesignation { Authentication = "authentication", diff --git a/web/src/api/Policies.ts b/web/src/api/Policies.ts new file mode 100644 index 000000000..1c3a26738 --- /dev/null +++ b/web/src/api/Policies.ts @@ -0,0 +1,24 @@ +import { DefaultClient, PBResponse, QueryArguments } from "./Client"; + +export class Policy { + pk: string; + name: string; + + constructor() { + throw Error(); + } + + static get(pk: string): Promise { + return DefaultClient.fetch(["policies", "all", pk]); + } + + static list(filter?: QueryArguments): Promise> { + return DefaultClient.fetch>(["policies", "all"], filter); + } + + static cached(): Promise { + return DefaultClient.fetch>(["policies", "cached"]).then(r => { + return r.pagination.count; + }); + } +} diff --git a/web/src/api/policy.ts b/web/src/api/PolicyBindings.ts similarity index 50% rename from web/src/api/policy.ts rename to web/src/api/PolicyBindings.ts index 16c7f7215..44a158019 100644 --- a/web/src/api/policy.ts +++ b/web/src/api/PolicyBindings.ts @@ -1,27 +1,5 @@ -import { DefaultClient, PBResponse, QueryArguments } from "./client"; - -export class Policy { - pk: string; - name: string; - - constructor() { - throw Error(); - } - - static get(pk: string): Promise { - return DefaultClient.fetch(["policies", "all", pk]); - } - - static list(filter?: QueryArguments): Promise> { - return DefaultClient.fetch>(["policies", "all"], filter); - } - - static cached(): Promise { - return DefaultClient.fetch>(["policies", "cached"]).then(r => { - return r.pagination.count; - }); - } -} +import { DefaultClient, PBResponse, QueryArguments } from "./Client"; +import { Policy } from "./Policies"; export class PolicyBinding { pk: string; diff --git a/web/src/api/provider.ts b/web/src/api/Providers.ts similarity index 87% rename from web/src/api/provider.ts rename to web/src/api/Providers.ts index b31d15459..e16b3b0b8 100644 --- a/web/src/api/provider.ts +++ b/web/src/api/Providers.ts @@ -1,4 +1,4 @@ -import { DefaultClient, PBResponse, QueryArguments } from "./client"; +import { DefaultClient, PBResponse, QueryArguments } from "./Client"; export class Provider { pk: number; diff --git a/web/src/api/source.ts b/web/src/api/Sources.ts similarity index 88% rename from web/src/api/source.ts rename to web/src/api/Sources.ts index c6d85b5fa..346ecf3c6 100644 --- a/web/src/api/source.ts +++ b/web/src/api/Sources.ts @@ -1,4 +1,4 @@ -import { DefaultClient, PBResponse, QueryArguments } from "./client"; +import { DefaultClient, PBResponse, QueryArguments } from "./Client"; export class Source { pk: string; diff --git a/web/src/api/token.ts b/web/src/api/Tokens.ts similarity index 85% rename from web/src/api/token.ts rename to web/src/api/Tokens.ts index 5b102f335..7a5e75d49 100644 --- a/web/src/api/token.ts +++ b/web/src/api/Tokens.ts @@ -1,4 +1,4 @@ -import { DefaultClient } from "./client"; +import { DefaultClient } from "./Client"; interface TokenResponse { key: string; diff --git a/web/src/api/user.ts b/web/src/api/Users.ts similarity index 92% rename from web/src/api/user.ts rename to web/src/api/Users.ts index d244327c5..46ab0e0c3 100644 --- a/web/src/api/user.ts +++ b/web/src/api/Users.ts @@ -1,4 +1,4 @@ -import { DefaultClient, PBResponse } from "./client"; +import { DefaultClient, PBResponse } from "./Client"; let _globalMePromise: Promise; diff --git a/web/src/api/version.ts b/web/src/api/Versions.ts similarity index 88% rename from web/src/api/version.ts rename to web/src/api/Versions.ts index f747bccb8..c5735a54a 100644 --- a/web/src/api/version.ts +++ b/web/src/api/Versions.ts @@ -1,4 +1,4 @@ -import { DefaultClient } from "./client"; +import { DefaultClient } from "./Client"; export class Version { diff --git a/web/src/api/client.ts b/web/src/api/client.ts index 8bb1f6092..8288867b3 100644 --- a/web/src/api/client.ts +++ b/web/src/api/client.ts @@ -1,4 +1,4 @@ -import { NotFoundError, RequestError } from "./errors"; +import { NotFoundError, RequestError } from "./Error"; export const VERSION = "v2beta"; diff --git a/web/src/api/config.ts b/web/src/api/config.ts index fa55b11d7..ab4ca0627 100644 --- a/web/src/api/config.ts +++ b/web/src/api/config.ts @@ -1,4 +1,4 @@ -import { DefaultClient } from "./client"; +import { DefaultClient } from "./Client"; import * as Sentry from "@sentry/browser"; import { Integrations } from "@sentry/tracing"; import { VERSION } from "../constants"; diff --git a/web/src/api/events.ts b/web/src/api/events.ts index 80ce3334f..9d2b2b961 100644 --- a/web/src/api/events.ts +++ b/web/src/api/events.ts @@ -1,4 +1,4 @@ -import { DefaultClient } from "./client"; +import { DefaultClient } from "./Client"; export class AuditEvent { //audit/events/top_per_user/?filter_action=authorize_application diff --git a/web/src/elements/buttons/TokenCopyButton.ts b/web/src/elements/buttons/TokenCopyButton.ts index fd87b8bf0..5b68818e0 100644 --- a/web/src/elements/buttons/TokenCopyButton.ts +++ b/web/src/elements/buttons/TokenCopyButton.ts @@ -3,7 +3,7 @@ import { css, CSSResult, customElement, html, LitElement, property, TemplateResu import GlobalsStyle from "@patternfly/patternfly/base/patternfly-globals.css"; // @ts-ignore import ButtonStyle from "@patternfly/patternfly/components/Button/button.css"; -import { tokenByIdentifier } from "../../api/token"; +import { tokenByIdentifier } from "../../api/Tokens"; import { ColorStyles, ERROR_CLASS, PRIMARY_CLASS, SUCCESS_CLASS } from "../../constants"; @customElement("ak-token-copy-button") diff --git a/web/src/elements/messages/MessageContainer.ts b/web/src/elements/messages/MessageContainer.ts index 9c0d2e681..4545a9f74 100644 --- a/web/src/elements/messages/MessageContainer.ts +++ b/web/src/elements/messages/MessageContainer.ts @@ -1,6 +1,6 @@ import { gettext } from "django"; import { LitElement, html, customElement, TemplateResult, property } from "lit-element"; -import { DefaultClient } from "../../api/client"; +import { DefaultClient } from "../../api/Client"; import "./Message"; import { APIMessage } from "./Message"; diff --git a/web/src/elements/policies/BoundPoliciesList.ts b/web/src/elements/policies/BoundPoliciesList.ts index ac3b73890..490d11065 100644 --- a/web/src/elements/policies/BoundPoliciesList.ts +++ b/web/src/elements/policies/BoundPoliciesList.ts @@ -1,8 +1,8 @@ import { gettext } from "django"; import { customElement, html, property, TemplateResult } from "lit-element"; -import { PBResponse } from "../../api/client"; -import { PolicyBinding } from "../../api/policy"; +import { PBResponse } from "../../api/Client"; import { Table } from "../../elements/table/Table"; +import { PolicyBinding } from "../../api/PolicyBindings"; import "../../elements/Tabs"; import "../../elements/AdminLoginsChart"; diff --git a/web/src/elements/sidebar/SidebarBrand.ts b/web/src/elements/sidebar/SidebarBrand.ts index 8b14057cb..e55e17edd 100644 --- a/web/src/elements/sidebar/SidebarBrand.ts +++ b/web/src/elements/sidebar/SidebarBrand.ts @@ -3,7 +3,7 @@ import { css, CSSResult, customElement, html, LitElement, property, TemplateResu import PageStyle from "@patternfly/patternfly/components/Page/page.css"; // @ts-ignore import GlobalsStyle from "@patternfly/patternfly/base/patternfly-globals.css"; -import { Config } from "../../api/config"; +import { Config } from "../../api/Config"; export const DefaultConfig: Config = { branding_logo: " /static/dist/assets/icons/icon_left_brand.svg", diff --git a/web/src/elements/sidebar/SidebarUser.ts b/web/src/elements/sidebar/SidebarUser.ts index 8985c6b4e..7cb9dee27 100644 --- a/web/src/elements/sidebar/SidebarUser.ts +++ b/web/src/elements/sidebar/SidebarUser.ts @@ -5,7 +5,7 @@ import NavStyle from "@patternfly/patternfly/components/Nav/nav.css"; import fa from "@fortawesome/fontawesome-free/css/all.css"; // @ts-ignore import AvatarStyle from "@patternfly/patternfly/components/Avatar/avatar.css"; -import { User } from "../../api/user"; +import { User } from "../../api/Users"; import { until } from "lit-html/directives/until"; @customElement("ak-sidebar-user") diff --git a/web/src/elements/table/Table.ts b/web/src/elements/table/Table.ts index 39a194e99..994453937 100644 --- a/web/src/elements/table/Table.ts +++ b/web/src/elements/table/Table.ts @@ -1,6 +1,6 @@ import { gettext } from "django"; import { CSSResult, html, LitElement, property, TemplateResult } from "lit-element"; -import { PBResponse } from "../../api/client"; +import { PBResponse } from "../../api/Client"; import { COMMON_STYLES } from "../../common/styles"; import "./TablePagination"; diff --git a/web/src/elements/table/TablePagination.ts b/web/src/elements/table/TablePagination.ts index bfad9d990..fa7f59802 100644 --- a/web/src/elements/table/TablePagination.ts +++ b/web/src/elements/table/TablePagination.ts @@ -1,6 +1,6 @@ import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; import { COMMON_STYLES } from "../../common/styles"; -import { PBPagination } from "../../api/client"; +import { PBPagination } from "../../api/Client"; @customElement("ak-table-pagination") export class TablePagination extends LitElement { diff --git a/web/src/interfaces/AdminInterface.ts b/web/src/interfaces/AdminInterface.ts index 79f4c3f3f..5614d7544 100644 --- a/web/src/interfaces/AdminInterface.ts +++ b/web/src/interfaces/AdminInterface.ts @@ -1,5 +1,5 @@ import { customElement } from "lit-element"; -import { User } from "../api/user"; +import { User } from "../api/Users"; import { SidebarItem } from "../elements/sidebar/Sidebar"; import { SLUG_REGEX } from "../elements/router/Route"; import { Interface } from "./Interface"; diff --git a/web/src/pages/LibraryPage.ts b/web/src/pages/LibraryPage.ts index 973eff30f..ecc7d3bc7 100644 --- a/web/src/pages/LibraryPage.ts +++ b/web/src/pages/LibraryPage.ts @@ -1,8 +1,8 @@ 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/application"; -import { PBResponse } from "../api/client"; +import { Application } from "../api/Applications"; +import { PBResponse } from "../api/Client"; import { COMMON_STYLES } from "../common/styles"; import { loading, truncate } from "../utils"; diff --git a/web/src/pages/admin-overview/AdminOverviewPage.ts b/web/src/pages/admin-overview/AdminOverviewPage.ts index 3825738ae..d49fa601b 100644 --- a/web/src/pages/admin-overview/AdminOverviewPage.ts +++ b/web/src/pages/admin-overview/AdminOverviewPage.ts @@ -1,7 +1,7 @@ import { gettext } from "django"; import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; -import { DefaultClient } from "../../api/client"; -import { User } from "../../api/user"; +import { DefaultClient } from "../../api/Client"; +import { User } from "../../api/Users"; import { COMMON_STYLES } from "../../common/styles"; import "../../elements/AdminLoginsChart"; diff --git a/web/src/pages/admin-overview/TopApplicationsTable.ts b/web/src/pages/admin-overview/TopApplicationsTable.ts index dc1f17dfa..fa91fc27a 100644 --- a/web/src/pages/admin-overview/TopApplicationsTable.ts +++ b/web/src/pages/admin-overview/TopApplicationsTable.ts @@ -1,6 +1,6 @@ import { gettext } from "django"; import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; -import { AuditEvent, TopNEvent } from "../../api/events"; +import { AuditEvent, TopNEvent } from "../../api/Events"; import { COMMON_STYLES } from "../../common/styles"; import "../../elements/Spinner"; diff --git a/web/src/pages/admin-overview/cards/FlowCacheStatusCard.ts b/web/src/pages/admin-overview/cards/FlowCacheStatusCard.ts index 1b34310c2..ebc5134ae 100644 --- a/web/src/pages/admin-overview/cards/FlowCacheStatusCard.ts +++ b/web/src/pages/admin-overview/cards/FlowCacheStatusCard.ts @@ -1,6 +1,6 @@ import { gettext } from "django"; import { customElement, html, TemplateResult } from "lit-element"; -import { Flow } from "../../../api/flow"; +import { Flow } from "../../../api/Flows"; import { AdminStatus, AdminStatusCard } from "./AdminStatusCard"; import "../../../elements/buttons/ModalButton"; diff --git a/web/src/pages/admin-overview/cards/PolicyCacheStatusCard.ts b/web/src/pages/admin-overview/cards/PolicyCacheStatusCard.ts index 85920a551..e91a4ddc8 100644 --- a/web/src/pages/admin-overview/cards/PolicyCacheStatusCard.ts +++ b/web/src/pages/admin-overview/cards/PolicyCacheStatusCard.ts @@ -1,7 +1,7 @@ import { gettext } from "django"; import { customElement } from "lit-element"; import { TemplateResult, html } from "lit-html"; -import { Policy } from "../../../api/policy"; +import { Policy } from "../../../api/Policies"; import { AdminStatusCard, AdminStatus } from "./AdminStatusCard"; import "../../../elements/buttons/ModalButton"; diff --git a/web/src/pages/admin-overview/cards/PolicyUnboundStatusCard.ts b/web/src/pages/admin-overview/cards/PolicyUnboundStatusCard.ts index 37a74a598..d5b11e9ee 100644 --- a/web/src/pages/admin-overview/cards/PolicyUnboundStatusCard.ts +++ b/web/src/pages/admin-overview/cards/PolicyUnboundStatusCard.ts @@ -1,6 +1,6 @@ import { gettext } from "django"; import { customElement } from "lit-element"; -import { Policy } from "../../../api/policy"; +import { Policy } from "../../../api/Policies"; import { AdminStatusCard, AdminStatus } from "./AdminStatusCard"; @customElement("ak-admin-status-card-policy-unbound") diff --git a/web/src/pages/admin-overview/cards/ProviderStatusCard.ts b/web/src/pages/admin-overview/cards/ProviderStatusCard.ts index b19404dd6..26b4f734e 100644 --- a/web/src/pages/admin-overview/cards/ProviderStatusCard.ts +++ b/web/src/pages/admin-overview/cards/ProviderStatusCard.ts @@ -1,6 +1,6 @@ import { gettext } from "django"; import { customElement } from "lit-element"; -import { Provider } from "../../../api/provider"; +import { Provider } from "../../../api/Providers"; import { AdminStatusCard, AdminStatus } from "./AdminStatusCard"; @customElement("ak-admin-status-card-provider") diff --git a/web/src/pages/admin-overview/cards/VersionStatusCard.ts b/web/src/pages/admin-overview/cards/VersionStatusCard.ts index a61e6abd9..458d23ec3 100644 --- a/web/src/pages/admin-overview/cards/VersionStatusCard.ts +++ b/web/src/pages/admin-overview/cards/VersionStatusCard.ts @@ -1,6 +1,6 @@ import { gettext } from "django"; import { customElement } from "lit-element"; -import { Version } from "../../../api/version"; +import { Version } from "../../../api/Versions"; import { AdminStatusCard, AdminStatus } from "./AdminStatusCard"; @customElement("ak-admin-status-version") diff --git a/web/src/pages/admin-overview/cards/WorkerStatusCard.ts b/web/src/pages/admin-overview/cards/WorkerStatusCard.ts index fab55d433..a335cee87 100644 --- a/web/src/pages/admin-overview/cards/WorkerStatusCard.ts +++ b/web/src/pages/admin-overview/cards/WorkerStatusCard.ts @@ -1,6 +1,6 @@ import { gettext } from "django"; import { customElement } from "lit-element"; -import { DefaultClient, PBResponse } from "../../../api/client"; +import { DefaultClient, PBResponse } from "../../../api/Client"; import { AdminStatus, AdminStatusCard } from "./AdminStatusCard"; @customElement("ak-admin-status-card-workers") diff --git a/web/src/pages/applications/ApplicationListPage.ts b/web/src/pages/applications/ApplicationListPage.ts index 5ab0e17e5..e0c3c1a51 100644 --- a/web/src/pages/applications/ApplicationListPage.ts +++ b/web/src/pages/applications/ApplicationListPage.ts @@ -1,7 +1,7 @@ import { gettext } from "django"; import { customElement, html, TemplateResult } from "lit-element"; -import { Application } from "../../api/application"; -import { PBResponse } from "../../api/client"; +import { Application } from "../../api/Applications"; +import { PBResponse } from "../../api/Client"; import { TablePage } from "../../elements/table/TablePage"; import "../../elements/buttons/ModalButton"; diff --git a/web/src/pages/applications/ApplicationViewPage.ts b/web/src/pages/applications/ApplicationViewPage.ts index dd0be9255..f461e5b38 100644 --- a/web/src/pages/applications/ApplicationViewPage.ts +++ b/web/src/pages/applications/ApplicationViewPage.ts @@ -1,7 +1,7 @@ import { gettext } from "django"; import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; -import { Application } from "../../api/application"; -import { DefaultClient } from "../../api/client"; +import { Application } from "../../api/Applications"; +import { DefaultClient } from "../../api/Client"; import { COMMON_STYLES } from "../../common/styles"; import "../../elements/Tabs"; diff --git a/web/src/pages/flows/BoundStagesList.ts b/web/src/pages/flows/BoundStagesList.ts index d5e73148f..d1c0717e0 100644 --- a/web/src/pages/flows/BoundStagesList.ts +++ b/web/src/pages/flows/BoundStagesList.ts @@ -1,6 +1,6 @@ import { gettext } from "django"; import { customElement, html, property, TemplateResult } from "lit-element"; -import { PBResponse } from "../../api/client"; +import { PBResponse } from "../../api/Client"; import { Table } from "../../elements/table/Table"; import "../../elements/Tabs"; @@ -8,7 +8,7 @@ import "../../elements/AdminLoginsChart"; import "../../elements/buttons/ModalButton"; import "../../elements/buttons/SpinnerButton"; import "../../elements/policies/BoundPoliciesList"; -import { FlowStageBinding } from "../../api/flow"; +import { FlowStageBinding } from "../../api/Flows"; @customElement("ak-bound-stages-list") export class BoundStagesList extends Table { diff --git a/web/src/pages/flows/FlowViewPage.ts b/web/src/pages/flows/FlowViewPage.ts index dd7df45f9..df4b1e048 100644 --- a/web/src/pages/flows/FlowViewPage.ts +++ b/web/src/pages/flows/FlowViewPage.ts @@ -1,7 +1,7 @@ import { gettext } from "django"; import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; import { COMMON_STYLES } from "../../common/styles"; -import { Flow } from "../../api/flow"; +import { Flow } from "../../api/Flows"; import "../../elements/Tabs"; import "../../elements/AdminLoginsChart"; diff --git a/web/src/pages/sources/SourceViewPage.ts b/web/src/pages/sources/SourceViewPage.ts index 89fde1e08..2b5aa1f68 100644 --- a/web/src/pages/sources/SourceViewPage.ts +++ b/web/src/pages/sources/SourceViewPage.ts @@ -7,7 +7,7 @@ import "../../elements/AdminLoginsChart"; import "../../elements/buttons/ModalButton"; import "../../elements/buttons/SpinnerButton"; import "../../elements/policies/BoundPoliciesList"; -import { Source } from "../../api/source"; +import { Source } from "../../api/Sources"; @customElement("ak-source-view") export class SourceViewPage extends LitElement {