mirror of https://github.com/gophish/gophish
Merge pull request #85 from gophish/34-csv-export
Added ability to export as CSV. Fixes #34pull/91/head
commit
b4379512f7
|
@ -56,6 +56,26 @@ function deleteCampaign() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exports campaign results as a CSV file
|
||||||
|
function exportAsCSV() {
|
||||||
|
exportHTML = $("#exportButton").html()
|
||||||
|
$("#exportButton").html('<i class="fa fa-spinner fa-spin"></i>')
|
||||||
|
var csvString = Papa.unparse(campaign.results, {})
|
||||||
|
var csvData = new Blob([csvString], {
|
||||||
|
type: 'text/csv;charset=utf-8;'
|
||||||
|
});
|
||||||
|
if (navigator.msSaveBlob) {
|
||||||
|
navigator.msSaveBlob(csvData, 'results.csv');
|
||||||
|
} else {
|
||||||
|
var csvURL = window.URL.createObjectURL(csvData);
|
||||||
|
var dlLink = document.createElement('a');
|
||||||
|
dlLink.href = csvURL;
|
||||||
|
dlLink.setAttribute('download', 'results.csv');
|
||||||
|
dlLink.click();
|
||||||
|
}
|
||||||
|
$("#exportButton").html(exportHTML)
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
campaign.id = window.location.pathname.split('/').slice(-1)[0]
|
campaign.id = window.location.pathname.split('/').slice(-1)[0]
|
||||||
api.campaignId.get(campaign.id)
|
api.campaignId.get(campaign.id)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -30,22 +30,11 @@
|
||||||
<h1 class="page-header" id="page-title">Results for campaign.name</h1>
|
<h1 class="page-header" id="page-title">Results for campaign.name</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!--
|
<button type="button" id="exportButton" class="btn btn-primary" onclick="exportAsCSV()">
|
||||||
<div class="btn-group">
|
<i class="fa fa-file-excel-o"></i> Export CSV
|
||||||
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
|
|
||||||
<i class="fa fa-cogs fa-lg"></i>
|
|
||||||
<span class="caret"></span>
|
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu">
|
<button type="button" class="btn btn-danger" data-toggle="tooltip" onclick="deleteCampaign()">
|
||||||
<li><a href="#">Export</a>
|
<i class="fa fa-trash-o fa-lg"></i> Delete
|
||||||
</li>
|
|
||||||
<li><a href="#">Relaunch</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
<button type="button" class="btn btn-danger" data-toggle="tooltip" data-placement="right" title="Delete Campaign" onclick="deleteCampaign()">
|
|
||||||
<i class="fa fa-trash-o fa-lg"></i>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
@ -114,5 +103,6 @@
|
||||||
<script src="/js/d3.min.js"></script>
|
<script src="/js/d3.min.js"></script>
|
||||||
<script src="/js/topojson.min.js"></script>
|
<script src="/js/topojson.min.js"></script>
|
||||||
<script src="/js/datamaps.min.js"></script>
|
<script src="/js/datamaps.min.js"></script>
|
||||||
|
<script src="/js/papaparse.min.js"></script>
|
||||||
<script src="/js/app/campaign_results.js"></script>
|
<script src="/js/app/campaign_results.js"></script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in New Issue