From dbc407676e22f5ab1124a686b8b433ff4312038f Mon Sep 17 00:00:00 2001 From: Jordan Wright Date: Fri, 29 Jan 2016 08:31:58 -0600 Subject: [PATCH] Adding initial structure of timeline --- static/css/main.css | 55 +++++++++++++++++++++++ static/js/app/campaign_results.js | 72 ++++++++++++++++++++++++++++--- templates/campaign_results.html | 1 + 3 files changed, 122 insertions(+), 6 deletions(-) diff --git a/static/css/main.css b/static/css/main.css index f1b50caa..8e748e37 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -374,3 +374,58 @@ table.dataTable thead .sorting_desc:after { content: "\f0dd" !important; opacity: .8 !important; } +.timeline{ + text-align:left; + background-color:#ffffff; +} +.timeline-graph{ + margin-left:30px; +} +.timeline>h6{ + margin-top:0px; + margin-bottom:5px; +} +.timeline>.subtitle{ + color: #999999; + font-style: italic; + margin-bottom:15px; + display:block; +} +.timeline-entry{ + position:relative; + padding-bottom:36px; +} +.timeline-bar { + display:block; + content:""; + position:absolute; + top:5px; + bottom:0; + width:1px; + left:-6px; + background:#aaaaaa; +} +.timeline-entry:last-child .timeline-bar{ + display:none; +} +.timeline-entry:last-child { + padding-bottom:0px; +} +.timeline-icon{ + position:relative; + float:left; + margin-left:-24px; + width:36px; + top:-5px; + height:36px; + text-align:center; + border-radius:50%; + background-color:#f05b4f; +} +.timeline-icon>i{ + margin-top:8px; + color:#ffffff; +} +.timeline-message { + padding-left:30px; +} diff --git a/static/js/app/campaign_results.js b/static/js/app/campaign_results.js index e3953f50..27331b9a 100644 --- a/static/js/app/campaign_results.js +++ b/static/js/app/campaign_results.js @@ -68,14 +68,45 @@ function exportAsCSV() { navigator.msSaveBlob(csvData, 'results.csv'); } else { var csvURL = window.URL.createObjectURL(csvData); - var dlLink = document.createElement('a'); - dlLink.href = csvURL; - dlLink.setAttribute('download', 'results.csv'); - dlLink.click(); + var dlLink = document.createElement('a'); + dlLink.href = csvURL; + dlLink.setAttribute('download', 'results.csv'); + dlLink.click(); } $("#exportButton").html(exportHTML) } +/*function eventToHtml(e, r) { + if !(event.email) { + + } +}*/ + +function renderTimeline(data) { + record = { + "first_name": data[1], + "last_name": data[2], + "email": data[3], + "position": data[4] + } + //the Email is index 3 + results = '
' + + '
Timeline for ' + record.first_name + ' ' + record.last_name + + '
Email: ' + record.email + '' + + '
' + $.each(campaign.timeline, function(i, event) { + if (!event.email || event.email == record.email) { + results += '
' + + '
' + + '
' + + '
' + event.message + '
' + results += '
' + //results += eventToHtml(event, record) + } + }) + results += '
' + return results +} $(document).ready(function() { campaign.id = window.location.pathname.split('/').slice(-1)[0] api.campaignId.get(campaign.id) @@ -123,10 +154,24 @@ $(document).ready(function() { showLabel: false } // Setup the results table - resultsTable = $("#resultsTable").DataTable(); + resultsTable = $("#resultsTable").DataTable({ + destroy: true, + destroy: true, + "order": [ + [1, "asc"] + ], + columnDefs: [{ + orderable: false, + targets: "no-sort" + }, { + className: "details-control", + "targets": [0] + }] + }); $.each(campaign.results, function(i, result) { label = statuses[result.status].label || "label-default"; resultsTable.row.add([ + "", result.first_name || "", result.last_name || "", result.email || "", @@ -139,7 +184,22 @@ $(document).ready(function() { email_series_data[result.status]++; } }) - // Setup the graphs + // Setup the individual timelines + $('#resultsTable tbody').on('click', 'td.details-control', function() { + var tr = $(this).closest('tr'); + var row = resultsTable.row(tr); + + if (row.child.isShown()) { + // This row is already open - close it + row.child.hide(); + tr.removeClass('shown'); + } else { + // Open this row + row.child(renderTimeline(row.data())).show(); + tr.addClass('shown'); + } + }); + // Setup the graphs $.each(campaign.timeline, function(i, event) { timeline_data.series[0].data.push({ meta: i, diff --git a/templates/campaign_results.html b/templates/campaign_results.html index 8f6d149c..66df1283 100644 --- a/templates/campaign_results.html +++ b/templates/campaign_results.html @@ -85,6 +85,7 @@ +
First Name Last Name Email