mirror of https://github.com/gophish/gophish
Removed minified js files after rebasing
parent
ba90b89c0b
commit
508ca998a6
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
var groups=[];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){$("#groupModalLabel").text("New Group")}else $("#groupModalLabel").text("Edit Group"),api.groupId.get(e).success((function(e){$("#name").val(e.name),targetRows=[],$.each(e.targets,(function(e,a){targetRows.push([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>'])})),targets.DataTable().rows.add(targetRows).draw()})).error((function(){errorFlash("Error fetching group")}));$("#csvupload").fileupload({url:"/api/import/group",dataType:"json",beforeSend:function(e){e.setRequestHeader("Authorization","Bearer "+user.api_key)},add:function(e,a){$("#modal\\.flashes").empty();var t=a.originalFiles[0].name;if(t&&!/(csv|txt)$/i.test(t.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()}})}var downloadCSVTemplate=function(){var e="group_template.csv",a=Papa.unparse([{"First Name":"Example","Last Name":"User",Email:"foobar@example.com",Position:"Systems Administrator"}],{}),t=new Blob([a],{type:"text/csv;charset=utf-8;"});if(navigator.msSaveBlob)navigator.msSaveBlob(t,e);else{var o=window.URL.createObjectURL(t),s=document.createElement("a");s.href=o,s.setAttribute("download",e),document.body.appendChild(s),s.click(),document.body.removeChild(s)}},deleteGroup=function(e){var a=groups.find((function(a){return a.id===e}));a&&Swal.fire({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(e){e.value&&Swal.fire("Group Deleted!","This group has been deleted!","success"),$('button:contains("OK")').on("click",(function(){location.reload()}))}))};function addTarget(e,a,t,o){var s=escapeHtml(t).toLowerCase(),r=[escapeHtml(e),escapeHtml(a),s,escapeHtml(o),'<span style="cursor:pointer;"><i class="fa fa-trash-o"></i></span>'],n=targets.DataTable(),i=n.column(2,{order:"index"}).data().indexOf(s);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(),groupRows=[],$.each(groups,(function(e,a){groupRows.push([escapeHtml(a.name),escapeHtml(a.num_targets),moment(a.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"<div class='pull-right'><button class='btn btn-primary' data-toggle='modal' data-backdrop='static' data-target='#modal' onclick='edit("+a.id+")'> <i class='fa fa-pencil'></i> </button> <button class='btn btn-danger' onclick='deleteGroup("+a.id+")'> <i class='fa fa-trash-o'></i> </button></div>"])})),a.rows.add(groupRows).draw()}else $("#emptyMessage").show()})).error((function(){errorFlash("Error fetching groups")}))}$(document).ready((function(){load(),$("#targetForm").submit((function(){var e=document.getElementById("targetForm");if(e.checkValidity())return addTarget($("#firstName").val(),$("#lastName").val(),$("#email").val(),$("#position").val()),targets.DataTable().draw(),$("#targetForm>div>input").val(""),$("#firstName").focus(),!1;e.reportValidity()})),$("#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)}));
|
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
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
let webhooks=[];const dismiss=()=>{$("#name").val(""),$("#url").val(""),$("#secret").val(""),$("#is_active").prop("checked",!1),$("#flashes").empty()},saveWebhook=e=>{let o={name:$("#name").val(),url:$("#url").val(),secret:$("#secret").val(),is_active:$("#is_active").is(":checked")};-1!=e?(o.id=parseInt(e),api.webhookId.put(o).success((function(e){dismiss(),load(),$("#modal").modal("hide"),successFlash(`Webhook "${escapeHtml(o.name)}" has been updated successfully!`)})).error((function(e){modalError(e.responseJSON.message)}))):api.webhooks.post(o).success((function(e){load(),dismiss(),$("#modal").modal("hide"),successFlash(`Webhook "${escapeHtml(o.name)}" has been created successfully!`)})).error((function(e){modalError(e.responseJSON.message)}))},load=()=>{$("#webhookTable").hide(),$("#loading").show(),api.webhooks.get().success((e=>{webhooks=e,$("#loading").hide(),$("#webhookTable").show();let o=$("#webhookTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]});o.clear(),$.each(webhooks,((e,t)=>{o.row.add([escapeHtml(t.name),escapeHtml(t.url),escapeHtml(t.is_active),`\n <div class="pull-right">\n <button class="btn btn-primary ping_button" data-webhook-id="${t.id}">\n Ping\n </button>\n <button class="btn btn-primary edit_button" data-toggle="modal" data-backdrop="static" data-target="#modal" data-webhook-id="${t.id}">\n <i class="fa fa-pencil"></i>\n </button>\n <button class="btn btn-danger delete_button" data-webhook-id="${t.id}">\n <i class="fa fa-trash-o"></i>\n </button>\n </div>\n `]).draw()}))})).error((()=>{errorFlash("Error fetching webhooks")}))},editWebhook=e=>{$("#modalSubmit").unbind("click").click((()=>{saveWebhook(e)})),-1!==e?($("#webhookModalLabel").text("Edit Webhook"),api.webhookId.get(e).success((function(e){$("#name").val(e.name),$("#url").val(e.url),$("#secret").val(e.secret),$("#is_active").prop("checked",e.is_active)})).error((function(){errorFlash("Error fetching webhook")}))):$("#webhookModalLabel").text("New Webhook")},deleteWebhook=e=>{var t=webhooks.find((o=>o.id==e));o&&Swal.fire({title:"Are you sure?",text:`This will delete the webhook '${escapeHtml(o.name)}'`,type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(((o,t)=>{api.webhookId.delete(e).success((e=>{o()})).error((e=>{t(e.responseJSON.message)}))})).catch((e=>{Swal.showValidationMessage(e)}))}}).then((function(e){e.value&&Swal.fire("Webhook Deleted!","The webhook has been deleted!","success"),$("button:contains('OK')").on("click",(function(){location.reload()}))}))},pingUrl=(e,o)=>{dismiss(),e.disabled=!0,api.webhookId.ping(o).success((function(o){e.disabled=!1,successFlash(`Ping of "${escapeHtml(o.name)}" webhook succeeded.`)})).error((function(t){e.disabled=!1;var s=webhooks.find((e=>e.id==o));s&&errorFlash(`Ping of "${escapeHtml(s.name)}" webhook failed: "${escapeHtml(t.responseJSON.message)}"`)}))};$(document).ready((function(){load(),$("#modal").on("hide.bs.modal",(function(){dismiss()})),$("#new_button").on("click",(function(){editWebhook(-1)})),$("#webhookTable").on("click",".edit_button",(function(e){editWebhook($(this).attr("data-webhook-id"))})),$("#webhookTable").on("click",".delete_button",(function(e){var o,t;o=$(this).attr("data-webhook-id"),(t=webhooks.find((e=>e.id==o)))&&Swal.fire({title:"Are you sure?",text:`This will delete the webhook '${escapeHtml(t.name)}'`,type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(((e,t)=>{api.webhookId.delete(o).success((o=>{e()})).error((e=>{t(e.responseJSON.message)}))})).catch((e=>{Swal.showValidationMessage(e)}))}}).then((function(e){e.value&&Swal.fire("Webhook Deleted!","The webhook has been deleted!","success"),$("button:contains('OK')").on("click",(function(){location.reload()}))}))})),$("#webhookTable").on("click",".ping_button",(function(e){var o,t;o=e.currentTarget,t=e.currentTarget.dataset.webhookId,dismiss(),o.disabled=!0,api.webhookId.ping(t).success((function(e){o.disabled=!1,successFlash(`Ping of "${escapeHtml(e.name)}" webhook succeeded.`)})).error((function(e){o.disabled=!1;var s=webhooks.find((e=>e.id==t));s&&errorFlash(`Ping of "${escapeHtml(s.name)}" webhook failed: "${escapeHtml(e.responseJSON.message)}"`)}))}))}));
|
Loading…
Reference in New Issue