This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/web/src/pages/applications/ApplicationViewPage.ts

111 lines
4.1 KiB
TypeScript
Raw Normal View History

import { css, customElement, html, LitElement, property, TemplateResult } from "lit-element";
import { Application } from "../../api/application";
import { DefaultClient, PBResponse } from "../../api/client";
2020-12-01 08:15:41 +00:00
import { PolicyBinding } from "../../api/policy_binding";
import { COMMON_STYLES } from "../../common/styles";
import { Table } from "../../elements/table/Table";
@customElement("pb-bound-policies-list")
2020-12-01 08:15:41 +00:00
export class BoundPoliciesList extends Table<PolicyBinding> {
@property()
target?: string;
2020-12-01 08:15:41 +00:00
apiEndpoint(page: number): Promise<PBResponse<PolicyBinding>> {
return DefaultClient.fetch<PBResponse<PolicyBinding>>(["policies", "bindings"], {
target: this.target!,
ordering: "order",
page: page,
});
}
columns(): string[] {
return ["Policy", "Enabled", "Order", "Timeout", ""];
}
2020-12-01 08:15:41 +00:00
row(item: PolicyBinding): string[] {
return [
item.policy_obj.name,
2020-12-01 08:15:41 +00:00
item.enabled ? "Yes" : "No",
item.order.toString(),
item.timeout.toString(),
`
<pb-modal-button href="administration/policies/bindings/${item.pk}/update/">
<pb-spinner-button slot="trigger" class="pf-m-secondary">
Edit
</pb-spinner-button>
<div slot="modal"></div>
</pb-modal-button>
<pb-modal-button href="administration/policies/bindings/${item.pk}/delete/">
<pb-spinner-button slot="trigger" class="pf-m-danger">
Delete
</pb-spinner-button>
<div slot="modal"></div>
</pb-modal-button>
`,
];
}
}
@customElement("pb-application-view")
export class ApplicationViewPage extends LitElement {
@property()
set args(value: { [key: string]: string }) {
this.applicationSlug = value.slug;
}
@property()
set applicationSlug(value: string) {
Application.get(value).then((app) => (this.application = app));
}
@property()
application?: Application;
static get styles() {
return COMMON_STYLES.concat(
css`
img.pf-icon {
max-height: 24px;
}
`
);
}
2020-12-01 08:15:41 +00:00
render(): TemplateResult {
if (!this.application) {
return html``;
}
return html`<section class="pf-c-page__main-section pf-m-light">
<div class="pf-c-content">
<h1>
2020-11-26 22:35:59 +00:00
<img class="pf-icon" src="${this.application?.meta_icon || ""}" />
${this.application?.name}
</h1>
<p>${this.application?.meta_publisher}</p>
</div>
</section>
2020-11-26 22:35:59 +00:00
<pb-tabs>
2020-12-01 08:15:41 +00:00
<section slot="page-1" tab-title="Users" class="pf-c-page__main-section pf-m-no-padding-mobile">
<div class="pf-l-gallery pf-m-gutter">
2020-12-01 08:15:41 +00:00
<div class="pf-c-card pf-c-card-aggregate pf-l-gallery__item pf-m-4-col" style="grid-column-end: span 3;grid-row-end: span 2;">
<div class="pf-c-card__header">
<div class="pf-c-card__header-main">
2020-12-01 08:15:41 +00:00
<i class="pf-icon pf-icon-server"></i> Logins over the last 24 hours
</div>
</div>
<div class="pf-c-card__body">
2020-12-01 08:15:41 +00:00
${this.application ?
html`<pb-admin-logins-chart url="${DefaultClient.makeUrl(["core", "applications", this.application?.slug!, "metrics"])}"></pb-admin-logins-chart>` : ""}
</div>
</div>
</div>
2020-11-26 22:35:59 +00:00
</section>
2020-12-01 08:15:41 +00:00
<div slot="page-2" tab-title="Policy Bindings" class="pf-c-page__main-section pf-m-no-padding-mobile">
<div class="pf-c-card">
2020-12-01 08:15:41 +00:00
<pb-bound-policies-list .target=${this.application.pk}></pb-bound-policies-list>
</div>
</div>
2020-11-26 22:35:59 +00:00
</pb-tabs>`;
}
}