mirror of https://github.com/gophish/gophish
Added sweetalert2 delete dialogs to all objects for consistency.
parent
7dcf30f277
commit
fa1d4d74b0
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
||||||
function save(a){var e=[];$.each($("#targetsTable").DataTable().rows().data(),function(a,t){e.push({first_name:unescapeHtml(t[0]),last_name:unescapeHtml(t[1]),email:unescapeHtml(t[2]),position:unescapeHtml(t[3])})});var t={name:$("#name").val(),targets:e};-1!=a?(t.id=a,api.groupId.put(t).success(function(a){successFlash("Group updated successfully!"),load(),dismiss(),$("#modal").modal("hide")}).error(function(a){modalError(a.responseJSON.message)})):api.groups.post(t).success(function(a){successFlash("Group added successfully!"),load(),dismiss(),$("#modal").modal("hide")}).error(function(a){modalError(a.responseJSON.message)})}function dismiss(){$("#targetsTable").dataTable().DataTable().clear().draw(),$("#name").val(""),$("#modal\\.flashes").empty()}function edit(a){if(targets=$("#targetsTable").dataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),$("#modalSubmit").unbind("click").click(function(){save(a)}),-1==a);else api.groupId.get(a).success(function(a){$("#name").val(a.name),$.each(a.targets,function(a,e){targets.DataTable().row.add([escapeHtml(e.first_name),escapeHtml(e.last_name),escapeHtml(e.email),escapeHtml(e.position),'<span style="cursor:pointer;"><i class="fa fa-trash-o"></i></span>']).draw()})}).error(function(){errorFlash("Error fetching group")});$("#csvupload").fileupload({url:"/api/import/group?api_key="+user.api_key,dataType:"json",add:function(a,e){$("#modal\\.flashes").empty();var t=/(csv|txt)$/i,s=e.originalFiles[0].name;if(s&&!t.test(s.split(".").pop()))return modalError("Unsupported file extension (use .csv or .txt)"),!1;e.submit()},done:function(a,e){$.each(e.result,function(a,e){addTarget(e.first_name,e.last_name,e.email,e.position)}),targets.DataTable().draw()}})}function deleteGroup(a){var e=groups.find(function(e){return e.id===a});if(!e)return void console.log("wat");confirm("Delete "+e.name+"?")&&api.groupId.delete(a).success(function(a){successFlash(a.message),load()})}function addTarget(a,e,t,s){var o=escapeHtml(t).toLowerCase(),r=[escapeHtml(a),escapeHtml(e),o,escapeHtml(s),'<span style="cursor:pointer;"><i class="fa fa-trash-o"></i></span>'],n=targets.DataTable(),i=n.column(2,{order:"index"}).data().indexOf(o);i>=0?n.row(i,{order:"index"}).data(r):n.row.add(r)}function load(){$("#groupTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.groups.summary().success(function(a){if($("#loading").hide(),a.total>0){groups=a.groups,$("#emptyMessage").hide(),$("#groupTable").show();var e=$("#groupTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]});e.clear(),$.each(groups,function(a,t){e.row.add([escapeHtml(t.name),escapeHtml(t.num_targets),moment(t.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"<div class='pull-right'><button class='btn btn-primary' data-toggle='modal' data-target='#modal' onclick='edit("+t.id+")'> <i class='fa fa-pencil'></i> </button> <button class='btn btn-danger' onclick='deleteGroup("+t.id+")'> <i class='fa fa-trash-o'></i> </button></div>"]).draw()})}else $("#emptyMessage").show()}).error(function(){errorFlash("Error fetching groups")})}var groups=[],downloadCSVTemplate=function(){var a=[{"First Name":"Example","Last Name":"User",Email:"foobar@example.com",Position:"Systems Administrator"}],e=Papa.unparse(a,{}),t=new Blob([e],{type:"text/csv;charset=utf-8;"});if(navigator.msSaveBlob)navigator.msSaveBlob(t,"group_template.csv");else{var s=window.URL.createObjectURL(t),o=document.createElement("a");o.href=s,o.setAttribute("download","group_template.csv"),document.body.appendChild(o),o.click(),document.body.removeChild(o)}};$(document).ready(function(){load(),$("#targetForm").submit(function(){return addTarget($("#firstName").val(),$("#lastName").val(),$("#email").val(),$("#position").val()),targets.DataTable().draw(),$("#targetForm>div>input").val(""),$("#firstName").focus(),!1}),$("#targetsTable").on("click","span>i.fa-trash-o",function(){targets.DataTable().row($(this).parents("tr")).remove().draw()}),$("#modal").on("hide.bs.modal",function(){dismiss()}),$("#csv-template").click(downloadCSVTemplate)});
|
function save(e){var a=[];$.each($("#targetsTable").DataTable().rows().data(),function(e,t){a.push({first_name:unescapeHtml(t[0]),last_name:unescapeHtml(t[1]),email:unescapeHtml(t[2]),position:unescapeHtml(t[3])})});var t={name:$("#name").val(),targets:a};-1!=e?(t.id=e,api.groupId.put(t).success(function(e){successFlash("Group updated successfully!"),load(),dismiss(),$("#modal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)})):api.groups.post(t).success(function(e){successFlash("Group added successfully!"),load(),dismiss(),$("#modal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)})}function dismiss(){$("#targetsTable").dataTable().DataTable().clear().draw(),$("#name").val(""),$("#modal\\.flashes").empty()}function edit(e){if(targets=$("#targetsTable").dataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),$("#modalSubmit").unbind("click").click(function(){save(e)}),-1==e);else api.groupId.get(e).success(function(e){$("#name").val(e.name),$.each(e.targets,function(e,a){targets.DataTable().row.add([escapeHtml(a.first_name),escapeHtml(a.last_name),escapeHtml(a.email),escapeHtml(a.position),'<span style="cursor:pointer;"><i class="fa fa-trash-o"></i></span>']).draw()})}).error(function(){errorFlash("Error fetching group")});$("#csvupload").fileupload({url:"/api/import/group?api_key="+user.api_key,dataType:"json",add:function(e,a){$("#modal\\.flashes").empty();var t=/(csv|txt)$/i,s=a.originalFiles[0].name;if(s&&!t.test(s.split(".").pop()))return modalError("Unsupported file extension (use .csv or .txt)"),!1;a.submit()},done:function(e,a){$.each(a.result,function(e,a){addTarget(a.first_name,a.last_name,a.email,a.position)}),targets.DataTable().draw()}})}function addTarget(e,a,t,s){var o=escapeHtml(t).toLowerCase(),r=[escapeHtml(e),escapeHtml(a),o,escapeHtml(s),'<span style="cursor:pointer;"><i class="fa fa-trash-o"></i></span>'],n=targets.DataTable(),i=n.column(2,{order:"index"}).data().indexOf(o);i>=0?n.row(i,{order:"index"}).data(r):n.row.add(r)}function load(){$("#groupTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.groups.summary().success(function(e){if($("#loading").hide(),e.total>0){groups=e.groups,$("#emptyMessage").hide(),$("#groupTable").show();var a=$("#groupTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]});a.clear(),$.each(groups,function(e,t){a.row.add([escapeHtml(t.name),escapeHtml(t.num_targets),moment(t.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"<div class='pull-right'><button class='btn btn-primary' data-toggle='modal' data-target='#modal' onclick='edit("+t.id+")'> <i class='fa fa-pencil'></i> </button> <button class='btn btn-danger' onclick='deleteGroup("+t.id+")'> <i class='fa fa-trash-o'></i> </button></div>"]).draw()})}else $("#emptyMessage").show()}).error(function(){errorFlash("Error fetching groups")})}var groups=[],downloadCSVTemplate=function(){var e=[{"First Name":"Example","Last Name":"User",Email:"foobar@example.com",Position:"Systems Administrator"}],a=Papa.unparse(e,{}),t=new Blob([a],{type:"text/csv;charset=utf-8;"});if(navigator.msSaveBlob)navigator.msSaveBlob(t,"group_template.csv");else{var s=window.URL.createObjectURL(t),o=document.createElement("a");o.href=s,o.setAttribute("download","group_template.csv"),document.body.appendChild(o),o.click(),document.body.removeChild(o)}},deleteGroup=function(e){var a=groups.find(function(a){return a.id===e});a&&swal({title:"Are you sure?",text:"This will delete the group. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+escapeHtml(a.name),confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(a,t){api.groupId.delete(e).success(function(e){a()}).error(function(e){t(e.responseJSON.message)})})}}).then(function(){swal("Group Deleted!","This group has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.reload()})})};$(document).ready(function(){load(),$("#targetForm").submit(function(){return addTarget($("#firstName").val(),$("#lastName").val(),$("#email").val(),$("#position").val()),targets.DataTable().draw(),$("#targetForm>div>input").val(""),$("#firstName").focus(),!1}),$("#targetsTable").on("click","span>i.fa-trash-o",function(){targets.DataTable().row($(this).parents("tr")).remove().draw()}),$("#modal").on("hide.bs.modal",function(){dismiss()}),$("#csv-template").click(downloadCSVTemplate)});
|
|
@ -48,14 +48,38 @@ function dismiss() {
|
||||||
$("#modal").modal('hide')
|
$("#modal").modal('hide')
|
||||||
}
|
}
|
||||||
|
|
||||||
function deletePage(idx) {
|
var deletePage = function (idx) {
|
||||||
if (confirm("Delete " + pages[idx].name + "?")) {
|
swal({
|
||||||
api.pageId.delete(pages[idx].id)
|
title: "Are you sure?",
|
||||||
.success(function (data) {
|
text: "This will delete the landing page. This can't be undone!",
|
||||||
successFlash(data.message)
|
type: "warning",
|
||||||
load()
|
animation: false,
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "Delete " + escapeHtml(pages[idx].name),
|
||||||
|
confirmButtonColor: "#428bca",
|
||||||
|
reverseButtons: true,
|
||||||
|
allowOutsideClick: false,
|
||||||
|
preConfirm: function () {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
api.pageId.delete(pages[idx].id)
|
||||||
|
.success(function (msg) {
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
.error(function (data) {
|
||||||
|
reject(data.responseJSON.message)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}).then(function () {
|
||||||
|
swal(
|
||||||
|
'Landing Page Deleted!',
|
||||||
|
'This landing page has been deleted!',
|
||||||
|
'success'
|
||||||
|
);
|
||||||
|
$('button:contains("OK")').on('click', function () {
|
||||||
|
location.reload()
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function importSite() {
|
function importSite() {
|
||||||
|
|
|
@ -102,14 +102,39 @@ var dismissSendTestEmailModal = function () {
|
||||||
$("#sendTestModalSubmit").html("<i class='fa fa-envelope'></i> Send")
|
$("#sendTestModalSubmit").html("<i class='fa fa-envelope'></i> Send")
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteProfile(idx) {
|
|
||||||
if (confirm("Delete " + profiles[idx].name + "?")) {
|
var deleteProfile = function (idx) {
|
||||||
api.SMTPId.delete(profiles[idx].id)
|
swal({
|
||||||
.success(function (data) {
|
title: "Are you sure?",
|
||||||
successFlash(data.message)
|
text: "This will delete the sending profile. This can't be undone!",
|
||||||
load()
|
type: "warning",
|
||||||
|
animation: false,
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "Delete " + escapeHtml(profiles[idx].name),
|
||||||
|
confirmButtonColor: "#428bca",
|
||||||
|
reverseButtons: true,
|
||||||
|
allowOutsideClick: false,
|
||||||
|
preConfirm: function () {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
api.SMTPId.delete(profiles[idx].id)
|
||||||
|
.success(function (msg) {
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
.error(function (data) {
|
||||||
|
reject(data.responseJSON.message)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}).then(function () {
|
||||||
|
swal(
|
||||||
|
'Sending Profile Deleted!',
|
||||||
|
'This sending profile has been deleted!',
|
||||||
|
'success'
|
||||||
|
);
|
||||||
|
$('button:contains("OK")').on('click', function () {
|
||||||
|
location.reload()
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit(idx) {
|
function edit(idx) {
|
||||||
|
@ -259,7 +284,8 @@ $(document).ready(function () {
|
||||||
if (
|
if (
|
||||||
this.$element[0] !== e.target && !this.$element.has(e.target).length
|
this.$element[0] !== e.target && !this.$element.has(e.target).length
|
||||||
// CKEditor compatibility fix start.
|
// CKEditor compatibility fix start.
|
||||||
&& !$(e.target).closest('.cke_dialog, .cke').length
|
&&
|
||||||
|
!$(e.target).closest('.cke_dialog, .cke').length
|
||||||
// CKEditor compatibility fix end.
|
// CKEditor compatibility fix end.
|
||||||
) {
|
) {
|
||||||
this.$element.trigger('focus');
|
this.$element.trigger('focus');
|
||||||
|
@ -298,4 +324,4 @@ $(document).ready(function () {
|
||||||
.draw();
|
.draw();
|
||||||
});
|
});
|
||||||
load()
|
load()
|
||||||
})
|
})
|
|
@ -78,6 +78,40 @@ function dismiss() {
|
||||||
$("#modal").modal('hide')
|
$("#modal").modal('hide')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deleteTemplate = function (idx) {
|
||||||
|
swal({
|
||||||
|
title: "Are you sure?",
|
||||||
|
text: "This will delete the template. This can't be undone!",
|
||||||
|
type: "warning",
|
||||||
|
animation: false,
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "Delete " + escapeHtml(templates[idx].name),
|
||||||
|
confirmButtonColor: "#428bca",
|
||||||
|
reverseButtons: true,
|
||||||
|
allowOutsideClick: false,
|
||||||
|
preConfirm: function () {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
api.templateId.delete(templates[idx].id)
|
||||||
|
.success(function (msg) {
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
.error(function (data) {
|
||||||
|
reject(data.responseJSON.message)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}).then(function () {
|
||||||
|
swal(
|
||||||
|
'Template Deleted!',
|
||||||
|
'This template has been deleted!',
|
||||||
|
'success'
|
||||||
|
);
|
||||||
|
$('button:contains("OK")').on('click', function () {
|
||||||
|
location.reload()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function deleteTemplate(idx) {
|
function deleteTemplate(idx) {
|
||||||
if (confirm("Delete " + templates[idx].name + "?")) {
|
if (confirm("Delete " + templates[idx].name + "?")) {
|
||||||
api.templateId.delete(templates[idx].id)
|
api.templateId.delete(templates[idx].id)
|
||||||
|
|
|
@ -137,21 +137,45 @@ var downloadCSVTemplate = function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteGroup(id) {
|
|
||||||
|
var deleteGroup = function (id) {
|
||||||
var group = groups.find(function (x) {
|
var group = groups.find(function (x) {
|
||||||
return x.id === id
|
return x.id === id
|
||||||
})
|
})
|
||||||
if (!group) {
|
if (!group) {
|
||||||
console.log('wat');
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (confirm("Delete " + group.name + "?")) {
|
swal({
|
||||||
api.groupId.delete(id)
|
title: "Are you sure?",
|
||||||
.success(function (data) {
|
text: "This will delete the group. This can't be undone!",
|
||||||
successFlash(data.message)
|
type: "warning",
|
||||||
load()
|
animation: false,
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "Delete " + escapeHtml(group.name),
|
||||||
|
confirmButtonColor: "#428bca",
|
||||||
|
reverseButtons: true,
|
||||||
|
allowOutsideClick: false,
|
||||||
|
preConfirm: function () {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
api.groupId.delete(id)
|
||||||
|
.success(function (msg) {
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
.error(function (data) {
|
||||||
|
reject(data.responseJSON.message)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}).then(function () {
|
||||||
|
swal(
|
||||||
|
'Group Deleted!',
|
||||||
|
'This group has been deleted!',
|
||||||
|
'success'
|
||||||
|
);
|
||||||
|
$('button:contains("OK")').on('click', function () {
|
||||||
|
location.reload()
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTarget(firstNameInput, lastNameInput, emailInput, positionInput) {
|
function addTarget(firstNameInput, lastNameInput, emailInput, positionInput) {
|
||||||
|
|
Loading…
Reference in New Issue