32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
// Dashboard page renderer for the signage overview.
|
|
|
|
const { renderView } = require('../../../view');
|
|
|
|
function normalizeBaseUrl(value) {
|
|
return String(value || '').trim().replace(/\/$/, '');
|
|
}
|
|
|
|
module.exports = function renderDashboardPage(data, message, currentUser) {
|
|
const primaryPlayerUrl = Array.isArray(data.screens)
|
|
? String((data.screens.find(function (screen) {
|
|
return screen && String(screen.public_base_url || '').trim();
|
|
}) || {}).public_base_url || '').trim()
|
|
: '';
|
|
|
|
return renderView('dashboard/index', {
|
|
title: 'Dashboard',
|
|
active: 'dashboard',
|
|
message: message,
|
|
currentUser: currentUser || null,
|
|
playlists: data.playlists || [],
|
|
screens: data.screens || [],
|
|
clients: data.clients || [],
|
|
kioskPlayers: data.kioskPlayers || [],
|
|
slides: data.slides || [],
|
|
connectedClientsCount: Number(data.connectedClientsCount || 0),
|
|
connectedPlayersCount: Number(data.connectedPlayersCount || data.connectedClientsCount || 0),
|
|
primaryPlayerUrl: normalizeBaseUrl(primaryPlayerUrl) || null,
|
|
scripts: ['js/dashboard/dashboard-page.js']
|
|
});
|
|
};
|