diff --git a/public/less/admin/general/dashboard.less b/public/less/admin/general/dashboard.less index eb527a5192..85d277f1c0 100644 --- a/public/less/admin/general/dashboard.less +++ b/public/less/admin/general/dashboard.less @@ -24,6 +24,27 @@ padding-left: 0px; padding-top: 60px; } + + &.legend-down { + padding-left: 0px; + padding-top: 0px; + + canvas { + margin-bottom: 25px; + } + + .graph-legend { + position: relative; + + li { + float: left; + width: 50%; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + } + } } .graph-legend { diff --git a/public/src/forum/admin/general/dashboard.js b/public/src/forum/admin/general/dashboard.js index 67b8afc175..51eefc0f5b 100644 --- a/public/src/forum/admin/general/dashboard.js +++ b/public/src/forum/admin/general/dashboard.js @@ -278,7 +278,7 @@ define('forum/admin/general/dashboard', ['semver'], function(semver) { updateTrafficGraph(); $(window).on('resize', function() { - $('.pie-chart.push-down').each(function() { + $('.pie-chart.legend-up').each(function() { var $this = $(this); if ($this.width() < 320) { @@ -320,7 +320,10 @@ define('forum/admin/general/dashboard', ['semver'], function(semver) { function updateTopicsGraph(topics) { if (!Object.keys(topics).length) { - topics = {"0": 1}; + topics = {"0": { + title: "No users browsing", + value: 1 + }}; } var tids = Object.keys(topics), @@ -338,7 +341,7 @@ define('forum/admin/general/dashboard', ['semver'], function(semver) { usedTopicColors.splice($.inArray(segments[i].color, usedTopicColors), 1); graphs.topics.removeData(i); } else { - graphs.topics.segments[i].value = topics[tid]; + graphs.topics.segments[i].value = topics[tid].value; delete topics[tid]; } } @@ -347,10 +350,10 @@ define('forum/admin/general/dashboard', ['semver'], function(semver) { function assignNewTopics() { while (segments.length < 10 && tids.length > 0) { var tid = tids.pop(), - value = topics[tid], + data = topics[tid], color = null; - if (!value) { + if (!data) { continue; } @@ -372,10 +375,10 @@ define('forum/admin/general/dashboard', ['semver'], function(semver) { if (color) { graphs.topics.addData({ - value: value, + value: data.value, color: color, highlight: lighten(color, 10), - label: tid !== '0' ? "tid " + tid : "No users browsing" + label: data.title }); segments[segments.length - 1].tid = tid; diff --git a/src/socket.io/meta.js b/src/socket.io/meta.js index 88db6ccec9..0b715be39a 100644 --- a/src/socket.io/meta.js +++ b/src/socket.io/meta.js @@ -10,6 +10,7 @@ var meta = require('../meta'), nconf = require('nconf'), gravatar = require('gravatar'), winston = require('winston'), + validator = require('validator'), websockets = require('./'), SocketMeta = { @@ -124,11 +125,18 @@ SocketMeta.rooms.getAll = function(socket, data, callback) { topTenTopics = topTenTopics.concat(scores[mostActive.pop()]); } - topTenTopics.splice(0, 9).slice(0,9).forEach(function(tid) { - socketData.topics[tid] = rooms['/topic_' + tid].length; - }); + topTenTopics = topTenTopics.slice(0,9); - callback(null, socketData); + topics.getTopicsFields(topTenTopics, ['title'], function(err, titles) { + topTenTopics.forEach(function(tid, id) { + socketData.topics[tid] = { + value: rooms['/topic_' + tid].length, + title: validator.escape(titles[id].title) + } + }); + + callback(null, socketData); + }); }; /* Exports */ diff --git a/src/views/admin/general/dashboard.tpl b/src/views/admin/general/dashboard.tpl index 4d5cf5434e..27a840a60c 100644 --- a/src/views/admin/general/dashboard.tpl +++ b/src/views/admin/general/dashboard.tpl @@ -60,7 +60,7 @@