diff --git a/src/routes/bins.js b/src/routes/bins.js index 621431bf..2541afb1 100644 --- a/src/routes/bins.js +++ b/src/routes/bins.js @@ -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 @@ -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() }) } diff --git a/src/static/main.css b/src/static/main.css index 826e8e8b..ef0477bc 100644 --- a/src/static/main.css +++ b/src/static/main.css @@ -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; diff --git a/src/views/bin/log.jade b/src/views/bin/log.jade index a6eb5743..41b1188b 100644 --- a/src/views/bin/log.jade +++ b/src/views/bin/log.jade @@ -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 @@ -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')