mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 13:32:45 +00:00
admin look by title
This commit is contained in:
@@ -66,6 +66,14 @@ 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>
|
||||||
|
|||||||
@@ -34,6 +34,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 Count</dt>
|
||||||
|
<dd>{this.state.stats.totalPublishedBrews || 'no published brews'}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
{this.state.fetching
|
{this.state.fetching
|
||||||
|
|||||||
@@ -64,6 +64,13 @@ router.get('/admin/lookup/:id', mw.adminOnly, (req, res, next)=>{
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* 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)=>{
|
||||||
@@ -91,13 +98,36 @@ router.put('/admin/compress/:id', (req, res)=>{
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/admin/stats', mw.adminOnly, (req, res)=>{
|
router.get('/admin/stats', mw.adminOnly, async (req, res) => {
|
||||||
HomebrewModel.count({}, (err, count)=>{
|
try {
|
||||||
return res.json({
|
const totalBrewsCount = await HomebrewModel.countDocuments({});
|
||||||
totalBrews : count
|
const publishedBrewsCount = await HomebrewModel.countDocuments({ published: true });
|
||||||
});
|
|
||||||
});
|
return res.json({
|
||||||
|
totalBrews: totalBrewsCount,
|
||||||
|
totalPublishedBrews: publishedBrewsCount
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return res.status(500).json({ error: 'Internal Server Error' });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
router.get('/admin/stats', mw.adminOnly, async (req, res) => {
|
||||||
|
try {
|
||||||
|
const count = await HomebrewModel.countDocuments({});
|
||||||
|
return res.json({
|
||||||
|
totalBrews: count
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return res.status(500).json({ error: 'Internal Server Error' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
router.get('/admin', mw.adminOnly, (req, res)=>{
|
router.get('/admin', mw.adminOnly, (req, res)=>{
|
||||||
templateFn('admin', {
|
templateFn('admin', {
|
||||||
|
|||||||
Reference in New Issue
Block a user