2022-06-25 15:44:17 +00:00
|
|
|
import { DEFAULT_CONFIG } from "@goauthentik/web/api/Config";
|
|
|
|
import { me } from "@goauthentik/web/api/Users";
|
|
|
|
import { WebsocketClient } from "@goauthentik/web/common/ws";
|
|
|
|
import {
|
|
|
|
EVENT_API_DRAWER_TOGGLE,
|
|
|
|
EVENT_NOTIFICATION_DRAWER_TOGGLE,
|
|
|
|
EVENT_SIDEBAR_TOGGLE,
|
|
|
|
VERSION,
|
|
|
|
} from "@goauthentik/web/constants";
|
|
|
|
import "@goauthentik/web/elements/messages/MessageContainer";
|
|
|
|
import "@goauthentik/web/elements/messages/MessageContainer";
|
|
|
|
import "@goauthentik/web/elements/notifications/NotificationDrawer";
|
|
|
|
import { ID_REGEX, SLUG_REGEX, UUID_REGEX } from "@goauthentik/web/elements/router/Route";
|
|
|
|
import { getURLParam, updateURLParams } from "@goauthentik/web/elements/router/RouteMatch";
|
|
|
|
import "@goauthentik/web/elements/router/RouterOutlet";
|
|
|
|
import "@goauthentik/web/elements/sidebar/Sidebar";
|
|
|
|
import "@goauthentik/web/elements/sidebar/SidebarItem";
|
|
|
|
import "@goauthentik/web/interfaces/locale";
|
|
|
|
import { ROUTES } from "@goauthentik/web/routesAdmin";
|
|
|
|
|
2021-09-21 09:31:37 +00:00
|
|
|
import { t } from "@lingui/macro";
|
|
|
|
|
2021-10-28 07:48:51 +00:00
|
|
|
import { CSSResult, LitElement, TemplateResult, css, html } from "lit";
|
2021-11-04 21:34:48 +00:00
|
|
|
import { customElement, property } from "lit/decorators.js";
|
|
|
|
import { until } from "lit/directives/until.js";
|
2021-09-21 09:31:37 +00:00
|
|
|
|
2022-06-25 15:44:17 +00:00
|
|
|
import AKGlobal from "@goauthentik/web/authentik.css";
|
2021-06-13 17:54:27 +00:00
|
|
|
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
|
|
|
import PFDrawer from "@patternfly/patternfly/components/Drawer/drawer.css";
|
2021-09-21 09:31:37 +00:00
|
|
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
|
|
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
2021-06-13 17:54:27 +00:00
|
|
|
|
2021-09-21 09:31:37 +00:00
|
|
|
import { AdminApi, Version } from "@goauthentik/api";
|
|
|
|
|
2020-12-05 21:08:42 +00:00
|
|
|
@customElement("ak-interface-admin")
|
2021-06-13 17:54:27 +00:00
|
|
|
export class AdminInterface extends LitElement {
|
2021-08-03 15:52:21 +00:00
|
|
|
@property({ type: Boolean })
|
2021-06-13 17:54:27 +00:00
|
|
|
sidebarOpen = true;
|
|
|
|
|
2021-08-03 15:52:21 +00:00
|
|
|
@property({ type: Boolean })
|
2021-11-18 20:40:34 +00:00
|
|
|
notificationDrawerOpen = getURLParam("notificationDrawerOpen", false);
|
2021-06-13 17:54:27 +00:00
|
|
|
|
2021-08-05 20:04:31 +00:00
|
|
|
@property({ type: Boolean })
|
2021-11-18 20:40:34 +00:00
|
|
|
apiDrawerOpen = getURLParam("apiDrawerOpen", false);
|
2021-08-05 20:04:31 +00:00
|
|
|
|
2021-07-22 11:47:27 +00:00
|
|
|
ws: WebsocketClient;
|
|
|
|
|
2021-08-11 14:46:23 +00:00
|
|
|
private version: Promise<Version>;
|
|
|
|
|
2021-06-13 17:54:27 +00:00
|
|
|
static get styles(): CSSResult[] {
|
2021-08-03 15:52:21 +00:00
|
|
|
return [
|
|
|
|
PFBase,
|
|
|
|
PFPage,
|
|
|
|
PFButton,
|
|
|
|
PFDrawer,
|
|
|
|
AKGlobal,
|
|
|
|
css`
|
|
|
|
.pf-c-page__main,
|
|
|
|
.pf-c-drawer__content,
|
|
|
|
.pf-c-page__drawer {
|
|
|
|
z-index: auto !important;
|
2021-09-20 10:29:32 +00:00
|
|
|
background-color: transparent;
|
2021-08-03 15:52:21 +00:00
|
|
|
}
|
2021-08-08 13:17:06 +00:00
|
|
|
.display-none {
|
|
|
|
display: none;
|
|
|
|
}
|
2021-09-20 10:29:32 +00:00
|
|
|
.pf-c-page {
|
2021-09-20 17:38:25 +00:00
|
|
|
background-color: var(--pf-c-page--BackgroundColor) !important;
|
2021-09-20 10:29:32 +00:00
|
|
|
}
|
|
|
|
@media (prefers-color-scheme: dark) {
|
|
|
|
/* Global page background colour */
|
|
|
|
.pf-c-page {
|
|
|
|
--pf-c-page--BackgroundColor: var(--ak-dark-background);
|
|
|
|
}
|
|
|
|
}
|
2021-08-03 15:52:21 +00:00
|
|
|
`,
|
|
|
|
];
|
2021-06-13 17:54:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
2021-07-22 11:47:27 +00:00
|
|
|
this.ws = new WebsocketClient();
|
2021-06-13 17:54:27 +00:00
|
|
|
this.sidebarOpen = window.innerWidth >= 1280;
|
|
|
|
window.addEventListener("resize", () => {
|
|
|
|
this.sidebarOpen = window.innerWidth >= 1280;
|
|
|
|
});
|
|
|
|
window.addEventListener(EVENT_SIDEBAR_TOGGLE, () => {
|
|
|
|
this.sidebarOpen = !this.sidebarOpen;
|
|
|
|
});
|
2021-08-05 20:04:31 +00:00
|
|
|
window.addEventListener(EVENT_NOTIFICATION_DRAWER_TOGGLE, () => {
|
2021-11-18 20:40:34 +00:00
|
|
|
this.notificationDrawerOpen = !this.notificationDrawerOpen;
|
|
|
|
updateURLParams({
|
|
|
|
notificationDrawerOpen: this.notificationDrawerOpen,
|
|
|
|
});
|
2021-06-13 17:54:27 +00:00
|
|
|
});
|
2021-08-05 20:04:31 +00:00
|
|
|
window.addEventListener(EVENT_API_DRAWER_TOGGLE, () => {
|
|
|
|
this.apiDrawerOpen = !this.apiDrawerOpen;
|
2021-11-18 20:40:34 +00:00
|
|
|
updateURLParams({
|
|
|
|
apiDrawerOpen: this.apiDrawerOpen,
|
|
|
|
});
|
2021-08-05 20:04:31 +00:00
|
|
|
});
|
2021-08-11 14:46:23 +00:00
|
|
|
this.version = new AdminApi(DEFAULT_CONFIG).adminVersionRetrieve();
|
2022-06-30 20:37:29 +00:00
|
|
|
me().then((u) => {
|
|
|
|
if (!u.user.isSuperuser && u.user.pk > 0) {
|
|
|
|
window.location.assign("/if/user");
|
|
|
|
}
|
|
|
|
});
|
2021-06-13 17:54:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render(): TemplateResult {
|
2021-08-03 15:52:21 +00:00
|
|
|
return html` <div class="pf-c-page">
|
|
|
|
<ak-sidebar
|
|
|
|
class="pf-c-page__sidebar ${this.sidebarOpen ? "pf-m-expanded" : "pf-m-collapsed"}"
|
|
|
|
>
|
|
|
|
${this.renderSidebarItems()}
|
|
|
|
</ak-sidebar>
|
|
|
|
<div class="pf-c-page__drawer">
|
|
|
|
<div
|
2021-11-18 20:40:34 +00:00
|
|
|
class="pf-c-drawer ${this.notificationDrawerOpen || this.apiDrawerOpen
|
2021-08-03 15:52:21 +00:00
|
|
|
? "pf-m-expanded"
|
|
|
|
: "pf-m-collapsed"}"
|
|
|
|
>
|
|
|
|
<div class="pf-c-drawer__main">
|
|
|
|
<div class="pf-c-drawer__content">
|
|
|
|
<div class="pf-c-drawer__body">
|
|
|
|
<main class="pf-c-page__main">
|
|
|
|
<ak-router-outlet
|
|
|
|
role="main"
|
|
|
|
class="pf-c-page__main"
|
|
|
|
tabindex="-1"
|
|
|
|
id="main-content"
|
2021-09-16 15:30:16 +00:00
|
|
|
defaultUrl="/administration/overview"
|
|
|
|
.routes=${ROUTES}
|
2021-08-03 15:52:21 +00:00
|
|
|
>
|
|
|
|
</ak-router-outlet>
|
|
|
|
</main>
|
2021-06-13 17:54:27 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-08 13:17:06 +00:00
|
|
|
<ak-notification-drawer
|
2021-11-18 20:40:34 +00:00
|
|
|
class="pf-c-drawer__panel pf-m-width-33 ${this.notificationDrawerOpen
|
2021-08-10 20:50:03 +00:00
|
|
|
? ""
|
|
|
|
: "display-none"}"
|
2021-11-18 20:40:34 +00:00
|
|
|
?hidden=${!this.notificationDrawerOpen}
|
2021-08-08 13:17:06 +00:00
|
|
|
></ak-notification-drawer>
|
|
|
|
<ak-api-drawer
|
|
|
|
class="pf-c-drawer__panel pf-m-width-33 ${this.apiDrawerOpen
|
2021-08-10 20:50:03 +00:00
|
|
|
? ""
|
|
|
|
: "display-none"}"
|
|
|
|
?hidden=${!this.apiDrawerOpen}
|
2021-08-08 13:17:06 +00:00
|
|
|
></ak-api-drawer>
|
2021-06-13 17:54:27 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
</div>
|
|
|
|
</div>`;
|
2021-06-13 17:54:27 +00:00
|
|
|
}
|
2020-12-02 12:56:26 +00:00
|
|
|
|
2021-05-05 17:14:37 +00:00
|
|
|
renderSidebarItems(): TemplateResult {
|
|
|
|
return html`
|
2021-08-03 15:52:21 +00:00
|
|
|
${until(
|
2021-08-11 14:46:23 +00:00
|
|
|
this.version.then((version) => {
|
2021-08-03 15:52:21 +00:00
|
|
|
if (version.versionCurrent !== VERSION) {
|
|
|
|
return html`<ak-sidebar-item ?highlight=${true}>
|
|
|
|
<span slot="label"
|
|
|
|
>${t`A newer version of the frontend is available.`}</span
|
|
|
|
>
|
|
|
|
</ak-sidebar-item>`;
|
|
|
|
}
|
|
|
|
return html``;
|
|
|
|
}),
|
|
|
|
)}
|
|
|
|
${until(
|
|
|
|
me().then((u) => {
|
|
|
|
if (u.original) {
|
|
|
|
return html`<ak-sidebar-item
|
|
|
|
?highlight=${true}
|
|
|
|
?isAbsoluteLink=${true}
|
2021-11-18 20:33:49 +00:00
|
|
|
path=${`/-/impersonation/end/?back=${encodeURIComponent(
|
|
|
|
`${window.location.pathname}#${window.location.hash}`,
|
|
|
|
)}`}
|
2021-08-03 15:52:21 +00:00
|
|
|
>
|
|
|
|
<span slot="label"
|
|
|
|
>${t`You're currently impersonating ${u.user.username}. Click to stop.`}</span
|
|
|
|
>
|
|
|
|
</ak-sidebar-item>`;
|
|
|
|
}
|
|
|
|
return html``;
|
|
|
|
}),
|
|
|
|
)}
|
2021-09-16 15:30:16 +00:00
|
|
|
<ak-sidebar-item path="/if/user/" ?isAbsoluteLink=${true} ?highlight=${true}>
|
2021-09-16 20:17:05 +00:00
|
|
|
<span slot="label">${t`User interface`}</span>
|
2021-05-05 17:14:37 +00:00
|
|
|
</ak-sidebar-item>
|
2021-12-14 14:57:03 +00:00
|
|
|
<ak-sidebar-item .expanded=${true}>
|
|
|
|
<span slot="label">${t`Dashboards`}</span>
|
|
|
|
<ak-sidebar-item path="/administration/overview">
|
|
|
|
<span slot="label">${t`Overview`}</span>
|
|
|
|
</ak-sidebar-item>
|
2021-12-14 21:04:16 +00:00
|
|
|
<ak-sidebar-item path="/administration/dashboard/users">
|
|
|
|
<span slot="label">${t`Users`}</span>
|
|
|
|
</ak-sidebar-item>
|
2021-12-14 14:57:03 +00:00
|
|
|
<ak-sidebar-item path="/administration/system-tasks">
|
|
|
|
<span slot="label">${t`System Tasks`}</span>
|
|
|
|
</ak-sidebar-item>
|
2021-05-05 17:14:37 +00:00
|
|
|
</ak-sidebar-item>
|
2021-09-16 15:30:16 +00:00
|
|
|
<ak-sidebar-item>
|
2021-12-14 14:57:03 +00:00
|
|
|
<span slot="label">${t`Applications`}</span>
|
2021-08-03 15:52:21 +00:00
|
|
|
<ak-sidebar-item
|
|
|
|
path="/core/applications"
|
|
|
|
.activeWhen=${[`^/core/applications/(?<slug>${SLUG_REGEX})$`]}
|
|
|
|
>
|
2021-05-05 17:14:37 +00:00
|
|
|
<span slot="label">${t`Applications`}</span>
|
|
|
|
</ak-sidebar-item>
|
2021-08-03 15:52:21 +00:00
|
|
|
<ak-sidebar-item
|
|
|
|
path="/core/providers"
|
|
|
|
.activeWhen=${[`^/core/providers/(?<id>${ID_REGEX})$`]}
|
|
|
|
>
|
2021-05-05 17:14:37 +00:00
|
|
|
<span slot="label">${t`Providers`}</span>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
<ak-sidebar-item path="/outpost/outposts">
|
|
|
|
<span slot="label">${t`Outposts`}</span>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
</ak-sidebar-item>
|
2021-09-16 15:30:16 +00:00
|
|
|
<ak-sidebar-item>
|
2021-05-05 17:14:37 +00:00
|
|
|
<span slot="label">${t`Events`}</span>
|
2021-08-03 15:52:21 +00:00
|
|
|
<ak-sidebar-item
|
|
|
|
path="/events/log"
|
|
|
|
.activeWhen=${[`^/events/log/(?<id>${UUID_REGEX})$`]}
|
|
|
|
>
|
2021-05-05 17:14:37 +00:00
|
|
|
<span slot="label">${t`Logs`}</span>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
<ak-sidebar-item path="/events/rules">
|
|
|
|
<span slot="label">${t`Notification Rules`}</span>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
<ak-sidebar-item path="/events/transports">
|
|
|
|
<span slot="label">${t`Notification Transports`}</span>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
</ak-sidebar-item>
|
2021-09-16 15:30:16 +00:00
|
|
|
<ak-sidebar-item>
|
2021-05-05 17:14:37 +00:00
|
|
|
<span slot="label">${t`Customisation`}</span>
|
|
|
|
<ak-sidebar-item path="/policy/policies">
|
|
|
|
<span slot="label">${t`Policies`}</span>
|
|
|
|
</ak-sidebar-item>
|
2022-01-05 20:02:33 +00:00
|
|
|
<ak-sidebar-item path="/policy/reputation">
|
|
|
|
<span slot="label">${t`Reputation scores`}</span>
|
2021-05-29 21:01:45 +00:00
|
|
|
</ak-sidebar-item>
|
2021-05-05 17:14:37 +00:00
|
|
|
<ak-sidebar-item path="/core/property-mappings">
|
|
|
|
<span slot="label">${t`Property Mappings`}</span>
|
|
|
|
</ak-sidebar-item>
|
2022-08-05 06:39:00 +00:00
|
|
|
<ak-sidebar-item path="/blueprints/instances">
|
|
|
|
<span slot="label">${t`Blueprints`}</span>
|
|
|
|
</ak-sidebar-item>
|
2021-05-05 17:14:37 +00:00
|
|
|
</ak-sidebar-item>
|
2021-09-16 15:30:16 +00:00
|
|
|
<ak-sidebar-item>
|
2021-12-30 21:10:31 +00:00
|
|
|
<span slot="label">${t`Flows & Stages`}</span>
|
2021-08-03 15:52:21 +00:00
|
|
|
<ak-sidebar-item
|
|
|
|
path="/flow/flows"
|
|
|
|
.activeWhen=${[`^/flow/flows/(?<slug>${SLUG_REGEX})$`]}
|
|
|
|
>
|
2021-05-05 17:14:37 +00:00
|
|
|
<span slot="label">${t`Flows`}</span>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
<ak-sidebar-item path="/flow/stages">
|
|
|
|
<span slot="label">${t`Stages`}</span>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
<ak-sidebar-item path="/flow/stages/prompts">
|
|
|
|
<span slot="label">${t`Prompts`}</span>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
</ak-sidebar-item>
|
2021-09-16 15:30:16 +00:00
|
|
|
<ak-sidebar-item>
|
2021-12-14 14:57:03 +00:00
|
|
|
<span slot="label">${t`Directory`}</span>
|
2021-08-03 15:52:21 +00:00
|
|
|
<ak-sidebar-item
|
2022-07-02 20:53:16 +00:00
|
|
|
path=${`/identity/users;${encodeURIComponent(
|
|
|
|
JSON.stringify({
|
|
|
|
path: "users",
|
|
|
|
}),
|
|
|
|
)}`}
|
2021-08-03 15:52:21 +00:00
|
|
|
.activeWhen=${[`^/identity/users/(?<id>${ID_REGEX})$`]}
|
|
|
|
>
|
2021-05-05 17:14:37 +00:00
|
|
|
<span slot="label">${t`Users`}</span>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
<ak-sidebar-item path="/identity/groups">
|
|
|
|
<span slot="label">${t`Groups`}</span>
|
|
|
|
</ak-sidebar-item>
|
2021-12-14 14:57:03 +00:00
|
|
|
<ak-sidebar-item
|
|
|
|
path="/core/sources"
|
|
|
|
.activeWhen=${[`^/core/sources/(?<slug>${SLUG_REGEX})$`]}
|
|
|
|
>
|
|
|
|
<span slot="label">${t`Federation & Social login`}</span>
|
2021-05-05 17:14:37 +00:00
|
|
|
</ak-sidebar-item>
|
|
|
|
<ak-sidebar-item path="/core/tokens">
|
2021-08-25 19:22:24 +00:00
|
|
|
<span slot="label">${t`Tokens & App passwords`}</span>
|
2021-05-05 17:14:37 +00:00
|
|
|
</ak-sidebar-item>
|
2021-12-14 14:57:03 +00:00
|
|
|
<ak-sidebar-item path="/flow/stages/invitations">
|
|
|
|
<span slot="label">${t`Invitations`}</span>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
<ak-sidebar-item>
|
|
|
|
<span slot="label">${t`System`}</span>
|
|
|
|
<ak-sidebar-item path="/core/tenants">
|
|
|
|
<span slot="label">${t`Tenants`}</span>
|
|
|
|
</ak-sidebar-item>
|
|
|
|
<ak-sidebar-item path="/crypto/certificates">
|
|
|
|
<span slot="label">${t`Certificates`}</span>
|
|
|
|
</ak-sidebar-item>
|
2022-08-05 06:39:00 +00:00
|
|
|
<ak-sidebar-item path="/outpost/integrations">
|
|
|
|
<span slot="label">${t`Outpost Integrations`}</span>
|
2022-08-02 22:05:49 +00:00
|
|
|
</ak-sidebar-item>
|
2021-05-05 17:14:37 +00:00
|
|
|
</ak-sidebar-item>
|
|
|
|
`;
|
2020-12-02 12:56:26 +00:00
|
|
|
}
|
|
|
|
}
|