Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Robert von Burg | 1447bcbc73 | |
Robert von Burg | 82ebdc1d22 | |
Robert von Burg | ca2f0799e3 |
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "strolch-wc-auth",
|
"name": "strolch-wc-auth",
|
||||||
"description": "Strolch WebComponent Auth",
|
"description": "Strolch WebComponent Auth",
|
||||||
"version": "0.9.9",
|
"version": "0.9.12",
|
||||||
"authors": ["Robert von Burg"],
|
"authors": ["Robert von Burg"],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"strolch",
|
"strolch",
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
"ignore": [],
|
"ignore": [],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"strolchjs": "4treesCH/strolchjs#^0.5.3",
|
"strolchjs": "4treesCH/strolchjs#^0.5.3",
|
||||||
"strolch-wc-localize-behavior": "strolch-li/strolch-wc-localize-behavior#^1.1.15",
|
"strolch-wc-localize-behavior": "strolch-li/strolch-wc-localize-behavior#^1.1.17",
|
||||||
|
|
||||||
"polymer": "Polymer/polymer#^1.12.0",
|
"polymer": "Polymer/polymer#^1.12.0",
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
|
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
|
||||||
<link rel="import" href="../paper-input/paper-input.html">
|
<link rel="import" href="../paper-input/paper-input.html">
|
||||||
<link rel="import" href="../paper-dialog/paper-dialog.html">
|
<link rel="import" href="../paper-dialog/paper-dialog.html">
|
||||||
|
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
|
||||||
|
<link rel="import" href="../paper-listbox/paper-listbox.html">
|
||||||
<link rel="import" href="../paper-button/paper-button.html">
|
<link rel="import" href="../paper-button/paper-button.html">
|
||||||
<link rel="import" href="../iron-a11y-keys/iron-a11y-keys.html">
|
<link rel="import" href="../iron-a11y-keys/iron-a11y-keys.html">
|
||||||
<link rel="import" href="../iron-ajax/iron-ajax.html">
|
<link rel="import" href="../iron-ajax/iron-ajax.html">
|
||||||
|
@ -28,7 +30,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.centered {
|
.centered {
|
||||||
width: 350px;
|
width: 400px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-top: 3rem;
|
margin-top: 3rem;
|
||||||
|
@ -39,7 +41,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-actions {
|
.card-actions {
|
||||||
text-align: right;
|
display: flex;
|
||||||
|
justify-content: space-between
|
||||||
}
|
}
|
||||||
|
|
||||||
paper-input {
|
paper-input {
|
||||||
|
@ -49,6 +52,10 @@
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#languageDlg paper-listbox {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -88,8 +95,24 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<paper-button on-tap="_showResetForm">[[localize('reset')]]</paper-button>
|
<div>
|
||||||
<paper-button on-tap="_submitForm">[[localize('login')]]</paper-button>
|
<paper-icon-button icon="icons:language" on-tap="showLanguages"></paper-icon-button>
|
||||||
|
<paper-dialog id="languageDlg" no-overlap horizontal-align="left" vertical-align="top"
|
||||||
|
class="aligned-dialog">
|
||||||
|
<paper-listbox class="dropdown-content" attr-for-selected="value"
|
||||||
|
selected="{{currentLanguage}}">
|
||||||
|
<template is="dom-repeat" items="[[languages]]" as="language">
|
||||||
|
<paper-item value="[[language.locale]]" on-tap="languageSelected">
|
||||||
|
[[language.name]]
|
||||||
|
</paper-item>
|
||||||
|
</template>
|
||||||
|
</paper-listbox>
|
||||||
|
</paper-dialog>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<paper-button on-tap="_showResetForm">[[localize('reset')]]</paper-button>
|
||||||
|
<paper-button on-tap="_submitForm">[[localize('login')]]</paper-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</paper-card>
|
||||||
</div>
|
</div>
|
||||||
|
@ -203,6 +226,13 @@
|
||||||
method="GET"
|
method="GET"
|
||||||
on-response="onGetVersionResponse"
|
on-response="onGetVersionResponse"
|
||||||
on-error="onGetVersionError"></iron-ajax>
|
on-error="onGetVersionError"></iron-ajax>
|
||||||
|
<iron-ajax id="ajaxGetSupportedLanguages"
|
||||||
|
url="[[basePath]]rest/strolch/languages/supported"
|
||||||
|
content-type="application/json"
|
||||||
|
handle-as="json"
|
||||||
|
method="GET"
|
||||||
|
on-response="onGetSupportedLanguagesResponse"
|
||||||
|
on-error="onGetSupportedLanguagesError"></iron-ajax>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -224,6 +254,16 @@
|
||||||
type: String,
|
type: String,
|
||||||
value: './locales.json'
|
value: './locales.json'
|
||||||
},
|
},
|
||||||
|
currentLanguage: {
|
||||||
|
type: String,
|
||||||
|
value: function () {
|
||||||
|
return Strolch.getUserLocale();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
languages: {
|
||||||
|
type: Array,
|
||||||
|
value: []
|
||||||
|
},
|
||||||
appTitle: {
|
appTitle: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
|
@ -285,6 +325,9 @@
|
||||||
computeShowAppEnvironment: function (appVersion, environment) {
|
computeShowAppEnvironment: function (appVersion, environment) {
|
||||||
return appVersion == null && environment != null;
|
return appVersion == null && environment != null;
|
||||||
},
|
},
|
||||||
|
arrayEmpty: function (arr) {
|
||||||
|
return arr == null || arr.length === 0;
|
||||||
|
},
|
||||||
|
|
||||||
ready: function () {
|
ready: function () {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -298,11 +341,29 @@
|
||||||
this.$.passwordInput.inputElement.select();
|
this.$.passwordInput.inputElement.select();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showLanguages: function (e) {
|
||||||
|
this.debounce('open-lang-dlg', function () {
|
||||||
|
var dlg = this.$$('#languageDlg');
|
||||||
|
dlg.positionTarget = e.target;
|
||||||
|
dlg.open();
|
||||||
|
});
|
||||||
|
|
||||||
|
// do not bubble the tap event to the wrapping element
|
||||||
|
e.stopPropagation ? e.stopPropagation() : (e.cancelBubble = true);
|
||||||
|
},
|
||||||
|
languageSelected: function (e) {
|
||||||
|
var language = e.model.language;
|
||||||
|
console.log(language);
|
||||||
|
Strolch.setUserLocale(language.locale);
|
||||||
|
sessionStorage.setItem("languageOverride", language.locale);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
|
||||||
reload: function () {
|
reload: function () {
|
||||||
|
|
||||||
if (this.showVersion) {
|
if (this.showVersion)
|
||||||
this.$.ajaxGetVersion.generateRequest();
|
this.$.ajaxGetVersion.generateRequest();
|
||||||
}
|
this.$.ajaxGetSupportedLanguages.generateRequest();
|
||||||
|
|
||||||
this.username = '';
|
this.username = '';
|
||||||
this.password = '';
|
this.password = '';
|
||||||
|
@ -484,6 +545,11 @@
|
||||||
password: btoa(unescape(encodeURIComponent(this.password))),
|
password: btoa(unescape(encodeURIComponent(this.password))),
|
||||||
keepAlive: this.keepAlive
|
keepAlive: this.keepAlive
|
||||||
};
|
};
|
||||||
|
var languageOverride = sessionStorage.getItem("languageOverride");
|
||||||
|
if (languageOverride != null && languageOverride.length !== 0) {
|
||||||
|
this.$.ajaxAuth.body.languageOverride = languageOverride;
|
||||||
|
}
|
||||||
|
|
||||||
this.password = "";
|
this.password = "";
|
||||||
this.$.ajaxAuth.url = this.basePath + 'rest/strolch/authentication';
|
this.$.ajaxAuth.url = this.basePath + 'rest/strolch/authentication';
|
||||||
this.$.ajaxAuth.method = 'POST';
|
this.$.ajaxAuth.method = 'POST';
|
||||||
|
@ -593,6 +659,18 @@
|
||||||
this.$.ajaxAuth.generateRequest();
|
this.$.ajaxAuth.generateRequest();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onGetSupportedLanguagesResponse: function (e) {
|
||||||
|
if (e.detail.response != null) {
|
||||||
|
this.languages = e.detail.response;
|
||||||
|
} else {
|
||||||
|
this.languages = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onGetSupportedLanguagesError: function (e) {
|
||||||
|
this.languages = [];
|
||||||
|
console.log("Failed to get supported languages: " + e.detail.response);
|
||||||
|
},
|
||||||
|
|
||||||
onGetVersionResponse: function (e) {
|
onGetVersionResponse: function (e) {
|
||||||
var version = e.detail.response;
|
var version = e.detail.response;
|
||||||
this.appName = version.agentVersion.agentName;
|
this.appName = version.agentVersion.agentName;
|
||||||
|
|
Loading…
Reference in New Issue