diff --git a/client/admin/homebrewAdmin/homebrewAdmin.jsx b/client/admin/homebrewAdmin/homebrewAdmin.jsx index 26b686f..2362f2d 100644 --- a/client/admin/homebrewAdmin/homebrewAdmin.jsx +++ b/client/admin/homebrewAdmin/homebrewAdmin.jsx @@ -25,11 +25,9 @@ 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(); }) }, diff --git a/client/homebrew/statusbar/statusbar.jsx b/client/homebrew/statusbar/statusbar.jsx index c273d3b..bd0c760 100644 --- a/client/homebrew/statusbar/statusbar.jsx +++ b/client/homebrew/statusbar/statusbar.jsx @@ -2,6 +2,7 @@ var React = require('react'); var _ = require('lodash'); var cx = require('classnames'); var Moment = require('moment'); +var request = require('superagent') var Logo = require('naturalCrit/logo/logo.jsx'); @@ -13,7 +14,7 @@ var Statusbar = React.createClass({ getDefaultProps: function() { return { - //editId: null, + editId: null, sourceText : null, shareId : null, printId : null, @@ -38,14 +39,22 @@ var Statusbar = React.createClass({ }, + deleteBrew : function(){ + if(!confirm("are you sure you want to delete this brew?")) return; + if(!confirm("are you REALLY sure? You will not be able to recover it")) return; + + request.get('/homebrew/remove/' + this.props.editId) + .send() + .end(function(err, res){ + window.location.href = '/homebrew'; + }); + }, + + openSourceWindow : function(){ var sourceWindow = window.open(); - var content = replaceAll(this.props.sourceText, '<', '<'); content = replaceAll(content, '>', '>'); - - console.log(content); - sourceWindow.document.write('
' + content + '
'); }, @@ -97,6 +106,15 @@ var Statusbar = React.createClass({ }, + renderDeleteButton : function(){ + if(!this.props.editId) return null; + + + return
+ Delete +
+ }, + renderStatus : function(){ if(!this.props.editId) return null; @@ -123,6 +141,7 @@ var Statusbar = React.createClass({ {this.renderStatus()} {this.renderInfo()} {this.renderSourceButton()} + {this.renderDeleteButton()} {this.renderPrintButton()} {this.renderShare()} {this.renderNewButton()} diff --git a/client/homebrew/statusbar/statusbar.less b/client/homebrew/statusbar/statusbar.less index 92b27b6..b3c2bb4 100644 --- a/client/homebrew/statusbar/statusbar.less +++ b/client/homebrew/statusbar/statusbar.less @@ -58,6 +58,15 @@ background-color : fade(@green, 70%); } } + .deleteButton{ + .animate(background-color); + color : white; + text-decoration : none; + cursor: pointer; + &:hover{ + background-color : fade(@red, 70%); + } + } .shareField{ .animate(background-color); cursor : pointer; diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 9088101..f6bb518 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -43,7 +43,7 @@ module.exports = function(app){ }); app.get('/homebrew/remove/:id', function(req, res){ - if(req.query && req.query.admin_key == process.env.ADMIN_KEY){ + //if(req.query && req.query.admin_key == process.env.ADMIN_KEY){ HomebrewModel.find({editId : req.params.id}, function(err, objs){ console.log(err); if(!objs.length || err) return res.status(404).send("Can not find homebrew with that id"); @@ -53,9 +53,9 @@ module.exports = function(app){ return res.status(200).send(); }) }); - }else{ - return res.status(401).send('Access denied'); - } + //}else{ + // return res.status(401).send('Access denied'); + //} }); app.get('/homebrew/clear', function(req, res){