1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-11 08:46:30 +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 />
<BrewCleanup />
</div>
</div>
</div>;
}
});

View File

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

View File

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

View File

@@ -16,13 +16,13 @@ const Stats = createClass({
totalBrews : 0
},
fetching : false
}
};
},
componentDidMount(){
this.fetchStats();
},
fetchStats(){
this.setState({ fetching : true})
this.setState({ fetching: true });
request.get('/admin/stats')
.then((res)=>this.setState({ stats: res.body }))
.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);
return res.json({ count: objs.length });
});
})
});
/* Searches for matching edit or share id, also attempts to partial match */
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)=>{
return res.json({
totalBrews : count
})
})
});
});
});
router.get('/admin', mw.adminOnly, (req, res)=>{
@@ -70,7 +70,7 @@ router.get('/admin', mw.adminOnly, (req, res)=>{
url : req.originalUrl
})
.then((page)=>res.send(page))
.catch((err)=>res.sendStatus(500))
.catch((err)=>res.sendStatus(500));
});
module.exports = router;