From b26e487f3c65808d349c7a53c0ea2a3981b61bac Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 20 Feb 2013 23:58:19 +1300 Subject: Add user preferences --- .../web/client/controller/LoginController.java | 7 ++++--- .../web/client/controller/SettingsController.java | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'src/org/traccar/web/client/controller') diff --git a/src/org/traccar/web/client/controller/LoginController.java b/src/org/traccar/web/client/controller/LoginController.java index d2b65ff5..06471377 100644 --- a/src/org/traccar/web/client/controller/LoginController.java +++ b/src/org/traccar/web/client/controller/LoginController.java @@ -36,10 +36,11 @@ public class LoginController implements LoginDialog.LoginHandler { public void login(final LoginHandler loginHandler) { this.loginHandler = loginHandler; - Application.getDataService().authenticated(new BaseAsyncCallback() { + Application.getDataService().authenticated(new BaseAsyncCallback() { @Override - public void onSuccess(Boolean result) { - if (result) { + public void onSuccess(User result) { + if (result != null) { + ApplicationContext.getInstance().setUser(result); loginHandler.onLogin(); } else { dialog = new LoginDialog(LoginController.this); diff --git a/src/org/traccar/web/client/controller/SettingsController.java b/src/org/traccar/web/client/controller/SettingsController.java index c369cbb1..a1892ae2 100644 --- a/src/org/traccar/web/client/controller/SettingsController.java +++ b/src/org/traccar/web/client/controller/SettingsController.java @@ -21,8 +21,10 @@ import org.traccar.web.client.model.BaseAsyncCallback; import org.traccar.web.client.view.ApplicationSettingsDialog; import org.traccar.web.client.view.DeviceView; import org.traccar.web.client.view.UserDialog; +import org.traccar.web.client.view.UserSettingsDialog; import org.traccar.web.shared.model.ApplicationSettings; import org.traccar.web.shared.model.User; +import org.traccar.web.shared.model.UserSettings; public class SettingsController implements DeviceView.SettingsHandler { @@ -45,8 +47,21 @@ public class SettingsController implements DeviceView.SettingsHandler { @Override public void onPreferencesSelected() { - // TODO Auto-generated method stub - + new UserSettingsDialog( + ApplicationContext.getInstance().getUserSettings(), + new UserSettingsDialog.UserSettingsHandler() { + @Override + public void onSave(UserSettings userSettings) { + ApplicationContext.getInstance().setUserSettings(userSettings); + User user = ApplicationContext.getInstance().getUser(); + Application.getDataService().updateUser(user, new BaseAsyncCallback() { + @Override + public void onSuccess(User result) { + ApplicationContext.getInstance().setUser(result); + } + }); + } + }).show(); } @Override -- cgit v1.2.3