diff --git a/static/js/dist/app/campaigns.min.js b/static/js/dist/app/campaigns.min.js deleted file mode 100644 index c2863326..00000000 --- a/static/js/dist/app/campaigns.min.js +++ /dev/null @@ -1 +0,0 @@ -var labels={"In progress":"label-primary",Queued:"label-info",Completed:"label-success","Emails Sent":"label-success",Error:"label-danger"};var campaigns=[];var campaign={};function launch(){Swal.fire({title:"Are you sure?",text:"This will schedule the campaign to be launched.",type:"question",animation:false,showCancelButton:true,confirmButtonText:"Launch",confirmButtonColor:"#428bca",reverseButtons:true,allowOutsideClick:false,showLoaderOnConfirm:true,preConfirm:function(){return new Promise(function(resolve,reject){groups=[];$("#users").select2("data").forEach(function(group){groups.push({name:group.text})});var send_by_date=$("#send_by_date").val();if(send_by_date!=""){send_by_date=moment(send_by_date,"MMMM Do YYYY, h:mm a").utc().format()}campaign={name:$("#name").val(),template:{name:$("#template").select2("data")[0].text},url:$("#url").val(),page:{name:$("#page").select2("data")[0].text},smtp:{name:$("#profile").select2("data")[0].text},launch_date:moment($("#launch_date").val(),"MMMM Do YYYY, h:mm a").utc().format(),send_by_date:send_by_date||null,groups:groups};api.campaigns.post(campaign).success(function(data){resolve();campaign=data}).error(function(data){$("#modal\\.flashes").empty().append('
'+data.responseJSON.message+"
");Swal.close()})})}}).then(function(result){if(result.value){Swal.fire("Campaign Scheduled!","This campaign has been scheduled for launch!","success")}$('button:contains("OK")').on("click",function(){window.location="/campaigns/"+campaign.id.toString()})})}function sendTestEmail(){var test_email_request={template:{name:$("#template").select2("data")[0].text},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:$("#url").val(),page:{name:$("#page").select2("data")[0].text},smtp:{name:$("#profile").select2("data")[0].text}};btnHtml=$("#sendTestModalSubmit").html();$("#sendTestModalSubmit").html(' Sending');api.send_test_email(test_email_request).success(function(data){$("#sendTestEmailModal\\.flashes").empty().append('
Email Sent!
');$("#sendTestModalSubmit").html(btnHtml)}).error(function(data){$("#sendTestEmailModal\\.flashes").empty().append('
'+data.responseJSON.message+"
");$("#sendTestModalSubmit").html(btnHtml)})}function dismiss(){$("#modal\\.flashes").empty();$("#name").val("");$("#template").val("").change();$("#page").val("").change();$("#url").val("");$("#profile").val("").change();$("#users").val("").change();$("#modal").modal("hide")}function deleteCampaign(idx){Swal.fire({title:"Are you sure?",text:"This will delete the campaign. This can't be undone!",type:"warning",animation:false,showCancelButton:true,confirmButtonText:"Delete "+campaigns[idx].name,confirmButtonColor:"#428bca",reverseButtons:true,allowOutsideClick:false,preConfirm:function(){return new Promise(function(resolve,reject){api.campaignId.delete(campaigns[idx].id).success(function(msg){resolve()}).error(function(data){reject(data.responseJSON.message)})})}}).then(function(result){if(result.value){Swal.fire("Campaign Deleted!","This campaign has been deleted!","success")}$('button:contains("OK")').on("click",function(){location.reload()})})}function setupOptions(){api.groups.summary().success(function(summaries){groups=summaries.groups;if(groups.length==0){modalError("No groups found!");return false}else{var group_s2=$.map(groups,function(obj){obj.text=obj.name;obj.title=obj.num_targets+" targets";return obj});console.log(group_s2);$("#users.form-control").select2({placeholder:"Select Groups",data:group_s2})}});api.templates.get().success(function(templates){if(templates.length==0){modalError("No templates found!");return false}else{var template_s2=$.map(templates,function(obj){obj.text=obj.name;return obj});var template_select=$("#template.form-control");template_select.select2({placeholder:"Select a Template",data:template_s2});if(templates.length===1){template_select.val(template_s2[0].id);template_select.trigger("change.select2")}}});api.pages.get().success(function(pages){if(pages.length==0){modalError("No pages found!");return false}else{var page_s2=$.map(pages,function(obj){obj.text=obj.name;return obj});var page_select=$("#page.form-control");page_select.select2({placeholder:"Select a Landing Page",data:page_s2});if(pages.length===1){page_select.val(page_s2[0].id);page_select.trigger("change.select2")}}});api.SMTP.get().success(function(profiles){if(profiles.length==0){modalError("No profiles found!");return false}else{var profile_s2=$.map(profiles,function(obj){obj.text=obj.name;return obj});var profile_select=$("#profile.form-control");profile_select.select2({placeholder:"Select a Sending Profile",data:profile_s2}).select2("val",profile_s2[0]);if(profiles.length===1){profile_select.val(profile_s2[0].id);profile_select.trigger("change.select2")}}})}function edit(campaign){setupOptions()}function copy(idx){setupOptions();api.campaignId.get(campaigns[idx].id).success(function(campaign){$("#name").val("Copy of "+campaign.name);if(!campaign.template.id){$("#template").val("").change();$("#template").select2({placeholder:campaign.template.name})}else{$("#template").val(campaign.template.id.toString());$("#template").trigger("change.select2")}if(!campaign.page.id){$("#page").val("").change();$("#page").select2({placeholder:campaign.page.name})}else{$("#page").val(campaign.page.id.toString());$("#page").trigger("change.select2")}if(!campaign.smtp.id){$("#profile").val("").change();$("#profile").select2({placeholder:campaign.smtp.name})}else{$("#profile").val(campaign.smtp.id.toString());$("#profile").trigger("change.select2")}$("#url").val(campaign.url)}).error(function(data){$("#modal\\.flashes").empty().append('
'+data.responseJSON.message+"
")})}$(document).ready(function(){$("#launch_date").datetimepicker({widgetPositioning:{vertical:"bottom"},showTodayButton:true,defaultDate:moment(),format:"MMMM Do YYYY, h:mm a"});$("#send_by_date").datetimepicker({widgetPositioning:{vertical:"bottom"},showTodayButton:true,useCurrent:false,format:"MMMM Do YYYY, h:mm a"});$(".modal").on("hidden.bs.modal",function(event){$(this).removeClass("fv-modal-stack");$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)});$(".modal").on("shown.bs.modal",function(event){if(typeof $("body").data("fv_open_modals")=="undefined"){$("body").data("fv_open_modals",0)}if($(this).hasClass("fv-modal-stack")){return}$(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")});$(document).on("hidden.bs.modal",".modal",function(){$(".modal:visible").length&&$(document.body).addClass("modal-open")});$("#modal").on("hidden.bs.modal",function(event){dismiss()});api.campaigns.summary().success(function(data){campaigns=data.campaigns;$("#loading").hide();if(campaigns.length>0){$("#campaignTable").show();$("#campaignTableArchive").show();activeCampaignsTable=$("#campaignTable").DataTable({columnDefs:[{orderable:false,targets:"no-sort"}],order:[[1,"desc"]]});archivedCampaignsTable=$("#campaignTableArchive").DataTable({columnDefs:[{orderable:false,targets:"no-sort"}],order:[[1,"desc"]]});rows={active:[],archived:[]};$.each(campaigns,function(i,campaign){label=labels[campaign.status]||"label-default";var launchDate;if(moment(campaign.launch_date).isAfter(moment())){launchDate="Scheduled to start: "+moment(campaign.launch_date).format("MMMM Do YYYY, h:mm:ss a");var quickStats=launchDate+"

"+"Number of recipients: "+campaign.stats.total}else{launchDate="Launch Date: "+moment(campaign.launch_date).format("MMMM Do YYYY, h:mm:ss a");var quickStats=launchDate+"

"+"Number of recipients: "+campaign.stats.total+"

"+"Emails opened: "+campaign.stats.opened+"

"+"Emails clicked: "+campaign.stats.clicked+"

"+"Submitted Credentials: "+campaign.stats.submitted_data+"

"+"Errors : "+campaign.stats.error+"

"+"Reported : "+campaign.stats.email_reported}var row=[escapeHtml(campaign.name),moment(campaign.created_date).format("MMMM Do YYYY, h:mm:ss a"),''+campaign.status+"","
"];if(campaign.status=="Completed"){rows["archived"].push(row)}else{rows["active"].push(row)}});activeCampaignsTable.rows.add(rows["active"]).draw();archivedCampaignsTable.rows.add(rows["archived"]).draw();$('[data-toggle="tooltip"]').tooltip()}else{$("#emptyMessage").show()}}).error(function(){$("#loading").hide();errorFlash("Error fetching campaigns")});$.fn.select2.defaults.set("width","100%");$.fn.select2.defaults.set("dropdownParent",$("#modal_body"));$.fn.select2.defaults.set("theme","bootstrap");$.fn.select2.defaults.set("sorter",function(data){return data.sort(function(a,b){if(a.text.toLowerCase()>b.text.toLowerCase()){return 1}if(a.text.toLowerCase()'])})),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 deleted file mode 100644 index 18092d80..00000000 --- a/static/js/dist/app/landing_pages.min.js +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index df2b5809..00000000 --- a/static/js/dist/app/sending_profiles.min.js +++ /dev/null @@ -1 +0,0 @@ -var profiles=[];function sendTestEmail(){var headers=[];$.each($("#headersTable").DataTable().rows().data(),function(i,header){headers.push({key:unescapeHtml(header[0]),value:unescapeHtml(header[1])})});var test_email_request={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:headers}};btnHtml=$("#sendTestModalSubmit").html();$("#sendTestModalSubmit").html(' Sending');api.send_test_email(test_email_request).success(function(data){$("#sendTestEmailModal\\.flashes").empty().append('
\t Email Sent!
');$("#sendTestModalSubmit").html(btnHtml)}).error(function(data){$("#sendTestEmailModal\\.flashes").empty().append('
\t '+escapeHtml(data.responseJSON.message)+"
");$("#sendTestModalSubmit").html(btnHtml)})}function save(idx){var profile={headers:[]};$.each($("#headersTable").DataTable().rows().data(),function(i,header){profile.headers.push({key:unescapeHtml(header[0]),value:unescapeHtml(header[1])})});profile.name=$("#name").val();profile.interface_type=$("#interface_type").val();profile.from_address=$("#from").val();profile.host=$("#host").val();profile.username=$("#username").val();profile.password=$("#password").val();profile.ignore_cert_errors=$("#ignore_cert_errors").prop("checked");if(idx!=-1){profile.id=profiles[idx].id;api.SMTPId.put(profile).success(function(data){successFlash("Profile edited successfully!");load();dismiss()}).error(function(data){modalError(data.responseJSON.message)})}else{api.SMTP.post(profile).success(function(data){successFlash("Profile added successfully!");load();dismiss()}).error(function(data){modalError(data.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",true);$("#headersTable").dataTable().DataTable().clear().draw();$("#modal").modal("hide")}var dismissSendTestEmailModal=function(){$("#sendTestEmailModal\\.flashes").empty();$("#sendTestModalSubmit").html(" Send")};var deleteProfile=function(idx){Swal.fire({title:"Are you sure?",text:"This will delete the sending profile. This can't be undone!",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(result){if(result.value){Swal.fire("Sending Profile Deleted!","This sending profile has been deleted!","success")}$('button:contains("OK")').on("click",function(){location.reload()})})};function edit(idx){headers=$("#headersTable").dataTable({destroy:true,columnDefs:[{orderable:false,targets:"no-sort"}]});$("#modalSubmit").unbind("click").click(function(){save(idx)});var profile={};if(idx!=-1){$("#profileModalLabel").text("Edit Sending Profile");profile=profiles[idx];$("#name").val(profile.name);$("#interface_type").val(profile.interface_type);$("#from").val(profile.from_address);$("#host").val(profile.host);$("#username").val(profile.username);$("#password").val(profile.password);$("#ignore_cert_errors").prop("checked",profile.ignore_cert_errors);$.each(profile.headers,function(i,record){addCustomHeader(record.key,record.value)})}else{$("#profileModalLabel").text("New Sending Profile")}}function copy(idx){$("#modalSubmit").unbind("click").click(function(){save(-1)});var profile={};profile=profiles[idx];$("#name").val("Copy of "+profile.name);$("#interface_type").val(profile.interface_type);$("#from").val(profile.from_address);$("#host").val(profile.host);$("#username").val(profile.username);$("#password").val(profile.password);$("#ignore_cert_errors").prop("checked",profile.ignore_cert_errors)}function load(){$("#profileTable").hide();$("#emptyMessage").hide();$("#loading").show();api.SMTP.get().success(function(ss){profiles=ss;$("#loading").hide();if(profiles.length>0){$("#profileTable").show();profileTable=$("#profileTable").DataTable({destroy:true,columnDefs:[{orderable:false,targets:"no-sort"}]});profileTable.clear();profileRows=[];$.each(profiles,function(i,profile){profileRows.push([escapeHtml(profile.name),profile.interface_type,moment(profile.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"
\t\t
"])});profileTable.rows.add(profileRows).draw();$('[data-toggle="tooltip"]').tooltip()}else{$("#emptyMessage").show()}}).error(function(){$("#loading").hide();errorFlash("Error fetching profiles")})}function addCustomHeader(header,value){var newRow=[escapeHtml(header),escapeHtml(value),''];var headersTable=headers.DataTable();var existingRowIndex=headersTable.column(0).data().indexOf(escapeHtml(header));if(existingRowIndex>=0){headersTable.row(existingRowIndex,{order:"index"}).data(newRow)}else{headersTable.row.add(newRow)}headersTable.draw()}$(document).ready(function(){$(".modal").on("hidden.bs.modal",function(event){$(this).removeClass("fv-modal-stack");$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)});$(".modal").on("shown.bs.modal",function(event){if(typeof $("body").data("fv_open_modals")=="undefined"){$("body").data("fv_open_modals",0)}if($(this).hasClass("fv-modal-stack")){return}$(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){if(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(event){dismiss()});$("#sendTestEmailModal").on("hidden.bs.modal",function(event){dismissSendTestEmailModal()});$("#addCustomHeader").on("click",function(){headerKey=$("#headerKey").val();headerValue=$("#headerValue").val();if(headerKey==""||headerValue==""){return false}addCustomHeader(headerKey,headerValue);$("#headerKey").val("");$("#headerValue").val("");$("#headerKey").focus();return false});$("#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 deleted file mode 100644 index 3d996d66..00000000 --- a/static/js/dist/app/templates.min.js +++ /dev/null @@ -1 +0,0 @@ -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 t={attachments:[]};t.name=$("#name").val(),t.subject=$("#subject").val(),t.envelope_sender=$("#envelope-sender").val(),t.html=CKEDITOR.instances.html_editor.getData(),t.html=t.html.replace(/https?:\/\/{{\.URL}}/gi,"{{.URL}}"),$("#use_tracker_checkbox").prop("checked")?-1==t.html.indexOf("{{.Tracker}}")&&-1==t.html.indexOf("{{.TrackingUrl}}")&&(t.html=t.html.replace("","{{.Tracker}}")):t.html=t.html.replace("{{.Tracker}}",""),t.text=$("#text_editor").val(),$.each($("#attachmentsTable").DataTable().rows().data(),(function(e,a){t.attachments.push({name:unescapeHtml(a[1]),content:a[3],type:a[4]})})),-1!=e?(t.id=templates[e].id,api.templateId.put(t).success((function(e){successFlash("Template edited successfully!"),load(),dismiss()})).error((function(e){modalError(e.responseJSON.message)}))):api.templates.post(t).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,t){var a=new FileReader;a.onload=function(e){var o=icons[t.type]||"fa-file-o";attachmentsTable.row.add(['',escapeHtml(t.name),'',a.result.split(",")[1],t.type||"application/octet-stream"]).draw()},a.onerror=function(e){console.log(e)},a.readAsDataURL(t)}))}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?($("#templateModalLabel").text("Edit Template"),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)):$("#templateModalLabel").text("New Template"),$("#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(),templates.length>0?($("#templateTable").show(),templateTable=$("#templateTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),templateTable.clear(),templateRows=[],$.each(templates,(function(e,t){templateRows.push([escapeHtml(t.name),moment(t.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(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,a=e.data.definition;"link"==t&&(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 deleted file mode 100644 index f1b7666d..00000000 --- a/static/js/dist/app/users.min.js +++ /dev/null @@ -1 +0,0 @@ -let users=[];const save=id=>{if($("#password").val()!==$("#confirm_password").val()){modalError("Passwords must match.");return}let user={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")};if(id!=-1){user.id=id;api.userId.put(user).success(data=>{successFlash("User "+escapeHtml(user.username)+" updated successfully!");load();dismiss();$("#modal").modal("hide")}).error(data=>{modalError(data.responseJSON.message)})}else{api.users.post(user).success(data=>{successFlash("User "+escapeHtml(user.username)+" registered successfully!");load();dismiss();$("#modal").modal("hide")}).error(data=>{modalError(data.responseJSON.message)})}};const dismiss=()=>{$("#username").val("");$("#password").val("");$("#confirm_password").val("");$("#role").val("");$("#force_password_change_checkbox").prop("checked",true);$("#account_locked_checkbox").prop("checked",false);$("#modal\\.flashes").empty()};const edit=id=>{$("#username").attr("disabled",false);$("#modalSubmit").unbind("click").click(()=>{save(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);$("#role").val(user.role.slug);$("#role").trigger("change");$("#force_password_change_checkbox").prop("checked",user.password_change_required);$("#account_locked_checkbox").prop("checked",user.account_locked);if(user.username=="admin"){$("#username").attr("disabled",true)}}).error(function(){errorFlash("Error fetching user")})}};const deleteUser=id=>{var user=users.find(x=>x.id==id);if(!user){return}if(user.username=="admin"){Swal.fire({title:"Unable to Delete User",text:"The user account "+escapeHtml(user.username)+" cannot be deleted.",type:"info"});return}Swal.fire({title:"Are you sure?",text:"This will delete the account for "+escapeHtml(user.username)+" as well as all of the objects they have created.\n\nThis can't be undone!",type:"warning",animation:false,showCancelButton:true,confirmButtonText:"Delete",confirmButtonColor:"#428bca",reverseButtons:true,allowOutsideClick:false,preConfirm:function(){return new Promise((resolve,reject)=>{api.userId.delete(id).success(msg=>{resolve()}).error(data=>{reject(data.responseJSON.message)})}).catch(error=>{Swal.showValidationMessage(error)})}}).then(function(result){if(result.value){Swal.fire("User Deleted!","The user account for "+escapeHtml(user.username)+" and all associated objects have been deleted!","success")}$('button:contains("OK")').on("click",function(){location.reload()})})};const impersonate=id=>{var user=users.find(x=>x.id==id);if(!user){return}Swal.fire({title:"Are you sure?",html:"You will be logged out of your account and logged in as "+escapeHtml(user.username)+"",type:"warning",animation:false,showCancelButton:true,confirmButtonText:"Swap User",confirmButtonColor:"#428bca",reverseButtons:true,allowOutsideClick:false}).then(result=>{if(result.value){fetch("/impersonate",{method:"post",body:"username="+user.username+"&csrf_token="+encodeURIComponent(csrf_token),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(response=>{if(response.status==200){Swal.fire({title:"Success!",html:"Successfully changed to user "+escapeHtml(user.username)+".",type:"success",showCancelButton:false,confirmButtonText:"Home",allowOutsideClick:false}).then(result=>{if(result.value){window.location.href="/"}})}else{Swal.fire({title:"Error!",type:"error",html:"Failed to change to user "+escapeHtml(user.username)+".",showCancelButton:false})}})}})};const load=()=>{$("#userTable").hide();$("#loading").show();api.users.get().success(us=>{users=us;$("#loading").hide();$("#userTable").show();let userTable=$("#userTable").DataTable({destroy:true,columnDefs:[{orderable:false,targets:"no-sort"}]});userTable.clear();userRows=[];$.each(users,(i,user)=>{lastlogin="";if(user.last_login!="0001-01-01T00:00:00Z"){lastlogin=moment(user.last_login).format("MMMM Do YYYY, h:mm:ss a")}userRows.push([escapeHtml(user.username),escapeHtml(user.role.name),lastlogin,"
"])});userTable.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(data){return data.sort(function(a,b){if(a.text.toLowerCase()>b.text.toLowerCase()){return 1}if(a.text.toLowerCase(){$("#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