@ -66,6 +66,7 @@ define([
] ,
] ,
'stats' : [ // Msg.admin_cat_stats
'stats' : [ // Msg.admin_cat_stats
'cp-admin-refresh-stats' ,
'cp-admin-refresh-stats' ,
'cp-admin-uptime' ,
'cp-admin-active-sessions' ,
'cp-admin-active-sessions' ,
'cp-admin-active-pads' ,
'cp-admin-active-pads' ,
'cp-admin-open-files' ,
'cp-admin-open-files' ,
@ -85,6 +86,8 @@ define([
'performance' : [ // Msg.admin_cat_performance
'performance' : [ // Msg.admin_cat_performance
'cp-admin-refresh-performance' ,
'cp-admin-refresh-performance' ,
'cp-admin-performance-profiling' ,
'cp-admin-performance-profiling' ,
'cp-admin-enable-disk-measurements' ,
'cp-admin-bytes-written' ,
] ,
] ,
'network' : [ // Msg.admin_cat_network
'network' : [ // Msg.admin_cat_network
'cp-admin-update-available' ,
'cp-admin-update-available' ,
@ -644,6 +647,29 @@ define([
return $div ;
return $div ;
} ;
} ;
Messages . admin _uptimeTitle = 'Launch time' ;
Messages . admin _uptimeHint = 'Date and time at which the server was launched' ;
create [ 'uptime' ] = function ( ) {
var key = 'uptime' ;
var $div = makeBlock ( key ) ; // Msg.admin_activeSessionsHint, .admin_activeSessionsTitle
var pre = h ( 'pre' ) ;
var set = function ( ) {
var uptime = APP . instanceStatus . launchTime ;
if ( typeof ( uptime ) !== 'number' ) { return ; }
pre . innerText = new Date ( uptime ) ;
} ;
set ( ) ;
$div . append ( pre ) ;
onRefreshStats . reg ( function ( ) {
set ( ) ;
} ) ;
return $div ;
} ;
create [ 'active-sessions' ] = function ( ) {
create [ 'active-sessions' ] = function ( ) {
var key = 'active-sessions' ;
var key = 'active-sessions' ;
var $div = makeBlock ( key ) ; // Msg.admin_activeSessionsHint, .admin_activeSessionsTitle
var $div = makeBlock ( key ) ; // Msg.admin_activeSessionsHint, .admin_activeSessionsTitle
@ -1739,6 +1765,84 @@ define([
return $div ;
return $div ;
} ;
} ;
Messages . admin _enableDiskMeasurementsTitle = "Measure disk performance" ; // XXX
Messages . admin _enableDiskMeasurementsHint = "If enabled, a JSON endpoint will be exposed under /api/profiling which keeps a running measurement of disk I/O within a configurable window. This setting can impact server performance and may reveal data you'd rather keep hidden. It is recommended that you leave it disabled unless you know what you are doing." ; // XXX
create [ 'enable-disk-measurements' ] = makeAdminCheckbox ( {
key : 'enable-disk-measurements' ,
getState : function ( ) {
return APP . instanceStatus . enableProfiling ;
} ,
query : function ( val , setState ) {
sFrameChan . query ( 'Q_ADMIN_RPC' , {
cmd : 'ADMIN_DECREE' ,
data : [ 'ENABLE_PROFILING' , [ val ] ]
} , function ( e , response ) {
if ( e || response . error ) {
UI . warn ( Messages . error ) ;
console . error ( e , response ) ;
}
APP . updateStatus ( function ( ) {
setState ( APP . instanceStatus . enableProfiling ) ;
} ) ;
} ) ;
} ,
} ) ;
Messages . admin _bytesWrittenTitle = "Disk performance measurement window" ;
Messages . admin _bytesWrittenHint = "If you have enabled disk performance measurements then the duration of the window can be configured below." ; // XXX
Messages . admin _bytesWrittenDuration = "Duration of the window in milliseconds: {0}" ; // XXX
Messages . admin _defaultDuration = "admin_defaultDuration" ; // XXX
Messages . admin _setDuration = "Set duration" ; // XXX
var isPositiveInteger = function ( n ) {
return n && typeof ( n ) === 'number' && n % 1 === 0 && n > 0 ;
} ;
create [ 'bytes-written' ] = function ( ) {
var key = 'bytes-written' ;
var $div = makeBlock ( key ) ;
var duration = APP . instanceStatus . profilingWindow ;
if ( ! isPositiveInteger ( duration ) ) { duration = 10000 ; }
var newDuration = h ( 'input' , { type : 'number' , min : 0 , value : duration } ) ;
var set = h ( 'button.btn.btn-primary' , Messages . admin _setDuration ) ;
$div . append ( h ( 'div' , [
h ( 'span.cp-admin-bytes-written-duration' , Messages . _getKey ( 'admin_bytesWrittenDuration' , [ duration ] ) ) ,
h ( 'div.cp-admin-setlimit-form' , [
newDuration ,
h ( 'nav' , [ set ] )
] )
] ) ) ;
UI . confirmButton ( set , {
classes : 'btn-primary' ,
multiple : true ,
validate : function ( ) {
var l = parseInt ( $ ( newDuration ) . val ( ) ) ;
if ( isNaN ( l ) ) { return false ; }
return true ;
}
} , function ( ) {
var d = parseInt ( $ ( newDuration ) . val ( ) ) ;
if ( ! isPositiveInteger ( d ) ) { return void UI . warn ( Messages . error ) ; }
var data = [ d ] ;
sFrameChan . query ( 'Q_ADMIN_RPC' , {
cmd : 'ADMIN_DECREE' ,
data : [ 'SET_PROFILING_WINDOW' , data ]
} , function ( e , response ) {
if ( e || response . error ) {
UI . warn ( Messages . error ) ;
return void console . error ( e , response ) ;
}
$div . find ( '.cp-admin-bytes-written-duration' ) . text ( Messages . _getKey ( 'admin_limit' , [ d ] ) ) ;
} ) ;
} ) ;
return $div ;
} ;
create [ 'update-available' ] = function ( ) { // Messages.admin_updateAvailableTitle.admin_updateAvailableHint.admin_updateAvailableLabel.admin_updateAvailableButton
create [ 'update-available' ] = function ( ) { // Messages.admin_updateAvailableTitle.admin_updateAvailableHint.admin_updateAvailableLabel.admin_updateAvailableButton
if ( ! APP . instanceStatus . updateAvailable ) { return ; }
if ( ! APP . instanceStatus . updateAvailable ) { return ; }
var $div = makeBlock ( 'update-available' , true ) ;
var $div = makeBlock ( 'update-available' , true ) ;