Fixing labels on dashboard

Added "Emails Sent" campaign status
pull/64/head
Jordan Wright 2015-09-27 22:25:38 -05:00
parent 6acbac26f5
commit 3bbd6b7ca1
4 changed files with 21 additions and 4 deletions

View File

@ -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"

View File

@ -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"
}
}

View File

@ -4,6 +4,7 @@ var labels = {
"In progress" : "label-primary",
"Queued" : "label-info",
"Completed" : "label-success",
"Emails Sent" : "label-success",
"Error" : "label-danger"
}

View File

@ -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,
"<span class=\"label " + label + "\">" + campaign.status + "</span>",
"<div class='pull-right'><a class='btn btn-primary' href='/campaigns/" + campaign.id + "'>\
<i class='fa fa-bar-chart'></i>\
</a>\
@ -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 + '<br>' + "Successes: " + value.toString() + "%").show();
});