1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-14 01:25:57 +00:00
This commit is contained in:
Scott Tolksdorf
2018-12-04 13:37:55 -05:00
parent 52c0462a4f
commit bf21c3d351
5 changed files with 34 additions and 34 deletions

View File

@@ -27,7 +27,7 @@ const Admin = createClass({
<hr /> <hr />
<BrewCleanup /> <BrewCleanup />
</div> </div>
</div> </div>;
} }
}); });

View File

@@ -25,7 +25,7 @@ const BrewCleanup = createClass({
request.get('/admin/cleanup') request.get('/admin/cleanup')
.then((res)=>this.setState({ count: res.body.count, primed: true })) .then((res)=>this.setState({ count: res.body.count, primed: true }))
.catch((err)=>this.setState({ error: err })) .catch((err)=>this.setState({ error: err }))
.finally(()=>this.setState({ pending : false })) .finally(()=>this.setState({ pending: false }));
}, },
cleanup(){ cleanup(){
this.setState({ pending: true }); this.setState({ pending: true });
@@ -33,13 +33,13 @@ const BrewCleanup = createClass({
request.post('/admin/cleanup') request.post('/admin/cleanup')
.then((res)=>this.setState({ count: res.body.count })) .then((res)=>this.setState({ count: res.body.count }))
.catch((err)=>this.setState({ error: err })) .catch((err)=>this.setState({ error: err }))
.finally(()=>this.setState({ pending : false, primed : false })) .finally(()=>this.setState({ pending: false, primed: false }));
}, },
renderPrimed(){ renderPrimed(){
if(!this.state.primed) return; if(!this.state.primed) return;
if(!this.state.count){ if(!this.state.count){
return <div className='removeBox'>No Matching Brews found.</div> return <div className='removeBox'>No Matching Brews found.</div>;
} }
return <div className='removeBox'> return <div className='removeBox'>
<button onClick={this.cleanup} className='remove'> <button onClick={this.cleanup} className='remove'>
@@ -49,7 +49,7 @@ const BrewCleanup = createClass({
} }
</button> </button>
<span>Found {this.state.count} Brews that could be removed. </span> <span>Found {this.state.count} Brews that could be removed. </span>
</div> </div>;
}, },
render(){ render(){
return <div className='BrewCleanup'> return <div className='BrewCleanup'>

View File

@@ -27,7 +27,7 @@ const BrewLookup = createClass({
request.get(`/admin/lookup/${this.state.query}`) request.get(`/admin/lookup/${this.state.query}`)
.then((res)=>this.setState({ foundBrew: res.body })) .then((res)=>this.setState({ foundBrew: res.body }))
.catch((err)=>this.setState({ error: err })) .catch((err)=>this.setState({ error: err }))
.finally(()=>this.setState({ searching : false })) .finally(()=>this.setState({ searching: false }));
}, },
renderFoundBrew(){ renderFoundBrew(){

View File

@@ -16,13 +16,13 @@ const Stats = createClass({
totalBrews : 0 totalBrews : 0
}, },
fetching : false fetching : false
} };
}, },
componentDidMount(){ componentDidMount(){
this.fetchStats(); this.fetchStats();
}, },
fetchStats(){ fetchStats(){
this.setState({ fetching : true}) this.setState({ fetching: true });
request.get('/admin/stats') request.get('/admin/stats')
.then((res)=>this.setState({ stats: res.body })) .then((res)=>this.setState({ stats: res.body }))
.finally(()=>this.setState({ fetching: false })); .finally(()=>this.setState({ fetching: false }));

View File

@@ -45,7 +45,7 @@ router.post('/admin/cleanup', mw.adminOnly, (req, res)=>{
if(err) return res.status(500).send(err); if(err) return res.status(500).send(err);
return res.json({ count: objs.length }); return res.json({ count: objs.length });
}); });
}) });
/* Searches for matching edit or share id, also attempts to partial match */ /* Searches for matching edit or share id, also attempts to partial match */
router.get('/admin/lookup/:id', mw.adminOnly, (req, res, next)=>{ router.get('/admin/lookup/:id', mw.adminOnly, (req, res, next)=>{
@@ -61,8 +61,8 @@ router.get('/admin/stats', mw.adminOnly, (req, res)=>{
HomebrewModel.count({}, (err, count)=>{ HomebrewModel.count({}, (err, count)=>{
return res.json({ return res.json({
totalBrews : count totalBrews : count
}) });
}) });
}); });
router.get('/admin', mw.adminOnly, (req, res)=>{ router.get('/admin', mw.adminOnly, (req, res)=>{
@@ -70,7 +70,7 @@ router.get('/admin', mw.adminOnly, (req, res)=>{
url : req.originalUrl url : req.originalUrl
}) })
.then((page)=>res.send(page)) .then((page)=>res.send(page))
.catch((err)=>res.sendStatus(500)) .catch((err)=>res.sendStatus(500));
}); });
module.exports = router; module.exports = router;