aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-11-19 23:21:07 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2012-11-19 23:21:07 +1300
commitcc06b3e29802b23b5c81270eec4133fa5d7b688d (patch)
treed6ed69d40d38243baeafe2ac75f3f34b257a5881 /src/main
parente081b313c717c1fb60a93f07613253f73b8cc933 (diff)
downloadetbsa-traccar-web-cc06b3e29802b23b5c81270eec4133fa5d7b688d.tar.gz
etbsa-traccar-web-cc06b3e29802b23b5c81270eec4133fa5d7b688d.tar.bz2
etbsa-traccar-web-cc06b3e29802b23b5c81270eec4133fa5d7b688d.zip
Create login controller
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/web/client/Traccar.java79
1 files changed, 8 insertions, 71 deletions
diff --git a/src/main/java/org/traccar/web/client/Traccar.java b/src/main/java/org/traccar/web/client/Traccar.java
index ca7cb3f..34a185d 100644
--- a/src/main/java/org/traccar/web/client/Traccar.java
+++ b/src/main/java/org/traccar/web/client/Traccar.java
@@ -1,21 +1,13 @@
package org.traccar.web.client;
-import java.util.List;
-
-import org.traccar.web.client.database.DatabaseService;
-import org.traccar.web.client.database.DatabaseServiceAsync;
-import org.traccar.web.client.login.LoginDialog;
-import org.traccar.web.shared.model.Device;
-
import com.google.gwt.core.client.EntryPoint;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.util.SC;
+import org.traccar.web.client.login.LoginController;
/**
* Entry point class
*/
-public class Traccar implements EntryPoint {
+public class Traccar implements EntryPoint, LoginController.LoginHandler {
private DevicePanel devicePanel;
private ArchivePanel archivePanel;
@@ -26,68 +18,8 @@ public class Traccar implements EntryPoint {
*/
@Override
public void onModuleLoad() {
+ new LoginController().login(this);
- final DatabaseServiceAsync databaseService = GWT.create(DatabaseService.class);
-
- final AsyncCallback<List<Device>> callback2 = new AsyncCallback<List<Device>>() {
- @Override
- public void onFailure(Throwable caught) {
- SC.say("onFailure2: " + caught.toString());
- }
- @Override
- public void onSuccess(List<Device> result) {
- String s = "";
- if (result!= null) {
- for (Device d : result) {
- s += d.getName() + " ";
- }
- }
- SC.say("Devices: " + s);
- }
- };
-
- final AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>() {
- @Override
- public void onFailure(Throwable caught) {
- SC.say("onFailure: " + caught.toString());
- }
-
- @Override
- public void onSuccess(Boolean result) {
- databaseService.getDevices(callback2);
- }
- };
-
- final LoginDialog loginDialog = new LoginDialog();
-
- loginDialog.setLoginHandler(new LoginDialog.LoginHandler() {
- private boolean validate(String login, String password) {
- if (login == null || login.isEmpty() || password == null || password.isEmpty()) {
- SC.warn("Login and password fields must not be blank");
- return false;
- }
- return true;
- }
-
- @Override
- public void onLogin(String login, String password) {
- if (validate(login, password)) {
- loginDialog.destroy();
- databaseService.authenticate(login, password, callback);
- }
- }
-
- @Override
- public void onRegister(String login, String password) {
- if (validate(login, password)) {
- loginDialog.destroy();
- databaseService.register(login, password, callback);
- }
- }
- });
-
- loginDialog.draw();
- loginDialog.centerInPage();
/*devicePanel = new DevicePanel();
devicePanel.setWidth("20%");
@@ -113,4 +45,9 @@ public class Traccar implements EntryPoint {
mainLayout.addMember(archivePanel);
mainLayout.draw();*/
}
+
+ @Override
+ public void onLogin() {
+ SC.warn("Woooohooo");
+ }
}