[Project] Fixed to webapp archetype for keepAlive and no more localStorage usage

This commit is contained in:
Robert von Burg 2020-05-11 17:50:46 +02:00
parent 5e5289cbc8
commit 2d9b776653
4 changed files with 31 additions and 15 deletions

View File

@ -110,6 +110,10 @@
is: "c-app-menu",
properties: {
localesPath: {
type: String,
value: '../../locales.json'
},
userConfig: {
type: Object
},

View File

@ -27,10 +27,6 @@
type: String,
value: "login"
},
defaultPage: {
type: String,
value: "default"
},
exposedPages: {
type: Array,
value: []
@ -61,13 +57,26 @@
"observeRoutePath(route.path)",
"redirectApp(path, authValid)"
],
computeDefaultPage: function (userConfig) {
if (userConfig == null)
return "inspector";
Strolch.setUserConfig(userConfig);
if (Strolch.hasRole("StrolchAdmin")) {
return "inspector";
} else {
return "reports";
}
},
observeRouteData: function (routeData) {
// redirect to login or default if there is no page
if (!routeData.page) {
var firstPage = this.authValid ? this.defaultPage : this.loginPage;
var firstPage = this.authValid ? this.computeDefaultPage(Strolch.getUserConfig()) : this.loginPage;
this.replaceCurrentPage(firstPage);
}
else {
} else {
// this debounces multiple page changes by the app route component
this.set("page", routeData.page);
}
@ -83,8 +92,11 @@
// prevent navigation to login if the auth is still valid
if (pathBase == this.loginPage && authValid == true) {
// instead return to a path that was tried to access before login or the default page
if (this.returnPath) this.replaceCurrentPath(this.returnPath);
else this.replaceCurrentPage(this.defaultPage);
if (this.returnPath) {
this.replaceCurrentPath(this.returnPath);
} else {
this.replaceCurrentPage(this.computeDefaultPage(Strolch.getUserConfig()));
}
}
// prevent navigation to any page but exposed pages if the auth is invalid

View File

@ -86,7 +86,6 @@
<!-- Routing -->
<c-app-routing id="appRouting"
login-page="login"
default-page="inspector"
auth-valid="[[authTokenValid]]"
page="{{page}}"
route-tail="{{routeTail}}"
@ -134,6 +133,7 @@
app-title="[[localize('appTitle')]]"
base-path="../"
show-version
show-keep-alive
on-strolch-session-valid="sessionValidated"></strolch-wc-auth>
<template is="dom-if" if="[[equal(page, 'inspector')]]" restamp>

View File

@ -5,14 +5,14 @@
],
"private": true,
"dependencies": {
"strolchjs": "4treesCH/strolchjs#^0.3.0",
"strolchjs": "4treesCH/strolchjs#^0.4.0",
"strolch-wc-styles": "4treesCH/strolch-wc-styles#^0.3.0",
"strolch-wc-auth": "4treesCH/strolch-wc-auth#^0.7.8",
"strolch-wc-inspector": "4treesCH/strolch-wc-inspector#^0.19.5",
"strolch-wc-localize-behavior": "4treesCH/strolch-wc-localize-behavior#^1.1.6",
"strolch-wc-reports": "4treesCH/strolch-wc-reports#^0.2.6",
"strolch-wc-inspector": "4treesCH/strolch-wc-inspector#^0.19.6",
"strolch-wc-localize-behavior": "4treesCH/strolch-wc-localize-behavior#^1.1.7",
"strolch-wc-reports": "4treesCH/strolch-wc-reports#^0.2.9",
"strolch-wc-paging": "4treesCH/strolch-wc-paging#^0.1.3",
"strolch-wc-ws-observer": "4treesCH/strolch-wc-ws-observer#^0.2.2",
"strolch-wc-ws-observer": "4treesCH/strolch-wc-ws-observer#^0.2.3",
"polymer": "Polymer/polymer#^1.11.3",
"iron-pages": "PolymerElements/iron-pages#^1.0.8",