[Minor] Handle version not supplied by server

This commit is contained in:
Robert von Burg 2021-11-15 09:54:52 +01:00
parent 39ca9f7e14
commit d847e3ac78
2 changed files with 30 additions and 7 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "strolch-wc-auth", "name": "strolch-wc-auth",
"description": "Strolch WebComponent Auth", "description": "Strolch WebComponent Auth",
"version": "0.9.2", "version": "0.9.3",
"authors": ["Robert von Burg"], "authors": ["Robert von Burg"],
"keywords": [ "keywords": [
"strolch", "strolch",

View File

@ -78,9 +78,12 @@
</template> </template>
<template is="dom-if" if="[[showVersion]]"> <template is="dom-if" if="[[showVersion]]">
<template is="dom-if" if="[[appVersion]]"> <template is="dom-if" if="[[showAppVersion]]">
<p>[[appName]] [[appVersion]] @ [[_getEnv(environment)]]</p> <p>[[appName]] [[appVersion]] @ [[_getEnv(environment)]]</p>
</template> </template>
<template is="dom-if" if="[[showAppEnvironment]]">
<p>[[appName]] @ [[_getEnv(environment)]]</p>
</template>
</template> </template>
</div> </div>
@ -215,9 +218,7 @@
properties: { properties: {
basePath: { basePath: {
type: String, type: String,
value: function () { value: './'
return './';
}
}, },
localesPath: { localesPath: {
type: String, type: String,
@ -234,11 +235,21 @@
type: Boolean, type: Boolean,
value: false value: false
}, },
showAppVersion: {
type: Boolean,
value: false
},
showAppEnvironment: {
type: Boolean,
value: false
},
appVersion: { appVersion: {
type: String type: String,
value: null
}, },
environment: { environment: {
type: String type: String,
value: null
}, },
username: { username: {
type: String type: String
@ -268,6 +279,13 @@
} }
}, },
computeShowAppVersion: function (appVersion, environment) {
return appVersion != null && environment != null;
},
computeShowAppEnvironment: function (appVersion, environment) {
return appVersion == null && environment != null;
},
ready: function () { ready: function () {
// do nothing // do nothing
}, },
@ -579,6 +597,8 @@
this.appName = version.agentVersion.agentName; this.appName = version.agentVersion.agentName;
this.appVersion = version.appVersion.artifactVersion; this.appVersion = version.appVersion.artifactVersion;
this.environment = version.agentVersion.environment; this.environment = version.agentVersion.environment;
this.showAppVersion = this.computeShowAppVersion(this.appVersion, this.environment)
this.showAppEnvironment = this.computeShowAppEnvironment(this.appVersion, this.environment)
Strolch.setAppVersion(version); Strolch.setAppVersion(version);
sessionStorage.setItem("strolchAppVersion", JSON.stringify(version)); sessionStorage.setItem("strolchAppVersion", JSON.stringify(version));
}, },
@ -589,6 +609,9 @@
console.log("Ignoring get version error due to readyState: " + readyState + " / status: " + status); console.log("Ignoring get version error due to readyState: " + readyState + " / status: " + status);
}, },
_getEnv: function (environment) { _getEnv: function (environment) {
console.log("environment=" + environment)
if (environment == null)
return "-";
if (environment.indexOf('prod') >= 0) { if (environment.indexOf('prod') >= 0) {
return this.localize('production'); return this.localize('production');
} else if (environment.indexOf('test') >= 0) { } else if (environment.indexOf('test') >= 0) {