mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-15 01:52:45 +00:00
admin page fix
This commit is contained in:
@@ -66,14 +66,6 @@ const BrewLookup = createClass({
|
|||||||
'fa-spin fa-spinner' : this.state.searching,
|
'fa-spin fa-spinner' : this.state.searching,
|
||||||
})} />
|
})} />
|
||||||
</button>
|
</button>
|
||||||
<input type='text' value={this.state.query} onChange={this.handleChange} placeholder='title' />
|
|
||||||
<button onClick={this.lookup}>
|
|
||||||
<i className={cx('fas', {
|
|
||||||
'fa-search' : !this.state.searching,
|
|
||||||
'fa-spin fa-spinner' : this.state.searching,
|
|
||||||
})} />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
|
|
||||||
{this.state.error
|
{this.state.error
|
||||||
&& <div className='error'>{this.state.error.toString()}</div>
|
&& <div className='error'>{this.state.error.toString()}</div>
|
||||||
|
|||||||
@@ -55,22 +55,31 @@ router.post('/admin/cleanup', mw.adminOnly, (req, res)=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* 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)=>{
|
|
||||||
HomebrewModel.findOne({ $or : [
|
router.get('/admin/lookup/:id', mw.adminOnly, async (req, res, next) => {
|
||||||
{ editId: { '$regex': req.params.id, '$options': 'i' } },
|
try {
|
||||||
{ shareId: { '$regex': req.params.id, '$options': 'i' } },
|
const brew = await HomebrewModel.findOne({
|
||||||
] }).exec((err, brew)=>{
|
$or: [
|
||||||
return res.json(brew);
|
{ editId: { $regex: req.params.id, $options: 'i' } },
|
||||||
});
|
{ shareId: { $regex: req.params.id, $options: 'i' } },
|
||||||
|
]
|
||||||
|
}).exec();
|
||||||
|
|
||||||
|
if (!brew) {
|
||||||
|
// No document found
|
||||||
|
return res.status(404).json({ error: 'Document not found' });
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.json(brew);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return res.status(500).json({ error: 'Internal Server Error' });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Searches for matching title, also attempts to partial match */
|
|
||||||
router.get('/admin/lookup/:id', mw.adminOnly, (req, res, next)=>{
|
|
||||||
HomebrewModel.findOne({ $or : { title: { '$regex': /./, '$options': 'i' } } }).exec((err, brew)=>{
|
|
||||||
return res.json(brew);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Find 50 brews that aren't compressed yet */
|
/* Find 50 brews that aren't compressed yet */
|
||||||
router.get('/admin/finduncompressed', mw.adminOnly, (req, res)=>{
|
router.get('/admin/finduncompressed', mw.adminOnly, (req, res)=>{
|
||||||
uncompressedBrewQuery.exec((err, objs)=>{
|
uncompressedBrewQuery.exec((err, objs)=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user