[New] Added showing version
This commit is contained in:
parent
3dc15658a1
commit
6248892979
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "strolch-wc-auth",
|
||||
"description": "Strolch WebComponent Auth",
|
||||
"version": "0.6.7",
|
||||
"version": "0.7.0",
|
||||
"authors": ["Robert von Burg"],
|
||||
"keywords": [
|
||||
"strolch",
|
||||
|
@ -17,7 +17,7 @@
|
|||
"homepage": "https://github.com/4treesCH/strolch-wc-auth",
|
||||
"ignore": [],
|
||||
"dependencies": {
|
||||
"strolchjs": "4treesCH/strolchjs#^0.2.3",
|
||||
"strolchjs": "4treesCH/strolchjs#^0.2.6",
|
||||
"strolch-wc-localize-behavior": "4treesCH/strolch-wc-localize-behavior#^1.1.3",
|
||||
|
||||
"polymer": "Polymer/polymer#^1.11.3",
|
||||
|
|
16
locales.json
16
locales.json
|
@ -19,9 +19,23 @@
|
|||
"authenticationFailed": "Authentication failed",
|
||||
"resetFailed": "Reset failed",
|
||||
"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": {
|
||||
"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",
|
||||
"pleaseLogin": "Melden Sie sich bei {appTitle} an",
|
||||
"username": "Nutzername",
|
||||
|
|
|
@ -71,6 +71,13 @@
|
|||
type="password"
|
||||
on-focus="onFocus"
|
||||
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 class="card-actions">
|
||||
<paper-button on-tap="_showResetForm">{{localize('reset')}}</paper-button>
|
||||
|
@ -176,7 +183,13 @@
|
|||
method="POST"
|
||||
on-response="_ajaxResponse"
|
||||
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>
|
||||
|
||||
<script>
|
||||
|
@ -204,6 +217,16 @@
|
|||
appTitle: {
|
||||
type: String
|
||||
},
|
||||
showVersion: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
appVersion: {
|
||||
type: String
|
||||
},
|
||||
environment: {
|
||||
type: String
|
||||
},
|
||||
username: {
|
||||
type: String
|
||||
},
|
||||
|
@ -233,11 +256,15 @@
|
|||
},
|
||||
|
||||
onCloseDlg: function (evt) {
|
||||
this.$.usernameInput.inputElement.select();
|
||||
this.$.passwordInput.inputElement.select();
|
||||
},
|
||||
|
||||
reload: function () {
|
||||
|
||||
if (this.showVersion) {
|
||||
this.$.ajaxGetVersion.generateRequest();
|
||||
}
|
||||
|
||||
this.username = '';
|
||||
this.password = '';
|
||||
this.password1 = '';
|
||||
|
@ -302,7 +329,14 @@
|
|||
|
||||
_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...');
|
||||
this._ajaxResponse = function (data) {
|
||||
|
@ -339,7 +373,7 @@
|
|||
this.$.authForm.hidden = false;
|
||||
},
|
||||
|
||||
_cancelReset : function() {
|
||||
_cancelReset: function () {
|
||||
this._hideAll();
|
||||
this.$.authForm.hidden = false;
|
||||
},
|
||||
|
@ -420,6 +454,33 @@
|
|||
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) {
|
||||
this.dlgTitle = title;
|
||||
this.dlgText = text;
|
||||
|
|
Loading…
Reference in New Issue