From d8cd9c2bba2b3bea5f6af15189f868fa6cffd9b0 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 26 Jul 2015 21:49:57 +1200 Subject: Implement language selection --- web/app/view/login/Login.js | 11 +++++++++++ web/app/view/login/LoginController.js | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'web/app/view/login') 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(); }, -- cgit v1.2.3