File tree 4 files changed +57
-3
lines changed
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) {
46
46
} )
47
47
}
48
48
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
+
49
61
Logs . prototype . generateLogFilePath = function ( prefix , suffix ) {
50
62
return path . join ( this . logsPath ( ) , Logs . generateLogFileName ( prefix , suffix ) )
51
63
}
Original file line number Diff line number Diff line change
1
+ var $ = require ( 'jquery' )
1
2
var _ = require ( 'underscore' )
2
3
var Marionette = require ( 'marionette' )
4
+ var sweetAlert = require ( 'sweet-alert' )
3
5
4
6
var ListItemView = require ( 'app/views/logs/list_item' )
5
7
var tpl = require ( 'tpl/logs/list.html' )
@@ -9,5 +11,31 @@ var template = _.template(tpl)
9
11
module . exports = Marionette . CompositeView . extend ( {
10
12
childView : ListItemView ,
11
13
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
+ }
13
41
} )
Original file line number Diff line number Diff line change 5
5
< th class ="hidden-xs hidden-sm "> Created</ th >
6
6
< th class ="hidden-xs hidden-sm "> Modified</ th >
7
7
< 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 >
10
14
</ tr >
11
15
</ thead >
12
16
Original file line number Diff line number Diff line change @@ -13,6 +13,16 @@ module.exports = function (logsManager) {
13
13
} )
14
14
} )
15
15
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
+
16
26
router . delete ( '/:log' , function ( req , res ) {
17
27
var filename = req . params . log
18
28
logsManager . delete ( filename , function ( err ) {
You can’t perform that action at this time.
0 commit comments