[New] Added showing version

(cherry picked from commit 6248892979)
This commit is contained in:
Robert von Burg 2019-05-27 18:53:28 +02:00
parent b69c30fe10
commit d02bb2d355
2 changed files with 78 additions and 3 deletions

View File

@ -19,9 +19,23 @@
"authenticationFailed": "Authentication failed", "authenticationFailed": "Authentication failed",
"resetFailed": "Reset failed", "resetFailed": "Reset failed",
"passwordsDontMatch": "Passwords don't match", "passwordsDontMatch": "Passwords don't match",
"cancel": "Cancel" "cancel": "Cancel",
"missingInput": "Missing input",
"usernameEmpty": "Username can not be empty",
"passwordEmpty": "Password can not be empty",
"production": "Production",
"testing": "Testing",
"staging": "Staging",
"development": "Development"
}, },
"de": { "de": {
"production": "Produktion",
"testing": "Testing",
"staging": "Staging",
"development": "Entwicklung",
"missingInput": "Fehlende Eingabe",
"usernameEmpty": "Benutzername kann nicht leer sein",
"passwordEmpty": "Passwort kann nicht leer sein",
"cancel": "Abbrechen", "cancel": "Abbrechen",
"pleaseLogin": "Melden Sie sich bei {appTitle} an", "pleaseLogin": "Melden Sie sich bei {appTitle} an",
"username": "Nutzername", "username": "Nutzername",

View File

@ -71,6 +71,13 @@
type="password" type="password"
on-focus="onFocus" on-focus="onFocus"
auto-validate></paper-input> auto-validate></paper-input>
<template is="dom-if" if="[[showVersion]]">
<template is="dom-if" if="[[appVersion]]">
<p>[[appName]] [[appVersion]] @ [[_getEnv(environment)]]</p>
</template>
</template>
</div> </div>
<div class="card-actions"> <div class="card-actions">
<paper-button on-tap="_showResetForm">{{localize('reset')}}</paper-button> <paper-button on-tap="_showResetForm">{{localize('reset')}}</paper-button>
@ -176,7 +183,13 @@
method="POST" method="POST"
on-response="_ajaxResponse" on-response="_ajaxResponse"
on-error="_handleAjaxError"></iron-ajax> on-error="_handleAjaxError"></iron-ajax>
<iron-ajax id="ajaxGetVersion"
url="[[basePath]]rest/strolch/version"
content-type="application/json"
handle-as="json"
method="GET"
on-response="onGetVersionResponse"
on-error="onGetVersionError"></iron-ajax>
</template> </template>
<script> <script>
@ -203,6 +216,16 @@
appTitle: { appTitle: {
type: String type: String
}, },
showVersion: {
type: Boolean,
value: false
},
appVersion: {
type: String
},
environment: {
type: String
},
username: { username: {
type: String type: String
}, },
@ -237,6 +260,10 @@
reload: function () { reload: function () {
if (this.showVersion) {
this.$.ajaxGetVersion.generateRequest();
}
this.username = ''; this.username = '';
this.password = ''; this.password = '';
this.password1 = ''; this.password1 = '';
@ -301,7 +328,14 @@
_submitForm: function () { _submitForm: function () {
if (!this.$.usernameInput.validate() || !this.$.passwordInput.validate()) return; if (!this.$.usernameInput.validate()) {
this.showError(this.localize('missingInput'), this.localize('usernameEmpty'));
return;
}
if (!this.$.passwordInput.validate()) {
this.showError(this.localize('missingInput'), this.localize('passwordEmpty'));
return;
}
console.log('Authenticating...'); console.log('Authenticating...');
this._ajaxResponse = function (data) { this._ajaxResponse = function (data) {
@ -419,6 +453,33 @@
this.$.ajaxAuth.generateRequest(); this.$.ajaxAuth.generateRequest();
}, },
onGetVersionResponse: function (event) {
var version = event.detail.response;
this.appName = version.agentVersion.agentName;
this.appVersion = version.appVersion.artifactVersion;
this.environment = version.agentVersion.environment;
Strolch.setAppVersion(version);
},
onGetVersionError: function (event) {
var readyState = event.detail.request.xhr.readyState;
var status = event.detail.request.xhr.status;
console.log("Ignoring get version error due to readyState: " + readyState + " / status: " + status);
},
_getEnv: function (environment) {
if (environment.indexOf('prod') >= 0) {
return this.localize('production');
} else if (environment.indexOf('test') >= 0) {
return this.localize('testing');
} else if (environment.indexOf('stag') >= 0) {
return this.localize('staging');
} else if (environment.indexOf('dev') >= 0) {
return this.localize('development');
} else {
return environment;
}
},
showError: function (title, text) { showError: function (title, text) {
this.dlgTitle = title; this.dlgTitle = title;
this.dlgText = text; this.dlgText = text;