mirror of https://github.com/gophish/gophish
Added ability to export raw events. Fixes #102
parent
a8f722b80f
commit
d714635e69
|
@ -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('<i class="fa fa-spinner fa-spin"></i>')
|
||||
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)
|
||||
|
|
|
@ -33,9 +33,16 @@
|
|||
<a href="/campaigns" class="btn btn-default">
|
||||
<i class="fa fa-arrow-circle-o-left fa-lg"></i> Back
|
||||
</a>
|
||||
<button type="button" id="exportButton" class="btn btn-primary" onclick="exportAsCSV()">
|
||||
<div class="btn-group">
|
||||
<button type="button" id="exportButton" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||
<i class="fa fa-file-excel-o"></i> Export CSV
|
||||
<i class="fa fa-caret-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="exportButton">
|
||||
<li><a href="#" onclick="exportAsCSV('results')">Results</a></li>
|
||||
<li><a href="#" onclick="exportAsCSV('events')">Raw Events</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<button type="button" class="btn btn-danger" data-toggle="tooltip" onclick="deleteCampaign()">
|
||||
<i class="fa fa-trash-o fa-lg"></i> Delete
|
||||
</button>
|
||||
|
|
Loading…
Reference in New Issue