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