aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/client/controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/web/client/controller')
-rw-r--r--src/org/traccar/web/client/controller/LoginController.java16
-rw-r--r--src/org/traccar/web/client/controller/SettingsController.java18
2 files changed, 25 insertions, 9 deletions
diff --git a/src/org/traccar/web/client/controller/LoginController.java b/src/org/traccar/web/client/controller/LoginController.java
index d9795f30..d2b65ff5 100644
--- a/src/org/traccar/web/client/controller/LoginController.java
+++ b/src/org/traccar/web/client/controller/LoginController.java
@@ -16,8 +16,10 @@
package org.traccar.web.client.controller;
import org.traccar.web.client.Application;
+import org.traccar.web.client.ApplicationContext;
import org.traccar.web.client.model.BaseAsyncCallback;
import org.traccar.web.client.view.LoginDialog;
+import org.traccar.web.shared.model.User;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
@@ -58,10 +60,11 @@ public class LoginController implements LoginDialog.LoginHandler {
@Override
public void onLogin(String login, String password) {
if (validate(login, password)) {
- Application.getDataService().login(login, password, new BaseAsyncCallback<Boolean>() {
+ Application.getDataService().login(login, password, new BaseAsyncCallback<User>() {
@Override
- public void onSuccess(Boolean result) {
- if (result) {
+ public void onSuccess(User result) {
+ if (result != null) {
+ ApplicationContext.getInstance().setUser(result);
if (loginHandler != null) {
dialog.hide();
loginHandler.onLogin();
@@ -77,10 +80,11 @@ public class LoginController implements LoginDialog.LoginHandler {
@Override
public void onRegister(String login, String password) {
if (validate(login, password)) {
- Application.getDataService().register(login, password, new BaseAsyncCallback<Boolean>() {
+ Application.getDataService().register(login, password, new BaseAsyncCallback<User>() {
@Override
- public void onSuccess(Boolean result) {
- if (result) {
+ public void onSuccess(User result) {
+ if (result != null) {
+ ApplicationContext.getInstance().setUser(result);
if (loginHandler != null) {
dialog.hide();
loginHandler.onLogin();
diff --git a/src/org/traccar/web/client/controller/SettingsController.java b/src/org/traccar/web/client/controller/SettingsController.java
index 75130f2b..c369cbb1 100644
--- a/src/org/traccar/web/client/controller/SettingsController.java
+++ b/src/org/traccar/web/client/controller/SettingsController.java
@@ -20,14 +20,27 @@ import org.traccar.web.client.ApplicationContext;
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.shared.model.ApplicationSettings;
+import org.traccar.web.shared.model.User;
public class SettingsController implements DeviceView.SettingsHandler {
@Override
public void onAccountSelected() {
- // TODO Auto-generated method stub
-
+ new UserDialog(
+ ApplicationContext.getInstance().getUser(),
+ new UserDialog.UserHandler() {
+ @Override
+ public void onSave(User user) {
+ Application.getDataService().updateUser(user, new BaseAsyncCallback<User>() {
+ @Override
+ public void onSuccess(User result) {
+ ApplicationContext.getInstance().setUser(result);
+ }
+ });
+ }
+ }).show();
}
@Override
@@ -55,7 +68,6 @@ public class SettingsController implements DeviceView.SettingsHandler {
ApplicationContext.getInstance().setApplicationSettings(result);
}
});
-
}
}).show();
}