0
0
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:
Scott Tolksdorf
2018-12-04 13:37:03 -05:00
parent 1184fe86a5
commit 52c0462a4f
7 changed files with 52 additions and 91 deletions

View File

@@ -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>
}

View File

@@ -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;
}
}
*/

View File

@@ -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>;
}
});

View File

@@ -1,3 +1,10 @@
.BrewCleanup{
.removeBox{
margin-top: 20px;
button{
background-color: @red;
margin-right: 10px;
}
}
}

View File

@@ -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 }))

View File

@@ -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}));
},