[New] Added showing version
This commit is contained in:
parent
3dc15658a1
commit
6248892979
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "strolch-wc-auth",
|
"name": "strolch-wc-auth",
|
||||||
"description": "Strolch WebComponent Auth",
|
"description": "Strolch WebComponent Auth",
|
||||||
"version": "0.6.7",
|
"version": "0.7.0",
|
||||||
"authors": ["Robert von Burg"],
|
"authors": ["Robert von Burg"],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"strolch",
|
"strolch",
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
"homepage": "https://github.com/4treesCH/strolch-wc-auth",
|
"homepage": "https://github.com/4treesCH/strolch-wc-auth",
|
||||||
"ignore": [],
|
"ignore": [],
|
||||||
"dependencies": {
|
"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",
|
"strolch-wc-localize-behavior": "4treesCH/strolch-wc-localize-behavior#^1.1.3",
|
||||||
|
|
||||||
"polymer": "Polymer/polymer#^1.11.3",
|
"polymer": "Polymer/polymer#^1.11.3",
|
||||||
|
|
16
locales.json
16
locales.json
|
@ -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",
|
||||||
|
|
|
@ -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>
|
||||||
|
@ -204,6 +217,16 @@
|
||||||
appTitle: {
|
appTitle: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
|
showVersion: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false
|
||||||
|
},
|
||||||
|
appVersion: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
environment: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
username: {
|
username: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
|
@ -233,11 +256,15 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
onCloseDlg: function (evt) {
|
onCloseDlg: function (evt) {
|
||||||
this.$.usernameInput.inputElement.select();
|
this.$.passwordInput.inputElement.select();
|
||||||
},
|
},
|
||||||
|
|
||||||
reload: function () {
|
reload: function () {
|
||||||
|
|
||||||
|
if (this.showVersion) {
|
||||||
|
this.$.ajaxGetVersion.generateRequest();
|
||||||
|
}
|
||||||
|
|
||||||
this.username = '';
|
this.username = '';
|
||||||
this.password = '';
|
this.password = '';
|
||||||
this.password1 = '';
|
this.password1 = '';
|
||||||
|
@ -302,7 +329,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) {
|
||||||
|
@ -339,7 +373,7 @@
|
||||||
this.$.authForm.hidden = false;
|
this.$.authForm.hidden = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
_cancelReset : function() {
|
_cancelReset: function () {
|
||||||
this._hideAll();
|
this._hideAll();
|
||||||
this.$.authForm.hidden = false;
|
this.$.authForm.hidden = false;
|
||||||
},
|
},
|
||||||
|
@ -420,6 +454,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;
|
||||||
|
|
Loading…
Reference in New Issue