mirror of https://github.com/gophish/gophish
Added ability to delete campaign. Fixes #72
parent
66720aa1b8
commit
cff666119e
|
@ -8,6 +8,8 @@ var labels = {
|
||||||
"Error": "label-danger"
|
"Error": "label-danger"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var campaigns = []
|
||||||
|
|
||||||
// Save attempts to POST to /campaigns/
|
// Save attempts to POST to /campaigns/
|
||||||
function save() {
|
function save() {
|
||||||
groups = []
|
groups = []
|
||||||
|
@ -16,7 +18,6 @@ function save() {
|
||||||
name: group[0]
|
name: group[0]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
console.log(groups)
|
|
||||||
var campaign = {
|
var campaign = {
|
||||||
name: $("#name").val(),
|
name: $("#name").val(),
|
||||||
template: {
|
template: {
|
||||||
|
@ -52,6 +53,16 @@ function dismiss() {
|
||||||
$("#groupTable").dataTable().DataTable().clear().draw()
|
$("#groupTable").dataTable().DataTable().clear().draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteCampaign(idx) {
|
||||||
|
if (confirm("Delete " + campaigns[idx].name + "?")) {
|
||||||
|
api.campaignId.delete(campaigns[idx].id)
|
||||||
|
.success(function(data) {
|
||||||
|
successFlash(data.message)
|
||||||
|
load()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function edit(campaign) {
|
function edit(campaign) {
|
||||||
// Clear the bloodhound instance
|
// Clear the bloodhound instance
|
||||||
group_bh.clear();
|
group_bh.clear();
|
||||||
|
@ -90,7 +101,8 @@ function edit(campaign) {
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
api.campaigns.get()
|
api.campaigns.get()
|
||||||
.success(function(campaigns) {
|
.success(function(cs) {
|
||||||
|
campaigns = cs
|
||||||
$("#loading").hide()
|
$("#loading").hide()
|
||||||
if (campaigns.length > 0) {
|
if (campaigns.length > 0) {
|
||||||
$("#campaignTable").show()
|
$("#campaignTable").show()
|
||||||
|
@ -104,7 +116,7 @@ $(document).ready(function() {
|
||||||
"<div class='pull-right'><a class='btn btn-primary' href='/campaigns/" + campaign.id + "'>\
|
"<div class='pull-right'><a class='btn btn-primary' href='/campaigns/" + campaign.id + "'>\
|
||||||
<i class='fa fa-bar-chart'></i>\
|
<i class='fa fa-bar-chart'></i>\
|
||||||
</a>\
|
</a>\
|
||||||
<button class='btn btn-danger' onclick='alert(\"test\")'>\
|
<button class='btn btn-danger' onclick='deleteCampaign(" + i + ")'>\
|
||||||
<i class='fa fa-trash-o'></i>\
|
<i class='fa fa-trash-o'></i>\
|
||||||
</button></div>"
|
</button></div>"
|
||||||
]).draw()
|
]).draw()
|
||||||
|
|
|
@ -9,6 +9,15 @@ var labels = {
|
||||||
"Error": "label-danger"
|
"Error": "label-danger"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteCampaign(idx) {
|
||||||
|
if (confirm("Delete " + campaigns[idx].name + "?")) {
|
||||||
|
api.campaignId.delete(campaigns[idx].id)
|
||||||
|
.success(function(data) {
|
||||||
|
successFlash(data.message)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
api.campaigns.get()
|
api.campaigns.get()
|
||||||
.success(function(cs) {
|
.success(function(cs) {
|
||||||
|
|
Loading…
Reference in New Issue