admin/shell: add loading animation
This commit is contained in:
parent
59e7d9b81e
commit
80866f00f4
|
@ -174,5 +174,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<pb-admin-shell defaultUrl="{% url 'passbook_admin:overview' %}" role="main" class="pf-c-page__main" tabindex="-1" id="main-content">
|
<pb-admin-shell defaultUrl="{% url 'passbook_admin:overview' %}" role="main" class="pf-c-page__main" tabindex="-1" id="main-content">
|
||||||
|
<div slot="body"></div>
|
||||||
</pb-admin-shell>
|
</pb-admin-shell>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,8 @@
|
||||||
import { customElement, html, LitElement, property } from "lit-element";
|
import { css, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||||
|
// @ts-ignore
|
||||||
|
import BullseyeStyle from "@patternfly/patternfly/layouts/Bullseye/bullseye.css";
|
||||||
|
// @ts-ignore
|
||||||
|
import SpinnerStyle from "@patternfly/patternfly/components/Spinner/spinner.css";
|
||||||
|
|
||||||
@customElement("pb-admin-shell")
|
@customElement("pb-admin-shell")
|
||||||
export class AdminSiteShell extends LitElement {
|
export class AdminSiteShell extends LitElement {
|
||||||
|
@ -10,8 +14,22 @@ export class AdminSiteShell extends LitElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createRenderRoot() {
|
@property()
|
||||||
return this;
|
loading: boolean = false;
|
||||||
|
|
||||||
|
static get styles() {
|
||||||
|
return [css`
|
||||||
|
:host {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
:host .pf-l-bullseye {
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
`, BullseyeStyle, SpinnerStyle];
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -25,8 +43,9 @@ export class AdminSiteShell extends LitElement {
|
||||||
if (url === "") {
|
if (url === "") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.loading = true;
|
||||||
fetch(url).then(r => r.text()).then((t) => {
|
fetch(url).then(r => r.text()).then((t) => {
|
||||||
this.innerHTML = t;
|
this.querySelector("[slot=body]")!.innerHTML = t;
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.querySelectorAll("a").forEach(a => {
|
this.querySelectorAll("a").forEach(a => {
|
||||||
if (a.href === "") {
|
if (a.href === "") {
|
||||||
|
@ -40,11 +59,24 @@ export class AdminSiteShell extends LitElement {
|
||||||
a.href = `#${a.href}`;
|
a.href = `#${a.href}`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.loading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return html`${this.innerHTML}`;
|
return html`
|
||||||
|
${this.loading ? html`
|
||||||
|
<div class="pf-l-bullseye">
|
||||||
|
<div class="pf-l-bullseye__item">
|
||||||
|
<span class="pf-c-spinner pf-m-xl" role="progressbar" aria-valuetext="Loading...">
|
||||||
|
<span class="pf-c-spinner__clipper"></span>
|
||||||
|
<span class="pf-c-spinner__lead-ball"></span>
|
||||||
|
<span class="pf-c-spinner__tail-ball"></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>`: ""}
|
||||||
|
<slot name="body">
|
||||||
|
</slot>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue