aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--database/changelog-3.6.xml2
-rw-r--r--setup/unix/traccar.xml6
-rw-r--r--setup/windows/traccar.xml6
-rw-r--r--src/org/traccar/api/resource/EventResource.java2
-rw-r--r--src/org/traccar/model/Event.java20
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java14
-rw-r--r--web/app/view/MapController.js2
-rw-r--r--web/app/view/ReportController.js34
8 files changed, 48 insertions, 38 deletions
diff --git a/database/changelog-3.6.xml b/database/changelog-3.6.xml
index f61755f36..378ec741f 100644
--- a/database/changelog-3.6.xml
+++ b/database/changelog-3.6.xml
@@ -14,7 +14,7 @@
<column name="type" type="VARCHAR(128)">
<constraints nullable="false" />
</column>
- <column name="eventtime" type="TIMESTAMP">
+ <column name="servertime" type="TIMESTAMP">
<constraints nullable="false" />
</column>
<column name="deviceid" type="INT" />
diff --git a/setup/unix/traccar.xml b/setup/unix/traccar.xml
index 22b71e204..a0233e601 100644
--- a/setup/unix/traccar.xml
+++ b/setup/unix/traccar.xml
@@ -177,12 +177,12 @@
</entry>
<entry key='database.insertEvent'>
- INSERT INTO events (type, eventTime, deviceId, positionId, attributes)
- VALUES (:type, :eventTime, :deviceId, :positionId, :attributes);
+ INSERT INTO events (type, serverTime, deviceId, positionId, attributes)
+ VALUES (:type, :serverTime, :deviceId, :positionId, :attributes);
</entry>
<entry key='database.selectEvents'>
- SELECT * FROM events WHERE deviceId = :deviceId AND type LIKE :type AND eventTime BETWEEN :from AND :to ORDER BY eventTime DESC;
+ SELECT * FROM events WHERE deviceId = :deviceId AND type LIKE :type AND serverTime BETWEEN :from AND :to ORDER BY serverTime DESC;
</entry>
<!-- PROTOCOL CONFIG -->
diff --git a/setup/windows/traccar.xml b/setup/windows/traccar.xml
index 649c3bb15..5748f3993 100644
--- a/setup/windows/traccar.xml
+++ b/setup/windows/traccar.xml
@@ -177,12 +177,12 @@
</entry>
<entry key='database.insertEvent'>
- INSERT INTO events (type, eventTime, deviceId, positionId, attributes)
- VALUES (:type, :eventTime, :deviceId, :positionId, :attributes);
+ INSERT INTO events (type, serverTime, deviceId, positionId, attributes)
+ VALUES (:type, :serverTime, :deviceId, :positionId, :attributes);
</entry>
<entry key='database.selectEvents'>
- SELECT * FROM events WHERE deviceId = :deviceId AND type LIKE :type AND eventTime BETWEEN :from AND :to ORDER BY eventTime DESC;
+ SELECT * FROM events WHERE deviceId = :deviceId AND type LIKE :type AND serverTime BETWEEN :from AND :to ORDER BY serverTime DESC;
</entry>
<!-- PROTOCOL CONFIG -->
diff --git a/src/org/traccar/api/resource/EventResource.java b/src/org/traccar/api/resource/EventResource.java
index 4ea3e3b49..74a748ea5 100644
--- a/src/org/traccar/api/resource/EventResource.java
+++ b/src/org/traccar/api/resource/EventResource.java
@@ -35,5 +35,5 @@ public class EventResource extends BaseResource {
@QueryParam("interval") int interval) throws SQLException {
Context.getPermissionsManager().checkDevice(getUserId(), deviceId);
return Context.getDataManager().getLastEvents(deviceId, type, interval);
- }
+ }
}
diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java
index 75049c433..6de885c70 100644
--- a/src/org/traccar/model/Event.java
+++ b/src/org/traccar/model/Event.java
@@ -8,13 +8,13 @@ public class Event extends Message {
this.setType(type);
this.setDeviceId(deviceId);
this.setPositionId(positionId);
- this.eventTime = new Date();
+ this.serverTime = new Date();
}
public Event(String type, long deviceId) {
this.setType(type);
this.setDeviceId(deviceId);
- this.eventTime = new Date();
+ this.serverTime = new Date();
}
public Event() {
@@ -43,21 +43,21 @@ public class Event extends Message {
public static final String TYPE_GEOFENCE_ENTER = "geofenceEnter";
public static final String TYPE_GEOFENCE_EXIT = "geofenceExit";
- private Date eventTime;
+ private Date serverTime;
- public Date getEventTime() {
- if (eventTime != null) {
- return new Date(eventTime.getTime());
+ public Date getServerTime() {
+ if (serverTime != null) {
+ return new Date(serverTime.getTime());
} else {
return null;
}
}
- public void setEventTime(Date eventTime) {
- if (eventTime != null) {
- this.eventTime = new Date(eventTime.getTime());
+ public void setServerTime(Date serverTime) {
+ if (serverTime != null) {
+ this.serverTime = new Date(serverTime.getTime());
} else {
- this.eventTime = null;
+ this.serverTime = null;
}
}
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index 9512910f2..36378d088 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -170,10 +170,16 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- if (Context.getConfig().getBoolean(getProtocolName() + ".mph")) {
- position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble()));
- } else {
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ switch (Context.getConfig().getString(getProtocolName() + ".speed", "kmh")) {
+ case "kn":
+ position.setSpeed(parser.nextDouble());
+ break;
+ case "mph":
+ position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble()));
+ break;
+ default:
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ break;
}
dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js
index b8b7290b8..eee74099f 100644
--- a/web/app/view/MapController.js
+++ b/web/app/view/MapController.js
@@ -176,6 +176,8 @@ Ext.define('Traccar.view.MapController', {
this.reportRoute.getGeometry().appendCoordinate(point);
}
+
+ this.getView().getMapView().fit(this.reportRoute.getGeometry(), this.getView().getMap().getSize());
},
clearReport: function (store) {
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js
index 9c2abcc71..4fe7c62b8 100644
--- a/web/app/view/ReportController.js
+++ b/web/app/view/ReportController.js
@@ -37,25 +37,27 @@ Ext.define('Traccar.view.ReportController', {
fromDate = this.lookupReference('fromDateField').getValue();
fromTime = this.lookupReference('fromTimeField').getValue();
- from = new Date(
- fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate(),
- fromTime.getHours(), fromTime.getMinutes(), fromTime.getSeconds(), fromTime.getMilliseconds());
+ if (deviceId) {
+ from = new Date(
+ fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate(),
+ fromTime.getHours(), fromTime.getMinutes(), fromTime.getSeconds(), fromTime.getMilliseconds());
- toDate = this.lookupReference('toDateField').getValue();
- toTime = this.lookupReference('toTimeField').getValue();
+ toDate = this.lookupReference('toDateField').getValue();
+ toTime = this.lookupReference('toTimeField').getValue();
- to = new Date(
- toDate.getFullYear(), toDate.getMonth(), toDate.getDate(),
- toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds());
+ to = new Date(
+ toDate.getFullYear(), toDate.getMonth(), toDate.getDate(),
+ toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds());
- store = Ext.getStore('Positions');
- store.load({
- params: {
- deviceId: deviceId,
- from: from.toISOString(),
- to: to.toISOString()
- }
- });
+ store = Ext.getStore('Positions');
+ store.load({
+ params: {
+ deviceId: deviceId,
+ from: from.toISOString(),
+ to: to.toISOString()
+ }
+ });
+ }
},
onClearClick: function () {