aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/resource/ReportResource.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-08-09 16:25:54 +0500
committerAbyss777 <abyss@fox5.ru>2016-08-09 16:25:54 +0500
commit226dcdde755ad2b2b7384ac9cd59e5fcc3af550b (patch)
treec9c4494d9ea55a0173d4ddaf3eb4b07a1c8dc6f3 /src/org/traccar/api/resource/ReportResource.java
parent7a6de316942316466622f9bfa64691c4ba433b88 (diff)
downloadtrackermap-server-226dcdde755ad2b2b7384ac9cd59e5fcc3af550b.tar.gz
trackermap-server-226dcdde755ad2b2b7384ac9cd59e5fcc3af550b.tar.bz2
trackermap-server-226dcdde755ad2b2b7384ac9cd59e5fcc3af550b.zip
- Fixed csv MIME type and added response header
- Added 3 report types - Changed some Strings - Fixed jscs issues in other files
Diffstat (limited to 'src/org/traccar/api/resource/ReportResource.java')
-rw-r--r--src/org/traccar/api/resource/ReportResource.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/org/traccar/api/resource/ReportResource.java b/src/org/traccar/api/resource/ReportResource.java
index 8682070b1..0dc9ab6a4 100644
--- a/src/org/traccar/api/resource/ReportResource.java
+++ b/src/org/traccar/api/resource/ReportResource.java
@@ -32,12 +32,14 @@ public class ReportResource extends BaseResource {
@Path("route")
@GET
- @Produces("application/ms-excel")
+ @Produces("text/csv")
public Response getRouteCsv(
@QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds,
@QueryParam("from") String from, @QueryParam("to") String to) throws SQLException {
return Response.ok(Route.getCsv(getUserId(), deviceIds, groupIds,
- JsonConverter.parseDate(from), JsonConverter.parseDate(to))).build();
+ JsonConverter.parseDate(from), JsonConverter.parseDate(to)))
+ .header("Content-Disposition", "attachment; filename=route.csv")
+ .build();
}
@Path("events")
@@ -53,13 +55,15 @@ public class ReportResource extends BaseResource {
@Path("events")
@GET
- @Produces("application/ms-excel")
+ @Produces("text/csv")
public Response getEventsCsv(
@QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds,
@QueryParam("type") final List<String> types,
@QueryParam("from") String from, @QueryParam("to") String to) throws SQLException {
return Response.ok(Events.getCsv(getUserId(), deviceIds, groupIds,
- types, JsonConverter.parseDate(from), JsonConverter.parseDate(to))).build();
+ types, JsonConverter.parseDate(from), JsonConverter.parseDate(to)))
+ .header("Content-Disposition", "attachment; filename=events.csv")
+ .build();
}
@Path("summary")
@@ -74,12 +78,14 @@ public class ReportResource extends BaseResource {
@Path("summary")
@GET
- @Produces("application/ms-excel")
+ @Produces("text/csv")
public Response getSummaryCsv(
@QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds,
@QueryParam("from") String from, @QueryParam("to") String to) throws SQLException {
return Response.ok(Summary.getCsv(getUserId(), deviceIds, groupIds,
- JsonConverter.parseDate(from), JsonConverter.parseDate(to))).build();
+ JsonConverter.parseDate(from), JsonConverter.parseDate(to)))
+ .header("Content-Disposition", "attachment; filename=summary.csv")
+ .build();
}
}