2021-03-17 16:11:39 +00:00
|
|
|
import { css, CSSResult, html, LitElement, property, TemplateResult } from "lit-element";
|
2020-12-02 12:56:26 +00:00
|
|
|
import { SidebarItem } from "../elements/sidebar/Sidebar";
|
2021-03-17 16:11:39 +00:00
|
|
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
|
|
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
|
|
|
import PFSkipToContent from "@patternfly/patternfly/components/SkipToContent/skip-to-content.css";
|
|
|
|
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
|
|
|
import PFDrawer from "@patternfly/patternfly/components/Drawer/drawer.css";
|
2020-12-02 12:56:26 +00:00
|
|
|
|
2020-12-12 18:39:09 +00:00
|
|
|
import "../elements/router/RouterOutlet";
|
2020-12-12 19:46:02 +00:00
|
|
|
import "../elements/messages/MessageContainer";
|
2020-12-19 15:54:25 +00:00
|
|
|
import "../elements/sidebar/SidebarHamburger";
|
2021-01-14 21:02:21 +00:00
|
|
|
import "../elements/notifications/NotificationDrawer";
|
2021-03-22 12:44:17 +00:00
|
|
|
import "../elements/Banner";
|
|
|
|
import { until } from "lit-html/directives/until";
|
|
|
|
import { me } from "../api/Users";
|
|
|
|
import { gettext } from "django";
|
2020-12-02 14:44:40 +00:00
|
|
|
|
2020-12-02 12:56:26 +00:00
|
|
|
export abstract class Interface extends LitElement {
|
2020-12-19 15:54:25 +00:00
|
|
|
@property({type: Boolean})
|
2020-12-30 22:12:13 +00:00
|
|
|
sidebarOpen = true;
|
2020-12-02 12:56:26 +00:00
|
|
|
|
2021-01-14 20:58:10 +00:00
|
|
|
@property({type: Boolean})
|
|
|
|
notificationOpen = false;
|
|
|
|
|
2020-12-02 12:56:26 +00:00
|
|
|
abstract get sidebar(): SidebarItem[];
|
|
|
|
|
2021-03-16 16:09:52 +00:00
|
|
|
static get styles(): CSSResult[] {
|
2021-03-17 16:11:39 +00:00
|
|
|
return [PFBase, PFPage, PFSkipToContent, PFButton, PFDrawer, css`
|
|
|
|
.pf-c-page__main, .pf-c-drawer__content, .pf-c-page__drawer {
|
|
|
|
z-index: auto !important;
|
|
|
|
}
|
|
|
|
`];
|
2020-12-02 12:56:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-19 15:54:25 +00:00
|
|
|
constructor() {
|
|
|
|
super();
|
2021-03-16 13:02:04 +00:00
|
|
|
this.sidebarOpen = window.innerWidth >= 1280;
|
2020-12-20 18:26:30 +00:00
|
|
|
window.addEventListener("resize", () => {
|
2021-03-16 13:02:04 +00:00
|
|
|
this.sidebarOpen = window.innerWidth >= 1280;
|
2020-12-20 18:26:30 +00:00
|
|
|
});
|
2020-12-19 15:54:25 +00:00
|
|
|
window.addEventListener("ak-sidebar-toggle", () => {
|
|
|
|
this.sidebarOpen = !this.sidebarOpen;
|
|
|
|
});
|
2021-01-14 20:58:10 +00:00
|
|
|
window.addEventListener("ak-notification-toggle", () => {
|
|
|
|
this.notificationOpen = !this.notificationOpen;
|
|
|
|
});
|
2020-12-19 15:54:25 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 12:56:26 +00:00
|
|
|
render(): TemplateResult {
|
2021-03-17 21:23:24 +00:00
|
|
|
return html`
|
2021-03-22 12:44:17 +00:00
|
|
|
${until(me().then((u) => {
|
|
|
|
if (u.original) {
|
|
|
|
return html`<ak-banner>
|
|
|
|
${gettext(`You're currently impersonating ${u.user.username}.`)}
|
|
|
|
<a href=${`/-/impersonation/end/?back=${window.location.pathname}%23${window.location.hash}`}>
|
|
|
|
${gettext("Stop impersonation")}
|
|
|
|
</a>
|
|
|
|
</ak-banner>`;
|
|
|
|
}
|
|
|
|
return html``;
|
|
|
|
}))}
|
2020-12-02 12:56:26 +00:00
|
|
|
<div class="pf-c-page">
|
2020-12-19 15:54:25 +00:00
|
|
|
<ak-sidebar-hamburger>
|
|
|
|
</ak-sidebar-hamburger>
|
|
|
|
<ak-sidebar class="pf-c-page__sidebar ${this.sidebarOpen ? "pf-m-expanded" : "pf-m-collapsed"}" .items=${this.sidebar}>
|
2020-12-05 21:08:42 +00:00
|
|
|
</ak-sidebar>
|
2021-01-14 20:58:10 +00:00
|
|
|
<div class="pf-c-page__drawer">
|
|
|
|
<div class="pf-c-drawer ${this.notificationOpen ? "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" defaultUrl="/library">
|
|
|
|
</ak-router-outlet>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<ak-notification-drawer class="pf-c-drawer__panel pf-m-width-33">
|
|
|
|
</ak-notification-drawer>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-12-02 12:56:26 +00:00
|
|
|
</div>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|