mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 01:22:44 +00:00
initial commit
This commit is contained in:
@@ -1,47 +1,47 @@
|
|||||||
require('./admin.less');
|
import './admin.less';
|
||||||
const React = require('react');
|
import React, { useEffect, useState } from 'react';
|
||||||
const createClass = require('create-react-class');
|
|
||||||
|
|
||||||
const BrewUtils = require('./brewUtils/brewUtils.jsx');
|
const BrewUtils = require('./brewUtils/brewUtils.jsx');
|
||||||
const NotificationUtils = require('./notificationUtils/notificationUtils.jsx');
|
const NotificationUtils = require('./notificationUtils/notificationUtils.jsx');
|
||||||
|
|
||||||
const tabGroups = ['brew', 'notifications'];
|
const tabGroups = ['brew', 'notifications'];
|
||||||
|
|
||||||
const Admin = createClass({
|
const Admin = ()=>{
|
||||||
getDefaultProps : function() {
|
const [currentTab, setCurrentTab] = useState('brew');
|
||||||
return {};
|
|
||||||
},
|
|
||||||
|
|
||||||
getInitialState : function(){
|
useEffect(()=>{
|
||||||
return ({
|
setCurrentTab(localStorage.getItem('hbAdminTab'));
|
||||||
currentTab : 'brew'
|
}, []);
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
handleClick : function(newTab){
|
useEffect(()=>{
|
||||||
if(this.state.currentTab === newTab) return;
|
localStorage.setItem('hbAdminTab', currentTab);
|
||||||
this.setState({
|
}, [currentTab]);
|
||||||
currentTab : newTab
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
render : function(){
|
return (
|
||||||
return <div className='admin'>
|
<div className='admin'>
|
||||||
<header>
|
<header>
|
||||||
<div className='container'>
|
<div className='container'>
|
||||||
<i className='fas fa-rocket' />
|
<i className='fas fa-rocket' />
|
||||||
homebrewery admin
|
The Homebrewery Admin Page
|
||||||
|
<a href='/'>back to homepage</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
<main className='container'>
|
<main className='container'>
|
||||||
<nav className='tabs'>
|
<nav className='tabs'>
|
||||||
{tabGroups.map((tab, idx)=>{ return <button className={tab===this.state.currentTab ? 'active' : ''} key={idx} onClick={()=>{ return this.handleClick(tab); }}>{tab.toUpperCase()}</button>; })}
|
{tabGroups.map((tab, idx)=>(
|
||||||
|
<button
|
||||||
|
className={tab === currentTab ? 'active' : ''}
|
||||||
|
key={idx}
|
||||||
|
onClick={()=>setCurrentTab(tab)}>
|
||||||
|
{tab.toUpperCase()}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
{this.state.currentTab==='brew' && <BrewUtils />}
|
{currentTab === 'brew' && <BrewUtils />}
|
||||||
{this.state.currentTab==='notifications' && <NotificationUtils />}
|
{currentTab === 'notifications' && <NotificationUtils />}
|
||||||
</main>
|
</main>
|
||||||
</div>;
|
</div>
|
||||||
}
|
);
|
||||||
});
|
};
|
||||||
|
|
||||||
module.exports = Admin;
|
module.exports = Admin;
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ body {
|
|||||||
color : white;
|
color : white;
|
||||||
background-color : @red;
|
background-color : @red;
|
||||||
i { margin-right : 30px; }
|
i { margin-right : 30px; }
|
||||||
|
|
||||||
|
a {
|
||||||
|
float:right;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hr { margin : 30px 0px; }
|
hr { margin : 30px 0px; }
|
||||||
@@ -48,10 +52,10 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dl {
|
dl {
|
||||||
@maxItemWidth : 132px;
|
@maxItemWidth : 180px;
|
||||||
dt {
|
dt {
|
||||||
float : left;
|
float : left;
|
||||||
width : @maxItemWidth;
|
max-width : @maxItemWidth;
|
||||||
clear : left;
|
clear : left;
|
||||||
text-align : right;
|
text-align : right;
|
||||||
&::after { content : ' : '; }
|
&::after { content : ' : '; }
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ const Stats = createClass({
|
|||||||
getInitialState(){
|
getInitialState(){
|
||||||
return {
|
return {
|
||||||
stats : {
|
stats : {
|
||||||
totalBrews : 0
|
totalBrews : 0,
|
||||||
|
totalPublishedBrews : 0
|
||||||
},
|
},
|
||||||
fetching : false
|
fetching : false
|
||||||
};
|
};
|
||||||
@@ -34,6 +35,8 @@ const Stats = createClass({
|
|||||||
<dl>
|
<dl>
|
||||||
<dt>Total Brew Count</dt>
|
<dt>Total Brew Count</dt>
|
||||||
<dd>{this.state.stats.totalBrews}</dd>
|
<dd>{this.state.stats.totalBrews}</dd>
|
||||||
|
<dt>Total Brews Published</dt>
|
||||||
|
<dd>{this.state.stats.totalPublishedBrews}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
{this.state.fetching
|
{this.state.fetching
|
||||||
|
|||||||
@@ -4,10 +4,13 @@
|
|||||||
|
|
||||||
.pending {
|
.pending {
|
||||||
position : absolute;
|
position : absolute;
|
||||||
top : 0px;
|
top : 0.5em;
|
||||||
left : 0px;
|
left : 100px;
|
||||||
width : 100%;
|
width : 100%;
|
||||||
height : 100%;
|
height : 100%;
|
||||||
background-color : rgba(238,238,238, 0.5);
|
}
|
||||||
|
|
||||||
|
&:has(.pending) {
|
||||||
|
opacity:0.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,6 @@ router.put('/admin/compress/:id', (req, res)=>{
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
router.get('/admin/stats', mw.adminOnly, async (req, res)=>{
|
router.get('/admin/stats', mw.adminOnly, async (req, res)=>{
|
||||||
try {
|
try {
|
||||||
const totalBrewsCount = await HomebrewModel.countDocuments({});
|
const totalBrewsCount = await HomebrewModel.countDocuments({});
|
||||||
|
|||||||
Reference in New Issue
Block a user