From ab470e12d064924ec306cacf4c43194683ab55e2 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Fri, 30 Sep 2022 14:27:37 +0200 Subject: [PATCH] [New] Added updateEnvironment() --- bower.json | 2 +- strolch-wc-component-behavior.html | 36 +++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 3ed8c39..64dd4b7 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "strolch-wc-util-behavior", "description": "Strolch Polymer Util Behaviors", - "version": "0.3.7", + "version": "0.3.8", "authors": [ "Robert von Burg" ], diff --git a/strolch-wc-component-behavior.html b/strolch-wc-component-behavior.html index 71da684..fb35f07 100644 --- a/strolch-wc-component-behavior.html +++ b/strolch-wc-component-behavior.html @@ -13,7 +13,7 @@ // app functions // clearSearchTerm: function () { - this.fire("strolch-clear-search-term"); + this.fire("strolch-clear-search-term"); }, // fires an event that will show a dialog @@ -67,6 +67,40 @@ this.fire('strolch-show-toast', {text: text}); }, + /** + * Set an environment property to a localized value + * @param version the version response from the server + */ + updateEnvironment: function (version) { + if (version == null || version.agentVersion == null || version.agentVersion.environment == null) { + this.environment = "-"; + return; + } + var environment = version.agentVersion.environment; + if (this.localize == null) { + this.environment = environment; + this.async(function () { + if (this.localize == null) { + console.error("The localize function is still not available after 100ms of waiting! Cancelling."); + } else { + this.updateEnvironment(version); + } + }.bind(this), 100); + return; + } + if (environment.indexOf('prod') >= 0) { + this.environment = this.localize('production'); + } else if (environment.indexOf('test') >= 0) { + this.environment = this.localize('testing'); + } else if (environment.indexOf('stag') >= 0) { + this.environment = this.localize('staging'); + } else if (environment.indexOf('dev') >= 0) { + this.environment = this.localize('development'); + } else { + this.environment = environment; + } + }, + // // Navigation functions //