Skip to content

Commit

Permalink
Option to mail reports
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Sep 29, 2018
1 parent 648c768 commit 32a0476
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions web/app/view/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ Ext.define('Traccar.view.Report', {
reference: 'exportButton',
disabled: true,
handler: 'onReportClick'
}, {
text: Strings.reportEmail,
reference: 'emailButton',
disabled: true,
handler: 'onReportClick'
}, {
text: Strings.reportClear,
handler: 'onClearClick'
Expand Down
12 changes: 7 additions & 5 deletions web/app/view/ReportController.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Ext.define('Traccar.view.ReportController', {
disabled = !reportType || !devices || !time || this.reportProgress;
this.lookupReference('showButton').setDisabled(disabled);
this.lookupReference('exportButton').setDisabled(reportType === 'chart' || disabled);
this.lookupReference('emailButton').setDisabled(reportType === 'chart' || disabled);
},

onReportClick: function (button) {
Expand Down Expand Up @@ -187,14 +188,15 @@ Ext.define('Traccar.view.ReportController', {
to: to.toISOString()
}
});
} else if (button.reference === 'exportButton') {
} else {
url = this.getGrid().getStore().getProxy().url;
this.downloadFile(url, {
this.excelReport(url, {
deviceId: this.deviceId,
groupId: this.groupId,
type: this.eventType,
from: Ext.Date.format(from, 'c'),
to: Ext.Date.format(to, 'c')
to: Ext.Date.format(to, 'c'),
mail: button.reference === 'emailButton'
});
}
}
Expand Down Expand Up @@ -371,7 +373,7 @@ Ext.define('Traccar.view.ReportController', {
});
},

downloadFile: function (requestUrl, requestParams) {
excelReport: function (requestUrl, requestParams) {
Ext.Ajax.request({
url: requestUrl,
method: 'GET',
Expand All @@ -384,7 +386,7 @@ Ext.define('Traccar.view.ReportController', {
scope: this,
callback: function (options, success, response) {
var disposition, filename, type, blob, url, downloadUrl;
if (success) {
if (success && !requestParams.mail) {
disposition = response.getResponseHeader('Content-Disposition');
filename = disposition.slice(disposition.indexOf('=') + 1, disposition.length);
type = response.getResponseHeader('Content-Type');
Expand Down
1 change: 1 addition & 0 deletions web/l10n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
"reportChartType": "Chart Type",
"reportShowMarkers": "Show Markers",
"reportExport": "Export",
"reportEmail": "Email Report",
"reportPeriod": "Period",
"reportCustom": "Custom",
"reportToday": "Today",
Expand Down

0 comments on commit 32a0476

Please sign in to comment.