From 2d9b776653119e995d1f51181ca7ca6d1f12ae0b Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Mon, 11 May 2020 17:50:46 +0200 Subject: [PATCH] [Project] Fixed to webapp archetype for keepAlive and no more localStorage usage --- .../src/main/webapp/app/src/c-app-menu.html | 4 +++ .../main/webapp/app/src/c-app-routing.html | 30 +++++++++++++------ .../src/main/webapp/app/src/c-app.html | 2 +- .../src/main/webapp/bower.json | 10 +++---- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app-menu.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app-menu.html index a889e54e6..af83d1247 100644 --- a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app-menu.html +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app-menu.html @@ -110,6 +110,10 @@ is: "c-app-menu", properties: { + localesPath: { + type: String, + value: '../../locales.json' + }, userConfig: { type: Object }, diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app-routing.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app-routing.html index 1607850f2..59bd52cbf 100644 --- a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app-routing.html +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app-routing.html @@ -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 diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app.html index 18807715c..6a30b9691 100644 --- a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app.html +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/c-app.html @@ -86,7 +86,6 @@