From 704e6d56b3285f9c9d3ef5eac4a53d019b730bc7 Mon Sep 17 00:00:00 2001 From: Jake Walker Date: Fri, 15 Apr 2022 15:28:19 +0100 Subject: [PATCH] Fix modal titles saying new when editing existing content (#2318) --- gulpfile.js | 7 +- package.json | 4 +- static/js/dist/app/groups.min.js | 2 +- static/js/dist/app/landing_pages.min.js | 2 +- static/js/dist/app/sending_profiles.min.js | 2 +- static/js/dist/app/templates.min.js | 2 +- static/js/dist/app/users.min.js | 2 +- static/js/dist/app/webhooks.min.js | 2 +- static/js/src/app/groups.js | 2 + static/js/src/app/landing_pages.js | 3 + static/js/src/app/sending_profiles.js | 3 + static/js/src/app/templates.js | 3 + static/js/src/app/users.js | 2 + static/js/src/app/webhooks.js | 3 + templates/users.html | 4 +- templates/webhooks.html | 6 +- yarn.lock | 96 ++++++++++++---------- 17 files changed, 88 insertions(+), 57 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 809c28f0..e7c914ed 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,7 +7,7 @@ var gulp = require('gulp'), rename = require('gulp-rename'), concat = require('gulp-concat'), - uglify = require('gulp-uglify'), + uglify = require('gulp-uglify-es').default, cleanCSS = require('gulp-clean-css'), babel = require('gulp-babel'), @@ -61,6 +61,9 @@ scripts = function () { app_directory + 'settings.js', app_directory + 'templates.js', app_directory + 'gophish.js', + app_directory + 'users.js', + app_directory + 'webhooks.js', + app_directory + 'passwords.js' ]) .pipe(rename({ suffix: '.min' @@ -97,4 +100,4 @@ exports.vendorjs = vendorjs exports.scripts = scripts exports.styles = styles exports.build = gulp.parallel(vendorjs, scripts, styles) -exports.default = exports.build \ No newline at end of file +exports.default = exports.build diff --git a/package.json b/package.json index 6b65458f..4f5ac766 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,9 @@ "gulp-concat": "^2.6.1", "gulp-jshint": "^2.1.0", "gulp-rename": "^1.4.0", - "gulp-uglify": "^3.0.2", + "gulp-uglify-es": "^3.0.0", "gulp-wrap": "^0.15.0", - "jshint": "^2.10.2", + "jshint": "^2.13.4", "jshint-stylish": "^2.2.1", "webpack": "^4.32.2", "webpack-cli": "^3.3.2" diff --git a/static/js/dist/app/groups.min.js b/static/js/dist/app/groups.min.js index 3be298c0..014688d0 100644 --- a/static/js/dist/app/groups.min.js +++ b/static/js/dist/app/groups.min.js @@ -1 +1 @@ -var groups=[];function save(e){var t=[];$.each($("#targetsTable").DataTable().rows().data(),function(e,a){t.push({first_name:unescapeHtml(a[0]),last_name:unescapeHtml(a[1]),email:unescapeHtml(a[2]),position:unescapeHtml(a[3])})});var a={name:$("#name").val(),targets:t};-1!=e?(a.id=e,api.groupId.put(a).success(function(e){successFlash("Group updated successfully!"),load(),dismiss(),$("#modal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)})):api.groups.post(a).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),targetRows=[],$.each(e.targets,function(e,a){targetRows.push([escapeHtml(a.first_name),escapeHtml(a.last_name),escapeHtml(a.email),escapeHtml(a.position),''])}),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(o){var e=groups.find(function(e){return e.id===o});e&&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(e.name),confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(a,t){api.groupId.delete(o).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),''],n=targets.DataTable(),i=n.column(2,{order:"index"}).data().indexOf(s);0<=i?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(),0 "])}),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)}); \ No newline at end of file +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),''])})),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),''],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"),"
"])})),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)})); \ No newline at end of file diff --git a/static/js/dist/app/landing_pages.min.js b/static/js/dist/app/landing_pages.min.js index 406deae3..18092d80 100644 --- a/static/js/dist/app/landing_pages.min.js +++ b/static/js/dist/app/landing_pages.min.js @@ -1 +1 @@ -var pages=[];function save(e){var a={};a.name=$("#name").val(),editor=CKEDITOR.instances.html_editor,a.html=editor.getData(),a.capture_credentials=$("#capture_credentials_checkbox").prop("checked"),a.capture_passwords=$("#capture_passwords_checkbox").prop("checked"),a.redirect_url=$("#redirect_url_input").val(),-1!=e?(a.id=pages[e].id,api.pageId.put(a).success(function(e){successFlash("Page edited successfully!"),load(),dismiss()})):api.pages.post(a).success(function(e){successFlash("Page added successfully!"),load(),dismiss()}).error(function(e){modalError(e.responseJSON.message)})}function dismiss(){$("#modal\\.flashes").empty(),$("#name").val(""),$("#html_editor").val(""),$("#url").val(""),$("#redirect_url_input").val(""),$("#modal").find("input[type='checkbox']").prop("checked",!1),$("#capture_passwords").hide(),$("#redirect_url").hide(),$("#modal").modal("hide")}var deletePage=function(e){Swal.fire({title:"Are you sure?",text:"This will delete the landing page. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+escapeHtml(pages[e].name),confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(a,t){api.pageId.delete(pages[e].id).success(function(e){a()}).error(function(e){t(e.responseJSON.message)})})}}).then(function(e){e.value&&Swal.fire("Landing Page Deleted!","This landing page has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.reload()})})};function importSite(){url=$("#url").val(),url?api.clone_site({url:url,include_resources:!1}).success(function(e){$("#html_editor").val(e.html),CKEDITOR.instances.html_editor.setMode("wysiwyg"),$("#importSiteModal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)}):modalError("No URL Specified!")}function edit(e){$("#modalSubmit").unbind("click").click(function(){save(e)}),$("#html_editor").ckeditor(),setupAutocomplete(CKEDITOR.instances.html_editor);var a={};-1!=e&&(a=pages[e],$("#name").val(a.name),$("#html_editor").val(a.html),$("#capture_credentials_checkbox").prop("checked",a.capture_credentials),$("#capture_passwords_checkbox").prop("checked",a.capture_passwords),$("#redirect_url_input").val(a.redirect_url),a.capture_credentials&&($("#capture_passwords").show(),$("#redirect_url").show()))}function copy(e){$("#modalSubmit").unbind("click").click(function(){save(-1)}),$("#html_editor").ckeditor();var a=pages[e];$("#name").val("Copy of "+a.name),$("#html_editor").val(a.html)}function load(){$("#pagesTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.pages.get().success(function(e){pages=e,$("#loading").hide(),0\t\t "])}),pagesTable.rows.add(pageRows).draw(),$('[data-toggle="tooltip"]').tooltip()):$("#emptyMessage").show()}).error(function(){$("#loading").hide(),errorFlash("Error fetching pages")})}$(document).ready(function(){$(".modal").on("hidden.bs.modal",function(e){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)}),$(".modal").on("shown.bs.modal",function(e){void 0===$("body").data("fv_open_modals")&&$("body").data("fv_open_modals",0),$(this).hasClass("fv-modal-stack")||($(this).addClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")+1),$(this).css("z-index",1040+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not(".fv-modal-stack").css("z-index",1039+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not("fv-modal-stack").addClass("fv-modal-stack"))}),$.fn.modal.Constructor.prototype.enforceFocus=function(){$(document).off("focusin.bs.modal").on("focusin.bs.modal",$.proxy(function(e){this.$element[0]===e.target||this.$element.has(e.target).length||$(e.target).closest(".cke_dialog, .cke").length||this.$element.trigger("focus")},this))},$(document).on("hidden.bs.modal",".modal",function(){$(".modal:visible").length&&$(document.body).addClass("modal-open")}),$("#modal").on("hidden.bs.modal",function(e){dismiss()}),$("#capture_credentials_checkbox").change(function(){$("#capture_passwords").toggle(),$("#redirect_url").toggle()}),CKEDITOR.on("dialogDefinition",function(e){var a=e.data.name,t=e.data.definition;"link"==a&&(t.minWidth=500,t.minHeight=100,t.getContents("info").get("linkType").hidden=!0)}),load()}); \ No newline at end of file +var pages=[];function save(e){var a={};a.name=$("#name").val(),editor=CKEDITOR.instances.html_editor,a.html=editor.getData(),a.capture_credentials=$("#capture_credentials_checkbox").prop("checked"),a.capture_passwords=$("#capture_passwords_checkbox").prop("checked"),a.redirect_url=$("#redirect_url_input").val(),-1!=e?(a.id=pages[e].id,api.pageId.put(a).success((function(e){successFlash("Page edited successfully!"),load(),dismiss()}))):api.pages.post(a).success((function(e){successFlash("Page added successfully!"),load(),dismiss()})).error((function(e){modalError(e.responseJSON.message)}))}function dismiss(){$("#modal\\.flashes").empty(),$("#name").val(""),$("#html_editor").val(""),$("#url").val(""),$("#redirect_url_input").val(""),$("#modal").find("input[type='checkbox']").prop("checked",!1),$("#capture_passwords").hide(),$("#redirect_url").hide(),$("#modal").modal("hide")}var deletePage=function(e){Swal.fire({title:"Are you sure?",text:"This will delete the landing page. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+escapeHtml(pages[e].name),confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise((function(a,t){api.pageId.delete(pages[e].id).success((function(e){a()})).error((function(e){t(e.responseJSON.message)}))}))}}).then((function(e){e.value&&Swal.fire("Landing Page Deleted!","This landing page has been deleted!","success"),$('button:contains("OK")').on("click",(function(){location.reload()}))}))};function importSite(){url=$("#url").val(),url?api.clone_site({url:url,include_resources:!1}).success((function(e){$("#html_editor").val(e.html),CKEDITOR.instances.html_editor.setMode("wysiwyg"),$("#importSiteModal").modal("hide")})).error((function(e){modalError(e.responseJSON.message)})):modalError("No URL Specified!")}function edit(e){$("#modalSubmit").unbind("click").click((function(){save(e)})),$("#html_editor").ckeditor(),setupAutocomplete(CKEDITOR.instances.html_editor);var a={};-1!=e?($("#modalLabel").text("Edit Landing Page"),a=pages[e],$("#name").val(a.name),$("#html_editor").val(a.html),$("#capture_credentials_checkbox").prop("checked",a.capture_credentials),$("#capture_passwords_checkbox").prop("checked",a.capture_passwords),$("#redirect_url_input").val(a.redirect_url),a.capture_credentials&&($("#capture_passwords").show(),$("#redirect_url").show())):$("#modalLabel").text("New Landing Page")}function copy(e){$("#modalSubmit").unbind("click").click((function(){save(-1)})),$("#html_editor").ckeditor();var a=pages[e];$("#name").val("Copy of "+a.name),$("#html_editor").val(a.html)}function load(){$("#pagesTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.pages.get().success((function(e){pages=e,$("#loading").hide(),pages.length>0?($("#pagesTable").show(),pagesTable=$("#pagesTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),pagesTable.clear(),pageRows=[],$.each(pages,(function(e,a){pageRows.push([escapeHtml(a.name),moment(a.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"
\t\t
"])})),pagesTable.rows.add(pageRows).draw(),$('[data-toggle="tooltip"]').tooltip()):$("#emptyMessage").show()})).error((function(){$("#loading").hide(),errorFlash("Error fetching pages")}))}$(document).ready((function(){$(".modal").on("hidden.bs.modal",(function(e){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)})),$(".modal").on("shown.bs.modal",(function(e){void 0===$("body").data("fv_open_modals")&&$("body").data("fv_open_modals",0),$(this).hasClass("fv-modal-stack")||($(this).addClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")+1),$(this).css("z-index",1040+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not(".fv-modal-stack").css("z-index",1039+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not("fv-modal-stack").addClass("fv-modal-stack"))})),$.fn.modal.Constructor.prototype.enforceFocus=function(){$(document).off("focusin.bs.modal").on("focusin.bs.modal",$.proxy((function(e){this.$element[0]===e.target||this.$element.has(e.target).length||$(e.target).closest(".cke_dialog, .cke").length||this.$element.trigger("focus")}),this))},$(document).on("hidden.bs.modal",".modal",(function(){$(".modal:visible").length&&$(document.body).addClass("modal-open")})),$("#modal").on("hidden.bs.modal",(function(e){dismiss()})),$("#capture_credentials_checkbox").change((function(){$("#capture_passwords").toggle(),$("#redirect_url").toggle()})),CKEDITOR.on("dialogDefinition",(function(e){var a=e.data.name,t=e.data.definition;"link"==a&&(t.minWidth=500,t.minHeight=100,t.getContents("info").get("linkType").hidden=!0)})),load()})); \ No newline at end of file diff --git a/static/js/dist/app/sending_profiles.min.js b/static/js/dist/app/sending_profiles.min.js index ab20df39..a77d4135 100644 --- a/static/js/dist/app/sending_profiles.min.js +++ b/static/js/dist/app/sending_profiles.min.js @@ -1 +1 @@ -var profiles=[];function sendTestEmail(){var t=[];$.each($("#headersTable").DataTable().rows().data(),function(e,a){t.push({key:unescapeHtml(a[0]),value:unescapeHtml(a[1])})});var e={template:{},first_name:$("input[name=to_first_name]").val(),last_name:$("input[name=to_last_name]").val(),email:$("input[name=to_email]").val(),position:$("input[name=to_position]").val(),url:"",smtp:{from_address:$("#from").val(),host:$("#host").val(),username:$("#username").val(),password:$("#password").val(),ignore_cert_errors:$("#ignore_cert_errors").prop("checked"),headers:t}};btnHtml=$("#sendTestModalSubmit").html(),$("#sendTestModalSubmit").html(' Sending'),api.send_test_email(e).success(function(e){$("#sendTestEmailModal\\.flashes").empty().append('
\t Email Sent!
'),$("#sendTestModalSubmit").html(btnHtml)}).error(function(e){$("#sendTestEmailModal\\.flashes").empty().append('
\t '+escapeHtml(e.responseJSON.message)+"
"),$("#sendTestModalSubmit").html(btnHtml)})}function save(e){var t={headers:[]};$.each($("#headersTable").DataTable().rows().data(),function(e,a){t.headers.push({key:unescapeHtml(a[0]),value:unescapeHtml(a[1])})}),t.name=$("#name").val(),t.interface_type=$("#interface_type").val(),t.from_address=$("#from").val(),t.host=$("#host").val(),t.username=$("#username").val(),t.password=$("#password").val(),t.ignore_cert_errors=$("#ignore_cert_errors").prop("checked"),-1!=e?(t.id=profiles[e].id,api.SMTPId.put(t).success(function(e){successFlash("Profile edited successfully!"),load(),dismiss()}).error(function(e){modalError(e.responseJSON.message)})):api.SMTP.post(t).success(function(e){successFlash("Profile added successfully!"),load(),dismiss()}).error(function(e){modalError(e.responseJSON.message)})}function dismiss(){$("#modal\\.flashes").empty(),$("#name").val(""),$("#interface_type").val("SMTP"),$("#from").val(""),$("#host").val(""),$("#username").val(""),$("#password").val(""),$("#ignore_cert_errors").prop("checked",!0),$("#headersTable").dataTable().DataTable().clear().draw(),$("#modal").modal("hide")}var dismissSendTestEmailModal=function(){$("#sendTestEmailModal\\.flashes").empty(),$("#sendTestModalSubmit").html(" Send")},deleteProfile=function(e){Swal.fire({title:"Are you sure?",text:"This will delete the sending profile. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+escapeHtml(profiles[e].name),confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(a,t){api.SMTPId.delete(profiles[e].id).success(function(e){a()}).error(function(e){t(e.responseJSON.message)})})}}).then(function(e){e.value&&Swal.fire("Sending Profile Deleted!","This sending profile has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.reload()})})};function edit(e){headers=$("#headersTable").dataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),$("#modalSubmit").unbind("click").click(function(){save(e)});var a;-1!=e&&(a=profiles[e],$("#name").val(a.name),$("#interface_type").val(a.interface_type),$("#from").val(a.from_address),$("#host").val(a.host),$("#username").val(a.username),$("#password").val(a.password),$("#ignore_cert_errors").prop("checked",a.ignore_cert_errors),$.each(a.headers,function(e,a){addCustomHeader(a.key,a.value)}))}function copy(e){$("#modalSubmit").unbind("click").click(function(){save(-1)});var a=profiles[e];$("#name").val("Copy of "+a.name),$("#interface_type").val(a.interface_type),$("#from").val(a.from_address),$("#host").val(a.host),$("#username").val(a.username),$("#password").val(a.password),$("#ignore_cert_errors").prop("checked",a.ignore_cert_errors)}function load(){$("#profileTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.SMTP.get().success(function(e){profiles=e,$("#loading").hide(),0\t\t "])}),profileTable.rows.add(profileRows).draw(),$('[data-toggle="tooltip"]').tooltip()):$("#emptyMessage").show()}).error(function(){$("#loading").hide(),errorFlash("Error fetching profiles")})}function addCustomHeader(e,a){var t=[escapeHtml(e),escapeHtml(a),''],a=headers.DataTable(),e=a.column(0).data().indexOf(escapeHtml(e));0<=e?a.row(e,{order:"index"}).data(t):a.row.add(t),a.draw()}$(document).ready(function(){$(".modal").on("hidden.bs.modal",function(e){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)}),$(".modal").on("shown.bs.modal",function(e){void 0===$("body").data("fv_open_modals")&&$("body").data("fv_open_modals",0),$(this).hasClass("fv-modal-stack")||($(this).addClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")+1),$(this).css("z-index",1040+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not(".fv-modal-stack").css("z-index",1039+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not("fv-modal-stack").addClass("fv-modal-stack"))}),$.fn.modal.Constructor.prototype.enforceFocus=function(){$(document).off("focusin.bs.modal").on("focusin.bs.modal",$.proxy(function(e){this.$element[0]===e.target||this.$element.has(e.target).length||$(e.target).closest(".cke_dialog, .cke").length||this.$element.trigger("focus")},this))},$(document).on("hidden.bs.modal",".modal",function(){$(".modal:visible").length&&$(document.body).addClass("modal-open")}),$("#modal").on("hidden.bs.modal",function(e){dismiss()}),$("#sendTestEmailModal").on("hidden.bs.modal",function(e){dismissSendTestEmailModal()}),$("#addCustomHeader").on("click",function(){return headerKey=$("#headerKey").val(),headerValue=$("#headerValue").val(),""==headerKey||""==headerValue||(addCustomHeader(headerKey,headerValue),$("#headerKey").val(""),$("#headerValue").val(""),$("#headerKey").focus()),!1}),$("#headersTable").on("click","span>i.fa-trash-o",function(){headers.DataTable().row($(this).parents("tr")).remove().draw()}),load()}); \ No newline at end of file +var profiles=[];function sendTestEmail(){var e=[];$.each($("#headersTable").DataTable().rows().data(),(function(a,o){e.push({key:unescapeHtml(o[0]),value:unescapeHtml(o[1])})}));var a={template:{},first_name:$("input[name=to_first_name]").val(),last_name:$("input[name=to_last_name]").val(),email:$("input[name=to_email]").val(),position:$("input[name=to_position]").val(),url:"",smtp:{from_address:$("#from").val(),host:$("#host").val(),username:$("#username").val(),password:$("#password").val(),ignore_cert_errors:$("#ignore_cert_errors").prop("checked"),headers:e}};btnHtml=$("#sendTestModalSubmit").html(),$("#sendTestModalSubmit").html(' Sending'),api.send_test_email(a).success((function(e){$("#sendTestEmailModal\\.flashes").empty().append('
\t Email Sent!
'),$("#sendTestModalSubmit").html(btnHtml)})).error((function(e){$("#sendTestEmailModal\\.flashes").empty().append('
\t '+escapeHtml(e.responseJSON.message)+"
"),$("#sendTestModalSubmit").html(btnHtml)}))}function save(e){var a={headers:[]};$.each($("#headersTable").DataTable().rows().data(),(function(e,o){a.headers.push({key:unescapeHtml(o[0]),value:unescapeHtml(o[1])})})),a.name=$("#name").val(),a.interface_type=$("#interface_type").val(),a.from_address=$("#from").val(),a.host=$("#host").val(),a.username=$("#username").val(),a.password=$("#password").val(),a.ignore_cert_errors=$("#ignore_cert_errors").prop("checked"),-1!=e?(a.id=profiles[e].id,api.SMTPId.put(a).success((function(e){successFlash("Profile edited successfully!"),load(),dismiss()})).error((function(e){modalError(e.responseJSON.message)}))):api.SMTP.post(a).success((function(e){successFlash("Profile added successfully!"),load(),dismiss()})).error((function(e){modalError(e.responseJSON.message)}))}function dismiss(){$("#modal\\.flashes").empty(),$("#name").val(""),$("#interface_type").val("SMTP"),$("#from").val(""),$("#host").val(""),$("#username").val(""),$("#password").val(""),$("#ignore_cert_errors").prop("checked",!0),$("#headersTable").dataTable().DataTable().clear().draw(),$("#modal").modal("hide")}var dismissSendTestEmailModal=function(){$("#sendTestEmailModal\\.flashes").empty(),$("#sendTestModalSubmit").html(" Send")},deleteProfile=function(e){Swal.fire({title:"Are you sure?",text:"This will delete the sending profile. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+escapeHtml(profiles[e].name),confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise((function(a,o){api.SMTPId.delete(profiles[e].id).success((function(e){a()})).error((function(e){o(e.responseJSON.message)}))}))}}).then((function(e){e.value&&Swal.fire("Sending Profile Deleted!","This sending profile has been deleted!","success"),$('button:contains("OK")').on("click",(function(){location.reload()}))}))};function edit(e){headers=$("#headersTable").dataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),$("#modalSubmit").unbind("click").click((function(){save(e)}));var a={};-1!=e?($("#profileModalLabel").text("Edit Sending Profile"),a=profiles[e],$("#name").val(a.name),$("#interface_type").val(a.interface_type),$("#from").val(a.from_address),$("#host").val(a.host),$("#username").val(a.username),$("#password").val(a.password),$("#ignore_cert_errors").prop("checked",a.ignore_cert_errors),$.each(a.headers,(function(e,a){addCustomHeader(a.key,a.value)}))):$("#profileModalLabel").text("New Sending Profile")}function copy(e){$("#modalSubmit").unbind("click").click((function(){save(-1)}));var a;a=profiles[e],$("#name").val("Copy of "+a.name),$("#interface_type").val(a.interface_type),$("#from").val(a.from_address),$("#host").val(a.host),$("#username").val(a.username),$("#password").val(a.password),$("#ignore_cert_errors").prop("checked",a.ignore_cert_errors)}function load(){$("#profileTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.SMTP.get().success((function(e){profiles=e,$("#loading").hide(),profiles.length>0?($("#profileTable").show(),profileTable=$("#profileTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),profileTable.clear(),profileRows=[],$.each(profiles,(function(e,a){profileRows.push([escapeHtml(a.name),a.interface_type,moment(a.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"
\t\t
"])})),profileTable.rows.add(profileRows).draw(),$('[data-toggle="tooltip"]').tooltip()):$("#emptyMessage").show()})).error((function(){$("#loading").hide(),errorFlash("Error fetching profiles")}))}function addCustomHeader(e,a){var o=[escapeHtml(e),escapeHtml(a),''],t=headers.DataTable(),s=t.column(0).data().indexOf(escapeHtml(e));s>=0?t.row(s,{order:"index"}).data(o):t.row.add(o),t.draw()}$(document).ready((function(){$(".modal").on("hidden.bs.modal",(function(e){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)})),$(".modal").on("shown.bs.modal",(function(e){void 0===$("body").data("fv_open_modals")&&$("body").data("fv_open_modals",0),$(this).hasClass("fv-modal-stack")||($(this).addClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")+1),$(this).css("z-index",1040+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not(".fv-modal-stack").css("z-index",1039+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not("fv-modal-stack").addClass("fv-modal-stack"))})),$.fn.modal.Constructor.prototype.enforceFocus=function(){$(document).off("focusin.bs.modal").on("focusin.bs.modal",$.proxy((function(e){this.$element[0]===e.target||this.$element.has(e.target).length||$(e.target).closest(".cke_dialog, .cke").length||this.$element.trigger("focus")}),this))},$(document).on("hidden.bs.modal",".modal",(function(){$(".modal:visible").length&&$(document.body).addClass("modal-open")})),$("#modal").on("hidden.bs.modal",(function(e){dismiss()})),$("#sendTestEmailModal").on("hidden.bs.modal",(function(e){dismissSendTestEmailModal()})),$("#headersForm").on("submit",(function(){return headerKey=$("#headerKey").val(),headerValue=$("#headerValue").val(),""==headerKey||""==headerValue||(addCustomHeader(headerKey,headerValue),$("#headersForm>div>input").val(""),$("#headerKey").focus()),!1})),$("#headersTable").on("click","span>i.fa-trash-o",(function(){headers.DataTable().row($(this).parents("tr")).remove().draw()})),load()})); \ No newline at end of file diff --git a/static/js/dist/app/templates.min.js b/static/js/dist/app/templates.min.js index 049676c4..9a76eaf2 100644 --- a/static/js/dist/app/templates.min.js +++ b/static/js/dist/app/templates.min.js @@ -1 +1 @@ -var templates=[],icons={"application/vnd.ms-excel":"fa-file-excel-o","text/plain":"fa-file-text-o","image/gif":"fa-file-image-o","image/png":"fa-file-image-o","application/pdf":"fa-file-pdf-o","application/x-zip-compressed":"fa-file-archive-o","application/x-gzip":"fa-file-archive-o","application/vnd.openxmlformats-officedocument.presentationml.presentation":"fa-file-powerpoint-o","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"fa-file-word-o","application/octet-stream":"fa-file-o","application/x-msdownload":"fa-file-o"};function save(e){var a={attachments:[]};a.name=$("#name").val(),a.subject=$("#subject").val(),a.envelope_sender=$("#envelope-sender").val(),a.html=CKEDITOR.instances.html_editor.getData(),a.html=a.html.replace(/https?:\/\/{{\.URL}}/gi,"{{.URL}}"),$("#use_tracker_checkbox").prop("checked")?-1==a.html.indexOf("{{.Tracker}}")&&-1==a.html.indexOf("{{.TrackingUrl}}")&&(a.html=a.html.replace("","{{.Tracker}}")):a.html=a.html.replace("{{.Tracker}}",""),a.text=$("#text_editor").val(),$.each($("#attachmentsTable").DataTable().rows().data(),function(e,t){a.attachments.push({name:unescapeHtml(t[1]),content:t[3],type:t[4]})}),-1!=e?(a.id=templates[e].id,api.templateId.put(a).success(function(e){successFlash("Template edited successfully!"),load(),dismiss()}).error(function(e){modalError(e.responseJSON.message)})):api.templates.post(a).success(function(e){successFlash("Template added successfully!"),load(),dismiss()}).error(function(e){modalError(e.responseJSON.message)})}function dismiss(){$("#modal\\.flashes").empty(),$("#attachmentsTable").dataTable().DataTable().clear().draw(),$("#name").val(""),$("#subject").val(""),$("#text_editor").val(""),$("#html_editor").val(""),$("#modal").modal("hide")}var deleteTemplate=function(e){Swal.fire({title:"Are you sure?",text:"This will delete the template. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+escapeHtml(templates[e].name),confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(t,a){api.templateId.delete(templates[e].id).success(function(e){t()}).error(function(e){a(e.responseJSON.message)})})}}).then(function(e){e.value&&Swal.fire("Template Deleted!","This template has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.reload()})})};function deleteTemplate(e){confirm("Delete "+templates[e].name+"?")&&api.templateId.delete(templates[e].id).success(function(e){successFlash(e.message),load()})}function attach(e){attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]}),$.each(e,function(e,a){var o=new FileReader;o.onload=function(e){var t=icons[a.type]||"fa-file-o";attachmentsTable.row.add(['',escapeHtml(a.name),'',o.result.split(",")[1],a.type||"application/octet-stream"]).draw()},o.onerror=function(e){console.log(e)},o.readAsDataURL(a)})}function edit(e){$("#modalSubmit").unbind("click").click(function(){save(e)}),$("#attachmentUpload").unbind("click").click(function(){this.value=null}),$("#html_editor").ckeditor(),setupAutocomplete(CKEDITOR.instances.html_editor),$("#attachmentsTable").show(),attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]});var t={attachments:[]};-1!=e&&(t=templates[e],$("#name").val(t.name),$("#subject").val(t.subject),$("#envelope-sender").val(t.envelope_sender),$("#html_editor").val(t.html),$("#text_editor").val(t.text),attachmentRows=[],$.each(t.attachments,function(e,t){var a=icons[t.type]||"fa-file-o";attachmentRows.push(['',escapeHtml(t.name),'',t.content,t.type||"application/octet-stream"])}),attachmentsTable.rows.add(attachmentRows).draw(),-1!=t.html.indexOf("{{.Tracker}}")?$("#use_tracker_checkbox").prop("checked",!0):$("#use_tracker_checkbox").prop("checked",!1)),$("#attachmentsTable").unbind("click").on("click","span>i.fa-trash-o",function(){attachmentsTable.row($(this).parents("tr")).remove().draw()})}function copy(e){$("#modalSubmit").unbind("click").click(function(){save(-1)}),$("#attachmentUpload").unbind("click").click(function(){this.value=null}),$("#html_editor").ckeditor(),$("#attachmentsTable").show(),attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]});var t={attachments:[]},t=templates[e];$("#name").val("Copy of "+t.name),$("#subject").val(t.subject),$("#envelope-sender").val(t.envelope_sender),$("#html_editor").val(t.html),$("#text_editor").val(t.text),$.each(t.attachments,function(e,t){var a=icons[t.type]||"fa-file-o";attachmentsTable.row.add(['',escapeHtml(t.name),'',t.content,t.type||"application/octet-stream"]).draw()}),$("#attachmentsTable").unbind("click").on("click","span>i.fa-trash-o",function(){attachmentsTable.row($(this).parents("tr")).remove().draw()}),-1!=t.html.indexOf("{{.Tracker}}")?$("#use_tracker_checkbox").prop("checked",!0):$("#use_tracker_checkbox").prop("checked",!1)}function importEmail(){raw=$("#email_content").val(),convert_links=$("#convert_links_checkbox").prop("checked"),raw?api.import_email({content:raw,convert_links:convert_links}).success(function(e){$("#text_editor").val(e.text),$("#html_editor").val(e.html),$("#subject").val(e.subject),e.html&&(CKEDITOR.instances.html_editor.setMode("wysiwyg"),$('.nav-tabs a[href="#html"]').click()),$("#importEmailModal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)}):modalError("No Content Specified!")}function load(){$("#templateTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.templates.get().success(function(e){templates=e,$("#loading").hide(),0\t\t "])}),templateTable.rows.add(templateRows).draw(),$('[data-toggle="tooltip"]').tooltip()):$("#emptyMessage").show()}).error(function(){$("#loading").hide(),errorFlash("Error fetching templates")})}$(document).ready(function(){$(".modal").on("hidden.bs.modal",function(e){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)}),$(".modal").on("shown.bs.modal",function(e){void 0===$("body").data("fv_open_modals")&&$("body").data("fv_open_modals",0),$(this).hasClass("fv-modal-stack")||($(this).addClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")+1),$(this).css("z-index",1040+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not(".fv-modal-stack").css("z-index",1039+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not("fv-modal-stack").addClass("fv-modal-stack"))}),$.fn.modal.Constructor.prototype.enforceFocus=function(){$(document).off("focusin.bs.modal").on("focusin.bs.modal",$.proxy(function(e){this.$element[0]===e.target||this.$element.has(e.target).length||$(e.target).closest(".cke_dialog, .cke").length||this.$element.trigger("focus")},this))},$(document).on("hidden.bs.modal",".modal",function(){$(".modal:visible").length&&$(document.body).addClass("modal-open")}),$("#modal").on("hidden.bs.modal",function(e){dismiss()}),$("#importEmailModal").on("hidden.bs.modal",function(e){$("#email_content").val("")}),CKEDITOR.on("dialogDefinition",function(e){var t=e.data.name,e=e.data.definition;"link"==t&&(e.minWidth=500,e.minHeight=100,e.getContents("info").get("linkType").hidden=!0)}),load()}); \ No newline at end of file +var templates=[],icons={"application/vnd.ms-excel":"fa-file-excel-o","text/plain":"fa-file-text-o","image/gif":"fa-file-image-o","image/png":"fa-file-image-o","application/pdf":"fa-file-pdf-o","application/x-zip-compressed":"fa-file-archive-o","application/x-gzip":"fa-file-archive-o","application/vnd.openxmlformats-officedocument.presentationml.presentation":"fa-file-powerpoint-o","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"fa-file-word-o","application/octet-stream":"fa-file-o","application/x-msdownload":"fa-file-o"};function save(t){var e={attachments:[]};e.name=$("#name").val(),e.subject=$("#subject").val(),e.html=CKEDITOR.instances.html_editor.getData(),e.html=e.html.replace(/https?:\/\/{{\.URL}}/gi,"{{.URL}}"),$("#use_tracker_checkbox").prop("checked")?-1==e.html.indexOf("{{.Tracker}}")&&-1==e.html.indexOf("{{.TrackingUrl}}")&&(e.html=e.html.replace("","{{.Tracker}}")):e.html=e.html.replace("{{.Tracker}}",""),e.text=$("#text_editor").val(),$.each($("#attachmentsTable").DataTable().rows().data(),(function(t,a){e.attachments.push({name:unescapeHtml(a[1]),content:a[3],type:a[4]})})),-1!=t?(e.id=templates[t].id,api.templateId.put(e).success((function(t){successFlash("Template edited successfully!"),load(),dismiss()})).error((function(t){modalError(t.responseJSON.message)}))):api.templates.post(e).success((function(t){successFlash("Template added successfully!"),load(),dismiss()})).error((function(t){modalError(t.responseJSON.message)}))}function dismiss(){$("#modal\\.flashes").empty(),$("#attachmentsTable").dataTable().DataTable().clear().draw(),$("#name").val(""),$("#subject").val(""),$("#text_editor").val(""),$("#html_editor").val(""),$("#modal").modal("hide")}var deleteTemplate=function(t){Swal.fire({title:"Are you sure?",text:"This will delete the template. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+escapeHtml(templates[t].name),confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise((function(e,a){api.templateId.delete(templates[t].id).success((function(t){e()})).error((function(t){a(t.responseJSON.message)}))}))}}).then((function(t){t.value&&Swal.fire("Template Deleted!","This template has been deleted!","success"),$('button:contains("OK")').on("click",(function(){location.reload()}))}))};function deleteTemplate(t){confirm("Delete "+templates[t].name+"?")&&api.templateId.delete(templates[t].id).success((function(t){successFlash(t.message),load()}))}function attach(t){attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]}),$.each(t,(function(t,e){var a=new FileReader;a.onload=function(t){var o=icons[e.type]||"fa-file-o";attachmentsTable.row.add(['',escapeHtml(e.name),'',a.result.split(",")[1],e.type||"application/octet-stream"]).draw()},a.onerror=function(t){console.log(t)},a.readAsDataURL(e)}))}function edit(t){$("#modalSubmit").unbind("click").click((function(){save(t)})),$("#attachmentUpload").unbind("click").click((function(){this.value=null})),$("#html_editor").ckeditor(),setupAutocomplete(CKEDITOR.instances.html_editor),$("#attachmentsTable").show(),attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]});var e={attachments:[]};-1!=t?($("#templateModalLabel").text("Edit Template"),e=templates[t],$("#name").val(e.name),$("#subject").val(e.subject),$("#html_editor").val(e.html),$("#text_editor").val(e.text),attachmentRows=[],$.each(e.attachments,(function(t,e){var a=icons[e.type]||"fa-file-o";attachmentRows.push(['',escapeHtml(e.name),'',e.content,e.type||"application/octet-stream"])})),attachmentsTable.rows.add(attachmentRows).draw(),-1!=e.html.indexOf("{{.Tracker}}")?$("#use_tracker_checkbox").prop("checked",!0):$("#use_tracker_checkbox").prop("checked",!1)):$("#templateModalLabel").text("New Template"),$("#attachmentsTable").unbind("click").on("click","span>i.fa-trash-o",(function(){attachmentsTable.row($(this).parents("tr")).remove().draw()}))}function copy(t){$("#modalSubmit").unbind("click").click((function(){save(-1)})),$("#attachmentUpload").unbind("click").click((function(){this.value=null})),$("#html_editor").ckeditor(),$("#attachmentsTable").show(),attachmentsTable=$("#attachmentsTable").DataTable({destroy:!0,order:[[1,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{sClass:"datatable_hidden",targets:[3,4]}]});var e={attachments:[]};e=templates[t],$("#name").val("Copy of "+e.name),$("#subject").val(e.subject),$("#html_editor").val(e.html),$("#text_editor").val(e.text),$.each(e.attachments,(function(t,e){var a=icons[e.type]||"fa-file-o";attachmentsTable.row.add(['',escapeHtml(e.name),'',e.content,e.type||"application/octet-stream"]).draw()})),$("#attachmentsTable").unbind("click").on("click","span>i.fa-trash-o",(function(){attachmentsTable.row($(this).parents("tr")).remove().draw()})),-1!=e.html.indexOf("{{.Tracker}}")?$("#use_tracker_checkbox").prop("checked",!0):$("#use_tracker_checkbox").prop("checked",!1)}function importEmail(){raw=$("#email_content").val(),convert_links=$("#convert_links_checkbox").prop("checked"),raw?api.import_email({content:raw,convert_links:convert_links}).success((function(t){$("#text_editor").val(t.text),$("#html_editor").val(t.html),$("#subject").val(t.subject),t.html&&(CKEDITOR.instances.html_editor.setMode("wysiwyg"),$('.nav-tabs a[href="#html"]').click()),$("#importEmailModal").modal("hide")})).error((function(t){modalError(t.responseJSON.message)})):modalError("No Content Specified!")}function load(){$("#templateTable").hide(),$("#emptyMessage").hide(),$("#loading").show(),api.templates.get().success((function(t){templates=t,$("#loading").hide(),templates.length>0?($("#templateTable").show(),templateTable=$("#templateTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),templateTable.clear(),templateRows=[],$.each(templates,(function(t,e){templateRows.push([escapeHtml(e.name),moment(e.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"
\t\t
"])})),templateTable.rows.add(templateRows).draw(),$('[data-toggle="tooltip"]').tooltip()):$("#emptyMessage").show()})).error((function(){$("#loading").hide(),errorFlash("Error fetching templates")}))}$(document).ready((function(){$(".modal").on("hidden.bs.modal",(function(t){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)})),$(".modal").on("shown.bs.modal",(function(t){void 0===$("body").data("fv_open_modals")&&$("body").data("fv_open_modals",0),$(this).hasClass("fv-modal-stack")||($(this).addClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")+1),$(this).css("z-index",1040+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not(".fv-modal-stack").css("z-index",1039+10*$("body").data("fv_open_modals")),$(".modal-backdrop").not("fv-modal-stack").addClass("fv-modal-stack"))})),$.fn.modal.Constructor.prototype.enforceFocus=function(){$(document).off("focusin.bs.modal").on("focusin.bs.modal",$.proxy((function(t){this.$element[0]===t.target||this.$element.has(t.target).length||$(t.target).closest(".cke_dialog, .cke").length||this.$element.trigger("focus")}),this))},$(document).on("hidden.bs.modal",".modal",(function(){$(".modal:visible").length&&$(document.body).addClass("modal-open")})),$("#modal").on("hidden.bs.modal",(function(t){dismiss()})),$("#importEmailModal").on("hidden.bs.modal",(function(t){$("#email_content").val("")})),CKEDITOR.on("dialogDefinition",(function(t){var e=t.data.name,a=t.data.definition;"link"==e&&(a.minWidth=500,a.minHeight=100,a.getContents("info").get("linkType").hidden=!0)})),load()})); \ No newline at end of file diff --git a/static/js/dist/app/users.min.js b/static/js/dist/app/users.min.js index 40631033..6c195c56 100644 --- a/static/js/dist/app/users.min.js +++ b/static/js/dist/app/users.min.js @@ -1 +1 @@ -!function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=8)}({8:function(e,t){var o=[],n=function(){$("#username").val(""),$("#password").val(""),$("#confirm_password").val(""),$("#role").val(""),$("#modal\\.flashes").empty()},r=function(e){$("#modalSubmit").unbind("click").click(function(){!function(e){if($("#password").val()===$("#confirm_password").val()){var t={username:$("#username").val(),password:$("#password").val(),role:$("#role").val(),password_change_required:$("#force_password_change_checkbox").prop("checked")};-1!=e?(t.id=e,api.userId.put(t).success(function(e){successFlash("User "+escapeHtml(t.username)+" updated successfully!"),s(),n(),$("#modal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)})):api.users.post(t).success(function(e){successFlash("User "+escapeHtml(t.username)+" registered successfully!"),s(),n(),$("#modal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)})}else modalError("Passwords must match.")}(e)}),$("#role").select2(),-1==e?($("#role").val("user"),$("#role").trigger("change")):api.userId.get(e).success(function(e){$("#username").val(e.username),$("#role").val(e.role.slug),$("#role").trigger("change"),$("#force_password_change_checkbox").prop("checked",!1)}).error(function(){errorFlash("Error fetching user")})},s=function(){$("#userTable").hide(),$("#loading").show(),api.users.get().success(function(e){o=e,$("#loading").hide(),$("#userTable").show();var t=$("#userTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]});t.clear(),userRows=[],$.each(o,function(e,t){lastlogin="Never","0001-01-01T00:00:00Z"!=t.last_login&&(lastlogin=moment(t.last_login).format("MMMM Do YYYY, h:mm:ss a")),userRows.push([escapeHtml(t.username),escapeHtml(t.role.name),lastlogin,"
"])}),t.rows.add(userRows).draw()}).error(function(){errorFlash("Error fetching users")})};$(document).ready(function(){s(),$("#modal").on("hide.bs.modal",function(){n()}),$.fn.select2.defaults.set("width","100%"),$.fn.select2.defaults.set("dropdownParent",$("#role-select")),$.fn.select2.defaults.set("theme","bootstrap"),$.fn.select2.defaults.set("sorter",function(e){return e.sort(function(e,t){return e.text.toLowerCase()>t.text.toLowerCase()?1:e.text.toLowerCase()"+escapeHtml(n.username)+"",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Swap User",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1}).then(function(e){e.value&&fetch("/impersonate",{method:"post",body:"username="+n.username+"&csrf_token="+encodeURIComponent(csrf_token),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(e){200==e.status?Swal.fire({title:"Success!",html:"Successfully changed to user "+escapeHtml(n.username)+".",type:"success",showCancelButton:!1,confirmButtonText:"Home",allowOutsideClick:!1}).then(function(e){e.value&&(window.location.href="/")}):Swal.fire({title:"Error!",type:"error",html:"Failed to change to user "+escapeHtml(n.username)+".",showCancelButton:!1})})})})})}}); \ No newline at end of file +let users=[];const save=e=>{if($("#password").val()!==$("#confirm_password").val())return void modalError("Passwords must match.");let t={username:$("#username").val(),password:$("#password").val(),role:$("#role").val(),password_change_required:$("#force_password_change_checkbox").prop("checked"),account_locked:$("#account_locked_checkbox").prop("checked")};-1!=e?(t.id=e,api.userId.put(t).success((e=>{successFlash("User "+escapeHtml(t.username)+" updated successfully!"),load(),dismiss(),$("#modal").modal("hide")})).error((e=>{modalError(e.responseJSON.message)}))):api.users.post(t).success((e=>{successFlash("User "+escapeHtml(t.username)+" registered successfully!"),load(),dismiss(),$("#modal").modal("hide")})).error((e=>{modalError(e.responseJSON.message)}))},dismiss=()=>{$("#username").val(""),$("#password").val(""),$("#confirm_password").val(""),$("#role").val(""),$("#force_password_change_checkbox").prop("checked",!0),$("#account_locked_checkbox").prop("checked",!1),$("#modal\\.flashes").empty()},edit=e=>{$("#modalSubmit").unbind("click").click((()=>{save(e)})),$("#role").select2(),-1==e?($("#userModalLabel").text("New User"),$("#role").val("user"),$("#role").trigger("change")):($("#userModalLabel").text("Edit User"),api.userId.get(e).success((e=>{$("#username").val(e.username),$("#role").val(e.role.slug),$("#role").trigger("change"),$("#force_password_change_checkbox").prop("checked",e.password_change_required),$("#account_locked_checkbox").prop("checked",e.account_locked)})).error((function(){errorFlash("Error fetching user")})))},deleteUser=e=>{var s=users.find((t=>t.id==e));t&&Swal.fire({title:"Are you sure?",text:"This will delete the account for "+escapeHtml(t.username)+" as well as all of the objects they have created.\n\nThis can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(((t,s)=>{api.userId.delete(e).success((e=>{t()})).error((e=>{s(e.responseJSON.message)}))})).catch((e=>{Swal.showValidationMessage(e)}))}}).then((function(e){e.value&&Swal.fire("User Deleted!","The user account for "+escapeHtml(t.username)+" and all associated objects have been deleted!","success"),$('button:contains("OK")').on("click",(function(){location.reload()}))}))},impersonate=e=>{var s=users.find((t=>t.id==e));t&&Swal.fire({title:"Are you sure?",html:"You will be logged out of your account and logged in as "+escapeHtml(t.username)+"",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Swap User",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1}).then((e=>{e.value&&fetch("/impersonate",{method:"post",body:"username="+t.username+"&csrf_token="+encodeURIComponent(csrf_token),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((e=>{200==e.status?Swal.fire({title:"Success!",html:"Successfully changed to user "+escapeHtml(t.username)+".",type:"success",showCancelButton:!1,confirmButtonText:"Home",allowOutsideClick:!1}).then((e=>{e.value&&(window.location.href="/")})):Swal.fire({title:"Error!",type:"error",html:"Failed to change to user "+escapeHtml(t.username)+".",showCancelButton:!1})}))}))},load=()=>{$("#userTable").hide(),$("#loading").show(),api.users.get().success((e=>{users=e,$("#loading").hide(),$("#userTable").show();let t=$("#userTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]});t.clear(),userRows=[],$.each(users,((e,t)=>{lastlogin="Never","0001-01-01T00:00:00Z"!=t.last_login&&(lastlogin=moment(t.last_login).format("MMMM Do YYYY, h:mm:ss a")),userRows.push([escapeHtml(t.username),escapeHtml(t.role.name),lastlogin,"
"])})),t.rows.add(userRows).draw()})).error((()=>{errorFlash("Error fetching users")}))};$(document).ready((function(){load(),$("#modal").on("hide.bs.modal",(function(){dismiss()})),$.fn.select2.defaults.set("width","100%"),$.fn.select2.defaults.set("dropdownParent",$("#role-select")),$.fn.select2.defaults.set("theme","bootstrap"),$.fn.select2.defaults.set("sorter",(function(e){return e.sort((function(e,t){return e.text.toLowerCase()>t.text.toLowerCase()?1:e.text.toLowerCase()e.id==t)))&&Swal.fire({title:"Are you sure?",text:"This will delete the account for "+escapeHtml(s.username)+" as well as all of the objects they have created.\n\nThis can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(((e,s)=>{api.userId.delete(t).success((t=>{e()})).error((e=>{s(e.responseJSON.message)}))})).catch((e=>{Swal.showValidationMessage(e)}))}}).then((function(e){e.value&&Swal.fire("User Deleted!","The user account for "+escapeHtml(s.username)+" and all associated objects have been deleted!","success"),$('button:contains("OK")').on("click",(function(){location.reload()}))}))})),$("#userTable").on("click",".impersonate_button",(function(e){var t,s;t=$(this).attr("data-user-id"),(s=users.find((e=>e.id==t)))&&Swal.fire({title:"Are you sure?",html:"You will be logged out of your account and logged in as "+escapeHtml(s.username)+"",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Swap User",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1}).then((e=>{e.value&&fetch("/impersonate",{method:"post",body:"username="+s.username+"&csrf_token="+encodeURIComponent(csrf_token),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((e=>{200==e.status?Swal.fire({title:"Success!",html:"Successfully changed to user "+escapeHtml(s.username)+".",type:"success",showCancelButton:!1,confirmButtonText:"Home",allowOutsideClick:!1}).then((e=>{e.value&&(window.location.href="/")})):Swal.fire({title:"Error!",type:"error",html:"Failed to change to user "+escapeHtml(s.username)+".",showCancelButton:!1})}))}))}))})); \ No newline at end of file diff --git a/static/js/dist/app/webhooks.min.js b/static/js/dist/app/webhooks.min.js index 1d677464..8511a1a3 100644 --- a/static/js/dist/app/webhooks.min.js +++ b/static/js/dist/app/webhooks.min.js @@ -1 +1 @@ -!function(e){var t={};function n(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(o,a,function(t){return e[t]}.bind(null,a));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=9)}({9:function(e,t){var n=[],o=function(){$("#name").val(""),$("#url").val(""),$("#secret").val(""),$("#is_active").prop("checked",!1),$("#flashes").empty()},a=function(){$("#webhookTable").hide(),$("#loading").show(),api.webhooks.get().success(function(e){n=e,$("#loading").hide(),$("#webhookTable").show();var t=$("#webhookTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]});t.clear(),$.each(n,function(e,n){t.row.add([escapeHtml(n.name),escapeHtml(n.url),escapeHtml(n.is_active),'\n
\n \n \n \n
\n ')]).draw()})}).error(function(){errorFlash("Error fetching webhooks")})},c=function(e){$("#modalSubmit").unbind("click").click(function(){!function(e){var t={name:$("#name").val(),url:$("#url").val(),secret:$("#secret").val(),is_active:$("#is_active").is(":checked")};-1!=e?(t.id=parseInt(e),api.webhookId.put(t).success(function(e){o(),a(),$("#modal").modal("hide"),successFlash('Webhook "'.concat(escapeHtml(t.name),'" has been updated successfully!'))}).error(function(e){modalError(e.responseJSON.message)})):api.webhooks.post(t).success(function(e){a(),o(),$("#modal").modal("hide"),successFlash('Webhook "'.concat(escapeHtml(t.name),'" has been created successfully!'))}).error(function(e){modalError(e.responseJSON.message)})}(e)}),-1!==e&&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")})};$(document).ready(function(){a(),$("#modal").on("hide.bs.modal",function(){o()}),$("#new_button").on("click",function(){c(-1)}),$("#webhookTable").on("click",".edit_button",function(e){c($(this).attr("data-webhook-id"))}),$("#webhookTable").on("click",".delete_button",function(e){var t,o;t=$(this).attr("data-webhook-id"),(o=n.find(function(e){return e.id==t}))&&Swal.fire({title:"Are you sure?",text:"This will delete the webhook '".concat(escapeHtml(o.name),"'"),type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(e,n){api.webhookId.delete(t).success(function(t){e()}).error(function(e){n(e.responseJSON.message)})}).catch(function(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 t,a;t=e.currentTarget,a=e.currentTarget.dataset.webhookId,o(),t.disabled=!0,api.webhookId.ping(a).success(function(e){t.disabled=!1,successFlash('Ping of "'.concat(escapeHtml(e.name),'" webhook succeeded.'))}).error(function(e){t.disabled=!1;var o=n.find(function(e){return e.id==a});o&&errorFlash('Ping of "'.concat(escapeHtml(o.name),'" webhook failed: "').concat(escapeHtml(e.responseJSON.message),'"'))})})})}}); \ No newline at end of file +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
\n \n \n \n
\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)}"`)}))}))})); \ No newline at end of file diff --git a/static/js/src/app/groups.js b/static/js/src/app/groups.js index 1bf701d8..1bb63ef5 100644 --- a/static/js/src/app/groups.js +++ b/static/js/src/app/groups.js @@ -64,8 +64,10 @@ function edit(id) { save(id) }) if (id == -1) { + $("#groupModalLabel").text("New Group"); var group = {} } else { + $("#groupModalLabel").text("Edit Group"); api.groupId.get(id) .success(function (group) { $("#name").val(group.name) diff --git a/static/js/src/app/landing_pages.js b/static/js/src/app/landing_pages.js index 29152746..a9392314 100644 --- a/static/js/src/app/landing_pages.js +++ b/static/js/src/app/landing_pages.js @@ -113,6 +113,7 @@ function edit(idx) { setupAutocomplete(CKEDITOR.instances["html_editor"]) var page = {} if (idx != -1) { + $("#modalLabel").text("Edit Landing Page") page = pages[idx] $("#name").val(page.name) $("#html_editor").val(page.html) @@ -123,6 +124,8 @@ function edit(idx) { $("#capture_passwords").show() $("#redirect_url").show() } + } else { + $("#modalLabel").text("New Landing Page") } } diff --git a/static/js/src/app/sending_profiles.js b/static/js/src/app/sending_profiles.js index d4874b8e..5d662c96 100644 --- a/static/js/src/app/sending_profiles.js +++ b/static/js/src/app/sending_profiles.js @@ -153,6 +153,7 @@ function edit(idx) { }) var profile = {} if (idx != -1) { + $("#profileModalLabel").text("Edit Sending Profile") profile = profiles[idx] $("#name").val(profile.name) $("#interface_type").val(profile.interface_type) @@ -164,6 +165,8 @@ function edit(idx) { $.each(profile.headers, function (i, record) { addCustomHeader(record.key, record.value) }); + } else { + $("#profileModalLabel").text("New Sending Profile") } } diff --git a/static/js/src/app/templates.js b/static/js/src/app/templates.js index cd92b3a0..154db7b8 100644 --- a/static/js/src/app/templates.js +++ b/static/js/src/app/templates.js @@ -187,6 +187,7 @@ function edit(idx) { attachments: [] } if (idx != -1) { + $("#templateModalLabel").text("Edit Template") template = templates[idx] $("#name").val(template.name) $("#subject").val(template.subject) @@ -212,6 +213,8 @@ function edit(idx) { $("#use_tracker_checkbox").prop("checked", false) } + } else { + $("#templateModalLabel").text("New Template") } // Handle Deletion $("#attachmentsTable").unbind('click').on("click", "span>i.fa-trash-o", function () { diff --git a/static/js/src/app/users.js b/static/js/src/app/users.js index 48d581cc..435c3a73 100644 --- a/static/js/src/app/users.js +++ b/static/js/src/app/users.js @@ -61,9 +61,11 @@ const edit = (id) => { }) $("#role").select2() if (id == -1) { + $("#userModalLabel").text("New User") $("#role").val("user") $("#role").trigger("change") } else { + $("#userModalLabel").text("Edit User") api.userId.get(id) .success((user) => { $("#username").val(user.username) diff --git a/static/js/src/app/webhooks.js b/static/js/src/app/webhooks.js index 2bffe1bd..22374b43 100644 --- a/static/js/src/app/webhooks.js +++ b/static/js/src/app/webhooks.js @@ -88,6 +88,7 @@ const editWebhook = (id) => { saveWebhook(id); }); if (id !== -1) { + $("#webhookModalLabel").text("Edit Webhook") api.webhookId.get(id) .success(function(wh) { $("#name").val(wh.name); @@ -98,6 +99,8 @@ const editWebhook = (id) => { .error(function () { errorFlash("Error fetching webhook") }); + } else { + $("#webhookModalLabel").text("New Webhook") } }; diff --git a/templates/users.html b/templates/users.html index 0626d714..ff5e754a 100644 --- a/templates/users.html +++ b/templates/users.html @@ -40,7 +40,7 @@ - +