mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-03 21:22:39 +00:00
Add UI to Admin page
This commit is contained in:
@@ -12,17 +12,18 @@ const BrewLookup = createClass({
|
|||||||
},
|
},
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {
|
return {
|
||||||
query : '',
|
query : '',
|
||||||
foundBrew : null,
|
foundBrew : null,
|
||||||
searching : false,
|
searching : false,
|
||||||
error : null
|
error : null,
|
||||||
|
checkForScript : false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
handleChange(e){
|
handleChange(e){
|
||||||
this.setState({ query: e.target.value });
|
this.setState({ query: e.target.value });
|
||||||
},
|
},
|
||||||
lookup(){
|
lookup(){
|
||||||
this.setState({ searching: true, error: null });
|
this.setState({ searching: true, error: null, checkForScript: false });
|
||||||
|
|
||||||
request.get(`/admin/lookup/${this.state.query}`)
|
request.get(`/admin/lookup/${this.state.query}`)
|
||||||
.then((res)=>this.setState({ foundBrew: res.body }))
|
.then((res)=>this.setState({ foundBrew: res.body }))
|
||||||
@@ -30,6 +31,23 @@ const BrewLookup = createClass({
|
|||||||
.finally(()=>this.setState({ searching: false }));
|
.finally(()=>this.setState({ searching: false }));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
checkForScript(){
|
||||||
|
const brew = this.state.foundBrew;
|
||||||
|
const scriptCheck = brew.text.match(/(<\/?s)cript/);
|
||||||
|
this.setState({
|
||||||
|
checkForScript : !!scriptCheck
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
cleanScript(){
|
||||||
|
if(!this.state.foundBrew?.shareId) return;
|
||||||
|
|
||||||
|
request.put(`/admin/clean/script/${this.state.foundBrew.shareId}`)
|
||||||
|
.then((res)=>this.setState({ foundBrew: res.body }))
|
||||||
|
.catch((err)=>this.setState({ error: err }))
|
||||||
|
.finally(()=>this.setState({ checkForScript: false }));
|
||||||
|
},
|
||||||
|
|
||||||
renderFoundBrew(){
|
renderFoundBrew(){
|
||||||
const brew = this.state.foundBrew;
|
const brew = this.state.foundBrew;
|
||||||
return <div className='foundBrew'>
|
return <div className='foundBrew'>
|
||||||
@@ -52,6 +70,8 @@ const BrewLookup = createClass({
|
|||||||
<dt>Num of Views</dt>
|
<dt>Num of Views</dt>
|
||||||
<dd>{brew.views}</dd>
|
<dd>{brew.views}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
<button onClick={this.checkForScript}>Scan for SCRIPTs</button>
|
||||||
|
{this.state.checkForScript && <button onClick={this.cleanScript}>CLEAN BREW</button>}
|
||||||
</div>;
|
</div>;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user