aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/app/store/ReportEventTypes.js2
-rw-r--r--web/app/view/Report.js4
-rw-r--r--web/app/view/ReportController.js25
-rw-r--r--web/l10n/en.json2
4 files changed, 17 insertions, 16 deletions
diff --git a/web/app/store/ReportEventTypes.js b/web/app/store/ReportEventTypes.js
index 7e71d934..bc2c4560 100644
--- a/web/app/store/ReportEventTypes.js
+++ b/web/app/store/ReportEventTypes.js
@@ -21,6 +21,6 @@ Ext.define('Traccar.store.ReportEventTypes', {
fields: ['type', 'name'],
statics: {
- allEvents: '%'
+ allEvents: 'allEvents'
}
});
diff --git a/web/app/view/Report.js b/web/app/view/Report.js
index 18debc63..a1fbd1b2 100644
--- a/web/app/view/Report.js
+++ b/web/app/view/Report.js
@@ -49,8 +49,8 @@ Ext.define('Traccar.view.Report', {
disabled: true,
handler: 'onReportClick'
}, {
- text: Strings.reportCsv,
- reference: 'csvButton',
+ text: Strings.reportExport,
+ reference: 'exportButton',
disabled: true,
handler: 'onReportClick'
}, {
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js
index 50f4251e..e8198b36 100644
--- a/web/app/view/ReportController.js
+++ b/web/app/view/ReportController.js
@@ -74,7 +74,7 @@ Ext.define('Traccar.view.ReportController', {
time = this.fromDate && this.fromTime && this.toDate && this.toTime;
disabled = !reportType || !devices || !time;
this.lookupReference('showButton').setDisabled(disabled);
- this.lookupReference('csvButton').setDisabled(disabled);
+ this.lookupReference('exportButton').setDisabled(disabled);
},
onReportClick: function (button) {
@@ -102,9 +102,9 @@ Ext.define('Traccar.view.ReportController', {
to: to.toISOString()
}
});
- } else if (button.reference === 'csvButton') {
+ } else if (button.reference === 'exportButton') {
url = this.getView().getStore().getProxy().url;
- this.downloadCsv(url, {
+ this.downloadFile(url, {
deviceId: this.deviceId,
groupId: this.groupId,
type: this.eventType,
@@ -166,20 +166,21 @@ Ext.define('Traccar.view.ReportController', {
});
},
- downloadCsv: function (requestUrl, requestParams) {
+ downloadFile: function (requestUrl, requestParams) {
Ext.Ajax.request({
url: requestUrl,
method: 'GET',
params: requestParams,
headers: {
- Accept: 'text/csv'
+ Accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
},
+ binary: true,
success: function (response) {
- var disposition, filename, type, blob, url, downloadUrl, elementA;
+ var disposition, filename, type, blob, url, downloadUrl;
disposition = response.getResponseHeader('Content-Disposition');
filename = disposition.slice(disposition.indexOf('=') + 1, disposition.length);
type = response.getResponseHeader('Content-Type');
- blob = new Blob([response.responseText], {type: type});
+ blob = new Blob([response.responseBytes], {type: type});
if (typeof window.navigator.msSaveBlob !== 'undefined') {
// IE workaround
window.navigator.msSaveBlob(blob, filename);
@@ -187,11 +188,11 @@ Ext.define('Traccar.view.ReportController', {
url = window.URL || window.webkitURL;
downloadUrl = url.createObjectURL(blob);
if (filename) {
- elementA = document.createElement('a');
- elementA.href = downloadUrl;
- elementA.download = filename;
- document.body.appendChild(elementA);
- elementA.click();
+ Ext.dom.Helper.append(Ext.getBody(), {
+ tag: 'a',
+ href: downloadUrl,
+ download: filename
+ }).click();
}
setTimeout(function () {
url.revokeObjectURL(downloadUrl);
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 30e15c71..46fb8582 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -160,7 +160,7 @@
"reportSummary": "Summary",
"reportConfigure": "Configure",
"reportEventTypes": "Event Types",
- "reportCsv": "CSV",
+ "reportExport": "Export",
"reportDeviceName": "Device Name",
"reportAverageSpeed": "Average Speed",
"reportMaximumSpeed": "Maximum Speed",