web/user: allow customisable background colour
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
84a800583c
commit
f8dee09107
|
@ -53,12 +53,7 @@ export class RouterOutlet extends LitElement {
|
|||
css`
|
||||
:host {
|
||||
height: 100vh;
|
||||
background-color: var(--pf-global--BackgroundColor--light-300) !important;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:host {
|
||||
background-color: var(--ak-dark-background) !important;
|
||||
}
|
||||
background-color: transparent !important;
|
||||
}
|
||||
*:first-child {
|
||||
flex-direction: column;
|
||||
|
|
|
@ -62,10 +62,20 @@ export class AdminInterface extends LitElement {
|
|||
.pf-c-drawer__content,
|
||||
.pf-c-page__drawer {
|
||||
z-index: auto !important;
|
||||
background-color: transparent;
|
||||
}
|
||||
.display-none {
|
||||
display: none;
|
||||
}
|
||||
.pf-c-page {
|
||||
background-color: var(--pf-global--BackgroundColor--light-300) !important;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
/* Global page background colour */
|
||||
.pf-c-page {
|
||||
--pf-c-page--BackgroundColor: var(--ak-dark-background);
|
||||
}
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
|
|
@ -72,6 +72,10 @@ export class UserInterface extends LitElement {
|
|||
.pf-c-drawer__content,
|
||||
.pf-c-page__drawer {
|
||||
z-index: auto !important;
|
||||
background-color: transparent !important;
|
||||
}
|
||||
.pf-c-page {
|
||||
background-color: var(--pf-global--BackgroundColor--light-300) !important;
|
||||
}
|
||||
.display-none {
|
||||
display: none;
|
||||
|
@ -114,185 +118,187 @@ export class UserInterface extends LitElement {
|
|||
}
|
||||
|
||||
render(): TemplateResult {
|
||||
return html` <div class="pf-c-page">
|
||||
<header class="pf-c-page__header">
|
||||
<div class="pf-c-page__header-brand">
|
||||
<a href="#/" class="pf-c-page__header-brand-link">
|
||||
<img
|
||||
class="pf-c-brand"
|
||||
src="${first(this.tenant.brandingLogo, DefaultTenant.brandingLogo)}"
|
||||
alt="${(this.tenant.brandingTitle, DefaultTenant.brandingTitle)}"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pf-c-page__header-tools">
|
||||
<div class="pf-c-page__header-tools-group">
|
||||
${until(
|
||||
uiConfig().then((config) => {
|
||||
if (!config.enabledFeatures.apiDrawer) {
|
||||
return html``;
|
||||
}
|
||||
return html`<div
|
||||
class="pf-c-page__header-tools-item pf-m-hidden pf-m-visible-on-lg"
|
||||
return html`${until(
|
||||
uiConfig().then((config) => {
|
||||
return html`<div
|
||||
class="pf-c-page"
|
||||
style="background: ${config.color.background} !important"
|
||||
>
|
||||
<header class="pf-c-page__header">
|
||||
<div class="pf-c-page__header-brand">
|
||||
<a href="#/" class="pf-c-page__header-brand-link">
|
||||
<img
|
||||
class="pf-c-brand"
|
||||
src="${first(
|
||||
this.tenant.brandingLogo,
|
||||
DefaultTenant.brandingLogo,
|
||||
)}"
|
||||
alt="${(this.tenant.brandingTitle,
|
||||
DefaultTenant.brandingTitle)}"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pf-c-page__header-tools">
|
||||
<div class="pf-c-page__header-tools-group">
|
||||
${config.enabledFeatures.apiDrawer
|
||||
? html`<div
|
||||
class="pf-c-page__header-tools-item pf-m-hidden pf-m-visible-on-lg"
|
||||
>
|
||||
<button
|
||||
class="pf-c-button pf-m-plain"
|
||||
type="button"
|
||||
@click=${() => {
|
||||
this.apiDrawerOpen = !this.apiDrawerOpen;
|
||||
}}
|
||||
>
|
||||
<i class="fas fa-code" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>`
|
||||
: html``}
|
||||
${config.enabledFeatures.notificationDrawer
|
||||
? html`
|
||||
<button
|
||||
class="pf-c-button pf-m-plain"
|
||||
type="button"
|
||||
aria-label="${t`Unread notifications`}"
|
||||
@click=${() => {
|
||||
this.notificationOpen = !this.notificationOpen;
|
||||
}}
|
||||
>
|
||||
<span
|
||||
class="pf-c-notification-badge ${this
|
||||
.notificationsCount > 0
|
||||
? "pf-m-unread"
|
||||
: ""}"
|
||||
>
|
||||
<i class="pf-icon-bell" aria-hidden="true"></i>
|
||||
<span class="pf-c-notification-badge__count"
|
||||
>${this.notificationsCount}</span
|
||||
>
|
||||
</span>
|
||||
</button>
|
||||
`
|
||||
: html``}
|
||||
${config.enabledFeatures.settings
|
||||
? html` <div
|
||||
class="pf-c-page__header-tools-item pf-m-hidden pf-m-visible-on-lg"
|
||||
>
|
||||
<a
|
||||
class="pf-c-button pf-m-plain"
|
||||
type="button"
|
||||
href="#/settings"
|
||||
>
|
||||
<i class="fas fa-cog" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>`
|
||||
: html``}
|
||||
<a
|
||||
href="/flows/-/default/invalidation/"
|
||||
class="pf-c-button pf-m-plain"
|
||||
>
|
||||
<button
|
||||
class="pf-c-button pf-m-plain"
|
||||
type="button"
|
||||
@click=${() => {
|
||||
this.apiDrawerOpen = !this.apiDrawerOpen;
|
||||
}}
|
||||
>
|
||||
<i class="fas fa-code" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>`;
|
||||
}),
|
||||
)}
|
||||
${until(
|
||||
uiConfig().then((config) => {
|
||||
if (!config.enabledFeatures.notificationDrawer) {
|
||||
return html``;
|
||||
}
|
||||
return html`
|
||||
<button
|
||||
class="pf-c-button pf-m-plain"
|
||||
type="button"
|
||||
aria-label="${t`Unread notifications`}"
|
||||
@click=${() => {
|
||||
this.notificationOpen = !this.notificationOpen;
|
||||
}}
|
||||
>
|
||||
<span
|
||||
class="pf-c-notification-badge ${this
|
||||
.notificationsCount > 0
|
||||
? "pf-m-unread"
|
||||
: ""}"
|
||||
>
|
||||
<i class="pf-icon-bell" aria-hidden="true"></i>
|
||||
<span class="pf-c-notification-badge__count"
|
||||
>${this.notificationsCount}</span
|
||||
<i class="fas fa-sign-out-alt" aria-hidden="true"></i>
|
||||
</a>
|
||||
${until(
|
||||
me().then((u) => {
|
||||
if (!u.user.isSuperuser) return html``;
|
||||
return html`
|
||||
<a
|
||||
class="pf-c-button pf-m-primary pf-m-small"
|
||||
href="/if/admin"
|
||||
>
|
||||
</span>
|
||||
</button>
|
||||
`;
|
||||
}),
|
||||
)}
|
||||
${until(
|
||||
uiConfig().then((config) => {
|
||||
if (!config.enabledFeatures.settings) {
|
||||
return html``;
|
||||
}
|
||||
return html` <div
|
||||
class="pf-c-page__header-tools-item pf-m-hidden pf-m-visible-on-lg"
|
||||
>
|
||||
<a
|
||||
class="pf-c-button pf-m-plain"
|
||||
type="button"
|
||||
href="#/settings"
|
||||
>
|
||||
<i class="fas fa-cog" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>`;
|
||||
}),
|
||||
)}
|
||||
<a href="/flows/-/default/invalidation/" class="pf-c-button pf-m-plain">
|
||||
<i class="fas fa-sign-out-alt" aria-hidden="true"></i>
|
||||
</a>
|
||||
${until(
|
||||
me().then((u) => {
|
||||
if (!u.user.isSuperuser) return html``;
|
||||
return html`
|
||||
<a class="pf-c-button pf-m-primary pf-m-small" href="/if/admin">
|
||||
${t`Admin interface`}
|
||||
</a>
|
||||
`;
|
||||
}),
|
||||
)}
|
||||
</div>
|
||||
${until(
|
||||
me().then((u) => {
|
||||
if (u.original) {
|
||||
return html`<div class="pf-c-page__header-tools">
|
||||
<div class="pf-c-page__header-tools-group">
|
||||
<a
|
||||
class="pf-c-button pf-m-warning pf-m-small"
|
||||
href=${`/-/impersonation/end/?back=${window.location.pathname}%23${window.location.hash}`}
|
||||
>
|
||||
${t`Stop impersonation`}
|
||||
</a>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
return html``;
|
||||
}),
|
||||
)}
|
||||
<div class="pf-c-page__header-tools-group">
|
||||
<div class="pf-c-page__header-tools-item pf-m-hidden pf-m-visible-on-md">
|
||||
${t`Admin interface`}
|
||||
</a>
|
||||
`;
|
||||
}),
|
||||
)}
|
||||
</div>
|
||||
${until(
|
||||
uiConfig().then((config) => {
|
||||
return me().then((me) => {
|
||||
switch (config.navbar.userDisplay) {
|
||||
case "username":
|
||||
return me.user.username;
|
||||
case "name":
|
||||
return me.user.name;
|
||||
case "email":
|
||||
return me.user.email;
|
||||
default:
|
||||
return me.user.username;
|
||||
}
|
||||
});
|
||||
me().then((u) => {
|
||||
if (u.original) {
|
||||
return html`<div class="pf-c-page__header-tools">
|
||||
<div class="pf-c-page__header-tools-group">
|
||||
<a
|
||||
class="pf-c-button pf-m-warning pf-m-small"
|
||||
href=${`/-/impersonation/end/?back=${window.location.pathname}%23${window.location.hash}`}
|
||||
>
|
||||
${t`Stop impersonation`}
|
||||
</a>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
return html``;
|
||||
}),
|
||||
)}
|
||||
<div class="pf-c-page__header-tools-group">
|
||||
<div
|
||||
class="pf-c-page__header-tools-item pf-m-hidden pf-m-visible-on-md"
|
||||
>
|
||||
${until(
|
||||
me().then((me) => {
|
||||
switch (config.navbar.userDisplay) {
|
||||
case "username":
|
||||
return me.user.username;
|
||||
case "name":
|
||||
return me.user.name;
|
||||
case "email":
|
||||
return me.user.email;
|
||||
default:
|
||||
return me.user.username;
|
||||
}
|
||||
}),
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
${until(
|
||||
me().then((me) => {
|
||||
return html`<img
|
||||
class="pf-c-avatar"
|
||||
src=${me.user.avatar}
|
||||
alt="${t`Avatar image`}"
|
||||
/>`;
|
||||
}),
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
${until(
|
||||
me().then((me) => {
|
||||
return html`<img
|
||||
class="pf-c-avatar"
|
||||
src=${me.user.avatar}
|
||||
alt="${t`Avatar image`}"
|
||||
/>`;
|
||||
}),
|
||||
)}
|
||||
</div>
|
||||
</header>
|
||||
<div class="pf-c-page__drawer">
|
||||
<div
|
||||
class="pf-c-drawer ${this.notificationOpen || this.apiDrawerOpen
|
||||
? "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-l-bullseye__item pf-c-page__main"
|
||||
tabindex="-1"
|
||||
id="main-content"
|
||||
defaultUrl="/library"
|
||||
.routes=${ROUTES}
|
||||
>
|
||||
</ak-router-outlet>
|
||||
</main>
|
||||
</header>
|
||||
<div class="pf-c-page__drawer">
|
||||
<div
|
||||
class="pf-c-drawer ${this.notificationOpen || this.apiDrawerOpen
|
||||
? "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-l-bullseye__item pf-c-page__main"
|
||||
tabindex="-1"
|
||||
id="main-content"
|
||||
defaultUrl="/library"
|
||||
.routes=${ROUTES}
|
||||
>
|
||||
</ak-router-outlet>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
<ak-notification-drawer
|
||||
class="pf-c-drawer__panel pf-m-width-33 ${this.notificationOpen
|
||||
? ""
|
||||
: "display-none"}"
|
||||
?hidden=${!this.notificationOpen}
|
||||
></ak-notification-drawer>
|
||||
<ak-api-drawer
|
||||
class="pf-c-drawer__panel pf-m-width-33 ${this.apiDrawerOpen
|
||||
? ""
|
||||
: "display-none"}"
|
||||
?hidden=${!this.apiDrawerOpen}
|
||||
></ak-api-drawer>
|
||||
</div>
|
||||
</div>
|
||||
<ak-notification-drawer
|
||||
class="pf-c-drawer__panel pf-m-width-33 ${this.notificationOpen
|
||||
? ""
|
||||
: "display-none"}"
|
||||
?hidden=${!this.notificationOpen}
|
||||
></ak-notification-drawer>
|
||||
<ak-api-drawer
|
||||
class="pf-c-drawer__panel pf-m-width-33 ${this.apiDrawerOpen
|
||||
? ""
|
||||
: "display-none"}"
|
||||
?hidden=${!this.apiDrawerOpen}
|
||||
></ak-api-drawer>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
</div>`;
|
||||
}),
|
||||
)}`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ export class LibraryApplication extends LitElement {
|
|||
@property({ type: Boolean })
|
||||
selected = false;
|
||||
|
||||
@property()
|
||||
background: string = "";
|
||||
|
||||
static get styles(): CSSResult[] {
|
||||
return [
|
||||
PFBase,
|
||||
|
@ -70,6 +73,7 @@ export class LibraryApplication extends LitElement {
|
|||
class="pf-c-card pf-m-hoverable pf-m-compact ${this.selected
|
||||
? "pf-m-selectable pf-m-selected"
|
||||
: ""}"
|
||||
style="background: ${this.background} !important"
|
||||
>
|
||||
<div class="pf-c-card__header">
|
||||
${this.application.metaIcon
|
||||
|
|
|
@ -21,7 +21,7 @@ import PFGallery from "@patternfly/patternfly/layouts/Gallery/gallery.css";
|
|||
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
||||
import "./LibraryApplication";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import { uiConfig } from "./config";
|
||||
import { UIConfig, uiConfig } from "./config";
|
||||
|
||||
@customElement("ak-library")
|
||||
export class LibraryPage extends LitElement {
|
||||
|
@ -71,6 +71,9 @@ export class LibraryPage extends LitElement {
|
|||
.header input:focus {
|
||||
outline: 0;
|
||||
}
|
||||
.pf-c-page__main-section {
|
||||
background-color: transparent;
|
||||
}
|
||||
`);
|
||||
}
|
||||
|
||||
|
@ -86,7 +89,7 @@ export class LibraryPage extends LitElement {
|
|||
</div>`;
|
||||
}
|
||||
|
||||
renderApps(): TemplateResult {
|
||||
renderApps(config: UIConfig): TemplateResult {
|
||||
return html`<div class="pf-l-gallery pf-m-gutter">
|
||||
${this.apps?.results
|
||||
.filter((app) => app.launchUrl)
|
||||
|
@ -94,6 +97,7 @@ export class LibraryPage extends LitElement {
|
|||
(app) =>
|
||||
html`<ak-library-app
|
||||
.application=${app}
|
||||
background=${config.color.cardBackground}
|
||||
?selected=${app.slug === this.selectedApp?.slug}
|
||||
></ak-library-app>`,
|
||||
)}
|
||||
|
@ -101,45 +105,49 @@ export class LibraryPage extends LitElement {
|
|||
}
|
||||
|
||||
render(): TemplateResult {
|
||||
return html`<main role="main" class="pf-c-page__main" tabindex="-1" id="main-content">
|
||||
<div class="pf-c-content header">
|
||||
<h1>${t`My applications`}</h1>
|
||||
${until(
|
||||
uiConfig().then((config) => {
|
||||
if (!config.enabledFeatures.search) {
|
||||
return html``;
|
||||
}
|
||||
return html` <input
|
||||
@input=${(ev: InputEvent) => {
|
||||
const query = (ev.target as HTMLInputElement).value;
|
||||
if (!this.fuse) return;
|
||||
const apps = this.fuse.search(query);
|
||||
if (apps.length < 1) return;
|
||||
this.selectedApp = apps[0].item;
|
||||
}}
|
||||
@keydown=${(ev: KeyboardEvent) => {
|
||||
if (ev.key === "Enter" && this.selectedApp?.launchUrl) {
|
||||
window.location.assign(this.selectedApp.launchUrl);
|
||||
} else if (ev.key === "Escape") {
|
||||
(ev.target as HTMLInputElement).value = "";
|
||||
this.selectedApp = undefined;
|
||||
}
|
||||
}}
|
||||
type="text"
|
||||
autofocus
|
||||
placeholder=${t`Search...`}
|
||||
/>`;
|
||||
}),
|
||||
)}
|
||||
</div>
|
||||
<section class="pf-c-page__main-section">
|
||||
${loading(
|
||||
this.apps,
|
||||
html`${(this.apps?.results.length || 0) > 0
|
||||
? this.renderApps()
|
||||
: this.renderEmptyState()}`,
|
||||
)}
|
||||
</section>
|
||||
</main>`;
|
||||
return html`${until(
|
||||
uiConfig().then((config) => {
|
||||
return html`<main
|
||||
role="main"
|
||||
class="pf-c-page__main"
|
||||
tabindex="-1"
|
||||
id="main-content"
|
||||
>
|
||||
<div class="pf-c-content header">
|
||||
<h1>${t`My applications`}</h1>
|
||||
${config.enabledFeatures.search
|
||||
? html`<input
|
||||
@input=${(ev: InputEvent) => {
|
||||
const query = (ev.target as HTMLInputElement).value;
|
||||
if (!this.fuse) return;
|
||||
const apps = this.fuse.search(query);
|
||||
if (apps.length < 1) return;
|
||||
this.selectedApp = apps[0].item;
|
||||
}}
|
||||
@keydown=${(ev: KeyboardEvent) => {
|
||||
if (ev.key === "Enter" && this.selectedApp?.launchUrl) {
|
||||
window.location.assign(this.selectedApp.launchUrl);
|
||||
} else if (ev.key === "Escape") {
|
||||
(ev.target as HTMLInputElement).value = "";
|
||||
this.selectedApp = undefined;
|
||||
}
|
||||
}}
|
||||
type="text"
|
||||
autofocus
|
||||
placeholder=${t`Search...`}
|
||||
/>`
|
||||
: html``}
|
||||
</div>
|
||||
<section class="pf-c-page__main-section">
|
||||
${loading(
|
||||
this.apps,
|
||||
html`${(this.apps?.results.length || 0) > 0
|
||||
? this.renderApps(config)
|
||||
: this.renderEmptyState()}`,
|
||||
)}
|
||||
</section>
|
||||
</main>`;
|
||||
}),
|
||||
)}`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@ export interface UIConfig {
|
|||
navbar: {
|
||||
userDisplay: "username" | "name" | "email";
|
||||
};
|
||||
color: {
|
||||
background: string;
|
||||
cardBackground: string;
|
||||
};
|
||||
}
|
||||
|
||||
export const DefaultUIConfig: UIConfig = {
|
||||
|
@ -27,6 +31,10 @@ export const DefaultUIConfig: UIConfig = {
|
|||
navbar: {
|
||||
userDisplay: "name",
|
||||
},
|
||||
color: {
|
||||
background: "",
|
||||
cardBackground: "",
|
||||
},
|
||||
};
|
||||
|
||||
export function uiConfig(): Promise<UIConfig> {
|
||||
|
|
Reference in New Issue