aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/web/client/i18n/ApplicationConstants.java55
-rw-r--r--src/main/java/org/traccar/web/client/view/ArchivePanel.java64
-rw-r--r--src/main/java/org/traccar/web/client/view/DevicePanel.java111
-rw-r--r--src/main/java/org/traccar/web/client/view/MapPanel.java95
4 files changed, 325 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/web/client/i18n/ApplicationConstants.java b/src/main/java/org/traccar/web/client/i18n/ApplicationConstants.java
new file mode 100644
index 00000000..d11781b0
--- /dev/null
+++ b/src/main/java/org/traccar/web/client/i18n/ApplicationConstants.java
@@ -0,0 +1,55 @@
+package org.traccar.web.client.i18n;
+
+import com.google.gwt.i18n.client.Constants;
+
+public interface ApplicationConstants extends Constants {
+
+ @DefaultStringValue("User Authentication")
+ String userAuthentication();
+
+ @DefaultStringValue("Login")
+ String login();
+
+ @DefaultStringValue("Password")
+ String password();
+
+ @DefaultStringValue("Register")
+ String register();
+
+ @DefaultStringValue("Login and password fields must not be blank")
+ String blankLoginPassword();
+
+ @DefaultStringValue("Remote procedure call error")
+ String remoteProcedureCallError();
+
+ @DefaultStringValue("Invalid login or password")
+ String invalidLoginPassword();
+
+ @DefaultStringValue("Registration failed")
+ String registrationError();
+
+ @DefaultStringValue("Devices")
+ String devices();
+
+ @DefaultStringValue("Add")
+ String add();
+
+ @DefaultStringValue("Remove")
+ String remove();
+
+ @DefaultStringValue("Edit")
+ String edit();
+
+ @DefaultStringValue("Settings")
+ String settings();
+
+ @DefaultStringValue("Object")
+ String object();
+
+ @DefaultStringValue("Unique Identifier")
+ String id();
+
+ @DefaultStringValue("Name")
+ String name();
+
+}
diff --git a/src/main/java/org/traccar/web/client/view/ArchivePanel.java b/src/main/java/org/traccar/web/client/view/ArchivePanel.java
new file mode 100644
index 00000000..b2ce329d
--- /dev/null
+++ b/src/main/java/org/traccar/web/client/view/ArchivePanel.java
@@ -0,0 +1,64 @@
+package org.traccar.web.client.view;
+
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.layout.SectionStack;
+import com.smartgwt.client.widgets.layout.SectionStackSection;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.DateTimeItem;
+import com.smartgwt.client.widgets.toolbar.ToolStripButton;
+
+/**
+ * Archive widget
+ */
+public class ArchivePanel extends SectionStack {
+
+ private ToolStrip toolbar;
+ private ListGrid list;
+
+ public ArchivePanel() {
+ SectionStackSection section = new SectionStackSection("Archive");
+ section.setCanCollapse(false);
+ section.setExpanded(true);
+
+ toolbar = new ToolStrip();
+ toolbar.setWidth100();
+
+ SelectItem deviceSelect = new SelectItem("device", "Device");
+ //fontItem.setShowTitle(false);
+ //fontItem.setWidth(120);
+ toolbar.addFormItem(deviceSelect);
+ toolbar.addSeparator();
+
+ DateTimeItem from = new DateTimeItem("from", "From");
+ toolbar.addFormItem(from);
+ toolbar.addSeparator();
+ DateTimeItem to = new DateTimeItem("to", "To");
+ toolbar.addFormItem(to);
+ toolbar.addSeparator();
+
+ ToolStripButton button = new ToolStripButton();
+ button.setTitle("Load");
+ toolbar.addButton(button);
+
+ list = new ListGrid();
+ list.setFields(
+ new ListGridField("deviceId", "Device Id"),
+ new ListGridField("time", "Time"),
+ new ListGridField("valid", "Valid"),
+ new ListGridField("latitude", "Latitude"),
+ new ListGridField("longitude", "Longitude"),
+ new ListGridField("speed", "Speed"),
+ new ListGridField("course", "Course"),
+ new ListGridField("power", "Power"));
+
+ list.setCanSort(false);
+ list.setShowHeaderContextMenu(false);
+ list.setShowHeaderMenuButton(false);
+
+ section.setItems(toolbar, list);
+ setSections(section);
+ }
+
+}
diff --git a/src/main/java/org/traccar/web/client/view/DevicePanel.java b/src/main/java/org/traccar/web/client/view/DevicePanel.java
new file mode 100644
index 00000000..4296a25a
--- /dev/null
+++ b/src/main/java/org/traccar/web/client/view/DevicePanel.java
@@ -0,0 +1,111 @@
+package org.traccar.web.client.view;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.traccar.web.client.i18n.ApplicationConstants;
+import org.traccar.web.shared.model.Device;
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.layout.SectionStack;
+import com.smartgwt.client.widgets.layout.SectionStackSection;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+import com.smartgwt.client.widgets.toolbar.ToolStripButton;
+
+/**
+ * Device list widget
+ */
+public class DevicePanel extends SectionStack {
+
+ private static final ApplicationConstants constants = GWT.create(ApplicationConstants.class);
+
+ private static final String COLUMN_OBJECT = "object";
+ private static final String COLUMN_NAME = "name";
+ private static final String COLUMN_ID = "id";
+
+ private ToolStrip toolbar;
+
+ private ToolStripButton buttonAdd;
+ private ToolStripButton buttonRemove;
+ private ToolStripButton buttonEdit;
+ private ToolStripButton buttonSettings;
+
+ private ListGrid list;
+
+ public DevicePanel() {
+ SectionStackSection section = new SectionStackSection(constants.devices());
+ section.setCanCollapse(false);
+ section.setExpanded(true);
+
+ toolbar = new ToolStrip();
+ toolbar.setWidth100();
+
+ buttonAdd = new ToolStripButton();
+ buttonAdd.setTitle(constants.add());
+ toolbar.addButton(buttonAdd);
+
+ buttonRemove = new ToolStripButton();
+ buttonRemove.setTitle(constants.remove());
+ toolbar.addButton(buttonRemove);
+
+ buttonEdit = new ToolStripButton();
+ buttonEdit.setTitle(constants.edit());
+ toolbar.addButton(buttonEdit);
+
+ toolbar.addFill();
+ toolbar.addSeparator();
+
+ buttonSettings = new ToolStripButton();
+ buttonSettings.setTitle(constants.settings());
+ toolbar.addButton(buttonSettings);
+
+ list = new ListGrid();
+ list.setFields(
+ new ListGridField(COLUMN_NAME, constants.name()),
+ new ListGridField(COLUMN_ID, constants.id()));
+
+ list.setCanSort(false);
+ list.setShowHeaderContextMenu(false);
+ list.setShowHeaderMenuButton(false);
+
+ section.setItems(toolbar, list);
+ setSections(section);
+ }
+
+ public void setAddClickHandler(ClickHandler handler) {
+ buttonAdd.addClickHandler(handler);
+ }
+
+ public void setRemoveClickHandler(ClickHandler handler) {
+ buttonRemove.addClickHandler(handler);
+ }
+
+ public void setEditClickHandler(ClickHandler handler) {
+ buttonEdit.addClickHandler(handler);
+ }
+
+ public void setSettingsClickHandler(ClickHandler handler) {
+ buttonSettings.addClickHandler(handler);
+ }
+
+ public void updateDevices(List<Device> devices) {
+ // TODO: clear
+
+ for (Device device : devices) {
+ Map<String, Object> map = new HashMap<String, Object>();
+ //map.put(COLUMN_OBJECT, device);
+ map.put(COLUMN_NAME, device.getName());
+ map.put(COLUMN_ID, device.getUniqueId());
+
+ Record record = new Record(map);
+ list.addData(record);
+ }
+ }
+
+
+}
diff --git a/src/main/java/org/traccar/web/client/view/MapPanel.java b/src/main/java/org/traccar/web/client/view/MapPanel.java
new file mode 100644
index 00000000..1b883760
--- /dev/null
+++ b/src/main/java/org/traccar/web/client/view/MapPanel.java
@@ -0,0 +1,95 @@
+package org.traccar.web.client.view;
+
+import org.gwtopenmaps.openlayers.client.LonLat;
+import org.gwtopenmaps.openlayers.client.Map;
+import org.gwtopenmaps.openlayers.client.MapOptions;
+import org.gwtopenmaps.openlayers.client.MapWidget;
+import org.gwtopenmaps.openlayers.client.Projection;
+import org.gwtopenmaps.openlayers.client.control.ScaleLine;
+import org.gwtopenmaps.openlayers.client.layer.OSM;
+
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.smartgwt.client.widgets.WidgetCanvas;
+import com.smartgwt.client.widgets.events.DrawEvent;
+import com.smartgwt.client.widgets.events.DrawHandler;
+import com.smartgwt.client.widgets.events.ResizedEvent;
+import com.smartgwt.client.widgets.events.ResizedHandler;
+import com.smartgwt.client.widgets.layout.SectionStack;
+import com.smartgwt.client.widgets.layout.SectionStackSection;
+
+/**
+ * Map panel widget
+ */
+public class MapPanel extends SectionStack {
+
+ private final static int BORDER_SIZE = 1;
+
+ private MapWidget mapWidget;
+ private WidgetCanvas mapWrapper;
+
+ private MapWidget createMapWidget() {
+ MapOptions defaultMapOptions = new MapOptions();
+ defaultMapOptions.setNumZoomLevels(16);
+
+ MapWidget mapWidget = new MapWidget("100%", "100%", defaultMapOptions);
+
+ // Google layer
+ /*GoogleV3Options layerOptiond = new GoogleV3Options();
+ layerOptiond.setIsBaseLayer(true);
+ layerOptiond.setType(GoogleV3MapType.G_NORMAL_MAP);
+ GoogleV3 layer = new GoogleV3("Google", layerOptiond);*/
+
+ // Open Street Map layer
+ OSM layer = OSM.Mapnik("Mapnik");
+ layer.setIsBaseLayer(true);
+
+ Map map = mapWidget.getMap();
+ map.addLayer(layer);
+ map.addControl(new ScaleLine());
+
+ // Default center
+ LonLat lonLat = new LonLat(12.5, 41.9);
+ lonLat.transform(new Projection("EPSG:4326").getProjectionCode(), map.getProjection());
+ map.setCenter(lonLat, 1);
+
+ return mapWidget;
+ }
+
+ public MapPanel() {
+ SectionStackSection section = new SectionStackSection("Map");
+ section.setCanCollapse(false);
+ section.setExpanded(true);
+
+ mapWidget = createMapWidget();
+
+ mapWrapper = new WidgetCanvas(mapWidget);
+ mapWrapper.setStyleName("defaultBorder");
+ mapWrapper.setHeight100();
+ mapWrapper.setWidth100();
+
+ // Map widget size hack
+ mapWrapper.addDrawHandler(new DrawHandler() {
+ @Override
+ public void onDraw(DrawEvent event) {
+ Element e = DOM.getElementById(mapWrapper.getID() + "_widget");
+ if (e.getParentNode() != null) {
+ e.getParentElement().getStyle().setProperty("width", "100%");
+ e.getParentElement().getStyle().setProperty("height", "100%");
+ }
+ }
+ });
+
+ // Map resize handler
+ mapWrapper.addResizedHandler(new ResizedHandler() {
+ @Override
+ public void onResized(ResizedEvent event) {
+ mapWidget.getMap().updateSize();
+ }
+ });
+
+ section.setItems(mapWrapper);
+ setSections(section);
+ }
+
+}