mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-29 15:32:40 +00:00
Finished the clean up brew ui
This commit is contained in:
@@ -8,9 +8,7 @@ const Stats = require('./stats/stats.jsx');
|
||||
|
||||
const Admin = createClass({
|
||||
getDefaultProps : function() {
|
||||
return {
|
||||
adminKey : ''
|
||||
};
|
||||
return {};
|
||||
},
|
||||
|
||||
render : function(){
|
||||
@@ -23,11 +21,11 @@ const Admin = createClass({
|
||||
</div>
|
||||
</header>
|
||||
<div className='container'>
|
||||
<Stats adminKey={this.props.adminKey} />
|
||||
<Stats />
|
||||
<hr />
|
||||
<BrewLookup adminKey={this.props.adminKey} />
|
||||
<BrewLookup />
|
||||
<hr />
|
||||
<BrewCleanup adminKey={this.props.adminKey} />
|
||||
<BrewCleanup />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -36,60 +36,9 @@ body{
|
||||
}
|
||||
}
|
||||
|
||||
hr{
|
||||
margin : 30px 0px;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*.homebrewAdmin{
|
||||
margin-bottom: 80px;
|
||||
.brewTable{
|
||||
table{
|
||||
|
||||
th{
|
||||
padding : 10px;
|
||||
font-weight : 800;
|
||||
}
|
||||
tr:nth-child(even){
|
||||
background-color : fade(@green, 10%);
|
||||
}
|
||||
tr.isEmpty{
|
||||
background-color : fade(@red, 30%);
|
||||
}
|
||||
td{
|
||||
min-width : 100px;
|
||||
padding : 10px;
|
||||
text-align : center;
|
||||
|
||||
&.preview{
|
||||
position : relative;
|
||||
&:hover{
|
||||
.content{
|
||||
display : block;
|
||||
}
|
||||
}
|
||||
.content{
|
||||
position : absolute;
|
||||
display : none;
|
||||
top : 100%;
|
||||
left : 0px;
|
||||
z-index : 1000;
|
||||
max-height : 500px;
|
||||
width : 300px;
|
||||
padding : 30px;
|
||||
background-color : white;
|
||||
font-family : monospace;
|
||||
text-align : left;
|
||||
pointer-events : none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.deleteButton{
|
||||
cursor: pointer;
|
||||
}
|
||||
button.clearOldButton{
|
||||
float : right;
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -8,25 +8,22 @@ const request = require('superagent');
|
||||
const BrewCleanup = createClass({
|
||||
displayName : 'BrewCleanup',
|
||||
getDefaultProps(){
|
||||
return {
|
||||
adminKey : '',
|
||||
};
|
||||
return {};
|
||||
},
|
||||
getInitialState() {
|
||||
return {
|
||||
count : 0,
|
||||
|
||||
pending : false,
|
||||
primed : false
|
||||
primed : false,
|
||||
err : null
|
||||
};
|
||||
},
|
||||
prime(){
|
||||
if(this.state.primed) return this.cleanup();
|
||||
this.setState({ pending: true });
|
||||
|
||||
request.get('/admin/cleanup')
|
||||
.query({ admin_key: this.props.adminKey })
|
||||
.then((res)=> this.setState({count : res.body.count }))
|
||||
.then((res)=> this.setState({count : res.body.count, primed : true }))
|
||||
.catch((err)=>this.setState({ error : err }))
|
||||
.finally(()=>this.setState({ pending : false }))
|
||||
},
|
||||
@@ -34,14 +31,42 @@ const BrewCleanup = createClass({
|
||||
this.setState({ pending: true });
|
||||
|
||||
request.post('/admin/cleanup')
|
||||
.query({ admin_key: this.props.adminKey })
|
||||
.then((res)=> this.setState({count : res.body.count }))
|
||||
.catch((err)=>this.setState({ error : err }))
|
||||
.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'>
|
||||
<button onClick={this.cleanup} className='remove'>
|
||||
{this.state.pending
|
||||
? <i className='fa fa-spin fa-spinner' />
|
||||
: <span><i className='fa fa-times' /> Remove</span>
|
||||
}
|
||||
</button>
|
||||
<span>Found {this.state.count} Brews that could be removed. </span>
|
||||
</div>
|
||||
},
|
||||
render(){
|
||||
return <div className='BrewCleanup'>
|
||||
BrewCleanup Component Ready.
|
||||
<h2> Brew Cleanup </h2>
|
||||
<p>Removes very short brews to tidy up the database</p>
|
||||
|
||||
<button onClick={this.prime} className='query'>
|
||||
{this.state.pending
|
||||
? <i className='fa fa-spin fa-spinner' />
|
||||
: 'Query Brews'
|
||||
}
|
||||
</button>
|
||||
{this.renderPrimed()}
|
||||
|
||||
{this.state.error
|
||||
&& <div className='error'>{this.state.error.toString()}</div>
|
||||
}
|
||||
</div>;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
.BrewCleanup{
|
||||
.removeBox{
|
||||
margin-top: 20px;
|
||||
button{
|
||||
background-color: @red;
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,9 +8,7 @@ const Moment = require('moment');
|
||||
|
||||
const BrewLookup = createClass({
|
||||
getDefaultProps() {
|
||||
return {
|
||||
adminKey : '',
|
||||
};
|
||||
return {};
|
||||
},
|
||||
getInitialState() {
|
||||
return {
|
||||
@@ -27,7 +25,6 @@ const BrewLookup = createClass({
|
||||
this.setState({ searching: true, error: null });
|
||||
|
||||
request.get(`/admin/lookup/${this.state.query}`)
|
||||
//.query({ admin_key: this.props.adminKey })
|
||||
.then((res)=> this.setState({foundBrew : res.body}))
|
||||
.catch((err)=>this.setState({ error : err }))
|
||||
.finally(()=>this.setState({ searching : false }))
|
||||
|
||||
@@ -8,9 +8,7 @@ const request = require('superagent');
|
||||
const Stats = createClass({
|
||||
displayName : 'Stats',
|
||||
getDefaultProps(){
|
||||
return {
|
||||
adminKey : ''
|
||||
};
|
||||
return {};
|
||||
},
|
||||
getInitialState(){
|
||||
return {
|
||||
@@ -26,7 +24,6 @@ const Stats = createClass({
|
||||
fetchStats(){
|
||||
this.setState({ fetching : true})
|
||||
request.get('/admin/stats')
|
||||
.query({ admin_key : this.props.adminKey })
|
||||
.then((res)=> this.setState({ stats : res.body }))
|
||||
.finally(()=>this.setState({fetching : false}));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user