2011-06-14 21:16:34 +08:00
dispatcher _add ( function ( sammy ) {
sammy . get ( '#/traces' , function ( ) {
2018-07-26 17:01:18 +08:00
var nodes = JSON . parse ( sync _get ( '/nodes' ) ) ;
go _to ( '#/traces/' + nodes [ 0 ] . name ) ;
2011-06-14 21:16:34 +08:00
} ) ;
2018-07-26 17:01:18 +08:00
sammy . get ( '#/traces/:node' , function ( ) {
2018-07-30 07:05:25 +08:00
render ( { 'traces' : '/traces/node/' + esc ( this . params [ 'node' ] ) ,
2018-07-26 17:01:18 +08:00
'vhosts' : '/vhosts' ,
'node' : '/nodes/' + esc ( this . params [ 'node' ] ) ,
'nodes' : '/nodes' ,
2018-07-30 07:05:25 +08:00
'files' : '/trace-files/node/' + esc ( this . params [ 'node' ] ) } ,
'traces' , '#/traces' ) ;
2018-07-26 17:01:18 +08:00
} ) ;
2018-07-30 07:05:25 +08:00
sammy . get ( '#/traces/node/:node/:vhost/:name' , function ( ) {
var path = '/traces/node/' + esc ( this . params [ 'node' ] ) + '/' + esc ( this . params [ 'vhost' ] ) + '/' + esc ( this . params [ 'name' ] ) ;
2011-06-14 21:16:34 +08:00
render ( { 'trace' : path } ,
'trace' , '#/traces' ) ;
} ) ;
2018-07-30 07:05:25 +08:00
sammy . put ( '#/traces/node/:node' , function ( ) {
2015-03-02 23:42:37 +08:00
if ( this . params [ 'max_payload_bytes' ] === '' ) {
delete this . params [ 'max_payload_bytes' ] ;
}
else {
this . params [ 'max_payload_bytes' ] =
parseInt ( this . params [ 'max_payload_bytes' ] ) ;
}
2018-07-30 07:05:25 +08:00
if ( sync _put ( this , '/traces/node/' + esc ( this . params [ 'node' ] ) + '/:vhost/:name' ) )
2011-06-14 21:16:34 +08:00
update ( ) ;
return false ;
} ) ;
2018-07-30 07:05:25 +08:00
sammy . del ( '#/traces/node/:node' , function ( ) {
if ( sync _delete ( this , '/traces/node/' + esc ( this . params [ 'node' ] )
2018-07-26 17:01:18 +08:00
+ '/:vhost/:name' ) )
2011-06-18 00:45:06 +08:00
partial _update ( ) ;
return false ;
} ) ;
2018-07-30 07:05:25 +08:00
sammy . del ( '#/trace-files/node/:node' , function ( ) {
if ( sync _delete ( this , '/trace-files/node/' + esc ( this . params [ 'node' ] ) + '/:name' ) )
2011-06-18 00:45:06 +08:00
partial _update ( ) ;
2011-06-14 21:16:34 +08:00
return false ;
} ) ;
} ) ;
2013-10-23 18:27:10 +08:00
NAVIGATION [ 'Admin' ] [ 0 ] [ 'Tracing' ] = [ '#/traces' , 'administrator' ] ;
2012-02-24 23:41:59 +08:00
2015-03-11 17:58:58 +08:00
HELP [ 'tracing-max-payload' ] =
'Maximum size of payload to log, in bytes. Payloads larger than this limit will be truncated. Leave blank to prevent truncation. Set to 0 to prevent logging of payload altogether.' ;
2018-07-26 17:01:18 +08:00
$ ( document ) . on ( 'change' , 'select#traces-node' , function ( ) {
var url = '#/traces/' + $ ( this ) . val ( ) ;
go _to ( url ) ;
} ) ;
function link _trace ( node , name ) {
2018-07-30 07:05:25 +08:00
return _link _to ( name , 'api/trace-files/node/' + esc ( node ) + '/' + esc ( name ) ) ;
2012-02-24 23:41:59 +08:00
}
function link _trace _queue ( trace ) {
return _link _to ( '(queue)' , '#/queues/' + esc ( trace . vhost ) + '/' + esc ( trace . queue . name ) ) ;
}