mirror of https://github.com/gophish/gophish
Leveraging the new campaign summary API endpoints in the web UI to help with displaying large campaigns.
parent
8738ebbb35
commit
b5100156f9
|
@ -240,12 +240,18 @@ function copy(idx) {
|
|||
}
|
||||
})
|
||||
// Set our initial values
|
||||
var campaign = campaigns[idx]
|
||||
api.campaignId.get(campaigns[idx].id)
|
||||
.success(function(campaign){
|
||||
$("#name").val("Copy of " + campaign.name)
|
||||
$("#template").val(campaign.template.name)
|
||||
$("#page").val(campaign.page.name)
|
||||
$("#profile").val(campaign.smtp.name)
|
||||
$("#url").val(campaign.url)
|
||||
})
|
||||
.error(function(data){
|
||||
$("#modal\\.flashes").empty().append("<div style=\"text-align:center\" class=\"alert alert-danger\">\
|
||||
<i class=\"fa fa-exclamation-circle\"></i> " + data.responseJSON.message + "</div>")
|
||||
})
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
@ -296,9 +302,9 @@ $(document).ready(function() {
|
|||
$('#modal').on('hidden.bs.modal', function(event) {
|
||||
dismiss()
|
||||
});
|
||||
api.campaigns.get()
|
||||
.success(function(cs) {
|
||||
campaigns = cs
|
||||
api.campaigns.summary()
|
||||
.success(function(data) {
|
||||
campaigns = data.campaigns
|
||||
$("#loading").hide()
|
||||
if (campaigns.length > 0) {
|
||||
$("#campaignTable").show()
|
||||
|
|
|
@ -20,10 +20,10 @@ function deleteCampaign(idx) {
|
|||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
api.campaigns.get()
|
||||
.success(function(cs) {
|
||||
api.campaigns.summary()
|
||||
.success(function(data) {
|
||||
$("#loading").hide()
|
||||
campaigns = cs
|
||||
campaigns = data.campaigns
|
||||
if (campaigns.length > 0) {
|
||||
$("#dashboard").show()
|
||||
// Create the overview chart data
|
||||
|
@ -41,7 +41,9 @@ $(document).ready(function() {
|
|||
showGrid: false
|
||||
},
|
||||
showArea: true,
|
||||
plugins: []
|
||||
plugins: [],
|
||||
low: 0,
|
||||
high: 100
|
||||
}
|
||||
var average_opts = {
|
||||
donut: true,
|
||||
|
@ -73,12 +75,8 @@ $(document).ready(function() {
|
|||
]).draw()
|
||||
// Add it to the chart data
|
||||
campaign.y = 0
|
||||
$.each(campaign.results, function(j, result) {
|
||||
if (result.status == "Clicked Link" || result.status == "Submitted Data") {
|
||||
campaign.y++;
|
||||
}
|
||||
})
|
||||
campaign.y = Math.floor((campaign.y / campaign.results.length) * 100)
|
||||
campaign.y += campaign.stats.clicked + campaign.stats.submitted_data
|
||||
campaign.y = Math.floor((campaign.y / campaign.stats.total) * 100)
|
||||
average += campaign.y
|
||||
// Add the data to the overview chart
|
||||
overview_data.labels.push(campaign_date)
|
||||
|
@ -87,7 +85,7 @@ $(document).ready(function() {
|
|||
value: campaign.y
|
||||
})
|
||||
})
|
||||
average = Math.floor(average / campaigns.length);
|
||||
average = Math.floor(average / data.total);
|
||||
average_data.series.push({
|
||||
meta: "Unsuccessful Phishes",
|
||||
value: 100 - average
|
||||
|
|
|
@ -47,6 +47,10 @@ var api = {
|
|||
// post() - Posts a campaign to POST /campaigns
|
||||
post: function(data) {
|
||||
return query("/campaigns/", "POST", data, false)
|
||||
},
|
||||
// summary() - Queries the API for GET /campaigns/summary
|
||||
summary: function() {
|
||||
return query("/campaigns/summary", "GET", {}, false)
|
||||
}
|
||||
},
|
||||
// campaignId contains the endpoints for /campaigns/:id
|
||||
|
@ -66,6 +70,10 @@ var api = {
|
|||
// complete() - Completes a campaign at POST /campaigns/:id/complete
|
||||
complete: function(id) {
|
||||
return query("/campaigns/" + id + "/complete", "GET", {}, true)
|
||||
},
|
||||
// summary() - Queries the API for GET /campaigns/summary
|
||||
summary: function(id) {
|
||||
return query("/campaigns/" + id + "/summary", "GET", {}, true)
|
||||
}
|
||||
},
|
||||
// groups contains the endpoints for /groups
|
||||
|
|
Loading…
Reference in New Issue