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/ArchiveController.java43
-rw-r--r--src/org/traccar/web/client/controller/DeviceController.java21
-rw-r--r--src/org/traccar/web/client/controller/MapController.java9
3 files changed, 60 insertions, 13 deletions
diff --git a/src/org/traccar/web/client/controller/ArchiveController.java b/src/org/traccar/web/client/controller/ArchiveController.java
index 598a744d..9f865b65 100644
--- a/src/org/traccar/web/client/controller/ArchiveController.java
+++ b/src/org/traccar/web/client/controller/ArchiveController.java
@@ -1,12 +1,19 @@
package org.traccar.web.client.controller;
-import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import org.traccar.web.client.Application;
+import org.traccar.web.client.model.BaseAsyncCallback;
+import org.traccar.web.client.model.PositionProperties;
import org.traccar.web.client.view.ArchiveView;
import org.traccar.web.shared.model.Device;
import org.traccar.web.shared.model.Position;
+import com.google.gwt.core.client.GWT;
+import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.widget.core.client.ContentPanel;
+import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
public class ArchiveController implements ContentController, ArchiveView.ArchiveHandler {
@@ -16,11 +23,19 @@ public class ArchiveController implements ContentController, ArchiveView.Archive
private ArchiveHandler archiveHandler;
+ private ListStore<Position> positionStore;
+
private ArchiveView archiveView;
- public ArchiveController(ArchiveHandler archiveHandler) {
+ public ArchiveController(ArchiveHandler archiveHandler, ListStore<Device> deviceStore) {
this.archiveHandler = archiveHandler;
- archiveView = new ArchiveView(this);
+ PositionProperties positionProperties = GWT.create(PositionProperties.class);
+ positionStore = new ListStore<Position>(positionProperties.id());
+ archiveView = new ArchiveView(this, positionStore, deviceStore);
+ }
+
+ public ListStore<Position> getPositionStore() {
+ return positionStore;
}
@Override
@@ -32,13 +47,29 @@ public class ArchiveController implements ContentController, ArchiveView.Archive
public void run() {
}
- public void updateDevices(Collection<Device> devices) {
+ @Override
+ public void onSelected(Position position) {
+ archiveHandler.onSelected(position);
+ }
+ @Override
+ public void onLoad(Device device, Date from, Date to) {
+ if (device != null && from != null && to != null) {
+ Application.getDataService().getPositions(device, from, to, new BaseAsyncCallback<List<Position>>() {
+ @Override
+ public void onSuccess(List<Position> result) {
+ positionStore.clear();
+ positionStore.addAll(result);
+ }
+ });
+ } else {
+ new AlertMessageBox("Error", "All form fields must be filled first").show();
+ }
}
@Override
- public void onSelected(Position position) {
- archiveHandler.onSelected(position);
+ public void onClear() {
+ positionStore.clear();
}
}
diff --git a/src/org/traccar/web/client/controller/DeviceController.java b/src/org/traccar/web/client/controller/DeviceController.java
index b24c205e..865aaeae 100644
--- a/src/org/traccar/web/client/controller/DeviceController.java
+++ b/src/org/traccar/web/client/controller/DeviceController.java
@@ -4,10 +4,13 @@ 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.client.view.DeviceDialog;
import org.traccar.web.client.view.DeviceView;
import org.traccar.web.shared.model.Device;
+import com.google.gwt.core.client.GWT;
+import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox;
@@ -26,11 +29,19 @@ public class DeviceController implements ContentController, DeviceView.DeviceHan
private DeviceHandler deviceHandler;
+ private ListStore<Device> deviceStore;
+
private DeviceView deviceView;
public DeviceController(DeviceHandler deviceHandler) {
this.deviceHandler = deviceHandler;
- deviceView = new DeviceView(this);
+ DeviceProperties deviceProperties = GWT.create(DeviceProperties.class);
+ deviceStore = new ListStore<Device>(deviceProperties.id());
+ deviceView = new DeviceView(this, deviceStore);
+ }
+
+ public ListStore<Device> getDeviceStore() {
+ return deviceStore;
}
@Override
@@ -43,7 +54,7 @@ public class DeviceController implements ContentController, DeviceView.DeviceHan
Application.getDataService().getDevices(new BaseAsyncCallback<List<Device>>() {
@Override
public void onSuccess(List<Device> result) {
- deviceView.load(result);
+ deviceStore.addAll(result);
deviceHandler.onLoad(result);
}
});
@@ -62,7 +73,7 @@ public class DeviceController implements ContentController, DeviceView.DeviceHan
Application.getDataService().addDevice(device, new BaseAsyncCallback<Device>() {
@Override
public void onSuccess(Device result) {
- deviceView.add(result);
+ deviceStore.add(result);
deviceHandler.onAdd(result);
}
});
@@ -78,7 +89,7 @@ public class DeviceController implements ContentController, DeviceView.DeviceHan
Application.getDataService().updateDevice(device, new BaseAsyncCallback<Device>() {
@Override
public void onSuccess(Device result) {
- deviceView.update(result);
+ deviceStore.update(result);
deviceHandler.onUpdate(result);
}
});
@@ -96,7 +107,7 @@ public class DeviceController implements ContentController, DeviceView.DeviceHan
Application.getDataService().removeDevice(device, new BaseAsyncCallback<Device>() {
@Override
public void onSuccess(Device result) {
- deviceView.remove(device);
+ deviceStore.remove(device);
deviceHandler.onRemove(device);
}
});
diff --git a/src/org/traccar/web/client/controller/MapController.java b/src/org/traccar/web/client/controller/MapController.java
index 5a53cf22..5ab5bbcf 100644
--- a/src/org/traccar/web/client/controller/MapController.java
+++ b/src/org/traccar/web/client/controller/MapController.java
@@ -1,9 +1,14 @@
package org.traccar.web.client.controller;
+import java.util.List;
+
+import org.traccar.web.client.Application;
import org.traccar.web.client.view.MapView;
import org.traccar.web.shared.model.Device;
+import org.traccar.web.shared.model.Position;
import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.sencha.gxt.widget.core.client.ContentPanel;
public class MapController implements ContentController {
@@ -36,7 +41,7 @@ public class MapController implements ContentController {
public void update() {
updateTimer.cancel();
- /*Application.getDataService().getLatestPositions(new AsyncCallback<List<Position>>() {
+ Application.getDataService().getLatestPositions(new AsyncCallback<List<Position>>() {
@Override
public void onSuccess(List<Position> result) {
mapView.showPositions(result);
@@ -46,7 +51,7 @@ public class MapController implements ContentController {
public void onFailure(Throwable caught) {
updateTimer.schedule(UPDATE_INTERVAL);
}
- });*/
+ });
}
public void select(Device device) {