mirror of https://github.com/gophish/gophish
Cleaning up some logic on updating the email chart legend.
parent
53e5508bca
commit
95fb02bade
|
@ -63,7 +63,6 @@ var statuses = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var campaign = {}
|
var campaign = {}
|
||||||
var email_legend = []
|
|
||||||
|
|
||||||
function dismiss() {
|
function dismiss() {
|
||||||
$("#modal\\.flashes").empty()
|
$("#modal\\.flashes").empty()
|
||||||
|
@ -204,41 +203,31 @@ function poll() {
|
||||||
email_series_data[result.status]++;
|
email_series_data[result.status]++;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
$("#email_chart_legend").html("")
|
||||||
$.each(email_series_data, function(status, count) {
|
$.each(email_series_data, function(status, count) {
|
||||||
email_data.series.push({
|
email_data.series.push({
|
||||||
meta: status,
|
meta: status,
|
||||||
value: count
|
value: count
|
||||||
})
|
})
|
||||||
|
$("#email_chart_legend").append('<li><span class="' + statuses[status].legend + '"></span>' + status + '</li>')
|
||||||
})
|
})
|
||||||
var email_chart = $("#email_chart")
|
var email_chart = $("#email_chart")
|
||||||
if (email_chart.get(0).__chartist__) {
|
if (email_chart.get(0).__chartist__) {
|
||||||
|
|
||||||
$("#email_chart_legend").html("")
|
|
||||||
email_legend = []
|
|
||||||
email_chart.get(0).__chartist__.on('draw', function(data) {
|
email_chart.get(0).__chartist__.on('draw', function(data) {
|
||||||
// We don't want to create the legend twice
|
|
||||||
if (!email_legend[data.meta]) {
|
|
||||||
$("#email_chart_legend").append('<li><span class="' + statuses[data.meta].legend + '"></span>' + data.meta + '</li>')
|
|
||||||
email_legend[data.meta] = true
|
|
||||||
}
|
|
||||||
data.element.addClass(statuses[data.meta].slice)
|
data.element.addClass(statuses[data.meta].slice)
|
||||||
})
|
})
|
||||||
|
// Update with the latest data
|
||||||
email_chart.get(0).__chartist__.update(email_data)
|
email_chart.get(0).__chartist__.update(email_data)
|
||||||
}
|
}
|
||||||
/* Update the datatable */
|
/* Update the datatable */
|
||||||
resultsTable = $("#resultsTable").DataTable()
|
resultsTable = $("#resultsTable").DataTable()
|
||||||
resultsTable.rows().each(function(i) {
|
resultsTable.rows().every(function(i, tableLoop, rowLoop) {
|
||||||
var rowData = this.row(i).data()
|
var rowData = this.row(i).data()
|
||||||
var rid = rowData[0]
|
var rid = rowData[0]
|
||||||
console.log("Updating information for " + rid)
|
|
||||||
$.each(campaign.results, function(j, result) {
|
$.each(campaign.results, function(j, result) {
|
||||||
if (result.id == rid) {
|
if (result.id == rid) {
|
||||||
console.log("Found entry for " + rid + " " + result.first_name)
|
|
||||||
console.log(rowData)
|
|
||||||
var label = statuses[result.status].label || "label-default";
|
var label = statuses[result.status].label || "label-default";
|
||||||
rowData[6] = "<span class=\"label " + label + "\">" + result.status + "</span>"
|
rowData[6] = "<span class=\"label " + label + "\">" + result.status + "</span>"
|
||||||
console.log("Updating row " + i)
|
|
||||||
console.log(resultsTable.row(i).data())
|
|
||||||
resultsTable.row(i).data(rowData).draw()
|
resultsTable.row(i).data(rowData).draw()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -373,11 +362,13 @@ function load() {
|
||||||
y: 1
|
y: 1
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
$("#email_chart_legend").html("")
|
||||||
$.each(email_series_data, function(status, count) {
|
$.each(email_series_data, function(status, count) {
|
||||||
email_data.series.push({
|
email_data.series.push({
|
||||||
meta: status,
|
meta: status,
|
||||||
value: count
|
value: count
|
||||||
})
|
})
|
||||||
|
$("#email_chart_legend").append('<li><span class="' + statuses[status].legend + '"></span>' + status + '</li>')
|
||||||
})
|
})
|
||||||
var timeline_chart = new Chartist.Line('#timeline_chart', timeline_data, timeline_opts)
|
var timeline_chart = new Chartist.Line('#timeline_chart', timeline_data, timeline_opts)
|
||||||
// Setup the overview chart listeners
|
// Setup the overview chart listeners
|
||||||
|
@ -406,12 +397,7 @@ function load() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
var email_chart = new Chartist.Pie("#email_chart", email_data, email_opts)
|
var email_chart = new Chartist.Pie("#email_chart", email_data, email_opts)
|
||||||
$("#email_chart_legend").html("")
|
|
||||||
email_chart.on('draw', function(data) {
|
email_chart.on('draw', function(data) {
|
||||||
if (!email_legend[data.meta]) {
|
|
||||||
$("#email_chart_legend").append('<li><span class="' + statuses[data.meta].legend + '"></span>' + data.meta + '</li>')
|
|
||||||
email_legend[data.meta] = true
|
|
||||||
}
|
|
||||||
data.element.addClass(statuses[data.meta].slice)
|
data.element.addClass(statuses[data.meta].slice)
|
||||||
})
|
})
|
||||||
// Setup the average chart listeners
|
// Setup the average chart listeners
|
||||||
|
|
Loading…
Reference in New Issue