2021-02-04 08:54:00 +00:00
|
|
|
import { gettext } from "django";
|
|
|
|
import { customElement, html, property, TemplateResult } from "lit-element";
|
|
|
|
import { Provider } from "../../api/Providers";
|
2021-02-09 16:04:55 +00:00
|
|
|
import { AKResponse } from "../../api/Client";
|
2021-02-04 08:54:00 +00:00
|
|
|
import { TablePage } from "../../elements/table/TablePage";
|
|
|
|
|
|
|
|
import "../../elements/buttons/ModalButton";
|
|
|
|
import "../../elements/buttons/SpinnerButton";
|
2021-02-04 09:22:14 +00:00
|
|
|
import "../../elements/buttons/Dropdown";
|
2021-02-04 08:54:00 +00:00
|
|
|
import { TableColumn } from "../../elements/table/Table";
|
2021-02-10 19:11:54 +00:00
|
|
|
import { until } from "lit-html/directives/until";
|
2021-03-02 14:12:26 +00:00
|
|
|
import { PAGE_SIZE } from "../../constants";
|
2021-02-04 08:54:00 +00:00
|
|
|
|
|
|
|
@customElement("ak-provider-list")
|
|
|
|
export class ProviderListPage extends TablePage<Provider> {
|
|
|
|
searchEnabled(): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
pageTitle(): string {
|
|
|
|
return gettext("Provider");
|
|
|
|
}
|
|
|
|
pageDescription(): string {
|
|
|
|
return gettext("Provide support for protocols like SAML and OAuth to assigned applications.");
|
|
|
|
}
|
|
|
|
pageIcon(): string {
|
|
|
|
return gettext("pf-icon pf-icon-integration");
|
|
|
|
}
|
|
|
|
|
|
|
|
@property()
|
|
|
|
order = "name";
|
|
|
|
|
2021-02-09 16:04:55 +00:00
|
|
|
apiEndpoint(page: number): Promise<AKResponse<Provider>> {
|
2021-02-04 08:54:00 +00:00
|
|
|
return Provider.list({
|
|
|
|
ordering: this.order,
|
|
|
|
page: page,
|
2021-03-02 14:12:26 +00:00
|
|
|
page_size: PAGE_SIZE,
|
2021-02-04 08:54:00 +00:00
|
|
|
search: this.search || "",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
columns(): TableColumn[] {
|
|
|
|
return [
|
|
|
|
new TableColumn("Name", "name"),
|
|
|
|
new TableColumn("Application"),
|
|
|
|
new TableColumn("Type", "type"),
|
|
|
|
new TableColumn(""),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
row(item: Provider): TemplateResult[] {
|
|
|
|
return [
|
2021-02-19 18:29:17 +00:00
|
|
|
html`<a href="#/core/providers/${item.pk}">
|
2021-02-04 08:54:00 +00:00
|
|
|
${item.name}
|
|
|
|
</a>`,
|
|
|
|
item.assigned_application_name ?
|
|
|
|
html`<i class="pf-icon pf-icon-ok"></i>
|
|
|
|
${gettext("Assigned to application ")}
|
2021-02-19 18:29:17 +00:00
|
|
|
<a href="#/core/applications/${item.assigned_application_slug}">${item.assigned_application_name}</a>` :
|
2021-02-04 08:54:00 +00:00
|
|
|
html`<i class="pf-icon pf-icon-warning-triangle"></i>
|
|
|
|
${gettext("Warning: Provider not assigned to any application.")}`,
|
|
|
|
html`${item.verbose_name}`,
|
|
|
|
html`
|
|
|
|
<ak-modal-button href="${Provider.adminUrl(`${item.pk}/update/`)}">
|
|
|
|
<ak-spinner-button slot="trigger" class="pf-m-secondary">
|
2021-02-04 09:22:14 +00:00
|
|
|
${gettext("Edit")}
|
2021-02-04 08:54:00 +00:00
|
|
|
</ak-spinner-button>
|
|
|
|
<div slot="modal"></div>
|
2021-02-17 19:49:58 +00:00
|
|
|
</ak-modal-button>
|
2021-02-04 08:54:00 +00:00
|
|
|
<ak-modal-button href="${Provider.adminUrl(`${item.pk}/delete/`)}">
|
|
|
|
<ak-spinner-button slot="trigger" class="pf-m-danger">
|
2021-02-04 09:22:14 +00:00
|
|
|
${gettext("Delete")}
|
2021-02-04 08:54:00 +00:00
|
|
|
</ak-spinner-button>
|
|
|
|
<div slot="modal"></div>
|
|
|
|
</ak-modal-button>
|
|
|
|
`,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
renderToolbar(): TemplateResult {
|
|
|
|
return html`
|
|
|
|
<ak-dropdown class="pf-c-dropdown">
|
|
|
|
<button class="pf-m-primary pf-c-dropdown__toggle" type="button">
|
|
|
|
<span class="pf-c-dropdown__toggle-text">${gettext("Create")}</span>
|
|
|
|
<i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i>
|
|
|
|
</button>
|
|
|
|
<ul class="pf-c-dropdown__menu" hidden>
|
2021-02-10 19:11:54 +00:00
|
|
|
${until(Provider.getTypes().then((types) => {
|
|
|
|
return types.map((type) => {
|
|
|
|
return html`<li>
|
|
|
|
<ak-modal-button href="${type.link}">
|
|
|
|
<button slot="trigger" class="pf-c-dropdown__menu-item">${type.name}<br>
|
|
|
|
<small>${type.description}</small>
|
|
|
|
</button>
|
|
|
|
<div slot="modal"></div>
|
|
|
|
</ak-modal-button>
|
|
|
|
</li>`;
|
2021-02-10 19:12:15 +00:00
|
|
|
});
|
2021-02-10 19:11:54 +00:00
|
|
|
}), html`<ak-spinner></ak-spinner>`)}
|
2021-02-04 08:54:00 +00:00
|
|
|
</ul>
|
|
|
|
</ak-dropdown>
|
|
|
|
${super.renderToolbar()}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|