From 3bbd6b7ca1520502d585a07d151fa47e7331b762 Mon Sep 17 00:00:00 2001 From: Jordan Wright Date: Sun, 27 Sep 2015 22:25:38 -0500 Subject: [PATCH] Fixing labels on dashboard Added "Emails Sent" campaign status --- models/models.go | 1 + static/js/app/campaign_results.js | 5 +++++ static/js/app/campaigns.js | 5 +++-- static/js/app/dashboard.js | 14 ++++++++++++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/models/models.go b/models/models.go index 3d263ea3..fb77870b 100644 --- a/models/models.go +++ b/models/models.go @@ -22,6 +22,7 @@ var Logger = log.New(os.Stdout, " ", log.Ldate|log.Ltime|log.Lshortfile) const ( CAMPAIGN_IN_PROGRESS string = "In progress" CAMPAIGN_QUEUED string = "Queued" + CAMPAIGN_EMAILS_SENT string = "Emails Sent" CAMPAIGN_COMPLETE string = "Completed" EVENT_SENT string = "Email Sent" EVENT_OPENED string = "Email Opened" diff --git a/static/js/app/campaign_results.js b/static/js/app/campaign_results.js index bf51f4c0..b992bcb4 100644 --- a/static/js/app/campaign_results.js +++ b/static/js/app/campaign_results.js @@ -26,6 +26,11 @@ var statuses = { slice: "ct-slice-donut-error", legend: "ct-legend-error", label: "label-default" + }, + "Unknown" : { + slice: "ct-slice-donut-error", + legend: "ct-legend-error", + label: "label-default" } } diff --git a/static/js/app/campaigns.js b/static/js/app/campaigns.js index d01f312c..24be4f07 100644 --- a/static/js/app/campaigns.js +++ b/static/js/app/campaigns.js @@ -3,8 +3,9 @@ var labels = { "In progress" : "label-primary", "Queued" : "label-info", - "Completed" : "label-success", - "Error" : "label-danger" + "Completed" : "label-success", + "Emails Sent" : "label-success", + "Error" : "label-danger" } // Save attempts to POST to /campaigns/ diff --git a/static/js/app/dashboard.js b/static/js/app/dashboard.js index 54fcfbc1..c13ea635 100644 --- a/static/js/app/dashboard.js +++ b/static/js/app/dashboard.js @@ -1,4 +1,13 @@ var campaigns = [] +// labels is a map of campaign statuses to +// CSS classes +var labels = { + "In progress" : "label-primary", + "Queued" : "label-info", + "Completed" : "label-success", + "Emails Sent" : "label-success", + "Error" : "label-danger" +} $(document).ready(function(){ api.campaigns.get() @@ -27,11 +36,12 @@ $(document).ready(function(){ campaignTable = $("#campaignTable").DataTable(); $.each(campaigns, function(i, campaign){ var campaign_date = moment(campaign.created_date).format('MMMM Do YYYY h:mm') + var label = labels[campaign.status] || "label-default"; // Add it to the table campaignTable.row.add([ campaign.name, campaign_date, - campaign.status, + "" + campaign.status + "", "
\ \ \ @@ -91,7 +101,7 @@ $(document).ready(function(){ $chart.on('mouseenter', '.ct-point', function() { var $point = $(this) - value = $point.attr('ct:value') + value = $point.attr('ct:value') || 0 cidx = $point.attr('ct:meta') $toolTip.html(campaigns[cidx].name + '
' + "Successes: " + value.toString() + "%").show(); });