mirror of
https://github.com/stolksdorf/homebrewery.git
synced 2025-12-21 00:41:30 +00:00
trying to improve the admin view
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
## changelog
|
## changelog
|
||||||
|
|
||||||
#### Tuesday, 16/02/2016
|
#### Tuesday, 16/02/2016, `v2.0.0`
|
||||||
* Paragraphs right after tables now indent (thanks LikeAJi6!)
|
* Paragraphs right after tables now indent (thanks LikeAJi6!)
|
||||||
|
* Added a `@page` css rule to auto turn off margins when printing
|
||||||
|
* Added a `page-break` property on each `.phb` page to properly page the pages up when exporting (thanks Jokefury!)
|
||||||
|
|
||||||
|
|
||||||
#### Sunday, 17/01/2016
|
#### Sunday, 17/01/2016
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ var React = require('react');
|
|||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
var cx = require('classnames');
|
var cx = require('classnames');
|
||||||
|
|
||||||
var Moment = require('moment')
|
var Moment = require('moment');
|
||||||
|
|
||||||
|
var VIEW_LIMIT = 30;
|
||||||
|
var COLUMN_HEIGHT = 52;
|
||||||
|
|
||||||
var HomebrewAdmin = React.createClass({
|
var HomebrewAdmin = React.createClass({
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
homebrews : [],
|
homebrews : [],
|
||||||
@@ -13,27 +15,29 @@ var HomebrewAdmin = React.createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return {
|
||||||
|
viewStartIndex: 0
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
renderBrews : function(){
|
renderBrews : function(){
|
||||||
return _.map(this.props.homebrews, (brew)=>{
|
return _.times(VIEW_LIMIT, (i)=>{
|
||||||
|
var brew = this.props.homebrews[i + this.state.viewStartIndex];
|
||||||
|
if(!brew) return null;
|
||||||
|
|
||||||
return <tr className={cx('brewRow', {'isEmpty' : brew.text == ""})} key={brew.sharedId}>
|
return <tr className={cx('brewRow', {'isEmpty' : brew.text == ""})} key={brew.sharedId}>
|
||||||
|
|
||||||
<td>{brew.editId}</td>
|
<td><a href={'/homebrew/edit/' + brew.editId} target='_blank'>{brew.editId}</a></td>
|
||||||
<td>{brew.shareId}</td>
|
<td><a href={'/homebrew/share/' + brew.shareId} target='_blank'>{brew.shareId}</a></td>
|
||||||
<td>{Moment(brew.createdAt).fromNow()}</td>
|
<td>{Moment(brew.createdAt).fromNow()}</td>
|
||||||
<td>{Moment(brew.updatedAt).fromNow()}</td>
|
<td>{Moment(brew.updatedAt).fromNow()}</td>
|
||||||
<td>{Moment(brew.lastViewed).fromNow()}</td>
|
<td>{Moment(brew.lastViewed).fromNow()}</td>
|
||||||
<td>{brew.views}</td>
|
<td>{brew.views}</td>
|
||||||
|
|
||||||
<td className='preview'>
|
|
||||||
<a target="_blank" href={'/homebrew/share/' + brew.shareId}>view</a>
|
|
||||||
<div className='content'>
|
|
||||||
{brew.text.slice(0, 500)}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><a href={'/homebrew/remove/' + brew.editId +'?admin_key=' + this.props.admin_key}><i className='fa fa-trash' /></a></td>
|
<td><a href={'/homebrew/remove/' + brew.editId +'?admin_key=' + this.props.admin_key}><i className='fa fa-trash' /></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
});
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
@@ -41,6 +45,7 @@ var HomebrewAdmin = React.createClass({
|
|||||||
return(
|
return(
|
||||||
<div className='homebrewAdmin'>
|
<div className='homebrewAdmin'>
|
||||||
<h2>Homebrews - {this.props.homebrews.length}</h2>
|
<h2>Homebrews - {this.props.homebrews.length}</h2>
|
||||||
|
<div className='brewTable'>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -50,7 +55,6 @@ var HomebrewAdmin = React.createClass({
|
|||||||
<th>Last Updated</th>
|
<th>Last Updated</th>
|
||||||
<th>Last Viewed</th>
|
<th>Last Viewed</th>
|
||||||
<th>Number of Views</th>
|
<th>Number of Views</th>
|
||||||
<th>Preview</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -58,6 +62,7 @@ var HomebrewAdmin = React.createClass({
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
|
||||||
.homebrewAdmin{
|
.homebrewAdmin{
|
||||||
table{
|
.brewTable{
|
||||||
overflow-y : scroll;
|
overflow-y : scroll;
|
||||||
max-height : 800px;
|
max-height : 500px;
|
||||||
|
table{
|
||||||
|
|
||||||
th{
|
th{
|
||||||
padding : 10px;
|
padding : 10px;
|
||||||
font-weight : 800;
|
font-weight : 800;
|
||||||
@@ -42,3 +44,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -9,9 +9,7 @@
|
|||||||
@horizontalRule : #9c2b1b;
|
@horizontalRule : #9c2b1b;
|
||||||
@headerText : #58180D;
|
@headerText : #58180D;
|
||||||
@monsterStatBackground : #FDF1DC;
|
@monsterStatBackground : #FDF1DC;
|
||||||
|
|
||||||
@page { margin: 0; }
|
@page { margin: 0; }
|
||||||
|
|
||||||
.useSansSerif(){
|
.useSansSerif(){
|
||||||
font-family : ScalySans;
|
font-family : ScalySans;
|
||||||
em{
|
em{
|
||||||
@@ -51,6 +49,8 @@
|
|||||||
font-family : BookSanity;
|
font-family : BookSanity;
|
||||||
font-size : 9pt;
|
font-size : 9pt;
|
||||||
text-rendering : optimizeLegibility;
|
text-rendering : optimizeLegibility;
|
||||||
|
page-break-before : always;
|
||||||
|
page-break-after : always;
|
||||||
//*****************************
|
//*****************************
|
||||||
// * BASE
|
// * BASE
|
||||||
// *****************************/
|
// *****************************/
|
||||||
@@ -69,9 +69,9 @@
|
|||||||
list-style-type : disc;
|
list-style-type : disc;
|
||||||
}
|
}
|
||||||
ol{
|
ol{
|
||||||
list-style-position: inside;
|
|
||||||
margin-bottom : 0.8em;
|
margin-bottom : 0.8em;
|
||||||
line-height : 1.3em;
|
line-height : 1.3em;
|
||||||
|
list-style-position : inside;
|
||||||
list-style-type : decimal;
|
list-style-type : decimal;
|
||||||
}
|
}
|
||||||
img{
|
img{
|
||||||
@@ -102,9 +102,9 @@
|
|||||||
&+p::first-letter{
|
&+p::first-letter{
|
||||||
float : left;
|
float : left;
|
||||||
font-family : Solberry;
|
font-family : Solberry;
|
||||||
line-height: 0.8em;
|
|
||||||
font-size : 10em;
|
font-size : 10em;
|
||||||
color : #222;
|
color : #222;
|
||||||
|
line-height : 0.8em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h2{
|
h2{
|
||||||
|
|||||||
@@ -199,6 +199,8 @@ table {
|
|||||||
font-family: BookSanity;
|
font-family: BookSanity;
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
|
page-break-before: always;
|
||||||
|
page-break-after: always;
|
||||||
}
|
}
|
||||||
.phb p {
|
.phb p {
|
||||||
padding-bottom: 0.8em;
|
padding-bottom: 0.8em;
|
||||||
|
|||||||
@@ -57,6 +57,28 @@ module.exports = function(app){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/homebrew/clear', function(req, res){
|
||||||
|
//if(req.query && req.query.admin_key == process.env.ADMIN_KEY){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HomebrewModel.find({text : ''}, function(err, objs){
|
||||||
|
|
||||||
|
return res.json(objs);
|
||||||
|
|
||||||
|
|
||||||
|
if(!objs.length || err) return res.status(404).send("Can not find homebrew with that id");
|
||||||
|
var resEntry = objs[0];
|
||||||
|
resEntry.remove(function(err){
|
||||||
|
if(err) return res.status(500).send("Error while removing");
|
||||||
|
return res.status(200).send();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
//}else{
|
||||||
|
// return res.status(401).send('Access denied');
|
||||||
|
//}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//Edit Page
|
//Edit Page
|
||||||
app.get('/homebrew/edit/:id', function(req, res){
|
app.get('/homebrew/edit/:id', function(req, res){
|
||||||
|
|||||||
Reference in New Issue
Block a user