From 226dcdde755ad2b2b7384ac9cd59e5fcc3af550b Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 9 Aug 2016 16:25:54 +0500 Subject: - Fixed csv MIME type and added response header - Added 3 report types - Changed some Strings - Fixed jscs issues in other files --- src/org/traccar/api/resource/ReportResource.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/org') 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 deviceIds, @QueryParam("groupId") final List 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 deviceIds, @QueryParam("groupId") final List groupIds, @QueryParam("type") final List 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 deviceIds, @QueryParam("groupId") final List 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(); } } -- cgit v1.2.3