2020-12-01 12:59:59 +00:00
|
|
|
import { gettext } from "django";
|
2020-12-01 16:27:19 +00:00
|
|
|
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
2020-11-26 14:55:01 +00:00
|
|
|
import { Application } from "../../api/application";
|
2020-11-29 11:01:06 +00:00
|
|
|
import { DefaultClient, PBResponse } from "../../api/client";
|
2020-12-01 08:15:41 +00:00
|
|
|
import { PolicyBinding } from "../../api/policy_binding";
|
2020-11-26 14:55:01 +00:00
|
|
|
import { COMMON_STYLES } from "../../common/styles";
|
2020-11-29 21:14:48 +00:00
|
|
|
import { Table } from "../../elements/table/Table";
|
2020-11-27 17:37:56 +00:00
|
|
|
|
2020-12-02 14:44:40 +00:00
|
|
|
import "../../elements/Tabs";
|
|
|
|
import "../../elements/AdminLoginsChart";
|
|
|
|
|
2020-11-27 17:37:56 +00:00
|
|
|
@customElement("pb-bound-policies-list")
|
2020-12-01 08:15:41 +00:00
|
|
|
export class BoundPoliciesList extends Table<PolicyBinding> {
|
2020-11-27 17:37:56 +00:00
|
|
|
@property()
|
|
|
|
target?: string;
|
|
|
|
|
2020-12-01 08:15:41 +00:00
|
|
|
apiEndpoint(page: number): Promise<PBResponse<PolicyBinding>> {
|
|
|
|
return DefaultClient.fetch<PBResponse<PolicyBinding>>(["policies", "bindings"], {
|
2020-12-01 16:27:19 +00:00
|
|
|
target: this.target || "",
|
2020-11-29 11:01:06 +00:00
|
|
|
ordering: "order",
|
2020-11-29 21:14:48 +00:00
|
|
|
page: page,
|
2020-11-29 11:01:06 +00:00
|
|
|
});
|
2020-11-27 17:37:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
columns(): string[] {
|
2020-11-29 11:01:06 +00:00
|
|
|
return ["Policy", "Enabled", "Order", "Timeout", ""];
|
2020-11-27 17:37:56 +00:00
|
|
|
}
|
|
|
|
|
2020-12-01 08:15:41 +00:00
|
|
|
row(item: PolicyBinding): string[] {
|
2020-11-29 11:01:06 +00:00
|
|
|
return [
|
2020-11-29 17:10:12 +00:00
|
|
|
item.policy_obj.name,
|
2020-12-01 08:15:41 +00:00
|
|
|
item.enabled ? "Yes" : "No",
|
|
|
|
item.order.toString(),
|
|
|
|
item.timeout.toString(),
|
2020-11-29 11:01:06 +00:00
|
|
|
`
|
2020-11-29 17:10:12 +00:00
|
|
|
<pb-modal-button href="administration/policies/bindings/${item.pk}/update/">
|
|
|
|
<pb-spinner-button slot="trigger" class="pf-m-secondary">
|
2020-11-29 11:01:06 +00:00
|
|
|
Edit
|
2020-11-29 17:10:12 +00:00
|
|
|
</pb-spinner-button>
|
2020-11-29 11:01:06 +00:00
|
|
|
<div slot="modal"></div>
|
|
|
|
</pb-modal-button>
|
2020-11-29 17:10:12 +00:00
|
|
|
<pb-modal-button href="administration/policies/bindings/${item.pk}/delete/">
|
|
|
|
<pb-spinner-button slot="trigger" class="pf-m-danger">
|
2020-11-29 11:01:06 +00:00
|
|
|
Delete
|
2020-11-29 17:10:12 +00:00
|
|
|
</pb-spinner-button>
|
2020-11-29 11:01:06 +00:00
|
|
|
<div slot="modal"></div>
|
|
|
|
</pb-modal-button>
|
2020-11-29 17:10:12 +00:00
|
|
|
`,
|
2020-11-29 11:01:06 +00:00
|
|
|
];
|
2020-11-27 17:37:56 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-26 14:55:01 +00:00
|
|
|
|
|
|
|
@customElement("pb-application-view")
|
|
|
|
export class ApplicationViewPage extends LitElement {
|
|
|
|
@property()
|
2020-11-26 14:58:05 +00:00
|
|
|
set args(value: { [key: string]: string }) {
|
2020-11-26 14:55:01 +00:00
|
|
|
this.applicationSlug = value.slug;
|
|
|
|
}
|
|
|
|
|
|
|
|
@property()
|
|
|
|
set applicationSlug(value: string) {
|
2020-11-26 14:58:05 +00:00
|
|
|
Application.get(value).then((app) => (this.application = app));
|
2020-11-26 14:55:01 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 14:44:40 +00:00
|
|
|
@property({attribute: false})
|
2020-11-26 14:55:01 +00:00
|
|
|
application?: Application;
|
|
|
|
|
2020-12-01 16:27:19 +00:00
|
|
|
static get styles(): CSSResult[] {
|
2020-11-26 22:31:56 +00:00
|
|
|
return COMMON_STYLES.concat(
|
|
|
|
css`
|
|
|
|
img.pf-icon {
|
|
|
|
max-height: 24px;
|
|
|
|
}
|
|
|
|
`
|
|
|
|
);
|
2020-11-26 14:55:01 +00:00
|
|
|
}
|
|
|
|
|
2020-12-01 08:15:41 +00:00
|
|
|
render(): TemplateResult {
|
2020-11-27 17:37:56 +00:00
|
|
|
if (!this.application) {
|
|
|
|
return html``;
|
|
|
|
}
|
2020-11-26 14:55:01 +00:00
|
|
|
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 || ""}" />
|
2020-11-26 14:55:01 +00:00
|
|
|
${this.application?.name}
|
|
|
|
</h1>
|
2020-11-26 22:31:56 +00:00
|
|
|
<p>${this.application?.meta_publisher}</p>
|
2020-11-26 14:55:01 +00:00
|
|
|
</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">
|
2020-11-27 17:37:56 +00:00
|
|
|
<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;">
|
2020-11-27 17:37:56 +00:00
|
|
|
<div class="pf-c-card__header">
|
|
|
|
<div class="pf-c-card__header-main">
|
2020-12-01 12:59:59 +00:00
|
|
|
<i class="pf-icon pf-icon-server"></i> ${gettext("Logins over the last 24 hours")}
|
2020-11-27 17:37:56 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-card__body">
|
2020-12-01 16:27:19 +00:00
|
|
|
${this.application ? html`
|
2020-12-01 12:59:59 +00:00
|
|
|
<pb-admin-logins-chart
|
|
|
|
url="${DefaultClient.makeUrl(["core", "applications", this.application?.slug, "metrics"])}">
|
2020-12-01 16:27:19 +00:00
|
|
|
</pb-admin-logins-chart>`: ""}
|
2020-11-27 17:37:56 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-26 14:55:01 +00:00
|
|
|
</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">
|
2020-11-29 11:01:06 +00:00
|
|
|
<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>
|
2020-11-27 17:37:56 +00:00
|
|
|
</div>
|
2020-11-26 14:55:01 +00:00
|
|
|
</div>
|
2020-11-26 22:35:59 +00:00
|
|
|
</pb-tabs>`;
|
2020-11-26 14:55:01 +00:00
|
|
|
}
|
|
|
|
}
|