[Project] Fixed to webapp archetype for keepAlive and no more localStorage usage
This commit is contained in:
parent
5e5289cbc8
commit
2d9b776653
|
@ -110,6 +110,10 @@
|
||||||
is: "c-app-menu",
|
is: "c-app-menu",
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
|
localesPath: {
|
||||||
|
type: String,
|
||||||
|
value: '../../locales.json'
|
||||||
|
},
|
||||||
userConfig: {
|
userConfig: {
|
||||||
type: Object
|
type: Object
|
||||||
},
|
},
|
||||||
|
|
|
@ -27,10 +27,6 @@
|
||||||
type: String,
|
type: String,
|
||||||
value: "login"
|
value: "login"
|
||||||
},
|
},
|
||||||
defaultPage: {
|
|
||||||
type: String,
|
|
||||||
value: "default"
|
|
||||||
},
|
|
||||||
exposedPages: {
|
exposedPages: {
|
||||||
type: Array,
|
type: Array,
|
||||||
value: []
|
value: []
|
||||||
|
@ -61,13 +57,26 @@
|
||||||
"observeRoutePath(route.path)",
|
"observeRoutePath(route.path)",
|
||||||
"redirectApp(path, authValid)"
|
"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) {
|
observeRouteData: function (routeData) {
|
||||||
// redirect to login or default if there is no page
|
// redirect to login or default if there is no page
|
||||||
if (!routeData.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);
|
this.replaceCurrentPage(firstPage);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// this debounces multiple page changes by the app route component
|
// this debounces multiple page changes by the app route component
|
||||||
this.set("page", routeData.page);
|
this.set("page", routeData.page);
|
||||||
}
|
}
|
||||||
|
@ -83,8 +92,11 @@
|
||||||
// prevent navigation to login if the auth is still valid
|
// prevent navigation to login if the auth is still valid
|
||||||
if (pathBase == this.loginPage && authValid == true) {
|
if (pathBase == this.loginPage && authValid == true) {
|
||||||
// instead return to a path that was tried to access before login or the default page
|
// instead return to a path that was tried to access before login or the default page
|
||||||
if (this.returnPath) this.replaceCurrentPath(this.returnPath);
|
if (this.returnPath) {
|
||||||
else this.replaceCurrentPage(this.defaultPage);
|
this.replaceCurrentPath(this.returnPath);
|
||||||
|
} else {
|
||||||
|
this.replaceCurrentPage(this.computeDefaultPage(Strolch.getUserConfig()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// prevent navigation to any page but exposed pages if the auth is invalid
|
// prevent navigation to any page but exposed pages if the auth is invalid
|
||||||
|
|
|
@ -86,7 +86,6 @@
|
||||||
<!-- Routing -->
|
<!-- Routing -->
|
||||||
<c-app-routing id="appRouting"
|
<c-app-routing id="appRouting"
|
||||||
login-page="login"
|
login-page="login"
|
||||||
default-page="inspector"
|
|
||||||
auth-valid="[[authTokenValid]]"
|
auth-valid="[[authTokenValid]]"
|
||||||
page="{{page}}"
|
page="{{page}}"
|
||||||
route-tail="{{routeTail}}"
|
route-tail="{{routeTail}}"
|
||||||
|
@ -134,6 +133,7 @@
|
||||||
app-title="[[localize('appTitle')]]"
|
app-title="[[localize('appTitle')]]"
|
||||||
base-path="../"
|
base-path="../"
|
||||||
show-version
|
show-version
|
||||||
|
show-keep-alive
|
||||||
on-strolch-session-valid="sessionValidated"></strolch-wc-auth>
|
on-strolch-session-valid="sessionValidated"></strolch-wc-auth>
|
||||||
|
|
||||||
<template is="dom-if" if="[[equal(page, 'inspector')]]" restamp>
|
<template is="dom-if" if="[[equal(page, 'inspector')]]" restamp>
|
||||||
|
|
|
@ -5,14 +5,14 @@
|
||||||
],
|
],
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"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-styles": "4treesCH/strolch-wc-styles#^0.3.0",
|
||||||
"strolch-wc-auth": "4treesCH/strolch-wc-auth#^0.7.8",
|
"strolch-wc-auth": "4treesCH/strolch-wc-auth#^0.7.8",
|
||||||
"strolch-wc-inspector": "4treesCH/strolch-wc-inspector#^0.19.5",
|
"strolch-wc-inspector": "4treesCH/strolch-wc-inspector#^0.19.6",
|
||||||
"strolch-wc-localize-behavior": "4treesCH/strolch-wc-localize-behavior#^1.1.6",
|
"strolch-wc-localize-behavior": "4treesCH/strolch-wc-localize-behavior#^1.1.7",
|
||||||
"strolch-wc-reports": "4treesCH/strolch-wc-reports#^0.2.6",
|
"strolch-wc-reports": "4treesCH/strolch-wc-reports#^0.2.9",
|
||||||
"strolch-wc-paging": "4treesCH/strolch-wc-paging#^0.1.3",
|
"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",
|
"polymer": "Polymer/polymer#^1.11.3",
|
||||||
"iron-pages": "PolymerElements/iron-pages#^1.0.8",
|
"iron-pages": "PolymerElements/iron-pages#^1.0.8",
|
||||||
|
|
Loading…
Reference in New Issue