Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added clear history button to history page #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/routes/bins.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ var Bins = function (dsn_str) {

router.get('/:uuid/log', mw.errorHandler, mw.bodyParser, this.routes.log.bind(this), mw.cors, mw.negotiateContent)

router.post('/:uuid/log/clear', mw.errorHandler, mw.bodyParser, this.routes.clear_log.bind(this), mw.cors, mw.negotiateContent)

router.all('/:uuid*', mw.errorHandler, mw.bodyParser, this.routes.send.bind(this), mw.cors, mw.negotiateContent)

return router
Expand Down Expand Up @@ -241,6 +243,20 @@ Bins.prototype.routes = {
})
}

next()
})
},

clear_log: function (req, res, next) {
this.client.del('log:' + req.params.uuid, function (err, history) {
if (err) {
debug(err)

throw err
}

res.view = 'redirect'
res.status(200).location(util.format('/bin/%s', req.params.uuid))
next()
})
}
Expand Down
4 changes: 4 additions & 0 deletions src/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ div[data-page="bin/log"] h3 {
margin-top: 0;
}

div[data-page="bin/log"] h3 label {
margin-left: 1em;
}

div[data-page="bin/log"] pre {
height: 500px;

Expand Down
14 changes: 13 additions & 1 deletion src/views/bin/log.jade
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ block content
div.btn-group.pull-right.hidden-xs
a(href= '/bin/' + req.params.uuid + '/view').btn.btn-primary View Details

h3 Bin History: #[code= req.params.uuid]
h3
| Bin History: #[code= req.params.uuid]
label(for='clear_log').btn.btn-xs.btn-default
span.glyphicon.glyphicon-trash
| Clear History
form(method="POST", action='/bin/' + req.params.uuid + '/log/clear').hidden
button(type='submit', id='clear_log').btn.btn-xs

div.visible-xs
a(href= '/bin/' + req.params.uuid + '/view').btn.btn-block.btn-primary View Details
Expand Down Expand Up @@ -68,6 +74,12 @@ block content
block scripts
script.
$(function() {
$('#clear_log').click(function (e) {
if (!confirm('Are you sure you want to clear the log?')) {
e.preventDefault();
}
});

$('tr[data-id] td, button[data-id]').on('click', function (e) {
var id = $(this).data('id')

Expand Down