aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-01-11 19:48:19 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-01-11 19:48:19 +1300
commit47cea42e319176aa69decc43e8d8074374ff0c4b (patch)
tree604850f3300e00bdd3a33735338949f2a9d39dfe /src/org
parent3defcd30d7ef7c10c82561b955c9e4e4fba789bf (diff)
downloadetbsa-traccar-web-47cea42e319176aa69decc43e8d8074374ff0c4b.tar.gz
etbsa-traccar-web-47cea42e319176aa69decc43e8d8074374ff0c4b.tar.bz2
etbsa-traccar-web-47cea42e319176aa69decc43e8d8074374ff0c4b.zip
Add logout button
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/web/client/controller/LoginController.java2
-rw-r--r--src/org/traccar/web/client/model/DataService.java4
-rw-r--r--src/org/traccar/web/client/model/DataServiceAsync.java6
-rw-r--r--src/org/traccar/web/client/view/DeviceView.java13
-rw-r--r--src/org/traccar/web/client/view/DeviceView.ui.xml3
-rw-r--r--src/org/traccar/web/client/view/MapView.java6
-rw-r--r--src/org/traccar/web/server/model/DataServiceImpl.java14
7 files changed, 35 insertions, 13 deletions
diff --git a/src/org/traccar/web/client/controller/LoginController.java b/src/org/traccar/web/client/controller/LoginController.java
index ceda85c..6f3bc56 100644
--- a/src/org/traccar/web/client/controller/LoginController.java
+++ b/src/org/traccar/web/client/controller/LoginController.java
@@ -43,7 +43,7 @@ public class LoginController implements LoginDialog.LoginHandler {
@Override
public void onLogin(String login, String password) {
if (validate(login, password)) {
- Application.getDataService().authenticate(login, password, new BaseAsyncCallback<Boolean>() {
+ Application.getDataService().login(login, password, new BaseAsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if (result) {
diff --git a/src/org/traccar/web/client/model/DataService.java b/src/org/traccar/web/client/model/DataService.java
index d8d7152..d3a9ea7 100644
--- a/src/org/traccar/web/client/model/DataService.java
+++ b/src/org/traccar/web/client/model/DataService.java
@@ -14,7 +14,9 @@ public interface DataService extends RemoteService {
boolean authenticated();
- boolean authenticate(String login, String password);
+ boolean login(String login, String password);
+
+ boolean logout();
boolean register(String login, String password);
diff --git a/src/org/traccar/web/client/model/DataServiceAsync.java b/src/org/traccar/web/client/model/DataServiceAsync.java
index 357beb5..51a419c 100644
--- a/src/org/traccar/web/client/model/DataServiceAsync.java
+++ b/src/org/traccar/web/client/model/DataServiceAsync.java
@@ -10,10 +10,12 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
public interface DataServiceAsync {
- void authenticate(String login, String password, AsyncCallback<Boolean> callback);
-
void authenticated(AsyncCallback<Boolean> callback);
+ void login(String login, String password, AsyncCallback<Boolean> callback);
+
+ void logout(AsyncCallback<Boolean> callback);
+
void register(String login, String password, AsyncCallback<Boolean> callback);
void getDevices(AsyncCallback<List<Device>> callback);
diff --git a/src/org/traccar/web/client/view/DeviceView.java b/src/org/traccar/web/client/view/DeviceView.java
index 1213e5f..76c773d 100644
--- a/src/org/traccar/web/client/view/DeviceView.java
+++ b/src/org/traccar/web/client/view/DeviceView.java
@@ -3,6 +3,8 @@ package org.traccar.web.client.view;
import java.util.LinkedList;
import java.util.List;
+import org.traccar.web.client.Application;
+import org.traccar.web.client.model.BaseAsyncCallback;
import org.traccar.web.client.model.DeviceProperties;
import org.traccar.web.shared.model.Device;
@@ -10,6 +12,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.data.shared.ListStore;
@@ -106,4 +109,14 @@ public class DeviceView implements SelectionChangedEvent.SelectionChangedHandler
deviceHandler.onRemove(grid.getSelectionModel().getSelectedItem());
}
+ @UiHandler("logoutButton")
+ public void onLogoutClicked(SelectEvent event) {
+ Application.getDataService().logout(new BaseAsyncCallback<Boolean>() {
+ @Override
+ public void onSuccess(Boolean result) {
+ Window.Location.reload();
+ }
+ });
+ }
+
}
diff --git a/src/org/traccar/web/client/view/DeviceView.ui.xml b/src/org/traccar/web/client/view/DeviceView.ui.xml
index af1b33c..77de651 100644
--- a/src/org/traccar/web/client/view/DeviceView.ui.xml
+++ b/src/org/traccar/web/client/view/DeviceView.ui.xml
@@ -33,7 +33,8 @@
<toolbar:FillToolItem />
<toolbar:SeparatorToolItem />
<button:TextButton ui:field="settingsButton" text="Settings" enabled="false" />
- </toolbar:ToolBar>
+ <button:TextButton ui:field="logoutButton" text="Logout" />
+ </toolbar:ToolBar>
</container:child>
<container:child layoutData="{layoutData}">
diff --git a/src/org/traccar/web/client/view/MapView.java b/src/org/traccar/web/client/view/MapView.java
index a7d1dad..70558b6 100644
--- a/src/org/traccar/web/client/view/MapView.java
+++ b/src/org/traccar/web/client/view/MapView.java
@@ -23,8 +23,6 @@ import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.user.client.Command;
import com.sencha.gxt.widget.core.client.ContentPanel;
-
-
public class MapView {
private ContentPanel contentPanel;
@@ -68,8 +66,6 @@ public class MapView {
MapOptions defaultMapOptions = new MapOptions();
defaultMapOptions.setNumZoomLevels(16);
- defaultMapOptions.setProjection("EPSG:4326");
- defaultMapOptions.setDisplayProjection(new Projection("EPSG:4326"));
mapWidget = new MapWidget("100%", "100%", defaultMapOptions);
map = mapWidget.getMap();
@@ -78,11 +74,9 @@ public class MapView {
mapLayer.setIsBaseLayer(true);
VectorOptions vectorOptions = new VectorOptions();
- vectorOptions.setProjection("EPSG:4326");
vectorLayer = new Vector("Vector", vectorOptions);
MarkersOptions markersOptions = new MarkersOptions();
- markersOptions.setProjection("EPSG:4326");
markerLayer = new Markers("Markers", markersOptions);
map.addLayer(mapLayer);
diff --git a/src/org/traccar/web/server/model/DataServiceImpl.java b/src/org/traccar/web/server/model/DataServiceImpl.java
index 9c69b48..01ab316 100644
--- a/src/org/traccar/web/server/model/DataServiceImpl.java
+++ b/src/org/traccar/web/server/model/DataServiceImpl.java
@@ -55,7 +55,11 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService
private void setUser(User user) {
HttpSession session = getThreadLocalRequest().getSession();
- session.setAttribute(ATTRIBUTE_USER, user);
+ if (user != null) {
+ session.setAttribute(ATTRIBUTE_USER, user);
+ } else {
+ session.removeAttribute(ATTRIBUTE_USER);
+ }
}
private User getUser() {
@@ -69,7 +73,7 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService
}
@Override
- public boolean authenticate(String login, String password) {
+ public boolean login(String login, String password) {
TypedQuery<User> query = entityManager.createQuery(
"SELECT x FROM User x WHERE x.login = :login", User.class);
query.setParameter("login", login);
@@ -83,6 +87,12 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService
}
@Override
+ public boolean logout() {
+ setUser(null);
+ return true;
+ }
+
+ @Override
public boolean register(String login, String password) {
User user = new User();
user.setLogin(login);