mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 00:56:13 +01:00
feat: topics dashboard details subpage
This commit is contained in:
@@ -76,5 +76,10 @@
|
|||||||
"graphs.registered-users": "Registered Users",
|
"graphs.registered-users": "Registered Users",
|
||||||
"graphs.anonymous-users": "Anonymous Users",
|
"graphs.anonymous-users": "Anonymous Users",
|
||||||
"last-restarted-by": "Last restarted by",
|
"last-restarted-by": "Last restarted by",
|
||||||
"no-users-browsing": "No users browsing"
|
"no-users-browsing": "No users browsing",
|
||||||
|
|
||||||
|
"back-to-dashboard": "Back to Dashboard",
|
||||||
|
"details.no-users": "No users have joined within the selected timeframe",
|
||||||
|
"details.no-topics": "No topics have been posted within the selected timeframe",
|
||||||
|
"details.no-logins": "No logins have been recorded within the selected timeframe"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,32 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('admin/dashboard/topics', ['admin/modules/dashboard-line-graph'], (graph) => {
|
define('admin/dashboard/topics', ['admin/modules/dashboard-line-graph', 'hooks'], (graph, hooks) => {
|
||||||
const ACP = {};
|
const ACP = {};
|
||||||
|
|
||||||
ACP.init = () => {
|
ACP.init = () => {
|
||||||
graph.init({
|
graph.init({
|
||||||
set: 'topics',
|
set: 'topics',
|
||||||
dataset: ajaxify.data.dataset,
|
dataset: ajaxify.data.dataset,
|
||||||
|
}).then(() => {
|
||||||
|
hooks.onPage('action:admin.dashboard.updateGraph', ACP.updateTable);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ACP.updateTable = () => {
|
||||||
|
if (window.fetch) {
|
||||||
|
fetch(`${config.relative_path}/api${ajaxify.data.url}${window.location.search}`, { credentials: 'include' }).then((response) => {
|
||||||
|
if (response.ok) {
|
||||||
|
response.json().then(function (payload) {
|
||||||
|
app.parseAndTranslate(ajaxify.data.template.name, 'topics', payload, function (html) {
|
||||||
|
const tbodyEl = document.querySelector('.topics-list tbody');
|
||||||
|
tbodyEl.innerHTML = '';
|
||||||
|
tbodyEl.append(...html.map((idx, el) => el));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return ACP;
|
return ACP;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const meta = require('../../meta');
|
|||||||
const analytics = require('../../analytics');
|
const analytics = require('../../analytics');
|
||||||
const plugins = require('../../plugins');
|
const plugins = require('../../plugins');
|
||||||
const user = require('../../user');
|
const user = require('../../user');
|
||||||
|
const topics = require('../../topics');
|
||||||
const utils = require('../../utils');
|
const utils = require('../../utils');
|
||||||
|
|
||||||
const dashboardController = module.exports;
|
const dashboardController = module.exports;
|
||||||
@@ -261,7 +262,7 @@ dashboardController.getUsers = async (req, res) => {
|
|||||||
month: stats[0].thismonth,
|
month: stats[0].thismonth,
|
||||||
};
|
};
|
||||||
|
|
||||||
// List of recently registered users
|
// List of users registered within time frame
|
||||||
const end = parseInt(req.query.until, 10) || Date.now();
|
const end = parseInt(req.query.until, 10) || Date.now();
|
||||||
const start = end - (1000 * 60 * 60 * (req.query.units === 'days' ? 24 : 1) * (req.query.count || (req.query.units === 'days' ? 30 : 24)));
|
const start = end - (1000 * 60 * 60 * (req.query.units === 'days' ? 24 : 1) * (req.query.count || (req.query.units === 'days' ? 30 : 24)));
|
||||||
const uids = await db.getSortedSetRangeByScore('users:joindate', 0, 500, start, end);
|
const uids = await db.getSortedSetRangeByScore('users:joindate', 0, 500, start, end);
|
||||||
@@ -288,10 +289,17 @@ dashboardController.getTopics = async (req, res) => {
|
|||||||
month: stats[0].thismonth,
|
month: stats[0].thismonth,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// List of topics created within time frame
|
||||||
|
const end = parseInt(req.query.until, 10) || Date.now();
|
||||||
|
const start = end - (1000 * 60 * 60 * (req.query.units === 'days' ? 24 : 1) * (req.query.count || (req.query.units === 'days' ? 30 : 24)));
|
||||||
|
const tids = await db.getSortedSetRangeByScore('topics:tid', 0, 500, start, end);
|
||||||
|
const topicData = await topics.getTopicsByTids(tids);
|
||||||
|
|
||||||
res.render('admin/dashboard/topics', {
|
res.render('admin/dashboard/topics', {
|
||||||
set: 'topics',
|
set: 'topics',
|
||||||
query: req.query,
|
query: req.query,
|
||||||
stats,
|
stats,
|
||||||
summary,
|
summary,
|
||||||
|
topics: topicData,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
<div class="row dashboard">
|
<div class="row dashboard">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
|
<a class="btn btn-link" href="{config.relative_path}/admin/dashboard">
|
||||||
|
<i class="fa fa-chevron-left"></i>
|
||||||
|
[[admin/dashboard:back-to-dashboard]]
|
||||||
|
</a>
|
||||||
|
|
||||||
<!-- IMPORT admin/partials/dashboard/graph.tpl -->
|
<!-- IMPORT admin/partials/dashboard/graph.tpl -->
|
||||||
<!-- IMPORT admin/partials/dashboard/stats.tpl -->
|
<!-- IMPORT admin/partials/dashboard/stats.tpl -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,28 @@
|
|||||||
<div class="row dashboard">
|
<div class="row dashboard">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
|
<a class="btn btn-link" href="{config.relative_path}/admin/dashboard">
|
||||||
|
<i class="fa fa-chevron-left"></i>
|
||||||
|
[[admin/dashboard:back-to-dashboard]]
|
||||||
|
</a>
|
||||||
|
|
||||||
<!-- IMPORT admin/partials/dashboard/graph.tpl -->
|
<!-- IMPORT admin/partials/dashboard/graph.tpl -->
|
||||||
<!-- IMPORT admin/partials/dashboard/stats.tpl -->
|
<!-- IMPORT admin/partials/dashboard/stats.tpl -->
|
||||||
|
|
||||||
|
<table class="table table-striped topics-list">
|
||||||
|
<tbody>
|
||||||
|
{{{ if !topics.length}}}
|
||||||
|
<tr>
|
||||||
|
<td colspan=4" class="text-center"><em>[[admin/dashboard:details.no-topics]]</em></td>
|
||||||
|
</tr>
|
||||||
|
{{{ end }}}
|
||||||
|
{{{ each topics }}}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{config.relative_path}/topics/{../slug}">{../title}</a></td>
|
||||||
|
<td>[[topic:posted_by, {../user.username}]]</td>
|
||||||
|
<td><span class="timeago" data-title="{../timestampISO}"></span></td>
|
||||||
|
</tr>
|
||||||
|
{{{ end }}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,4 +1,10 @@
|
|||||||
<div class="dashboard">
|
<div class="dashboard">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<a class="btn btn-link" href="{config.relative_path}/admin/dashboard">
|
||||||
|
<i class="fa fa-chevron-left"></i>
|
||||||
|
[[admin/dashboard:back-to-dashboard]]
|
||||||
|
</a>
|
||||||
|
|
||||||
<!-- IMPORT admin/partials/dashboard/graph.tpl -->
|
<!-- IMPORT admin/partials/dashboard/graph.tpl -->
|
||||||
<!-- IMPORT admin/partials/dashboard/stats.tpl -->
|
<!-- IMPORT admin/partials/dashboard/stats.tpl -->
|
||||||
|
|
||||||
@@ -10,6 +16,11 @@
|
|||||||
<th data-sort="joindate">[[admin/manage/users:users.joined]]</th>
|
<th data-sort="joindate">[[admin/manage/users:users.joined]]</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{{{ if !users.length}}}
|
||||||
|
<tr>
|
||||||
|
<td colspan=4" class="text-center"><em>[[admin/dashboard:details.no-logins]]</em></td>
|
||||||
|
</tr>
|
||||||
|
{{{ end }}}
|
||||||
{{{ each users }}}
|
{{{ each users }}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{../uid}</td>
|
<td>{../uid}</td>
|
||||||
@@ -20,4 +31,5 @@
|
|||||||
{{{ end }}}
|
{{{ end }}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<div class="row">
|
<div class="table-responsive">
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -45,5 +44,4 @@
|
|||||||
<!-- END stats -->
|
<!-- END stats -->
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user