diff --git a/controllers/api.go b/controllers/api.go index a9ec4f03..c1591ac9 100644 --- a/controllers/api.go +++ b/controllers/api.go @@ -203,7 +203,7 @@ func API_Groups(w http.ResponseWriter, r *http.Request) { JSONResponse(w, models.Response{Success: false, Message: "Group name already in use"}, http.StatusConflict) return } - g.ModifiedDate = time.Now() + g.ModifiedDate = time.Now().UTC() g.UserId = ctx.Get(r, "user_id").(int64) err = models.PostGroup(&g) if err != nil { @@ -256,7 +256,7 @@ func API_Groups_Id(w http.ResponseWriter, r *http.Request) { JSONResponse(w, models.Response{Success: false, Message: "Error: /:id and group_id mismatch"}, http.StatusInternalServerError) return } - g.ModifiedDate = time.Now() + g.ModifiedDate = time.Now().UTC() g.UserId = ctx.Get(r, "user_id").(int64) err = models.PutGroup(&g) if err != nil { @@ -305,7 +305,7 @@ func API_Templates(w http.ResponseWriter, r *http.Request) { JSONResponse(w, models.Response{Success: false, Message: "Template name already in use"}, http.StatusConflict) return } - t.ModifiedDate = time.Now() + t.ModifiedDate = time.Now().UTC() t.UserId = ctx.Get(r, "user_id").(int64) err = models.PostTemplate(&t) if err == models.ErrTemplateNameNotSpecified { @@ -354,7 +354,7 @@ func API_Templates_Id(w http.ResponseWriter, r *http.Request) { JSONResponse(w, models.Response{Success: false, Message: "Error: /:id and template_id mismatch"}, http.StatusBadRequest) return } - t.ModifiedDate = time.Now() + t.ModifiedDate = time.Now().UTC() t.UserId = ctx.Get(r, "user_id").(int64) err = models.PutTemplate(&t) if err != nil { @@ -390,7 +390,7 @@ func API_Pages(w http.ResponseWriter, r *http.Request) { Logger.Println(err) return } - p.ModifiedDate = time.Now() + p.ModifiedDate = time.Now().UTC() p.UserId = ctx.Get(r, "user_id").(int64) err = models.PostPage(&p) if err != nil { @@ -431,7 +431,7 @@ func API_Pages_Id(w http.ResponseWriter, r *http.Request) { JSONResponse(w, models.Response{Success: false, Message: "/:id and /:page_id mismatch"}, http.StatusBadRequest) return } - p.ModifiedDate = time.Now() + p.ModifiedDate = time.Now().UTC() p.UserId = ctx.Get(r, "user_id").(int64) err = models.PutPage(&p) if err != nil { @@ -467,7 +467,7 @@ func API_SMTP(w http.ResponseWriter, r *http.Request) { Logger.Println(err) return } - s.ModifiedDate = time.Now() + s.ModifiedDate = time.Now().UTC() s.UserId = ctx.Get(r, "user_id").(int64) err = models.PostSMTP(&s) if err != nil { @@ -513,7 +513,7 @@ func API_SMTP_Id(w http.ResponseWriter, r *http.Request) { JSONResponse(w, models.Response{Success: false, Message: err.Error()}, http.StatusBadRequest) return } - s.ModifiedDate = time.Now() + s.ModifiedDate = time.Now().UTC() s.UserId = ctx.Get(r, "user_id").(int64) err = models.PutSMTP(&s) if err != nil { diff --git a/db/db_mysql/migrations/20170828220440_0.4_utc_dates.sql b/db/db_mysql/migrations/20170828220440_0.4_utc_dates.sql new file mode 100644 index 00000000..3bbbb081 --- /dev/null +++ b/db/db_mysql/migrations/20170828220440_0.4_utc_dates.sql @@ -0,0 +1,16 @@ + +-- +goose Up +-- SQL in section 'Up' is executed when this migration is applied +UPDATE campaigns SET `created_date`=CONVERT_TZ(`created_date`, @@session.time_zone, '+00:00'); +UPDATE campaigns SET `completed_date`=CONVERT_TZ(`completed_date`, @@session.time_zone, '+00:00'); +UPDATE campaigns SET `launch_date`=CONVERT_TZ(`launch_date`, @@session.time_zone, '+00:00'); +UPDATE events SET `time`=CONVERT_TZ(`time`, @@session.time_zone, '+00:00'); +UPDATE groups SET `modified_date`=CONVERT_TZ(`modified_date`, @@session.time_zone, '+00:00'); +UPDATE templates SET `modified_date`=CONVERT_TZ(`modified_date`, @@session.time_zone, '+00:00'); +UPDATE pages SET `modified_date`=CONVERT_TZ(`modified_date`, @@session.time_zone, '+00:00'); +UPDATE smtp SET `modified_date`=CONVERT_TZ(`modified_date`, @@session.time_zone, '+00:00'); + + +-- +goose Down +-- SQL section 'Down' is executed when this migration is rolled back + diff --git a/db/db_sqlite3/migrations/20170827141312_0.4_utc_dates.sql b/db/db_sqlite3/migrations/20170827141312_0.4_utc_dates.sql new file mode 100644 index 00000000..1f853c6d --- /dev/null +++ b/db/db_sqlite3/migrations/20170827141312_0.4_utc_dates.sql @@ -0,0 +1,15 @@ + +-- +goose Up +-- SQL in section 'Up' is executed when this migration is applied +UPDATE campaigns SET created_date=STRFTIME('%Y-%m-%d %H:%M:%S+00:00', DATETIME(created_date, 'utc')); +UPDATE campaigns SET completed_date=STRFTIME('%Y-%m-%d %H:%M:%S+00:00', DATETIME(completed_date, 'utc')); +UPDATE campaigns SET launch_date=STRFTIME('%Y-%m-%d %H:%M:%S+00:00', DATETIME(launch_date, 'utc')); +UPDATE events SET `time`=STRFTIME('%Y-%m-%d %H:%M:%S+00:00', DATETIME(`time`, 'utc')); +UPDATE groups SET modified_date=STRFTIME('%Y-%m-%d %H:%M:%S+00:00', DATETIME(modified_date, 'utc')); +UPDATE templates SET modified_date=STRFTIME('%Y-%m-%d %H:%M:%S+00:00', DATETIME(modified_date, 'utc')); +UPDATE pages SET modified_date=STRFTIME('%Y-%m-%d %H:%M:%S+00:00', DATETIME(modified_date, 'utc')); +UPDATE smtp SET modified_date=STRFTIME('%Y-%m-%d %H:%M:%S+00:00', DATETIME(modified_date, 'utc')); + +-- +goose Down +-- SQL section 'Down' is executed when this migration is rolled back + diff --git a/models/campaign.go b/models/campaign.go index 5e294ed9..90136c10 100644 --- a/models/campaign.go +++ b/models/campaign.go @@ -140,7 +140,7 @@ func (c *Campaign) UpdateStatus(s string) error { // AddEvent creates a new campaign event in the database func (c *Campaign) AddEvent(e Event) error { e.CampaignId = c.Id - e.Time = time.Now() + e.Time = time.Now().UTC() return db.Debug().Save(&e).Error } @@ -226,7 +226,7 @@ func getCampaignStats(cid int64) (CampaignStats, error) { if err != nil { return s, err } - // Every opened email event implies the email was sent + // Every opened email event implies the email was sent s.EmailsSent += s.OpenedEmail err = query.Where("status=?", ERROR).Count(&s.Error).Error return s, err @@ -279,6 +279,7 @@ func GetCampaignSummaries(uid int64) (CampaignSummaries, error) { return overview, err } cs[i].Stats = s + Logger.Println(cs[i].CreatedDate.String()) } overview.Total = int64(len(cs)) overview.Campaigns = cs @@ -361,11 +362,13 @@ func PostCampaign(c *Campaign, uid int64) error { } // Fill in the details c.UserId = uid - c.CreatedDate = time.Now() + c.CreatedDate = time.Now().UTC() c.CompletedDate = time.Time{} c.Status = CAMPAIGN_CREATED if c.LaunchDate.IsZero() { - c.LaunchDate = time.Now() + c.LaunchDate = time.Now().UTC() + } else { + c.LaunchDate = c.LaunchDate.UTC() } // Check to make sure all the groups already exist for i, g := range c.Groups { @@ -479,7 +482,7 @@ func CompleteCampaign(id int64, uid int64) error { return nil } // Mark the campaign as complete - c.CompletedDate = time.Now() + c.CompletedDate = time.Now().UTC() c.Status = CAMPAIGN_COMPLETE err = db.Where("id=? and user_id=?", id, uid).Save(&c).Error if err != nil { diff --git a/static/js/dist/app/campaign_results.min.js b/static/js/dist/app/campaign_results.min.js index 608c3631..0913e25e 100644 --- a/static/js/dist/app/campaign_results.min.js +++ b/static/js/dist/app/campaign_results.min.js @@ -1 +1 @@ -function dismiss(){$("#modal\\.flashes").empty(),$("#modal").modal("hide"),$("#resultsTable").dataTable().DataTable().clear().draw()}function deleteCampaign(){swal({title:"Are you sure?",text:"This will delete the campaign. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete Campaign",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,showLoaderOnConfirm:!0,preConfirm:function(){return new Promise(function(e,t){api.campaignId.delete(campaign.id).success(function(t){e()}).error(function(e){t(e.responseJSON.message)})})}}).then(function(){swal("Campaign Deleted!","This campaign has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.href="/campaigns"})})}function completeCampaign(){swal({title:"Are you sure?",text:"Gophish will stop processing events for this campaign",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Complete Campaign",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,showLoaderOnConfirm:!0,preConfirm:function(){return new Promise(function(e,t){api.campaignId.complete(campaign.id).success(function(t){e()}).error(function(e){t(e.responseJSON.message)})})}}).then(function(){swal("Campaign Completed!","This campaign has been completed!","success"),$("#complete_button")[0].disabled=!0,$("#complete_button").text("Completed!"),doPoll=!1})}function exportAsCSV(e){exportHTML=$("#exportButton").html();var t=null;switch(e){case"results":t=campaign.results;break;case"events":t=campaign.timeline}if(t){$("#exportButton").html('');var a=Papa.unparse(t,{}),i=new Blob([a],{type:"text/csv;charset=utf-8;"});if(navigator.msSaveBlob)navigator.msSaveBlob(i,e+".csv");else{var s=window.URL.createObjectURL(i),l=document.createElement("a");l.href=s,l.setAttribute("download",e+".csv"),document.body.appendChild(l),l.click(),document.body.removeChild(l)}$("#exportButton").html(exportHTML)}}function replay(e){function t(){form.attr({action:url}),form.appendTo("body").submit().remove()}request=campaign.timeline[e],details=JSON.parse(request.details),url=null,form=$("
").attr({method:"POST",target:"_blank"}),$.each(Object.keys(details.payload),function(e,t){return"rid"==t||("__original_url"==t?(url=details.payload[t],!0):void $("").attr({name:t}).val(details.payload[t]).appendTo(form))}),swal({title:"Where do you want the credentials submitted to?",input:"text",showCancelButton:!0,inputPlaceholder:"http://example.com/login",inputValue:url||"",inputValidator:function(e){return new Promise(function(t,a){e?t():a("Invalid URL.")})}}).then(function(e){url=e,t()})}function renderTimeline(e){return record={first_name:e[2],last_name:e[3],email:e[4],position:e[5]},results='
Timeline for '+escapeHtml(record.first_name)+" "+escapeHtml(record.last_name)+'
Email: '+escapeHtml(record.email)+'
',$.each(campaign.timeline,function(e,t){t.email&&t.email!=record.email||(results+='
',results+='
'+escapeHtml(t.message)+' '+moment(t.time).format("MMMM Do YYYY h:mm a")+"",t.details&&("Submitted Data"==t.message&&(results+='
',results+='
View Details
'),details=JSON.parse(t.details),details.payload&&(results+='
',results+=' ',results+=" ",$.each(Object.keys(details.payload),function(e,t){return"rid"==t||(results+=" ",results+=" ",results+=" ",void(results+=" "))}),results+="
ParameterValue(s)
"+escapeHtml(t)+""+escapeHtml(details.payload[t])+"
",results+="
"),details.error&&(results+='
View Details
',results+='
',results+='Error '+details.error,results+="
")),results+="
")}),results+="
",results}function poll(){api.campaignId.results(campaign.id).success(function(e){campaign=e;var t=[];$.each(campaign.timeline,function(e,a){var i=moment(a.time);t.push({email:a.email,x:i.valueOf(),y:1})});var t=[];$.each(campaign.timeline,function(e,a){var i=moment(a.time);t.push({email:a.email,message:a.message,x:i.valueOf(),y:1,marker:{fillColor:statuses[a.message].color}})});var a=$("#timeline_chart").highcharts();a.series[0].update({data:t});var i={};Object.keys(statusMapping).forEach(function(e){i[e]=0}),$.each(campaign.results,function(e,t){i[t.status]++;for(var a=progressListing.indexOf(t.status),e=0;e'+a.status+"",resultsTable.row(e).data(s).draw(!1),i.child.isShown()&&i.child(renderTimeline(i.data())),!1}})}),bubbles=[],$.each(campaign.results,function(e,t){return 0==t.latitude&&0==t.longitude||(newIP=!0,$.each(bubbles,function(e,a){if(a.ip==t.ip)return bubbles[e].radius+=1,newIP=!1,!1}),void(newIP&&bubbles.push({latitude:t.latitude,longitude:t.longitude,name:t.ip,fillKey:"point",radius:2})))}),map.bubbles(bubbles),$("#refresh_message").hide(),$("#refresh_btn").show()})}function load(){campaign.id=window.location.pathname.split("/").slice(-1)[0],api.campaignId.results(campaign.id).success(function(e){if(campaign=e){$("title").text(e.name+" - Gophish"),$("#loading").hide(),$("#campaignResults").show(),$("#page-title").text("Results for "+e.name),"Completed"==e.status&&($("#complete_button")[0].disabled=!0,$("#complete_button").text("Completed!"),doPoll=!1),$('[data-toggle="tooltip"]').tooltip(),$("#resultsTable").on("click",".timeline-event-details",function(){payloadResults=$(this).parent().find(".timeline-event-results"),payloadResults.is(":visible")?($(this).find("i").removeClass("fa-caret-down"),$(this).find("i").addClass("fa-caret-right"),payloadResults.hide()):($(this).find("i").removeClass("fa-caret-right"),$(this).find("i").addClass("fa-caret-down"),payloadResults.show())}),resultsTable=$("#resultsTable").DataTable({destroy:!0,order:[[2,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{className:"details-control",targets:[1]},{visible:!1,targets:[0]}]}),resultsTable.clear();var t={},a=[];Object.keys(statusMapping).forEach(function(e){t[e]=0}),$.each(campaign.results,function(e,a){label=statuses[a.status].label||"label-default",resultsTable.row.add([a.id,'',escapeHtml(a.first_name)||"",escapeHtml(a.last_name)||"",escapeHtml(a.email)||"",escapeHtml(a.position)||"",''+a.status+""]).draw(),t[a.status]++;for(var i=progressListing.indexOf(a.status),e=0;eEvent: "+this.point.message+"
Email: "+this.point.email+""}},legend:{enabled:!1},plotOptions:{series:{marker:{enabled:!0,symbol:"circle",radius:3},cursor:"pointer"},line:{states:{hover:{lineWidth:1}}}},credits:{enabled:!1},series:[{data:e.data,dashStyle:"shortdash",color:"#cccccc",lineWidth:1}]})},renderPieChart=function(e){return Highcharts.chart(e.elemId,{chart:{type:"pie",events:{load:function(){var t=this,a=t.renderer,i=t.series[0],s=t.plotLeft+i.center[0],l=t.plotTop+i.center[1];this.innerText=a.text(e.data[0].y,s,l).attr({"text-anchor":"middle","font-size":"24px","font-weight":"bold",fill:e.colors[0],"font-family":"Helvetica,Arial,sans-serif"}).add()},render:function(){this.innerText.attr({text:e.data[0].y})}}},title:{text:e.title},plotOptions:{pie:{innerSize:"80%",dataLabels:{enabled:!1}}},credits:{enabled:!1},tooltip:{formatter:function(){return void 0!=this.key&&''+this.point.name+": "+this.y+"
"}},series:[{data:e.data,colors:e.colors}]})},setRefresh;$(document).ready(function(){Highcharts.setOptions({global:{useUTC:!1}}),load(),setRefresh=setTimeout(refresh,6e4)}); \ No newline at end of file +function dismiss(){$("#modal\\.flashes").empty(),$("#modal").modal("hide"),$("#resultsTable").dataTable().DataTable().clear().draw()}function deleteCampaign(){swal({title:"Are you sure?",text:"This will delete the campaign. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete Campaign",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,showLoaderOnConfirm:!0,preConfirm:function(){return new Promise(function(e,t){api.campaignId.delete(campaign.id).success(function(t){e()}).error(function(e){t(e.responseJSON.message)})})}}).then(function(){swal("Campaign Deleted!","This campaign has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.href="/campaigns"})})}function completeCampaign(){swal({title:"Are you sure?",text:"Gophish will stop processing events for this campaign",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Complete Campaign",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,showLoaderOnConfirm:!0,preConfirm:function(){return new Promise(function(e,t){api.campaignId.complete(campaign.id).success(function(t){e()}).error(function(e){t(e.responseJSON.message)})})}}).then(function(){swal("Campaign Completed!","This campaign has been completed!","success"),$("#complete_button")[0].disabled=!0,$("#complete_button").text("Completed!"),doPoll=!1})}function exportAsCSV(e){exportHTML=$("#exportButton").html();var t=null;switch(e){case"results":t=campaign.results;break;case"events":t=campaign.timeline}if(t){$("#exportButton").html('');var a=Papa.unparse(t,{}),i=new Blob([a],{type:"text/csv;charset=utf-8;"});if(navigator.msSaveBlob)navigator.msSaveBlob(i,e+".csv");else{var s=window.URL.createObjectURL(i),l=document.createElement("a");l.href=s,l.setAttribute("download",e+".csv"),document.body.appendChild(l),l.click(),document.body.removeChild(l)}$("#exportButton").html(exportHTML)}}function replay(e){function t(){form.attr({action:url}),form.appendTo("body").submit().remove()}request=campaign.timeline[e],details=JSON.parse(request.details),url=null,form=$("").attr({method:"POST",target:"_blank"}),$.each(Object.keys(details.payload),function(e,t){return"rid"==t||("__original_url"==t?(url=details.payload[t],!0):void $("").attr({name:t}).val(details.payload[t]).appendTo(form))}),swal({title:"Where do you want the credentials submitted to?",input:"text",showCancelButton:!0,inputPlaceholder:"http://example.com/login",inputValue:url||"",inputValidator:function(e){return new Promise(function(t,a){e?t():a("Invalid URL.")})}}).then(function(e){url=e,t()})}function renderTimeline(e){return record={first_name:e[2],last_name:e[3],email:e[4],position:e[5]},results='
Timeline for '+escapeHtml(record.first_name)+" "+escapeHtml(record.last_name)+'
Email: '+escapeHtml(record.email)+'
',$.each(campaign.timeline,function(e,t){t.email&&t.email!=record.email||(results+='
',results+='
'+escapeHtml(t.message)+' '+moment.utc(t.time).local().format("MMMM Do YYYY h:mm a")+"",t.details&&("Submitted Data"==t.message&&(results+='
',results+='
View Details
'),details=JSON.parse(t.details),details.payload&&(results+='
',results+=' ',results+=" ",$.each(Object.keys(details.payload),function(e,t){return"rid"==t||(results+=" ",results+=" ",results+=" ",void(results+=" "))}),results+="
ParameterValue(s)
"+escapeHtml(t)+""+escapeHtml(details.payload[t])+"
",results+="
"),details.error&&(results+='
View Details
',results+='
',results+='Error '+details.error,results+="
")),results+="
")}),results+="
",results}function poll(){api.campaignId.results(campaign.id).success(function(e){campaign=e;var t=[];$.each(campaign.timeline,function(e,a){var i=moment.utc(a.time).local();t.push({email:a.email,x:i.valueOf(),y:1})});var t=[];$.each(campaign.timeline,function(e,a){var i=moment.utc(a.time).local();t.push({email:a.email,message:a.message,x:i.valueOf(),y:1,marker:{fillColor:statuses[a.message].color}})});var a=$("#timeline_chart").highcharts();a.series[0].update({data:t});var i={};Object.keys(statusMapping).forEach(function(e){i[e]=0}),$.each(campaign.results,function(e,t){i[t.status]++;for(var a=progressListing.indexOf(t.status),e=0;e'+a.status+"",resultsTable.row(e).data(s).draw(!1),i.child.isShown()&&i.child(renderTimeline(i.data())),!1}})}),bubbles=[],$.each(campaign.results,function(e,t){return 0==t.latitude&&0==t.longitude||(newIP=!0,$.each(bubbles,function(e,a){if(a.ip==t.ip)return bubbles[e].radius+=1,newIP=!1,!1}),void(newIP&&bubbles.push({latitude:t.latitude,longitude:t.longitude,name:t.ip,fillKey:"point",radius:2})))}),map.bubbles(bubbles),$("#refresh_message").hide(),$("#refresh_btn").show()})}function load(){campaign.id=window.location.pathname.split("/").slice(-1)[0],api.campaignId.results(campaign.id).success(function(e){if(campaign=e){$("title").text(e.name+" - Gophish"),$("#loading").hide(),$("#campaignResults").show(),$("#page-title").text("Results for "+e.name),"Completed"==e.status&&($("#complete_button")[0].disabled=!0,$("#complete_button").text("Completed!"),doPoll=!1),$('[data-toggle="tooltip"]').tooltip(),$("#resultsTable").on("click",".timeline-event-details",function(){payloadResults=$(this).parent().find(".timeline-event-results"),payloadResults.is(":visible")?($(this).find("i").removeClass("fa-caret-down"),$(this).find("i").addClass("fa-caret-right"),payloadResults.hide()):($(this).find("i").removeClass("fa-caret-right"),$(this).find("i").addClass("fa-caret-down"),payloadResults.show())}),resultsTable=$("#resultsTable").DataTable({destroy:!0,order:[[2,"asc"]],columnDefs:[{orderable:!1,targets:"no-sort"},{className:"details-control",targets:[1]},{visible:!1,targets:[0]}]}),resultsTable.clear();var t={},a=[];Object.keys(statusMapping).forEach(function(e){t[e]=0}),$.each(campaign.results,function(e,a){label=statuses[a.status].label||"label-default",resultsTable.row.add([a.id,'',escapeHtml(a.first_name)||"",escapeHtml(a.last_name)||"",escapeHtml(a.email)||"",escapeHtml(a.position)||"",''+a.status+""]).draw(),t[a.status]++;for(var i=progressListing.indexOf(a.status),e=0;eEvent: "+this.point.message+"
Email: "+this.point.email+""}},legend:{enabled:!1},plotOptions:{series:{marker:{enabled:!0,symbol:"circle",radius:3},cursor:"pointer"},line:{states:{hover:{lineWidth:1}}}},credits:{enabled:!1},series:[{data:e.data,dashStyle:"shortdash",color:"#cccccc",lineWidth:1}]})},renderPieChart=function(e){return Highcharts.chart(e.elemId,{chart:{type:"pie",events:{load:function(){var t=this,a=t.renderer,i=t.series[0],s=t.plotLeft+i.center[0],l=t.plotTop+i.center[1];this.innerText=a.text(e.data[0].y,s,l).attr({"text-anchor":"middle","font-size":"24px","font-weight":"bold",fill:e.colors[0],"font-family":"Helvetica,Arial,sans-serif"}).add()},render:function(){this.innerText.attr({text:e.data[0].y})}}},title:{text:e.title},plotOptions:{pie:{innerSize:"80%",dataLabels:{enabled:!1}}},credits:{enabled:!1},tooltip:{formatter:function(){return void 0!=this.key&&''+this.point.name+": "+this.y+"
"}},series:[{data:e.data,colors:e.colors}]})},setRefresh;$(document).ready(function(){Highcharts.setOptions({global:{useUTC:!1}}),load(),setRefresh=setTimeout(refresh,6e4)}); \ No newline at end of file diff --git a/static/js/dist/app/campaigns.min.js b/static/js/dist/app/campaigns.min.js index b3dbd113..bb3086fc 100644 --- a/static/js/dist/app/campaigns.min.js +++ b/static/js/dist/app/campaigns.min.js @@ -1 +1 @@ -function launch(){swal({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(a){groups.push({name:a.text})}),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(),"MM/DD/YYYY hh:mm a").format(),groups:groups},api.campaigns.post(campaign).success(function(e){a(),campaign=e}).error(function(a){$("#modal\\.flashes").empty().append('
'+a.responseJSON.message+"
"),swal.close()})})}}).then(function(){swal("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 a={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(a).success(function(a){$("#sendTestEmailModal\\.flashes").empty().append('
Email Sent!
'),$("#sendTestModalSubmit").html(btnHtml)}).error(function(a){$("#sendTestEmailModal\\.flashes").empty().append('
'+a.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(a){swal({title:"Are you sure?",text:"This will delete the campaign. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+campaigns[a].name,confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(e,t){api.campaignId.delete(campaigns[a].id).success(function(a){e()}).error(function(a){t(a.responseJSON.message)})})}}).then(function(){swal("Campaign Deleted!","This campaign has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.reload()})})}function setupOptions(){api.groups.get().success(function(a){if(0==a.length)return modalError("No groups found!"),!1;var e=$.map(a,function(a){return a.text=a.name,a});$("#users.form-control").select2({placeholder:"Select Groups",data:e})}),api.templates.get().success(function(a){if(0==a.length)return modalError("No templates found!"),!1;var e=$.map(a,function(a){return a.text=a.name,a});$("#template.form-control").select2({placeholder:"Select a Template",data:e})}),api.pages.get().success(function(a){if(0==a.length)return modalError("No pages found!"),!1;var e=$.map(a,function(a){return a.text=a.name,a});$("#page.form-control").select2({placeholder:"Select a Landing Page",data:e})}),api.SMTP.get().success(function(a){if(0==a.length)return modalError("No profiles found!"),!1;var e=$.map(a,function(a){return a.text=a.name,a});$("#profile.form-control").select2({placeholder:"Select a Sending Profile",data:e})})}function edit(a){setupOptions()}function copy(a){setupOptions(),api.campaignId.get(campaigns[a].id).success(function(a){$("#name").val("Copy of "+a.name),a.template.id?$("#template").select2("val",a.template.id.toString()):$("#template").select2({placeholder:a.template.name}),a.page.id?$("#page").select2("val",a.page.id.toString()):$("#page").select2({placeholder:a.page.name}),a.smtp.id?$("#profile").select2("val",a.smtp.id.toString()):$("#profile").select2({placeholder:a.smtp.name}),$("#url").val(a.url)}).error(function(a){$("#modal\\.flashes").empty().append('
'+a.responseJSON.message+"
")})}var labels={"In progress":"label-primary",Queued:"label-info",Completed:"label-success","Emails Sent":"label-success",Error:"label-danger"},campaigns=[],campaign={};$(document).ready(function(){$("#launch_date").datetimepicker({widgetPositioning:{vertical:"bottom"},showTodayButton:!0,defaultDate:moment()}),$(".modal").on("hidden.bs.modal",function(a){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)}),$(".modal").on("shown.bs.modal",function(a){"undefined"==typeof $("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(a){dismiss()}),api.campaigns.summary().success(function(a){campaigns=a.campaigns,$("#loading").hide(),campaigns.length>0?($("#campaignTable").show(),campaignTable=$("#campaignTable").DataTable({columnDefs:[{orderable:!1,targets:"no-sort"}],order:[[1,"desc"]]}),$.each(campaigns,function(a,e){label=labels[e.status]||"label-default";var t;if(moment(e.launch_date).isAfter(moment())){t="Scheduled to start: "+moment(e.launch_date).format("MMMM Do YYYY, h:mm:ss a");var n=t+"

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

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

Emails opened: "+e.stats.opened+"

Emails clicked: "+e.stats.clicked+"

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

Errors : "+e.stats.error}campaignTable.row.add([escapeHtml(e.name),moment(e.created_date).format("MMMM Do YYYY, h:mm:ss a"),''+e.status+"",""]).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")}); \ No newline at end of file +function launch(){swal({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(a){groups.push({name:a.text})}),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(),"MM/DD/YYYY hh:mm a").utc().format(),groups:groups},console.log("Launching campaign at time: "+campaign.launch_date),api.campaigns.post(campaign).success(function(e){a(),campaign=e}).error(function(a){$("#modal\\.flashes").empty().append('
'+a.responseJSON.message+"
"),swal.close()})})}}).then(function(){swal("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 a={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(a).success(function(a){$("#sendTestEmailModal\\.flashes").empty().append('
Email Sent!
'),$("#sendTestModalSubmit").html(btnHtml)}).error(function(a){$("#sendTestEmailModal\\.flashes").empty().append('
'+a.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(a){swal({title:"Are you sure?",text:"This will delete the campaign. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+campaigns[a].name,confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(e,t){api.campaignId.delete(campaigns[a].id).success(function(a){e()}).error(function(a){t(a.responseJSON.message)})})}}).then(function(){swal("Campaign Deleted!","This campaign has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.reload()})})}function setupOptions(){api.groups.get().success(function(a){if(0==a.length)return modalError("No groups found!"),!1;var e=$.map(a,function(a){return a.text=a.name,a});$("#users.form-control").select2({placeholder:"Select Groups",data:e})}),api.templates.get().success(function(a){if(0==a.length)return modalError("No templates found!"),!1;var e=$.map(a,function(a){return a.text=a.name,a});$("#template.form-control").select2({placeholder:"Select a Template",data:e})}),api.pages.get().success(function(a){if(0==a.length)return modalError("No pages found!"),!1;var e=$.map(a,function(a){return a.text=a.name,a});$("#page.form-control").select2({placeholder:"Select a Landing Page",data:e})}),api.SMTP.get().success(function(a){if(0==a.length)return modalError("No profiles found!"),!1;var e=$.map(a,function(a){return a.text=a.name,a});$("#profile.form-control").select2({placeholder:"Select a Sending Profile",data:e})})}function edit(a){setupOptions()}function copy(a){setupOptions(),api.campaignId.get(campaigns[a].id).success(function(a){$("#name").val("Copy of "+a.name),a.template.id?$("#template").select2("val",a.template.id.toString()):$("#template").select2({placeholder:a.template.name}),a.page.id?$("#page").select2("val",a.page.id.toString()):$("#page").select2({placeholder:a.page.name}),a.smtp.id?$("#profile").select2("val",a.smtp.id.toString()):$("#profile").select2({placeholder:a.smtp.name}),$("#url").val(a.url)}).error(function(a){$("#modal\\.flashes").empty().append('
'+a.responseJSON.message+"
")})}var labels={"In progress":"label-primary",Queued:"label-info",Completed:"label-success","Emails Sent":"label-success",Error:"label-danger"},campaigns=[],campaign={};$(document).ready(function(){$("#launch_date").datetimepicker({widgetPositioning:{vertical:"bottom"},showTodayButton:!0,defaultDate:moment()}),$(".modal").on("hidden.bs.modal",function(a){$(this).removeClass("fv-modal-stack"),$("body").data("fv_open_modals",$("body").data("fv_open_modals")-1)}),$(".modal").on("shown.bs.modal",function(a){"undefined"==typeof $("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(a){dismiss()}),api.campaigns.summary().success(function(a){campaigns=a.campaigns,$("#loading").hide(),campaigns.length>0?($("#campaignTable").show(),campaignTable=$("#campaignTable").DataTable({columnDefs:[{orderable:!1,targets:"no-sort"}],order:[[1,"desc"]]}),$.each(campaigns,function(a,e){console.log(e),console.log(e.created_date),label=labels[e.status]||"label-default";var t;if(moment(e.launch_date).isAfter(moment())){t="Scheduled to start: "+moment(e.launch_date).format("MMMM Do YYYY, h:mm:ss a");var n=t+"

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

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

Emails opened: "+e.stats.opened+"

Emails clicked: "+e.stats.clicked+"

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

Errors : "+e.stats.error}campaignTable.row.add([escapeHtml(e.name),moment(e.created_date).format("MMMM Do YYYY, h:mm:ss a"),''+e.status+"",""]).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")}); \ No newline at end of file diff --git a/static/js/dist/app/dashboard.min.js b/static/js/dist/app/dashboard.min.js index a65a8cc2..3c41c32f 100644 --- a/static/js/dist/app/dashboard.min.js +++ b/static/js/dist/app/dashboard.min.js @@ -1 +1 @@ -function deleteCampaign(e){confirm("Delete "+campaigns[e].name+"?")&&api.campaignId.delete(campaigns[e].id).success(function(e){successFlash(e.message),location.reload()})}function renderPieChart(e){return Highcharts.chart(e.elemId,{chart:{type:"pie",events:{load:function(){var t=this,a=t.renderer,n=t.series[0],i=t.plotLeft+n.center[0],s=t.plotTop+n.center[1];this.innerText=a.text(e.data[0].count,i,s).attr({"text-anchor":"middle","font-size":"24px","font-weight":"bold",fill:e.colors[0],"font-family":"Helvetica,Arial,sans-serif"}).add()},render:function(){this.innerText.attr({text:e.data[0].count})}}},title:{text:e.title},plotOptions:{pie:{innerSize:"80%",dataLabels:{enabled:!1}}},credits:{enabled:!1},tooltip:{formatter:function(){return void 0!=this.key&&''+this.point.name+": "+this.y+"%
"}},series:[{data:e.data,colors:e.colors}]})}function generateStatsPieCharts(e){var t=[],a={},n=0;$.each(e,function(e,t){$.each(t.stats,function(e,t){return"total"==e?(n+=t,!0):void(a[e]?a[e]+=t:a[e]=t)})}),$.each(a,function(e,a){if(!(e in statsMapping))return!0;status_label=statsMapping[e],t.push({name:status_label,y:Math.floor(a/n*100),count:a}),t.push({name:"",y:100-Math.floor(a/n*100)});renderPieChart({elemId:e+"_chart",title:status_label,name:e,data:t,colors:[statuses[status_label].color,"#dddddd"]});t=[]})}function generateTimelineChart(e){var t=[];$.each(e,function(e,a){var n=moment(a.created_date);a.y=0,a.y+=a.stats.clicked,a.y=Math.floor(a.y/a.stats.total*100),t.push({campaign_id:a.id,name:a.name,x:n.valueOf(),y:a.y})}),Highcharts.chart("overview_chart",{chart:{zoomType:"x",type:"areaspline"},title:{text:"Phishing Success Overview"},xAxis:{type:"datetime",dateTimeLabelFormats:{second:"%l:%M:%S",minute:"%l:%M",hour:"%l:%M",day:"%b %d, %Y",week:"%b %d, %Y",month:"%b %Y"}},yAxis:{min:0,max:100,title:{text:"% of Success"}},tooltip:{formatter:function(){return Highcharts.dateFormat("%A, %b %d %l:%M:%S %P",new Date(this.x))+"
"+this.point.name+"
% Success: "+this.y+"%"}},legend:{enabled:!1},plotOptions:{series:{marker:{enabled:!0,symbol:"circle",radius:3},cursor:"pointer",point:{events:{click:function(e){window.location.href="/campaigns/"+this.campaign_id}}}}},credits:{enabled:!1},series:[{data:t,color:"#f05b4f",fillOpacity:.5}]})}var campaigns=[],statuses={"Email Sent":{color:"#1abc9c",label:"label-success",icon:"fa-envelope",point:"ct-point-sent"},"Emails Sent":{color:"#1abc9c",label:"label-success",icon:"fa-envelope",point:"ct-point-sent"},"In progress":{label:"label-primary"},Queued:{label:"label-info"},Completed:{label:"label-success"},"Email Opened":{color:"#f9bf3b",label:"label-warning",icon:"fa-envelope",point:"ct-point-opened"},"Clicked Link":{color:"#F39C12",label:"label-clicked",icon:"fa-mouse-pointer",point:"ct-point-clicked"},Success:{color:"#f05b4f",label:"label-danger",icon:"fa-exclamation",point:"ct-point-clicked"},Error:{color:"#6c7a89",label:"label-default",icon:"fa-times",point:"ct-point-error"},"Error Sending Email":{color:"#6c7a89",label:"label-default",icon:"fa-times",point:"ct-point-error"},"Submitted Data":{color:"#f05b4f",label:"label-danger",icon:"fa-exclamation",point:"ct-point-clicked"},Unknown:{color:"#6c7a89",label:"label-default",icon:"fa-question",point:"ct-point-error"},Sending:{color:"#428bca",label:"label-primary",icon:"fa-spinner",point:"ct-point-sending"},"Campaign Created":{label:"label-success",icon:"fa-rocket"}},statsMapping={sent:"Email Sent",opened:"Email Opened",clicked:"Clicked Link",submitted_data:"Submitted Data"};$(document).ready(function(){api.campaigns.summary().success(function(e){$("#loading").hide(),campaigns=e.campaigns,campaigns.length>0?($("#dashboard").show(),campaignTable=$("#campaignTable").DataTable({columnDefs:[{orderable:!1,targets:"no-sort"},{className:"color-sent",targets:[2]},{className:"color-opened",targets:[3]},{className:"color-clicked",targets:[4]},{className:"color-success",targets:[5]}],order:[[1,"desc"]]}),$.each(campaigns,function(e,t){var a,n=moment(t.created_date).format("MMMM Do YYYY, h:mm:ss a"),i=statuses[t.status].label||"label-default";if(moment(t.launch_date).isAfter(moment())){a="Scheduled to start: "+moment(t.launch_date).format("MMMM Do YYYY, h:mm:ss a");var s=a+"

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

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

Emails opened: "+t.stats.opened+"

Emails clicked: "+t.stats.clicked+"

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

Errors : "+t.stats.error}campaignTable.row.add([escapeHtml(t.name),n,t.stats.sent,t.stats.opened,t.stats.clicked,t.stats.submitted_data,''+t.status+"",""]).draw(),$('[data-toggle="tooltip"]').tooltip()}),generateStatsPieCharts(campaigns),generateTimelineChart(campaigns)):$("#emptyMessage").show()}).error(function(){errorFlash("Error fetching campaigns")})}); \ No newline at end of file +function deleteCampaign(e){confirm("Delete "+campaigns[e].name+"?")&&api.campaignId.delete(campaigns[e].id).success(function(e){successFlash(e.message),location.reload()})}function renderPieChart(e){return Highcharts.chart(e.elemId,{chart:{type:"pie",events:{load:function(){var t=this,a=t.renderer,n=t.series[0],i=t.plotLeft+n.center[0],s=t.plotTop+n.center[1];this.innerText=a.text(e.data[0].count,i,s).attr({"text-anchor":"middle","font-size":"24px","font-weight":"bold",fill:e.colors[0],"font-family":"Helvetica,Arial,sans-serif"}).add()},render:function(){this.innerText.attr({text:e.data[0].count})}}},title:{text:e.title},plotOptions:{pie:{innerSize:"80%",dataLabels:{enabled:!1}}},credits:{enabled:!1},tooltip:{formatter:function(){return void 0!=this.key&&''+this.point.name+": "+this.y+"%
"}},series:[{data:e.data,colors:e.colors}]})}function generateStatsPieCharts(e){var t=[],a={},n=0;$.each(e,function(e,t){$.each(t.stats,function(e,t){return"total"==e?(n+=t,!0):void(a[e]?a[e]+=t:a[e]=t)})}),$.each(a,function(e,a){if(!(e in statsMapping))return!0;status_label=statsMapping[e],t.push({name:status_label,y:Math.floor(a/n*100),count:a}),t.push({name:"",y:100-Math.floor(a/n*100)});renderPieChart({elemId:e+"_chart",title:status_label,name:e,data:t,colors:[statuses[status_label].color,"#dddddd"]});t=[]})}function generateTimelineChart(e){var t=[];$.each(e,function(e,a){var n=moment.utc(a.created_date).local();a.y=0,a.y+=a.stats.clicked,a.y=Math.floor(a.y/a.stats.total*100),t.push({campaign_id:a.id,name:a.name,x:n.valueOf(),y:a.y})}),Highcharts.chart("overview_chart",{chart:{zoomType:"x",type:"areaspline"},title:{text:"Phishing Success Overview"},xAxis:{type:"datetime",dateTimeLabelFormats:{second:"%l:%M:%S",minute:"%l:%M",hour:"%l:%M",day:"%b %d, %Y",week:"%b %d, %Y",month:"%b %Y"}},yAxis:{min:0,max:100,title:{text:"% of Success"}},tooltip:{formatter:function(){return Highcharts.dateFormat("%A, %b %d %l:%M:%S %P",new Date(this.x))+"
"+this.point.name+"
% Success: "+this.y+"%"}},legend:{enabled:!1},plotOptions:{series:{marker:{enabled:!0,symbol:"circle",radius:3},cursor:"pointer",point:{events:{click:function(e){window.location.href="/campaigns/"+this.campaign_id}}}}},credits:{enabled:!1},series:[{data:t,color:"#f05b4f",fillOpacity:.5}]})}var campaigns=[],statuses={"Email Sent":{color:"#1abc9c",label:"label-success",icon:"fa-envelope",point:"ct-point-sent"},"Emails Sent":{color:"#1abc9c",label:"label-success",icon:"fa-envelope",point:"ct-point-sent"},"In progress":{label:"label-primary"},Queued:{label:"label-info"},Completed:{label:"label-success"},"Email Opened":{color:"#f9bf3b",label:"label-warning",icon:"fa-envelope",point:"ct-point-opened"},"Clicked Link":{color:"#F39C12",label:"label-clicked",icon:"fa-mouse-pointer",point:"ct-point-clicked"},Success:{color:"#f05b4f",label:"label-danger",icon:"fa-exclamation",point:"ct-point-clicked"},Error:{color:"#6c7a89",label:"label-default",icon:"fa-times",point:"ct-point-error"},"Error Sending Email":{color:"#6c7a89",label:"label-default",icon:"fa-times",point:"ct-point-error"},"Submitted Data":{color:"#f05b4f",label:"label-danger",icon:"fa-exclamation",point:"ct-point-clicked"},Unknown:{color:"#6c7a89",label:"label-default",icon:"fa-question",point:"ct-point-error"},Sending:{color:"#428bca",label:"label-primary",icon:"fa-spinner",point:"ct-point-sending"},"Campaign Created":{label:"label-success",icon:"fa-rocket"}},statsMapping={sent:"Email Sent",opened:"Email Opened",clicked:"Clicked Link",submitted_data:"Submitted Data"};$(document).ready(function(){Highcharts.setOptions({global:{useUTC:!1}}),api.campaigns.summary().success(function(e){$("#loading").hide(),campaigns=e.campaigns,campaigns.length>0?($("#dashboard").show(),campaignTable=$("#campaignTable").DataTable({columnDefs:[{orderable:!1,targets:"no-sort"},{className:"color-sent",targets:[2]},{className:"color-opened",targets:[3]},{className:"color-clicked",targets:[4]},{className:"color-success",targets:[5]}],order:[[1,"desc"]]}),$.each(campaigns,function(e,t){var a,n=moment(t.created_date).format("MMMM Do YYYY, h:mm:ss a"),i=statuses[t.status].label||"label-default";if(moment(t.launch_date).isAfter(moment())){a="Scheduled to start: "+moment(t.launch_date).format("MMMM Do YYYY, h:mm:ss a");var s=a+"

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

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

Emails opened: "+t.stats.opened+"

Emails clicked: "+t.stats.clicked+"

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

Errors : "+t.stats.error}campaignTable.row.add([escapeHtml(t.name),n,t.stats.sent,t.stats.opened,t.stats.clicked,t.stats.submitted_data,''+t.status+"",""]).draw(),$('[data-toggle="tooltip"]').tooltip()}),generateStatsPieCharts(campaigns),generateTimelineChart(campaigns)):$("#emptyMessage").show()}).error(function(){errorFlash("Error fetching campaigns")})}); \ No newline at end of file diff --git a/static/js/src/app/campaign_results.js b/static/js/src/app/campaign_results.js index af8de7c8..4f5543e7 100644 --- a/static/js/src/app/campaign_results.js +++ b/static/js/src/app/campaign_results.js @@ -282,7 +282,7 @@ function renderTimeline(data) { '
' + '
' + '
' + escapeHtml(event.message) + - ' ' + moment(event.time).format('MMMM Do YYYY h:mm a') + '' + ' ' + moment.utc(event.time).local().format('MMMM Do YYYY h:mm a') + '' if (event.details) { if (event.message == "Submitted Data") { results += '