mirror of
https://github.com/stolksdorf/homebrewery.git
synced 2025-12-16 07:55:57 +00:00
admin panel should be good
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
var React = require('react');
|
||||
var _ = require('lodash');
|
||||
var cx = require('classnames');
|
||||
var request = require('superagent');
|
||||
|
||||
var Moment = require('moment');
|
||||
|
||||
|
||||
//TODO: Add incremental React scrolling
|
||||
var VIEW_LIMIT = 30;
|
||||
var COLUMN_HEIGHT = 52;
|
||||
|
||||
@@ -21,49 +24,64 @@ var HomebrewAdmin = React.createClass({
|
||||
};
|
||||
},
|
||||
|
||||
deleteBrew : function(brewId){
|
||||
console.log('removing');
|
||||
request.get('/homebrew/remove/' + brewId +'?admin_key=' + this.props.admin_key)
|
||||
.send()
|
||||
.end(function(err, res){
|
||||
console.log('DONE');
|
||||
window.location.reload();
|
||||
})
|
||||
},
|
||||
|
||||
renderBrews : function(){
|
||||
return _.times(VIEW_LIMIT, (i)=>{
|
||||
var brew = this.props.homebrews[i + this.state.viewStartIndex];
|
||||
if(!brew) return null;
|
||||
// return _.times(VIEW_LIMIT, (i)=>{
|
||||
// var brew = this.props.homebrews[i + this.state.viewStartIndex];
|
||||
// if(!brew) return null;
|
||||
|
||||
return _.map(this.props.homebrews, (brew)=>{
|
||||
return <tr className={cx('brewRow', {'isEmpty' : brew.text == ""})} key={brew.sharedId}>
|
||||
|
||||
<td><a href={'/homebrew/edit/' + brew.editId} target='_blank'>{brew.editId}</a></td>
|
||||
<td><a href={'/homebrew/share/' + brew.shareId} target='_blank'>{brew.shareId}</a></td>
|
||||
<td>{Moment(brew.createdAt).fromNow()}</td>
|
||||
<td>{Moment(brew.updatedAt).fromNow()}</td>
|
||||
<td>{Moment(brew.lastViewed).fromNow()}</td>
|
||||
<td>{brew.views}</td>
|
||||
|
||||
<td><a href={'/homebrew/remove/' + brew.editId +'?admin_key=' + this.props.admin_key}><i className='fa fa-trash' /></a></td>
|
||||
<td>
|
||||
<div className='deleteButton' onClick={this.deleteBrew.bind(this, brew.editId)}>
|
||||
<i className='fa fa-trash' />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
});
|
||||
},
|
||||
|
||||
renderBrewTable : function(){
|
||||
return <div className='brewTable'>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Edit Id</th>
|
||||
<th>Share Id</th>
|
||||
<th>Created At</th>
|
||||
<th>Last Updated</th>
|
||||
<th>Last Viewed</th>
|
||||
<th>Number of Views</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{this.renderBrews()}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
},
|
||||
|
||||
render : function(){
|
||||
var self = this;
|
||||
return(
|
||||
<div className='homebrewAdmin'>
|
||||
<h2>Homebrews - {this.props.homebrews.length}</h2>
|
||||
<div className='brewTable'>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Edit Id</th>
|
||||
<th>Share Id</th>
|
||||
<th>Created At</th>
|
||||
<th>Last Updated</th>
|
||||
<th>Last Viewed</th>
|
||||
<th>Number of Views</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{this.renderBrews()}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
return <div className='homebrewAdmin'>
|
||||
<h2>Homebrews - {this.props.homebrews.length}</h2>
|
||||
{this.renderBrewTable()}
|
||||
</div>
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user