mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 08:25:46 +01:00
Squashed commit of the following:
commit 49e6c0040cc82c1e2684933a8e167ef14854aff8 Author: Julian Lam <julian@designcreateplay.com> Date: Thu Feb 25 16:12:15 2016 -0500 added recording and charts for topic and post counts globally and by cid commit e02ff70757f778aa016fbc42ef10a5da2d07a9d9 Author: Julian Lam <julian@designcreateplay.com> Date: Thu Feb 25 15:35:49 2016 -0500 added labels to charts commit e75d83bf3886e5183bcf5fcd848d71c513761e01 Author: Julian Lam <julian@designcreateplay.com> Date: Thu Feb 25 13:30:47 2016 -0500 added per category graphs to ACP management page commit e3f543200950925cc9e8bf33cccb592f949a100e Author: Julian Lam <julian@designcreateplay.com> Date: Thu Feb 25 12:36:11 2016 -0500 updated analytics to move helper methods to analytics lib and sending per category analytics to ACP page commit 01891d8f7c408925fcdad18dcaa941e5ebbeb9b2 Author: Julian Lam <julian@designcreateplay.com> Date: Wed Feb 24 16:48:55 2016 -0500 saving per-category analytics, and updated the writeData method to use async for "clarity"
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
/*global define, app, socket, ajaxify, RELATIVE_PATH, bootbox, templates */
|
||||
/*global define, app, socket, ajaxify, RELATIVE_PATH, bootbox, templates, Chart */
|
||||
|
||||
define('admin/manage/category', [
|
||||
'uploader',
|
||||
@@ -145,6 +145,12 @@ define('admin/manage/category', [
|
||||
});
|
||||
|
||||
Category.setupPrivilegeTable();
|
||||
|
||||
if (window.location.hash === '#analytics') {
|
||||
Category.setupGraphs();
|
||||
} else {
|
||||
$('a[href="#analytics"]').on('shown.bs.tab', Category.setupGraphs);
|
||||
}
|
||||
};
|
||||
|
||||
Category.setupPrivilegeTable = function() {
|
||||
@@ -345,5 +351,106 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.setupGraphs = function() {
|
||||
var hourlyCanvas = document.getElementById('pageviews:hourly'),
|
||||
dailyCanvas = document.getElementById('pageviews:daily'),
|
||||
topicsCanvas = document.getElementById('topics:daily'),
|
||||
postsCanvas = document.getElementById('posts:daily'),
|
||||
hourlyLabels = utils.getHoursArray().map(function(text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
}),
|
||||
dailyLabels = utils.getDaysArray().map(function(text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
});
|
||||
|
||||
if (utils.isMobile()) {
|
||||
Chart.defaults.global.showTooltips = false;
|
||||
}
|
||||
|
||||
var data = {
|
||||
'pageviews:hourly': {
|
||||
labels: hourlyLabels,
|
||||
datasets: [
|
||||
{
|
||||
label: "",
|
||||
fillColor: "rgba(220,220,220,0.2)",
|
||||
strokeColor: "rgba(220,220,220,1)",
|
||||
pointColor: "rgba(220,220,220,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(220,220,220,1)",
|
||||
data: ajaxify.data.analytics['pageviews:hourly']
|
||||
}
|
||||
]
|
||||
},
|
||||
'pageviews:daily': {
|
||||
labels: dailyLabels,
|
||||
datasets: [
|
||||
{
|
||||
label: "",
|
||||
fillColor: "rgba(151,187,205,0.2)",
|
||||
strokeColor: "rgba(151,187,205,1)",
|
||||
pointColor: "rgba(151,187,205,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(151,187,205,1)",
|
||||
data: ajaxify.data.analytics['pageviews:daily']
|
||||
}
|
||||
]
|
||||
},
|
||||
'topics:daily': {
|
||||
labels: dailyLabels.slice(-7),
|
||||
datasets: [
|
||||
{
|
||||
label: "",
|
||||
fillColor: "rgba(151,187,205,0.2)",
|
||||
strokeColor: "rgba(151,187,205,1)",
|
||||
pointColor: "rgba(151,187,205,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(151,187,205,1)",
|
||||
data: ajaxify.data.analytics['topics:daily']
|
||||
}
|
||||
]
|
||||
},
|
||||
'posts:daily': {
|
||||
labels: dailyLabels.slice(-7),
|
||||
datasets: [
|
||||
{
|
||||
label: "",
|
||||
fillColor: "rgba(151,187,205,0.2)",
|
||||
strokeColor: "rgba(151,187,205,1)",
|
||||
pointColor: "rgba(151,187,205,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(151,187,205,1)",
|
||||
data: ajaxify.data.analytics['posts:daily']
|
||||
}
|
||||
]
|
||||
},
|
||||
};
|
||||
|
||||
hourlyCanvas.width = $(hourlyCanvas).parent().width();
|
||||
dailyCanvas.width = $(dailyCanvas).parent().width();
|
||||
topicsCanvas.width = $(topicsCanvas).parent().width();
|
||||
postsCanvas.width = $(postsCanvas).parent().width();
|
||||
new Chart(hourlyCanvas.getContext('2d')).Line(data['pageviews:hourly'], {
|
||||
responsive: true,
|
||||
animation: false
|
||||
});
|
||||
new Chart(dailyCanvas.getContext('2d')).Line(data['pageviews:daily'], {
|
||||
responsive: true,
|
||||
animation: false
|
||||
});
|
||||
new Chart(topicsCanvas.getContext('2d')).Line(data['topics:daily'], {
|
||||
responsive: true,
|
||||
animation: false
|
||||
});
|
||||
new Chart(postsCanvas.getContext('2d')).Line(data['posts:daily'], {
|
||||
responsive: true,
|
||||
animation: false
|
||||
});
|
||||
};
|
||||
|
||||
return Category;
|
||||
});
|
||||
Reference in New Issue
Block a user