mirror of https://github.com/gophish/gophish
Implementing new alert dialogs.
parent
737acbdb4e
commit
e746a86816
File diff suppressed because one or more lines are too long
|
@ -83,62 +83,72 @@ function dismiss() {
|
||||||
|
|
||||||
// Deletes a campaign after prompting the user
|
// Deletes a campaign after prompting the user
|
||||||
function deleteCampaign() {
|
function deleteCampaign() {
|
||||||
if (confirm("Are you sure you want to delete: " + campaign.name + "?")) {
|
swal({
|
||||||
api.campaignId.delete(campaign.id)
|
title: "Are you sure?",
|
||||||
.success(function(msg) {
|
text: "This will delete the campaign. This can't be undone!",
|
||||||
location.href = '/campaigns'
|
type: "warning",
|
||||||
|
animation: false,
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "Delete Campaign",
|
||||||
|
confirmButtonColor: "#428bca",
|
||||||
|
reverseButtons: true,
|
||||||
|
allowOutsideClick: false,
|
||||||
|
preConfirm: function() {
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
api.campaignId.delete(campaign.id)
|
||||||
|
.success(function(msg) {
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
.error(function(data) {
|
||||||
|
reject(data.responseJSON.message)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.error(function(e) {
|
}
|
||||||
$("#modal\\.flashes").empty().append("<div style=\"text-align:center\" class=\"alert alert-danger\">\
|
}).then(function() {
|
||||||
<i class=\"fa fa-exclamation-circle\"></i> " + data.responseJSON.message + "</div>")
|
swal(
|
||||||
})
|
'Campaign Deleted!',
|
||||||
}
|
'This campaign has been deleted!',
|
||||||
|
'success'
|
||||||
|
);
|
||||||
|
$('button:contains("OK")').on('click', function() {
|
||||||
|
location.href = '/campaigns'
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Completes a campaign after prompting the user
|
// Completes a campaign after prompting the user
|
||||||
function completeCampaign() {
|
function completeCampaign() {
|
||||||
swal({
|
swal({
|
||||||
title: "Are you sure?",
|
title: "Are you sure?",
|
||||||
text: "Gophish will stop processing events for this campaign",
|
text: "Gophish will stop processing events for this campaign",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
animation: false,
|
animation: false,
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonText: "Complete Campaign",
|
confirmButtonText: "Complete Campaign",
|
||||||
confirmButtonColor: "#428bca",
|
confirmButtonColor: "#428bca",
|
||||||
reverseButtons: true,
|
reverseButtons: true,
|
||||||
allowOutsideClick: false,
|
allowOutsideClick: false,
|
||||||
preConfirm: function() {
|
preConfirm: function() {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
api.campaignId.complete(campaign.id)
|
api.campaignId.complete(campaign.id)
|
||||||
.success(function(msg) {
|
.success(function(msg) {
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
.error(function(data) {
|
.error(function(data) {
|
||||||
reject(data.responseJSON.message)
|
reject(data.responseJSON.message)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
swal(
|
swal(
|
||||||
'Campaign Completed!',
|
'Campaign Completed!',
|
||||||
'This campaign has been completed!',
|
'This campaign has been completed!',
|
||||||
'success'
|
'success'
|
||||||
);
|
);
|
||||||
$('#complete_button')[0].disabled = true;
|
$('#complete_button')[0].disabled = true;
|
||||||
$('#complete_button').text('Completed!')
|
$('#complete_button').text('Completed!')
|
||||||
doPoll = false;
|
doPoll = false;
|
||||||
})
|
})
|
||||||
/*
|
|
||||||
if (confirm("Are you sure you want to delete: " + campaign.name + "?")) {
|
|
||||||
api.campaignId.delete(campaign.id)
|
|
||||||
.success(function(msg) {
|
|
||||||
location.href = '/campaigns'
|
|
||||||
})
|
|
||||||
.error(function(e) {
|
|
||||||
$("#modal\\.flashes").empty().append("<div style=\"text-align:center\" class=\"alert alert-danger\">\
|
|
||||||
<i class=\"fa fa-exclamation-circle\"></i> " + data.responseJSON.message + "</div>")
|
|
||||||
})
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exports campaign results as a CSV file
|
// Exports campaign results as a CSV file
|
||||||
|
|
|
@ -9,47 +9,67 @@ var labels = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var campaigns = []
|
var campaigns = []
|
||||||
|
var campaign = {}
|
||||||
|
|
||||||
// Launch attempts to POST to /campaigns/
|
// Launch attempts to POST to /campaigns/
|
||||||
function launch() {
|
function launch() {
|
||||||
if (!confirm("This will launch the campaign. Are you sure?")) {
|
swal({
|
||||||
return false;
|
title: "Are you sure?",
|
||||||
}
|
text: "This will schedule the campaign to be launched.",
|
||||||
groups = []
|
type: "question",
|
||||||
$.each($("#groupTable").DataTable().rows().data(), function(i, group) {
|
animation: false,
|
||||||
groups.push({
|
showCancelButton: true,
|
||||||
name: group[0]
|
confirmButtonText: "Launch",
|
||||||
|
confirmButtonColor: "#428bca",
|
||||||
|
reverseButtons: true,
|
||||||
|
allowOutsideClick: false,
|
||||||
|
showLoaderOnConfirm: true,
|
||||||
|
preConfirm: function() {
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
groups = []
|
||||||
|
$.each($("#groupTable").DataTable().rows().data(), function(i, group) {
|
||||||
|
groups.push({
|
||||||
|
name: group[0]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
campaign = {
|
||||||
|
name: $("#name").val(),
|
||||||
|
template: {
|
||||||
|
name: $("#template").val()
|
||||||
|
},
|
||||||
|
url: $("#url").val(),
|
||||||
|
page: {
|
||||||
|
name: $("#page").val()
|
||||||
|
},
|
||||||
|
smtp: {
|
||||||
|
name: $("#profile").val()
|
||||||
|
},
|
||||||
|
launch_date: moment($("#launch_date").val(), "MM/DD/YYYY HH:mm").format(),
|
||||||
|
groups: groups
|
||||||
|
}
|
||||||
|
// Submit the campaign
|
||||||
|
api.campaigns.post(campaign)
|
||||||
|
.success(function(data) {
|
||||||
|
resolve()
|
||||||
|
campaign = data
|
||||||
|
})
|
||||||
|
.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>")
|
||||||
|
swal.close()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}).then(function() {
|
||||||
|
swal(
|
||||||
|
'Campaign Scheduled!',
|
||||||
|
'This campaign has been scheduled for launch!',
|
||||||
|
'success'
|
||||||
|
);
|
||||||
|
$('button:contains("OK")').on('click', function() {
|
||||||
|
window.location = "/campaigns/" + campaign.id.toString()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
var campaign = {
|
|
||||||
name: $("#name").val(),
|
|
||||||
template: {
|
|
||||||
name: $("#template").val()
|
|
||||||
},
|
|
||||||
url: $("#url").val(),
|
|
||||||
page: {
|
|
||||||
name: $("#page").val()
|
|
||||||
},
|
|
||||||
smtp: {
|
|
||||||
name: $("#profile").val()
|
|
||||||
},
|
|
||||||
launch_date: moment($("#launch_date").val(), "MM/DD/YYYY HH:mm").format(),
|
|
||||||
groups: groups
|
|
||||||
}
|
|
||||||
launchHtml = $("launchButton").html()
|
|
||||||
$("launchButton").html('<i class="fa fa-spinner fa-spin"></i> Launching Campaign')
|
|
||||||
// Submit the campaign
|
|
||||||
api.campaigns.post(campaign)
|
|
||||||
.success(function(data) {
|
|
||||||
successFlash("Campaign successfully launched!")
|
|
||||||
$("launchButton").html('<i class="fa fa-spinner fa-spin"></i> Redirecting')
|
|
||||||
window.location = "/campaigns/" + data.id.toString()
|
|
||||||
})
|
|
||||||
.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>")
|
|
||||||
$("#launchButton").html(launchHtml)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempts to send a test email by POSTing to /campaigns/
|
// Attempts to send a test email by POSTing to /campaigns/
|
||||||
|
@ -99,13 +119,37 @@ function dismiss() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteCampaign(idx) {
|
function deleteCampaign(idx) {
|
||||||
if (confirm("Delete " + campaigns[idx].name + "?")) {
|
swal({
|
||||||
api.campaignId.delete(campaigns[idx].id)
|
title: "Are you sure?",
|
||||||
.success(function(data) {
|
text: "This will delete the campaign. This can't be undone!",
|
||||||
successFlash(data.message)
|
type: "warning",
|
||||||
location.reload()
|
animation: false,
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "Delete " + campaigns[idx].name,
|
||||||
|
confirmButtonColor: "#428bca",
|
||||||
|
reverseButtons: true,
|
||||||
|
allowOutsideClick: false,
|
||||||
|
preConfirm: function() {
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
api.campaignId.delete(campaigns[idx].id)
|
||||||
|
.success(function(msg) {
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
.error(function(data) {
|
||||||
|
reject(data.responseJSON.message)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}).then(function() {
|
||||||
|
swal(
|
||||||
|
'Campaign Deleted!',
|
||||||
|
'This campaign has been deleted!',
|
||||||
|
'success'
|
||||||
|
);
|
||||||
|
$('button:contains("OK")').on('click', function() {
|
||||||
|
location.reload()
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit(campaign) {
|
function edit(campaign) {
|
||||||
|
|
|
@ -158,5 +158,6 @@
|
||||||
<script src="/js/bootstrap-datetime.js"></script>
|
<script src="/js/bootstrap-datetime.js"></script>
|
||||||
<script src="/js/hogan.js"></script>
|
<script src="/js/hogan.js"></script>
|
||||||
<script src="/js/typeahead.min.js"></script>
|
<script src="/js/typeahead.min.js"></script>
|
||||||
|
<script src="/js/sweetalert2.min.js"></script>
|
||||||
<script src="/js/app/campaigns.js"></script>
|
<script src="/js/app/campaigns.js"></script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in New Issue