start admin panel
This commit is contained in:
parent
c39f6d2a31
commit
1ca055a526
10
package.json
10
package.json
@ -8,11 +8,13 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"css": "mkdir -p build/style && stylus -o build/style src/style/*.styl",
|
||||
"css:watch": "mkdir -p build/style && stylus -w -o build/style src/style/*.styl",
|
||||
"js": "mkdir -p build/script && browserify src/script/main.js -o build/script/main.js && uglifyjs --overwrite build/script/main.js",
|
||||
"js:watch": "mkdir -p build/script && watchify src/script/main.js -o build/script/main.js",
|
||||
"watch": "concurrently --kill-others \"npm run css:watch\" \"npm run js:watch\"",
|
||||
"js:main": "mkdir -p build/script && browserify src/script/main.js -o build/script/main.js && uglifyjs --overwrite build/script/main.js",
|
||||
"js:main:watch": "mkdir -p build/script && watchify src/script/main.js -o build/script/main.js",
|
||||
"js:admin": "mkdir -p build/script && browserify src/script/admin.js -o build/script/admin.js && uglifyjs --overwrite build/script/admin.js",
|
||||
"js:admin:watch": "mkdir -p build/script && watchify src/script/admin.js -o build/script/admin.js",
|
||||
"watch": "concurrently --kill-others \"npm run css:watch\" \"npm run js:main:watch\" \"npm run js:admin:watch\"",
|
||||
"clean": "rm -rf build/",
|
||||
"build": "npm run clean && npm run css && npm run js"
|
||||
"build": "npm run clean && npm run css && npm run js:main && npm run js:admin"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
49
server/routes/admin.js
Normal file
49
server/routes/admin.js
Normal file
@ -0,0 +1,49 @@
|
||||
import express from 'express'
|
||||
import multiparty from 'multiparty'
|
||||
import config from '../../scripts/load-config'
|
||||
import wrap from '../../scripts/asyncRoute'
|
||||
import API from '../api'
|
||||
import News from '../api/news'
|
||||
import Image from '../api/image'
|
||||
import APIExtern from '../api/external'
|
||||
|
||||
const router = express.Router()
|
||||
const apiRouter = express.Router()
|
||||
|
||||
router.use(wrap(async (req, res, next) => {
|
||||
if (!req.session.user) return res.redirect('/login')
|
||||
|
||||
if (!req.session.privilege) {
|
||||
let u = await API.User.get(req.session.user)
|
||||
req.session.privilege = u.nw_privilege
|
||||
}
|
||||
|
||||
if (req.session.user && req.session.privilege !== 5) {
|
||||
return res.redirect('/login')
|
||||
}
|
||||
|
||||
res.locals.server_time = process.uptime()
|
||||
next()
|
||||
}))
|
||||
|
||||
/* =========
|
||||
* VIEWS
|
||||
* =========
|
||||
*/
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
res.render('admin/index')
|
||||
})
|
||||
|
||||
router.get('/oauth2', wrap(async (req, res) => {
|
||||
res.render('admin/oauth2')
|
||||
}))
|
||||
|
||||
/* =======
|
||||
* API
|
||||
* =======
|
||||
*/
|
||||
|
||||
router.use('/api', apiRouter)
|
||||
|
||||
module.exports = router
|
@ -11,6 +11,7 @@ import emailer from '../api/emailer'
|
||||
|
||||
import apiRouter from './api'
|
||||
import oauthRouter from './oauth2'
|
||||
import adminRouter from './admin'
|
||||
|
||||
let router = express.Router()
|
||||
|
||||
@ -703,6 +704,7 @@ router.get('/activate/:token', wrap(async (req, res) => {
|
||||
}))
|
||||
|
||||
router.use('/api', apiRouter)
|
||||
router.use('/admin', adminRouter)
|
||||
|
||||
/*
|
||||
NO ROUTES BEYOND THIS POINT
|
||||
|
3
src/script/admin.js
Normal file
3
src/script/admin.js
Normal file
@ -0,0 +1,3 @@
|
||||
window.$ = require('jquery')
|
||||
|
||||
$(window).ready(function () {})
|
37
src/style/admin.styl
Normal file
37
src/style/admin.styl
Normal file
@ -0,0 +1,37 @@
|
||||
body
|
||||
margin: 0
|
||||
background-color: #f5f5f5
|
||||
font-family: Helvetica
|
||||
|
||||
nav
|
||||
display: block
|
||||
height: 60px
|
||||
background-color: #6b6b6b
|
||||
border-bottom: 5px solid #383838
|
||||
ul
|
||||
display: inline-block
|
||||
margin: 0
|
||||
padding: 0
|
||||
list-style-type: none
|
||||
&.right
|
||||
float: right
|
||||
li
|
||||
height: 60px
|
||||
display: inline-block
|
||||
a
|
||||
font-size: 180%
|
||||
padding: 15px
|
||||
line-height: 2
|
||||
color: #ddd
|
||||
text-decoration: none
|
||||
text-transform: uppercase
|
||||
font-weight: bold
|
||||
&:hover
|
||||
background-color: #868686
|
||||
|
||||
.wrapper
|
||||
min-height: 100vh
|
||||
overflow: hidden
|
||||
.container
|
||||
overflow: hidden
|
||||
padding: 10px
|
6
views/admin/index.pug
Normal file
6
views/admin/index.pug
Normal file
@ -0,0 +1,6 @@
|
||||
extends layout.pug
|
||||
|
||||
block body
|
||||
.container
|
||||
.content
|
||||
h1 Welcome to the Admin Panel
|
27
views/admin/layout.pug
Normal file
27
views/admin/layout.pug
Normal file
@ -0,0 +1,27 @@
|
||||
html
|
||||
head
|
||||
meta(charset="utf8")
|
||||
link(rel="stylesheet", type="text/css", href="/style/admin.css")
|
||||
script.
|
||||
window.variables = {
|
||||
server_time: parseInt('#{server_time}')
|
||||
};
|
||||
script(src="/script/admin.js")
|
||||
title
|
||||
block title
|
||||
|Icy Network - Administration
|
||||
body
|
||||
block navigation
|
||||
nav
|
||||
ul
|
||||
li
|
||||
a.logo(href="/") Icy Network
|
||||
li
|
||||
a(href="/admin/") Home
|
||||
li
|
||||
a(href="/admin/oauth2/") OAuth2
|
||||
ul.right
|
||||
li
|
||||
a(href="/user/manage") #{user.display_name}
|
||||
.wrapper
|
||||
block body
|
6
views/admin/oauth2.pug
Normal file
6
views/admin/oauth2.pug
Normal file
@ -0,0 +1,6 @@
|
||||
extends layout.pug
|
||||
|
||||
block body
|
||||
.container
|
||||
.content
|
||||
h1 Manage OAuth2 Clients
|
Reference in New Issue
Block a user