diff --git a/static/js/dist/app/campaigns.min.js b/static/js/dist/app/campaigns.min.js index ed63d1eb..c2863326 100644 --- a/static/js/dist/app/campaigns.min.js +++ b/static/js/dist/app/campaigns.min.js @@ -1 +1 @@ -var labels={"In progress":"label-primary",Queued:"label-info",Completed:"label-success","Emails Sent":"label-success",Error:"label-danger"},campaigns=[],campaign={};function launch(){Swal.fire({title:"Are you sure?",text:"This will schedule the campaign to be launched.",type:"question",animation:!1,showCancelButton:!0,confirmButtonText:"Launch",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,showLoaderOnConfirm:!0,preConfirm:function(){return new Promise(function(a,e){groups=[],$("#users").select2("data").forEach(function(e){groups.push({name:e.text})});var t=$("#send_by_date").val();""!=t&&(t=moment(t,"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:t||null,groups:groups},api.campaigns.post(campaign).success(function(e){a(),campaign=e}).error(function(e){$("#modal\\.flashes").empty().append('
'+e.responseJSON.message+"
"),Swal.close()})})}}).then(function(e){e.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 e={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(e).success(function(e){$("#sendTestEmailModal\\.flashes").empty().append('
Email Sent!
'),$("#sendTestModalSubmit").html(btnHtml)}).error(function(e){$("#sendTestEmailModal\\.flashes").empty().append('
'+e.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(e){Swal.fire({title:"Are you sure?",text:"This will delete the campaign. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+campaigns[e].name,confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(a,t){api.campaignId.delete(campaigns[e].id).success(function(e){a()}).error(function(e){t(e.responseJSON.message)})})}}).then(function(e){e.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(e){if(groups=e.groups,0==groups.length)return modalError("No groups found!"),!1;var a=$.map(groups,function(e){return e.text=e.name,e.title=e.num_targets+" targets",e});console.log(a),$("#users.form-control").select2({placeholder:"Select Groups",data:a})}),api.templates.get().success(function(e){if(0==e.length)return modalError("No templates found!"),!1;var a=$.map(e,function(e){return e.text=e.name,e}),t=$("#template.form-control");t.select2({placeholder:"Select a Template",data:a}),1===e.length&&(t.val(a[0].id),t.trigger("change.select2"))}),api.pages.get().success(function(e){if(0==e.length)return modalError("No pages found!"),!1;var a=$.map(e,function(e){return e.text=e.name,e}),t=$("#page.form-control");t.select2({placeholder:"Select a Landing Page",data:a}),1===e.length&&(t.val(a[0].id),t.trigger("change.select2"))}),api.SMTP.get().success(function(e){if(0==e.length)return modalError("No profiles found!"),!1;var a=$.map(e,function(e){return e.text=e.name,e}),t=$("#profile.form-control");t.select2({placeholder:"Select a Sending Profile",data:a}).select2("val",a[0]),1===e.length&&(t.val(a[0].id),t.trigger("change.select2"))})}function edit(e){setupOptions()}function copy(e){setupOptions(),api.campaignId.get(campaigns[e].id).success(function(e){$("#name").val("Copy of "+e.name),e.template.id?($("#template").val(e.template.id.toString()),$("#template").trigger("change.select2")):$("#template").select2({placeholder:e.template.name}),e.page.id?($("#page").val(e.page.id.toString()),$("#page").trigger("change.select2")):$("#page").select2({placeholder:e.page.name}),e.smtp.id?($("#profile").val(e.smtp.id.toString()),$("#profile").trigger("change.select2")):$("#profile").select2({placeholder:e.smtp.name}),$("#url").val(e.url)}).error(function(e){$("#modal\\.flashes").empty().append('
'+e.responseJSON.message+"
")})}$(document).ready(function(){$("#launch_date").datetimepicker({widgetPositioning:{vertical:"bottom"},showTodayButton:!0,defaultDate:moment(),format:"MMMM Do YYYY, h:mm a"}),$("#send_by_date").datetimepicker({widgetPositioning:{vertical:"bottom"},showTodayButton:!0,useCurrent:!1,format:"MMMM Do YYYY, h:mm a"}),$(".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"))}),$(document).on("hidden.bs.modal",".modal",function(){$(".modal:visible").length&&$(document.body).addClass("modal-open")}),$("#modal").on("hidden.bs.modal",function(e){dismiss()}),api.campaigns.summary().success(function(e){campaigns=e.campaigns,$("#loading").hide(),0
Number of recipients: "+a.stats.total;else t="Launch Date: "+moment(a.launch_date).format("MMMM Do YYYY, h:mm:ss a")+"

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

Emails opened: "+a.stats.opened+"

Emails clicked: "+a.stats.clicked+"

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

Errors : "+a.stats.error+"

Reported : "+a.stats.email_reported;var n=[escapeHtml(a.name),moment(a.created_date).format("MMMM Do YYYY, h:mm:ss a"),''+a.status+"","
"];"Completed"==a.status?rows.archived.push(n):rows.active.push(n)}),activeCampaignsTable.rows.add(rows.active).draw(),archivedCampaignsTable.rows.add(rows.archived).draw(),$('[data-toggle="tooltip"]').tooltip()):$("#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(e){return e.sort(function(e,a){return e.text.toLowerCase()>a.text.toLowerCase()?1:e.text.toLowerCase() '+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()