aboutsummaryrefslogtreecommitdiff
path: root/web/app/view
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-26 21:49:57 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-26 21:49:57 +1200
commitd8cd9c2bba2b3bea5f6af15189f868fa6cffd9b0 (patch)
treed5db965d1e8aaece457f300ddc432caf5b6a25d5 /web/app/view
parent15a540f2b585bb8c7cd7097386957ee332e3d202 (diff)
downloadtrackermap-server-d8cd9c2bba2b3bea5f6af15189f868fa6cffd9b0.tar.gz
trackermap-server-d8cd9c2bba2b3bea5f6af15189f868fa6cffd9b0.tar.bz2
trackermap-server-d8cd9c2bba2b3bea5f6af15189f868fa6cffd9b0.zip
Implement language selection
Diffstat (limited to 'web/app/view')
-rw-r--r--web/app/view/login/Login.js11
-rw-r--r--web/app/view/login/LoginController.js20
2 files changed, 31 insertions, 0 deletions
diff --git a/web/app/view/login/Login.js b/web/app/view/login/Login.js
index fdaaadcfb..49fc8e011 100644
--- a/web/app/view/login/Login.js
+++ b/web/app/view/login/Login.js
@@ -33,6 +33,17 @@ Ext.define('Traccar.view.login.Login', {
reference: 'form',
items: [{
+ xtype: 'combobox',
+ name: 'language',
+ fieldLabel: strings.login_language,
+ store: 'Languages',
+ displayField: 'name',
+ valueField: 'code',
+ submitValue: false,
+ listeners: {
+ select: 'onSelectLanguage'
+ }
+ }, {
xtype: 'textfield',
name: 'email',
fieldLabel: strings.user_email,
diff --git a/web/app/view/login/LoginController.js b/web/app/view/login/LoginController.js
index e94d0de9d..6620e07df 100644
--- a/web/app/view/login/LoginController.js
+++ b/web/app/view/login/LoginController.js
@@ -28,6 +28,26 @@ Ext.define('Traccar.view.login.LoginController', {
);
},
+ onSelectLanguage: function(selected) {
+ var paramName = 'locale';
+ var paramValue = selected.getValue();
+ var url = window.location.href;
+ if (url.indexOf(paramName + '=') >= 0) {
+ var prefix = url.substring(0, url.indexOf(paramName));
+ var suffix = url.substring(url.indexOf(paramName));
+ suffix = suffix.substring(suffix.indexOf("=") + 1);
+ suffix = (suffix.indexOf('&') >= 0) ? suffix.substring(suffix.indexOf('&')) : '';
+ url = prefix + paramName + "=" + paramValue + suffix;
+ } else {
+ if (url.indexOf('?') < 0) {
+ url += '?' + paramName + '=' + paramValue;
+ } else {
+ url += '&' + paramName + '=' + paramValue;
+ }
+ }
+ window.location.href = url;
+ },
+
onAfterRender: function(field) {
field.focus();
},