diff --git a/static/js/app/campaign_results.js b/static/js/app/campaign_results.js
index 06e127ce..440b3439 100644
--- a/static/js/app/campaign_results.js
+++ b/static/js/app/campaign_results.js
@@ -73,20 +73,30 @@ function deleteCampaign() {
}
// Exports campaign results as a CSV file
-function exportAsCSV() {
+function exportAsCSV(scope) {
exportHTML = $("#exportButton").html()
+ var csvScope = null
+ switch (scope) {
+ case "results":
+ csvScope = campaign.results
+ break;
+ case "events":
+ csvScope = campaign.timeline
+ break;
+ }
+ if (!csvScope){return}
$("#exportButton").html('')
- var csvString = Papa.unparse(campaign.results, {})
+ var csvString = Papa.unparse(csvScope, {})
var csvData = new Blob([csvString], {
type: 'text/csv;charset=utf-8;'
});
if (navigator.msSaveBlob) {
- navigator.msSaveBlob(csvData, 'results.csv');
+ navigator.msSaveBlob(csvData, scope + '.csv');
} else {
var csvURL = window.URL.createObjectURL(csvData);
var dlLink = document.createElement('a');
dlLink.href = csvURL;
- dlLink.setAttribute('download', 'results.csv');
+ dlLink.setAttribute('download', scope + '.csv');
dlLink.click();
}
$("#exportButton").html(exportHTML)
diff --git a/templates/campaign_results.html b/templates/campaign_results.html
index f1877273..1ddf4a7c 100644
--- a/templates/campaign_results.html
+++ b/templates/campaign_results.html
@@ -33,9 +33,16 @@
Back
-