diff --git a/static/js/app/campaign_results.js b/static/js/app/campaign_results.js
index 69495a6c..cc70f4c9 100644
--- a/static/js/app/campaign_results.js
+++ b/static/js/app/campaign_results.js
@@ -1,90 +1,73 @@
// labels is a map of campaign statuses to
// CSS classes
var labels = {
- "In progress" : "label-primary",
- "Queued" : "label-info",
- "Completed" : "label-success",
+ "Email Sent" : "label-primary",
+ "Email Opened" : "label-info",
+ "Success" : "label-success",
+ "Clicked Link" : "label-success",
"Error" : "label-danger"
}
var campaign = {}
-// Save attempts to POST to /campaigns/
-function save(){
- var campaign = {
- name: $("#name").val(),
- template:{
- name: $("#template").val()
- },
- smtp: {
- from_address: $("input[name=from]").val(),
- host: $("input[name=host]").val(),
- username: $("input[name=username]").val(),
- password: $("input[name=password]").val(),
- },
- groups: [{name : "Test group"}]
- }
- // Submit the campaign
- api.campaigns.post(campaign)
- .success(function(data){
- successFlash("Campaign successfully launched!")
- load()
- })
- .error(function(data){
- $("#modal\\.flashes").empty().append("
\
- " + data.responseJSON.message + "
")
- })
-}
-
function dismiss(){
$("#modal\\.flashes").empty()
$("#modal").modal('hide')
- $("#groupTable").dataTable().DataTable().clear().draw()
+ $("#resultsTable").dataTable().DataTable().clear().draw()
}
-function edit(campaign){
- // Clear the bloodhound instance
- bh.clear();
- if (campaign == "new") {
- api.groups.get()
- .success(function(groups){
- if (groups.length == 0){
- modalError("No groups found!")
- return false;
- }
- else {
- bh.add(groups)
- }
+// Deletes a campaign after prompting the user
+function deleteCampaign(){
+ if (confirm("Are you sure you want to delete: " + campaign.name + "?")){
+ api.campaignId.delete(campaign.id)
+ .success(function(msg){
+ console.log(msg)
+ })
+ .error(function(e){
+ $("#modal\\.flashes").empty().append("\
+ " + data.responseJSON.message + "
")
})
}
}
$(document).ready(function(){
- var id = window.location.pathname.split('/').slice(-1)[0]
- api.campaignId.get(id)
+ campaign.id = window.location.pathname.split('/').slice(-1)[0]
+ api.campaignId.get(campaign.id)
.success(function(c){
campaign = c
if (campaign){
- $("#emptyMessage").hide()
- $("#campaignTable").show()
- campaignTable = $("#campaignTable").DataTable();
- $.each(campaigns, function(i, campaign){
- label = labels[campaign.status] || "label-default";
- campaignTable.row.add([
- campaign.name,
- moment(campaign.created_date).format('MMMM Do YYYY, h:mm:ss a'),
- "" + campaign.status + "",
- "\
-
"
+ // Setup our graphs
+ var timeline_chart = {labels:[],series:[[]]}
+ var email_chart = {series:[]}
+ var timeline_opts = {
+ axisX: {
+ showGrid: false
+ },
+ showArea: true,
+ plugins: []
+ }
+ var email_opts = {
+ donut : true,
+ donutWidth: 40,
+ chartPadding: 0,
+ showLabel: false
+ }
+ $("#loading").hide()
+ $("#campaignResults").show()
+ resultsTable = $("#resultsTable").DataTable();
+ $.each(campaign.results, function(i, result){
+ label = labels[result.status] || "label-default";
+ resultsTable.row.add([
+ result.first_name || "",
+ result.last_name || "",
+ result.email || "",
+ result.position || "",
+ "" + result.status + ""
]).draw()
})
}
})
.error(function(){
- errorFlash("Error fetching campaign")
+ errorFlash(" Campaign not found!")
})
})
diff --git a/static/js/app/campaigns.js b/static/js/app/campaigns.js
index 8a30953f..dd03803b 100644
--- a/static/js/app/campaigns.js
+++ b/static/js/app/campaigns.js
@@ -60,8 +60,8 @@ function edit(campaign){
$(document).ready(function(){
api.campaigns.get()
.success(function(campaigns){
+ $("#loading").hide()
if (campaigns.length > 0){
- $("#emptyMessage").hide()
$("#campaignTable").show()
campaignTable = $("#campaignTable").DataTable();
$.each(campaigns, function(i, campaign){
@@ -78,9 +78,12 @@ $(document).ready(function(){
"
]).draw()
})
+ } else {
+ $("#emptyMessage").show()
}
})
.error(function(){
+ $("#loading").hide()
errorFlash("Error fetching campaigns")
})
$("#groupForm").submit(function(){
diff --git a/templates/campaign_results.html b/templates/campaign_results.html
index eb972475..59e7b50a 100644
--- a/templates/campaign_results.html
+++ b/templates/campaign_results.html
@@ -21,8 +21,11 @@
-
-
+
@@ -49,10 +53,10 @@
@@ -62,25 +66,25 @@
Details
-
-
-
- result.email |
- result.status |
+
+
+
+ First Name |
+ Last Name |
+ Email |
+ Position |
+ Status |
+
+
-
-
- Campaign not found!
-
-
+
{{end}}
{{define "scripts"}}
-
-
+
{{end}}
diff --git a/templates/campaigns.html b/templates/campaigns.html
index 858b831b..370c6f79 100644
--- a/templates/campaigns.html
+++ b/templates/campaigns.html
@@ -32,7 +32,10 @@
-
+
+
+
+
No campaigns created yet. Let's create one!
diff --git a/templates/users.html b/templates/users.html
index 62edf1cf..3aefd5e4 100644
--- a/templates/users.html
+++ b/templates/users.html
@@ -128,12 +128,6 @@
Position |
|
-