1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-15 16:45:57 +00:00

Adding in lookup route

This commit is contained in:
Scott Tolksdorf
2017-01-09 20:51:37 -05:00
parent 37de888f03
commit cd2eb5fdce
3 changed files with 54 additions and 30 deletions

View File

@@ -3,11 +3,9 @@ const _ = require('lodash');
const Nav = require('naturalcrit/nav/nav.jsx'); const Nav = require('naturalcrit/nav/nav.jsx');
//const HomebrewAdmin = require('./homebrewAdmin/homebrewAdmin.jsx');
const BrewLookup = require('./brewLookup/brewLookup.jsx'); const BrewLookup = require('./brewLookup/brewLookup.jsx');
const AdminSearch = require('./adminSearch/adminSearch.jsx');
const InvalidBrew = require('./invalidBrew/invalidBrew.jsx');
const Admin = React.createClass({ const Admin = React.createClass({
getDefaultProps: function() { getDefaultProps: function() {
@@ -31,10 +29,11 @@ const Admin = React.createClass({
{this.renderNavbar()} {this.renderNavbar()}
<main className='content'> <main className='content'>
<BrewLookup adminKey={this.props.admin_key} /> <BrewLookup adminKey={this.props.admin_key} />
<AdminSearch adminKey={this.props.admin_key} />
Test <div className='dangerZone'>Danger Zone</div>
<InvalidBrew adminKey={this.props.admin_key} />
</main> </main>
</div> </div>
} }

View File

@@ -1,20 +1,18 @@
@import 'naturalcrit/styles/core.less';
@import 'naturalcrit/styles/core.less';
html,body, #reactRoot{ html,body, #reactRoot{
min-height : 100%; min-height : 100%;
} }
body{ body{
background-color : #ddd; height : 100%;
font-family : 'Open Sans', sans-serif;
color : #4b5055;
font-weight : 100;
text-rendering : optimizeLegibility;
margin : 0; margin : 0;
padding : 0; padding : 0;
height : 100%; background-color : #ddd;
font-family : 'Open Sans', sans-serif;
font-weight : 100;
color : #4b5055;
text-rendering : optimizeLegibility;
} }
.admin { .admin {
nav { nav {
background-color : @red; background-color : @red;
@@ -31,19 +29,25 @@ body{
} }
} }
} }
h1{ h1{
margin-bottom : 10px;
font-size : 2em; font-size : 2em;
font-weight : 800; font-weight : 800;
border-bottom : 1px solid #ddd; border-bottom : 1px solid #ddd;
margin-bottom: 10px;
} }
main.content{ main.content{
background-color: white;
padding: 50px 20px;
width : 1000px; width : 1000px;
margin : 0 auto; margin : 0 auto;
padding : 50px 20px;
background-color : white;
.dangerZone{
margin : 30px 0px;
padding : 10px 20px;
background : repeating-linear-gradient(45deg, @yellow, @yellow 10px, darken(#333, 10%) 10px, darken(#333, 10%) 20px);
font-size : 1em;
font-weight : 800;
color : white;
text-transform : uppercase;
}
} }
} }

View File

@@ -8,7 +8,6 @@ const mw = require('./middleware.js');
const BrewData = require('./brew.data.js'); const BrewData = require('./brew.data.js');
router.get('/admin', mw.adminLogin, (req, res, next) => { router.get('/admin', mw.adminLogin, (req, res, next) => {
console.log('yo');
return vitreumRender('admin', templateFn, { return vitreumRender('admin', templateFn, {
url : req.originalUrl, url : req.originalUrl,
admin_key : config.get('admin:key') admin_key : config.get('admin:key')
@@ -30,4 +29,26 @@ router.delete('/admin/invalid', mw.adminOnly, (req, res, next)=>{
.catch(next); .catch(next);
}); });
router.get('/admin/lookup/:search', (req, res) => {
//search for mathcing edit id
//search for matching share id
// search for partial match
BrewData.get({editId : req.params.search})
.then((brew) => {
})
BrewData.get({ $or:[
{editId : { "$regex": req.params.search, "$options": "i" }},
{shareId : { "$regex": req.params.search, "$options": "i" }},
]})
.then((brews) => {
console.log(brews);
return res.json(brews);
})
})
module.exports = router; module.exports = router;