mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 20:23:39 +00:00
Load lock details to the Lock Brew form
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/
|
/*eslint max-lines: ["warn", {"max": 500, "skipBlankLines": true, "skipComments": true}]*/
|
||||||
require('./lockTools.less');
|
require('./lockTools.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
|
|
||||||
// const request = require('superagent');
|
|
||||||
import request from '../../homebrew/utils/request-middleware.js';
|
import request from '../../homebrew/utils/request-middleware.js';
|
||||||
|
|
||||||
const LockTools = createClass({
|
const LockTools = createClass({
|
||||||
@@ -29,17 +28,23 @@ const LockTools = createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateLockData : function(lock){
|
||||||
|
this.setState({
|
||||||
|
lock : lock
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
render : function() {
|
render : function() {
|
||||||
return <div className='lockTools'>
|
return <div className='lockTools'>
|
||||||
<h2>Lock Count</h2>
|
<h2>Lock Count</h2>
|
||||||
<p>Number of brews currently locked: {this.state.reviewCount}</p>
|
<p>Number of brews currently locked: {this.state.reviewCount}</p>
|
||||||
<button onClick={this.updateReviewCount}>REFRESH</button>
|
<button onClick={this.updateReviewCount}>REFRESH</button>
|
||||||
<hr />
|
<hr />
|
||||||
<LockTable title='Locked Brews' text='Total Locked Brews' resultName='lockedDocuments' fetchURL='/api/locks' propertyNames={['shareId', 'title']} ></LockTable>
|
<LockTable title='Locked Brews' text='Total Locked Brews' resultName='lockedDocuments' fetchURL='/api/locks' propertyNames={['shareId', 'title']} loadBrew={this.updateLockData} ></LockTable>
|
||||||
<hr />
|
<hr />
|
||||||
<LockTable title='Brews Awaiting Review' text='Total Reviews Waiting' resultName='reviewDocuments' fetchURL='/api/lock/reviews' propertyNames={['shareId', 'title']} ></LockTable>
|
<LockTable title='Brews Awaiting Review' text='Total Reviews Waiting' resultName='reviewDocuments' fetchURL='/api/lock/reviews' propertyNames={['shareId', 'title']} loadBrew={this.updateLockData} ></LockTable>
|
||||||
<hr />
|
<hr />
|
||||||
<LockBrew></LockBrew>
|
<LockBrew key={this.state.lock?.key || 0} lock={this.state.lock}></LockBrew>
|
||||||
<hr />
|
<hr />
|
||||||
<div style={{ columns: 2 }}>
|
<div style={{ columns: 2 }}>
|
||||||
<LockLookup title='Unlock Brew' fetchURL='/api/unlock' updateFn={this.updateReviewCount}></LockLookup>
|
<LockLookup title='Unlock Brew' fetchURL='/api/unlock' updateFn={this.updateReviewCount}></LockLookup>
|
||||||
@@ -55,12 +60,12 @@ const LockBrew = createClass({
|
|||||||
getInitialState : function() {
|
getInitialState : function() {
|
||||||
// Default values
|
// Default values
|
||||||
return {
|
return {
|
||||||
brewId : '',
|
brewId : this.props.lock?.shareId || '',
|
||||||
code : 455,
|
code : this.props.lock?.code || 455,
|
||||||
editMessage : '',
|
editMessage : this.props.lock?.editMessage || '',
|
||||||
shareMessage : 'This Brew has been locked.',
|
shareMessage : this.props.lock?.shareMessage || 'This Brew has been locked.',
|
||||||
result : {},
|
result : {},
|
||||||
overwrite : false
|
overwrite : false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -186,7 +191,8 @@ const LockTable = createClass({
|
|||||||
text : '',
|
text : '',
|
||||||
fetchURL : '/api/locks',
|
fetchURL : '/api/locks',
|
||||||
resultName : '',
|
resultName : '',
|
||||||
propertyNames : ['shareId']
|
propertyNames : ['shareId'],
|
||||||
|
loadBrew : ()=>{}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -198,7 +204,9 @@ const LockTable = createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
clickFn(){
|
lockKey : React.createRef(0),
|
||||||
|
|
||||||
|
clickFn : function (){
|
||||||
this.setState({ searching: true, error: null });
|
this.setState({ searching: true, error: null });
|
||||||
|
|
||||||
request.get(this.props.fetchURL)
|
request.get(this.props.fetchURL)
|
||||||
@@ -209,6 +217,18 @@ const LockTable = createClass({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateBrewLockData : function (lockData){
|
||||||
|
this.lockKey.current++;
|
||||||
|
const brewData = {
|
||||||
|
key : this.lockKey.current,
|
||||||
|
shareId : lockData.shareId,
|
||||||
|
code : lockData.lock.code,
|
||||||
|
editMessage : lockData.lock.editMessage,
|
||||||
|
shareMessage : lockData.lock.shareMessage
|
||||||
|
};
|
||||||
|
this.props.loadBrew(brewData);
|
||||||
|
},
|
||||||
|
|
||||||
render : function () {
|
render : function () {
|
||||||
return <>
|
return <>
|
||||||
<div className='brewsAwaitingReview'>
|
<div className='brewsAwaitingReview'>
|
||||||
@@ -229,7 +249,7 @@ const LockTable = createClass({
|
|||||||
return <th key={idx}>{name}</th>;
|
return <th key={idx}>{name}</th>;
|
||||||
})}
|
})}
|
||||||
<th>clip</th>
|
<th>clip</th>
|
||||||
<th>view</th>
|
<th>load</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -240,8 +260,8 @@ const LockTable = createClass({
|
|||||||
{result[name].toString()}
|
{result[name].toString()}
|
||||||
</td>;
|
</td>;
|
||||||
})}
|
})}
|
||||||
<td className='icon' onClick={()=>{navigator.clipboard.writeText(result.shareId.toString());}}><i className='fa-regular fa-clipboard'></i></td>
|
<td className='icon' title='Copy ID to Clipboard' onClick={()=>{navigator.clipboard.writeText(result.shareId.toString());}}><i className='fa-regular fa-clipboard'></i></td>
|
||||||
<td className='icon'><a href={`/share/${result.shareId.toString()}`} target='_blank'><i className='fa-regular fa-circle-right'></i></a></td>
|
<td className='icon' title='View Lock details' onClick={()=>{this.updateBrewLockData(result);}}><i className='fa-regular fa-circle-down'></i></td>
|
||||||
</tr>;
|
</tr>;
|
||||||
})}
|
})}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user