6 changed files with 168 additions and 114 deletions
@ -0,0 +1,21 @@ |
|||||
|
{ |
||||
|
// Use IntelliSense to learn about possible attributes. |
||||
|
// Hover to view descriptions of existing attributes. |
||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 |
||||
|
"version": "0.2.0", |
||||
|
"configurations": [ |
||||
|
{ |
||||
|
"type": "pwa-node", |
||||
|
"request": "launch", |
||||
|
"name": "Launch Program", |
||||
|
"skipFiles": [ |
||||
|
"<node_internals>/**" |
||||
|
], |
||||
|
"program": "${workspaceFolder:dtp-sites}/dtp-sites.js", |
||||
|
"console": "integratedTerminal", |
||||
|
"env": { |
||||
|
"HTTP_BIND_PORT": "3333" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
@ -0,0 +1,68 @@ |
|||||
|
// admin.js
|
||||
|
// Copyright (C) 2021 Digital Telepresence, LLC
|
||||
|
// All Rights Reserved
|
||||
|
|
||||
|
'use strict'; |
||||
|
|
||||
|
const DTP_COMPONENT_NAME = 'admin'; |
||||
|
|
||||
|
const path = require('path'); |
||||
|
const express = require('express'); |
||||
|
|
||||
|
const mongoose = require('mongoose'); |
||||
|
const User = mongoose.model('User'); |
||||
|
|
||||
|
const { SiteError, SiteController } = require('../../lib/site-lib'); |
||||
|
|
||||
|
class AdminController extends SiteController { |
||||
|
|
||||
|
constructor (dtp) { |
||||
|
super(dtp, DTP_COMPONENT_NAME); |
||||
|
} |
||||
|
|
||||
|
async start ( ) { |
||||
|
const { otpAuth: otpAuthService } = this.dtp.services; |
||||
|
|
||||
|
const router = express.Router(); |
||||
|
this.dtp.app.use('/admin', router); |
||||
|
|
||||
|
router.use( |
||||
|
async (req, res, next) => { |
||||
|
res.locals.currentView = 'admin'; |
||||
|
res.locals.adminView = 'home'; |
||||
|
|
||||
|
if (!req.user || !req.user.flags.isAdmin) { |
||||
|
return next(new SiteError(403, 'Administrative privileges required')); |
||||
|
} |
||||
|
|
||||
|
return next(); |
||||
|
}, |
||||
|
otpAuthService.middleware('Admin', { |
||||
|
adminRequired: true, |
||||
|
otpRequired: true, |
||||
|
otpRedirectURL: '/admin', |
||||
|
}), |
||||
|
); |
||||
|
|
||||
|
router.use('/domain',await this.loadChild(path.join(__dirname, 'admin', 'domain'))); |
||||
|
router.use('/host',await this.loadChild(path.join(__dirname, 'admin', 'host'))); |
||||
|
router.use('/job-queue',await this.loadChild(path.join(__dirname, 'admin', 'job-queue'))); |
||||
|
router.use('/user', await this.loadChild(path.join(__dirname, 'admin', 'user'))); |
||||
|
|
||||
|
router.get('/', this.getHomeView.bind(this)); |
||||
|
|
||||
|
return router; |
||||
|
} |
||||
|
|
||||
|
async getHomeView (req, res) { |
||||
|
res.locals.stats = { |
||||
|
memberCount: await User.estimatedDocumentCount(), |
||||
|
}; |
||||
|
res.render('admin/index'); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = async (dtp) => { |
||||
|
let controller = new AdminController(dtp); |
||||
|
return controller; |
||||
|
}; |
@ -1,79 +1,87 @@ |
|||||
.uk-navbar-container.uk-padding-remove.uk-position-fixed.uk-position-top |
nav(uk-navbar).uk-navbar-container.uk-position-fixed.uk-position-top |
||||
nav(uk-navbar) |
.uk-navbar-left |
||||
.uk-navbar-left |
.uk-navbar-item |
||||
.uk-navbar-item |
button(type="button", uk-toggle="target: #dtp-offcanvas").uk-button.uk-button-link.uk-padding-small |
||||
button(type="button", uk-toggle="target: #dtp-offcanvas").uk-button.uk-button-link.uk-padding-small |
i.fas.fa-bars |
||||
i.fas.fa-chevron-right |
|
||||
|
//- Site icon |
||||
|
a(href="/", class="uk-visible@m").uk-navbar-item |
||||
|
img(src=`/img/icon/${site.domainKey}/icon-48x48.png`) |
||||
|
|
||||
|
//- Site name |
||||
|
a(href="/", class="uk-visible@xl").uk-navbar-item.uk-logo |
||||
|
span= site.name |
||||
|
|
||||
.uk-navbar-center |
//- Center menu (visible only on tablet and mobile) |
||||
a(href="/").uk-navbar-item.uk-logo |
div(class="uk-hidden@m").uk-navbar-center |
||||
img(src=`/img/icon/${site.domainKey}/icon-48x48.png`) |
a(href="/").uk-navbar-item |
||||
|
img(src=`/img/icon/${site.domainKey}/icon-48x48.png`) |
||||
.uk-navbar-right |
|
||||
.uk-navbar-item |
|
||||
if user |
|
||||
div.no-select |
|
||||
if user.picture_url |
|
||||
img( |
|
||||
src= user.picture_url || '/img/default-member.png', |
|
||||
title="Member Menu", |
|
||||
).profile-navbar |
|
||||
else |
|
||||
include missing-profile-icon |
|
||||
div(uk-dropdown={ mode: 'click' }).uk-navbar-dropdown |
|
||||
ul.uk-nav.uk-navbar-dropdown-nav(style="z-index: 1024;") |
|
||||
li.uk-nav-heading.uk-text-center= user.displayName || user.username |
|
||||
li.uk-nav-divider |
|
||||
if (user.channel) |
|
||||
li |
|
||||
a(href=`/channel/${user.channel.slug}`) |
|
||||
span.nav-item-icon |
|
||||
i.fas.fa-broadcast-tower |
|
||||
span(style="max-width: 120px;").uk-text-truncate= user.channel.name |
|
||||
if (user.channel.liveEpisode) |
|
||||
li |
|
||||
a(href=`/channel/${user.channel.slug}/broadcaster`) |
|
||||
span.nav-item-icon |
|
||||
i.fas.fa-box-open |
|
||||
span Broadcaster |
|
||||
li |
|
||||
a(href='/dashboard') |
|
||||
span.nav-item-icon |
|
||||
i.fas.fa-tachometer-alt |
|
||||
span Dashboard |
|
||||
|
|
||||
li.uk-nav-divider |
|
||||
|
|
||||
|
.uk-navbar-right |
||||
|
.uk-navbar-item |
||||
|
if user |
||||
|
div.no-select |
||||
|
if user.picture_url |
||||
|
img( |
||||
|
src= user.picture_url || '/img/default-member.png', |
||||
|
title="Member Menu", |
||||
|
).profile-navbar |
||||
|
else |
||||
|
include missing-profile-icon |
||||
|
div(uk-dropdown={ mode: 'click' }).uk-navbar-dropdown |
||||
|
ul.uk-nav.uk-navbar-dropdown-nav(style="z-index: 1024;") |
||||
|
li.uk-nav-heading.uk-text-center= user.displayName || user.username |
||||
|
li.uk-nav-divider |
||||
|
if (user.channel) |
||||
li |
li |
||||
a(href=`/user/${user._id}`) |
a(href=`/channel/${user.channel.slug}`) |
||||
span.nav-item-icon |
span.nav-item-icon |
||||
i.fas.fa-user |
i.fas.fa-broadcast-tower |
||||
span Profile |
span(style="max-width: 120px;").uk-text-truncate= user.channel.name |
||||
li |
if (user.channel.liveEpisode) |
||||
a(href=`/user/${user._id}/settings`) |
|
||||
span.nav-item-icon |
|
||||
i.fas.fa-cog |
|
||||
span Settings |
|
||||
|
|
||||
if user.flags && user.flags.isAdmin |
|
||||
li.uk-nav-divider |
|
||||
li |
li |
||||
a(href='/admin') |
a(href=`/channel/${user.channel.slug}/broadcaster`) |
||||
span.nav-item-icon |
span.nav-item-icon |
||||
i.fas.fa-user-lock |
i.fas.fa-box-open |
||||
span Admin |
span Broadcaster |
||||
|
li |
||||
|
a(href='/dashboard') |
||||
|
span.nav-item-icon |
||||
|
i.fas.fa-tachometer-alt |
||||
|
span Dashboard |
||||
|
|
||||
li.uk-nav-divider |
li.uk-nav-divider |
||||
|
|
||||
|
li |
||||
|
a(href=`/user/${user._id}`) |
||||
|
span.nav-item-icon |
||||
|
i.fas.fa-user |
||||
|
span Profile |
||||
|
li |
||||
|
a(href=`/user/${user._id}/settings`) |
||||
|
span.nav-item-icon |
||||
|
i.fas.fa-cog |
||||
|
span Settings |
||||
|
|
||||
|
if user.flags && user.flags.isAdmin |
||||
|
li.uk-nav-divider |
||||
li |
li |
||||
a(href='/auth/logout') |
a(href='/admin') |
||||
span.nav-item-icon |
span.nav-item-icon |
||||
i.fas.fa-sign-out-alt |
i.fas.fa-user-lock |
||||
span Logout |
span Admin |
||||
else |
|
||||
ul.uk-navbar-nav |
li.uk-nav-divider |
||||
|
|
||||
li |
li |
||||
a(href='/welcome').uk-button.uk-button-link |
a(href='/auth/logout') |
||||
span.nav-item-icon |
span.nav-item-icon |
||||
i.fas.fa-sign-in-alt |
i.fas.fa-sign-out-alt |
||||
span(class="uk-visible@m").uk-margin-small-left GET STARTED! |
span Logout |
||||
|
else |
||||
|
ul.uk-navbar-nav |
||||
|
li |
||||
|
a(href='/welcome').uk-button.uk-button-link |
||||
|
span.nav-item-icon |
||||
|
i.fas.fa-sign-in-alt |
||||
|
span(class="uk-visible@m").uk-margin-small-left GET STARTED! |
Loading…
Reference in new issue