improved UI
This commit is contained in:
1 parent
520fab5c93
commit
e9da24b54d
13 files changed
+491
-32
No files matched your search
@@ -0,0 +1,33 @@
|
||||
const sessionLocalStorageKey = 'dgt-session';
|
||||
|
||||
let cachedPathVariables = null;
|
||||
|
||||
function getPathVariables(){
|
||||
if (cachedPathVariables !== null) {
|
||||
return cachedPathVariables;
|
||||
}
|
||||
const raw = document.getElementById("url-placeholders")?.textContent || "{}"
|
||||
cachedPathVariables = Object.entries(JSON.parse(raw)?.pathVariables || {})
|
||||
return cachedPathVariables
|
||||
|
||||
}
|
||||
|
||||
window.addEventListener('login', function (evt) {
|
||||
localStorage.setItem(sessionLocalStorageKey, evt.detail.value);
|
||||
document.location.href = "/";
|
||||
});
|
||||
|
||||
window.addEventListener('logout', function (evt) {
|
||||
window.localStorage.removeItem(sessionLocalStorageKey);
|
||||
document.location.href = "/login.html";
|
||||
});
|
||||
|
||||
window.addEventListener('htmx:configRequest', function(evt) {
|
||||
evt.detail.headers['dgt-session'] = localStorage.getItem(sessionLocalStorageKey);
|
||||
|
||||
function reducer(path, [key, value]){
|
||||
return path.replace(key, value)
|
||||
}
|
||||
|
||||
evt.detail.path = getPathVariables().reduce(reducer, evt.detail.path)
|
||||
});
|
||||
Reference in new issue
Block a user