-
+
${tmpl}
@@ -188,7 +189,7 @@ class ComponentBreadcrumb extends window.HTMLDivElement {
__htmlLogout() {
if (window.self !== window.top) return ""; // no logout button from an iframe
return `
-
+
`;
diff --git a/public/assets/components/decorator_shell_filemanager.js b/public/assets/components/decorator_shell_filemanager.js
index 430bd6ec..ce75c937 100644
--- a/public/assets/components/decorator_shell_filemanager.js
+++ b/public/assets/components/decorator_shell_filemanager.js
@@ -1,5 +1,5 @@
import { createElement, createRender } from "../lib/skeleton/index.js";
-import { navigate } from "../lib/skeleton/router.js";
+import { navigate, fromHref } from "../lib/skeleton/router.js";
import rxjs, { effect, preventDefault } from "../lib/rx.js";
import { onDestroy } from "../lib/skeleton/lifecycle.js";
import { animate, slideYOut } from "../lib/animate.js";
@@ -25,7 +25,7 @@ export default function(ctrl) {
// feature1: setup the breadcrumb path
const $breadcrumb = qs($page, `[is="component-breadcrumb"]`);
- $breadcrumb.setAttribute("path", urlToPath(location.pathname + location.hash));
+ $breadcrumb.setAttribute("path", urlToPath(fromHref(location.pathname + location.hash)));
// feature2: setup the childrens
const $main = qs($page, `[data-bind="filemanager-children"]`);
diff --git a/public/assets/components/loader.js b/public/assets/components/loader.js
index f4fe0a27..73071dac 100644
--- a/public/assets/components/loader.js
+++ b/public/assets/components/loader.js
@@ -59,13 +59,16 @@ export function createLoader($parent, opts = {}) {
`);
+ let $cache = null;
const id = window.setTimeout(() => {
+ $cache = $parent.cloneNode(true);
$parent.replaceChildren($icon);
animate($icon, { time: 750, keyframes: opacityIn() });
}, wait);
return () => {
clearTimeout(id);
$icon.remove();
+ if ($cache) $parent.replaceChildren(...$cache.children);
};
}));
return rxjs.tap(() => cancel());
diff --git a/public/assets/helpers/loader.js b/public/assets/helpers/loader.js
index 5c9d555b..99922ae8 100644
--- a/public/assets/helpers/loader.js
+++ b/public/assets/helpers/loader.js
@@ -1,15 +1,15 @@
import { get as getRelease } from "../pages/adminpage/model_release.js";
+import { toHref } from "../lib/skeleton/router.js";
let version = null;
export async function loadJS(baseURL, path, opts = {}) {
const $script = document.createElement("script");
- const link = new URL(path, baseURL) + "?version=" + version;
+ const link = new URL(path, baseURL) + (version ? "?version=" + version : "");
$script.setAttribute("src", link.toString());
for (const key in opts) {
$script.setAttribute(key, opts[key]);
}
- if (typeof type === "string") ;
if (document.head.querySelector(`[src="${link.toString()}"]`)) return Promise.resolve();
document.head.appendChild($script);
return new Promise((done) => {
diff --git a/public/assets/helpers/log.js b/public/assets/helpers/log.js
index 263f63e5..c5cd809b 100644
--- a/public/assets/helpers/log.js
+++ b/public/assets/helpers/log.js
@@ -1,6 +1,6 @@
export function report(msg, error, link, lineNo, columnNo) {
if (window.navigator.onLine === false) return Promise.resolve();
- let url = "/report?";
+ let url = "./report?";
url += "url=" + encodeURIComponent(location.href) + "&";
url += "msg=" + encodeURIComponent(msg) + "&";
url += "from=" + encodeURIComponent(link) + "&";
diff --git a/public/assets/lib/animate.js b/public/assets/lib/animate.js
index 1d281098..0ed1b33d 100644
--- a/public/assets/lib/animate.js
+++ b/public/assets/lib/animate.js
@@ -22,7 +22,9 @@ export function animate($node, opts = {}) {
duration: time,
fill,
easing,
- }).onfinish = done;
+ }).onfinish = () => done(() => {
+ $node.animate(keyframes.reverse(), { duration: 0, fill });
+ });
});
}
diff --git a/public/assets/lib/skeleton/router.js b/public/assets/lib/skeleton/router.js
index 7175ecf4..4ff19f99 100644
--- a/public/assets/lib/skeleton/router.js
+++ b/public/assets/lib/skeleton/router.js
@@ -1,4 +1,10 @@
const triggerPageChange = () => window.dispatchEvent(new window.Event("pagechange"));
+const trimPrefix = (value, prefix) => value.startsWith(prefix) ? value.slice(prefix.length) : value;
+
+const _base = window.document.head.querySelector("base").getAttribute("href").replace(new RegExp("/$"), "");
+export const base = () => _base;
+export const fromHref = (href) => trimPrefix(href, base());
+export const toHref = (href) => base() + href;
export async function init($root) {
window.addEventListener("DOMContentLoaded", triggerPageChange);
@@ -22,13 +28,8 @@ export async function navigate(href) {
triggerPageChange();
}
-const trimPrefix = (value, prefix) => value.startsWith(prefix) ? value.slice(prefix.length) : value;
-
export function currentRoute(r, notFoundRoute) {
- const currentRoute = trimPrefix(
- window.location.pathname,
- window.document.head.querySelector("base")?.getAttribute("href") || ""
- );
+ const currentRoute = fromHref(window.location.pathname);
for (const routeKey in r) {
if (new RegExp("^" + routeKey + "$").test(currentRoute)) {
return r[routeKey];
diff --git a/public/assets/model/backend.js b/public/assets/model/backend.js
index d3028b2d..e753ad09 100644
--- a/public/assets/model/backend.js
+++ b/public/assets/model/backend.js
@@ -2,7 +2,7 @@ import rxjs from "../lib/rx.js";
import ajax from "../lib/ajax.js";
const backend$ = ajax({
- url: "/api/backend",
+ url: "api/backend",
method: "GET",
responseType: "json"
}).pipe(
diff --git a/public/assets/model/config.js b/public/assets/model/config.js
index 5f2a5d4e..fcfcd046 100644
--- a/public/assets/model/config.js
+++ b/public/assets/model/config.js
@@ -2,7 +2,7 @@ import rxjs from "../lib/rx.js";
import ajax from "../lib/ajax.js";
const config$ = ajax({
- url: "/api/config",
+ url: "api/config",
method: "GET",
responseType: "json",
}).pipe(
diff --git a/public/assets/model/session.js b/public/assets/model/session.js
index 760ef61b..96eb1151 100644
--- a/public/assets/model/session.js
+++ b/public/assets/model/session.js
@@ -4,7 +4,7 @@ import ajax from "../lib/ajax.js";
export function createSession(authenticationRequest) {
return ajax({
method: "POST",
- url: "/api/session",
+ url: "./api/session",
body: authenticationRequest,
responseType: "json",
});
@@ -12,7 +12,7 @@ export function createSession(authenticationRequest) {
export function getSession() {
return ajax({
- url: "/api/session",
+ url: "./api/session",
method: "GET",
responseType: "json"
}).pipe(
@@ -22,7 +22,7 @@ export function getSession() {
export function deleteSession() {
return ajax({
- url: "/api/session",
+ url: "./api/session",
method: "DELETE"
});
}
diff --git a/public/assets/pages/adminpage/decorator_sidemenu.js b/public/assets/pages/adminpage/decorator_sidemenu.js
index 9061cd41..7818fb3c 100644
--- a/public/assets/pages/adminpage/decorator_sidemenu.js
+++ b/public/assets/pages/adminpage/decorator_sidemenu.js
@@ -1,4 +1,5 @@
import { createElement, createRender } from "../../lib/skeleton/index.js";
+import { toHref } from "../../lib/skeleton/router.js";
import rxjs, { effect, stateMutation } from "../../lib/rx.js";
import { qs } from "../../lib/dom.js";
@@ -16,7 +17,7 @@ export default function(ctrl) {