mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Delete all log files button
This commit is contained in:
parent
c5d69ac61b
commit
203e8a7484
12
lib/logs.js
12
lib/logs.js
@ -46,6 +46,18 @@ Logs.prototype.delete = function (filename, callback) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logs.prototype.deleteAll = function (callback) {
|
||||||
|
this.logFiles(function (err, files) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
async.map(files, function (logFile, cb) {
|
||||||
|
fs.unlink(logFile.path, cb)
|
||||||
|
}, callback)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
Logs.prototype.generateLogFilePath = function (prefix, suffix) {
|
Logs.prototype.generateLogFilePath = function (prefix, suffix) {
|
||||||
return path.join(this.logsPath(), Logs.generateLogFileName(prefix, suffix))
|
return path.join(this.logsPath(), Logs.generateLogFileName(prefix, suffix))
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
var $ = require('jquery')
|
||||||
var _ = require('underscore')
|
var _ = require('underscore')
|
||||||
var Marionette = require('marionette')
|
var Marionette = require('marionette')
|
||||||
|
var sweetAlert = require('sweet-alert')
|
||||||
|
|
||||||
var ListItemView = require('app/views/logs/list_item')
|
var ListItemView = require('app/views/logs/list_item')
|
||||||
var tpl = require('tpl/logs/list.html')
|
var tpl = require('tpl/logs/list.html')
|
||||||
@ -9,5 +11,31 @@ var template = _.template(tpl)
|
|||||||
module.exports = Marionette.CompositeView.extend({
|
module.exports = Marionette.CompositeView.extend({
|
||||||
childView: ListItemView,
|
childView: ListItemView,
|
||||||
childViewContainer: 'tbody',
|
childViewContainer: 'tbody',
|
||||||
template: template
|
template: template,
|
||||||
|
|
||||||
|
events: {
|
||||||
|
'click .delete-all': 'deleteAll'
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteAll: function (event) {
|
||||||
|
var self = this
|
||||||
|
|
||||||
|
sweetAlert({
|
||||||
|
title: 'Are you sure?',
|
||||||
|
text: 'All logs will be deleted from the server!',
|
||||||
|
type: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonClass: 'btn-danger',
|
||||||
|
confirmButtonText: 'Yes, delete all!'
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
$.ajax('/api/logs/all', {
|
||||||
|
type: 'DELETE',
|
||||||
|
success: function (data) {
|
||||||
|
self.collection.fetch()
|
||||||
|
},
|
||||||
|
error: function () {}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
@ -5,8 +5,12 @@
|
|||||||
<th class="hidden-xs hidden-sm">Created</th>
|
<th class="hidden-xs hidden-sm">Created</th>
|
||||||
<th class="hidden-xs hidden-sm">Modified</th>
|
<th class="hidden-xs hidden-sm">Modified</th>
|
||||||
<th>Size</th>
|
<th>Size</th>
|
||||||
<th></th>
|
<th colspan="2">
|
||||||
<th></th>
|
<a class="btn btn-danger btn-xs delete-all ladda-button pull-right" data-style="expand-left">
|
||||||
|
<span class="glyphicon glyphicon-trash"></span>
|
||||||
|
Delete all
|
||||||
|
</a>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
|
@ -13,6 +13,16 @@ module.exports = function (logsManager) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.delete('/all', function (req, res) {
|
||||||
|
logsManager.deleteAll(function (err) {
|
||||||
|
if (err) {
|
||||||
|
res.status(500).send(err)
|
||||||
|
} else {
|
||||||
|
res.status(204).send()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
router.delete('/:log', function (req, res) {
|
router.delete('/:log', function (req, res) {
|
||||||
var filename = req.params.log
|
var filename = req.params.log
|
||||||
logsManager.delete(filename, function (err) {
|
logsManager.delete(filename, function (err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user