File tree Expand file tree Collapse file tree 4 files changed +57
-3
lines changed
Expand file tree Collapse file tree 4 files changed +57
-3
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,18 @@ Logs.prototype.delete = function (filename, callback) {
4646 } )
4747}
4848
49+ Logs . prototype . deleteAll = function ( callback ) {
50+ this . logFiles ( function ( err , files ) {
51+ if ( err ) {
52+ return callback ( err )
53+ }
54+
55+ async . map ( files , function ( logFile , cb ) {
56+ fs . unlink ( logFile . path , cb )
57+ } , callback )
58+ } )
59+ }
60+
4961Logs . prototype . generateLogFilePath = function ( prefix , suffix ) {
5062 return path . join ( this . logsPath ( ) , Logs . generateLogFileName ( prefix , suffix ) )
5163}
Original file line number Diff line number Diff line change 1+ var $ = require ( 'jquery' )
12var _ = require ( 'underscore' )
23var Marionette = require ( 'marionette' )
4+ var sweetAlert = require ( 'sweet-alert' )
35
46var ListItemView = require ( 'app/views/logs/list_item' )
57var tpl = require ( 'tpl/logs/list.html' )
@@ -9,5 +11,31 @@ var template = _.template(tpl)
911module . exports = Marionette . CompositeView . extend ( {
1012 childView : ListItemView ,
1113 childViewContainer : 'tbody' ,
12- template : template
14+ template : template ,
15+
16+ events : {
17+ 'click .delete-all' : 'deleteAll'
18+ } ,
19+
20+ deleteAll : function ( event ) {
21+ var self = this
22+
23+ sweetAlert ( {
24+ title : 'Are you sure?' ,
25+ text : 'All logs will be deleted from the server!' ,
26+ type : 'warning' ,
27+ showCancelButton : true ,
28+ confirmButtonClass : 'btn-danger' ,
29+ confirmButtonText : 'Yes, delete all!'
30+ } ,
31+ function ( ) {
32+ $ . ajax ( '/api/logs/all' , {
33+ type : 'DELETE' ,
34+ success : function ( data ) {
35+ self . collection . fetch ( )
36+ } ,
37+ error : function ( ) { }
38+ } )
39+ } )
40+ }
1341} )
Original file line number Diff line number Diff line change 55 < th class ="hidden-xs hidden-sm "> Created</ th >
66 < th class ="hidden-xs hidden-sm "> Modified</ th >
77 < th > Size</ th >
8- < th > </ th >
9- < th > </ th >
8+ < th colspan ="2 ">
9+ < a class ="btn btn-danger btn-xs delete-all ladda-button pull-right " data-style ="expand-left ">
10+ < span class ="glyphicon glyphicon-trash "> </ span >
11+ Delete all
12+ </ a >
13+ </ th >
1014 </ tr >
1115 </ thead >
1216
Original file line number Diff line number Diff line change @@ -13,6 +13,16 @@ module.exports = function (logsManager) {
1313 } )
1414 } )
1515
16+ router . delete ( '/all' , function ( req , res ) {
17+ logsManager . deleteAll ( function ( err ) {
18+ if ( err ) {
19+ res . status ( 500 ) . send ( err )
20+ } else {
21+ res . status ( 204 ) . send ( )
22+ }
23+ } )
24+ } )
25+
1626 router . delete ( '/:log' , function ( req , res ) {
1727 var filename = req . params . log
1828 logsManager . delete ( filename , function ( err ) {
You can’t perform that action at this time.
0 commit comments