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 --- web/l10n/en.json | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'web/l10n') diff --git a/web/l10n/en.json b/web/l10n/en.json index 37e4537f2..3c30353ac 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -24,6 +24,8 @@ "sharedAttribute": "Attribute", "sharedArea": "Area", "sharedMute": "Mute", + "sharedType": "Type", + "sharedDistance": "Distance", "errorTitle": "Error", "errorUnknown": "Unknown error", "errorConnection": "Connection error", @@ -53,7 +55,6 @@ "settingsGroups": "Groups", "settingsServer": "Server", "settingsUsers": "Users", - "settingsDistanceUnit": "Distance", "settingsSpeedUnit": "Speed", "settingsTwelveHourFormat": "12-hour Format", "reportTitle": "Reports", @@ -89,7 +90,6 @@ "stateValue": "Value", "commandTitle": "Command", "commandSend": "Send", - "commandType": "Type", "commandSent": "Command has been sent", "commandPositionPeriodic": "Periodic Reporting", "commandPositionStop": "Stop Reporting", @@ -132,5 +132,12 @@ "alarmFault": "Fault Alarm", "notificationType": "Type of Notification", "notificationWeb": "Send via Web", - "notificationMail": "Send via Mail" + "notificationMail": "Send via Mail", + "reportRoute": "Route", + "reportEvents": "Events", + "reportSummary": "Summary", + "reportCsv": "Csv", + "reportDeviceName": "Device Name", + "summaryAverageSpeed": "Average Speed", + "summaryMaximumSpeed": "Maximum Speed" } \ No newline at end of file -- cgit v1.2.3 From a2caa60c024e2cf858ed4f7ed1c4afcfdb7b523b Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 10 Aug 2016 13:52:56 +0500 Subject: - Used constants in ReportResource - Renamed variables and functions in ReportController - Changed Strings - Fixed year --- src/org/traccar/api/resource/ReportResource.java | 23 +++++++++++++---------- web/app/model/ReportSummary.js | 2 +- web/app/view/ReportController.js | 24 ++++++++++++------------ web/l10n/en.json | 6 +++--- 4 files changed, 29 insertions(+), 26 deletions(-) (limited to 'web/l10n') diff --git a/src/org/traccar/api/resource/ReportResource.java b/src/org/traccar/api/resource/ReportResource.java index 0dc9ab6a4..d5687c741 100644 --- a/src/org/traccar/api/resource/ReportResource.java +++ b/src/org/traccar/api/resource/ReportResource.java @@ -17,12 +17,15 @@ import org.traccar.reports.Route; import org.traccar.web.JsonConverter; @Path("reports") -@Consumes("application/json") +@Consumes(javax.ws.rs.core.MediaType.APPLICATION_JSON) public class ReportResource extends BaseResource { + public static final String TEXT_CSV = "text/csv"; + public static final String CONTENT_DISPOSITION_VALUE = "attachment; filename=report.csv"; + @Path("route") @GET - @Produces("application/json") + @Produces(javax.ws.rs.core.MediaType.APPLICATION_JSON) public Response getRouteJson( @QueryParam("deviceId") final List deviceIds, @QueryParam("groupId") final List groupIds, @QueryParam("from") String from, @QueryParam("to") String to) throws SQLException { @@ -32,19 +35,19 @@ public class ReportResource extends BaseResource { @Path("route") @GET - @Produces("text/csv") + @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))) - .header("Content-Disposition", "attachment; filename=route.csv") + .header(javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION, CONTENT_DISPOSITION_VALUE) .build(); } @Path("events") @GET - @Produces("application/json") + @Produces(javax.ws.rs.core.MediaType.APPLICATION_JSON) public Response getEventsJson( @QueryParam("deviceId") final List deviceIds, @QueryParam("groupId") final List groupIds, @QueryParam("type") final List types, @@ -55,20 +58,20 @@ public class ReportResource extends BaseResource { @Path("events") @GET - @Produces("text/csv") + @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))) - .header("Content-Disposition", "attachment; filename=events.csv") + .header(javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION, CONTENT_DISPOSITION_VALUE) .build(); } @Path("summary") @GET - @Produces("application/json") + @Produces(javax.ws.rs.core.MediaType.APPLICATION_JSON) public Response getSummaryJson( @QueryParam("deviceId") final List deviceIds, @QueryParam("groupId") final List groupIds, @QueryParam("from") String from, @QueryParam("to") String to) throws SQLException { @@ -78,13 +81,13 @@ public class ReportResource extends BaseResource { @Path("summary") @GET - @Produces("text/csv") + @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))) - .header("Content-Disposition", "attachment; filename=summary.csv") + .header(javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION, CONTENT_DISPOSITION_VALUE) .build(); } diff --git a/web/app/model/ReportSummary.js b/web/app/model/ReportSummary.js index 816dc76ab..7821e1c00 100644 --- a/web/app/model/ReportSummary.js +++ b/web/app/model/ReportSummary.js @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 7ff994202..ecc7b0f91 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -63,7 +63,7 @@ Ext.define('Traccar.view.ReportController', { }); } else if (button.reference === "csvButton") { url = this.getView().getStore().getProxy().url; - this.doDownloadCsv(url, { + this.downloadCsv(url, { deviceId: deviceId, type: '%', from: from.toISOString(), @@ -95,7 +95,7 @@ Ext.define('Traccar.view.ReportController', { } }, - doDownloadCsv: function (requestUrl, requestParams) { + downloadCsv: function (requestUrl, requestParams) { Ext.Ajax.request({ url: requestUrl, method: 'GET', @@ -104,7 +104,7 @@ Ext.define('Traccar.view.ReportController', { Accept: 'text/csv' }, success: function (response) { - var disposition, filename, type, blob, url, downloadUrl, a; + var disposition, filename, type, blob, url, downloadUrl, elementA; disposition = response.getResponseHeader('Content-Disposition'); filename = disposition.slice(disposition.indexOf("=") + 1, disposition.length); type = response.getResponseHeader('Content-Type'); @@ -116,15 +116,15 @@ Ext.define('Traccar.view.ReportController', { url = window.URL || window.webkitURL; downloadUrl = URL.createObjectURL(blob); if (filename) { - a = document.createElement("a"); - a.href = downloadUrl; - a.download = filename; - document.body.appendChild(a); - a.click(); + elementA = document.createElement("a"); + elementA.href = downloadUrl; + elementA.download = filename; + document.body.appendChild(elementA); + elementA.click(); } setTimeout(function () { - url.revokeObjectURL(downloadUrl); - }, 100); + url.revokeObjectURL(downloadUrl); + }, 100); } } }); @@ -218,12 +218,12 @@ Ext.define('Traccar.view.ReportController', { flex: 1, renderer: Traccar.AttributeFormatter.getFormatter('distance') }, { - text: Strings.summaryAverageSpeed, + text: Strings.reportAverageSpeed, dataIndex: 'averageSpeed', flex: 1, renderer: Traccar.AttributeFormatter.getFormatter('speed') }, { - text: Strings.summaryMaximumSpeed, + text: Strings.reportMaximumSpeed, dataIndex: 'maxSpeed', flex: 1, renderer: Traccar.AttributeFormatter.getFormatter('speed') diff --git a/web/l10n/en.json b/web/l10n/en.json index 3c30353ac..b98e6d127 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -136,8 +136,8 @@ "reportRoute": "Route", "reportEvents": "Events", "reportSummary": "Summary", - "reportCsv": "Csv", + "reportCsv": "CSV", "reportDeviceName": "Device Name", - "summaryAverageSpeed": "Average Speed", - "summaryMaximumSpeed": "Maximum Speed" + "reportAverageSpeed": "Average Speed", + "reportMaximumSpeed": "Maximum Speed" } \ No newline at end of file -- cgit v1.2.3