@@ -2787,8 +2787,8 @@ app.$Menu.add("dashboard", new class {
27872787 this . _be_qps = app . createEcharts ( ) . style ( "min-height: 162px;" )
27882788 this . _pe_qps = app . createEcharts ( ) . style ( "min-height: 162px;" )
27892789 this . _e_geo = app . createEcharts ( ) . style ( "min-height: 416px;" )
2790- this . _e_cpu = app . createEcharts ( ) . style ( "min-height: 162px;" )
2791- this . _e_memory = app . createEcharts ( ) . style ( "min-height: 162px;" )
2790+ this . _e_cpu = app . createEcharts ( ) . style ( "min-height: 162px;" ) . setFormatter ( ( n ) => n + "%" )
2791+ this . _e_memory = app . createEcharts ( ) . style ( "min-height: 162px;" ) . setFormatter ( ( n ) => this . _format_bytes ( n ) )
27922792 this . _e_connection = app . createEcharts ( ) . style ( "min-height: 162px;" )
27932793 this . _e_ua = app . createEcharts ( ) . setType ( EchartType . LABEL ) . style ( "min-height: 140px" )
27942794 this . _e_status = app . createEcharts ( ) . setType ( EchartType . LABEL ) . style ( "min-height: 140px" )
@@ -3049,6 +3049,9 @@ app.$Menu.add("dashboard", new class {
30493049 this . _e_status . resize ( )
30503050 this . _e_geo . resize ( )
30513051 this . pgeorank . update ( false )
3052+ this . _e_cpu . resize ( )
3053+ this . _e_memory . resize ( )
3054+ this . _e_connection . resize ( )
30523055 } )
30533056 ] ;
30543057 this . initGlobals ( )
@@ -3278,7 +3281,7 @@ app.$Menu.add("dashboard", new class {
32783281 global : false ,
32793282 colorStops : [ { offset : 0 , color : app . getThemeVar ( "echarts-main-line-color" ) } , { offset : 1 , color : app . getThemeVar ( "echarts-dark-color" ) } ]
32803283 } ,
3281- type : " solid"
3284+ type : "solid"
32823285 } ,
32833286 itemStyle : { borderRadius : [ 2 , 2 , 0 , 0 ] } ,
32843287 z : 3 ,
@@ -3382,6 +3385,72 @@ app.$Menu.add("dashboard", new class {
33823385 data : [ ]
33833386 } ]
33843387 } )
3388+ for ( let val of [
3389+ [ "cpu" , this . _e_cpu , ] ,
3390+ [ "memory" , this . _e_memory ] ,
3391+ [ "connection" , this . _e_connection ]
3392+ ] ) {
3393+ val [ 1 ] . setOption ( {
3394+ color : app . getThemeVar ( "main-color" ) ,
3395+ yAxis : [
3396+ {
3397+ type : "value" ,
3398+ show : true ,
3399+ max : val [ 0 ] == "cpu" ? 100 : 1
3400+ }
3401+ ] ,
3402+ tooltip : {
3403+ trigger : "axis" ,
3404+ } ,
3405+ xAxis : [
3406+ {
3407+ type : "category" ,
3408+ show : false ,
3409+ }
3410+ ] ,
3411+ stateAnimation : {
3412+ duration : 300 ,
3413+ easing : "cubicOut"
3414+ } ,
3415+ grid : [
3416+ {
3417+ top : 15 ,
3418+ bottom : 10 ,
3419+ right : 0 ,
3420+ show : false ,
3421+ z : 0 ,
3422+ containLabel : false ,
3423+ backgroundColor : "rgba(0,0,0,0)" ,
3424+ borderWidth : 1 ,
3425+ borderColor : "#ccc"
3426+ }
3427+ ] ,
3428+ series : [
3429+ {
3430+ name : $I18N . t ( "dashboard.distincts" ) ,
3431+ type : "line" ,
3432+ symbol : "none" ,
3433+ data : [ ] ,
3434+ smooth : true ,
3435+ lineStyle : {
3436+ width : 3 ,
3437+ color : {
3438+ type : "linear" ,
3439+ x : 0 ,
3440+ y : 0 ,
3441+ x2 : 0 ,
3442+ y2 : 1 ,
3443+ global : false ,
3444+ colorStops : [ { offset : 0 , color : app . getThemeVar ( "echarts-main-line-color" ) } , { offset : 1 , color : app . getThemeVar ( "echarts-dark-color" ) } ]
3445+ } ,
3446+ type : "solid"
3447+ } ,
3448+ itemStyle : { borderRadius : [ 2 , 2 , 0 , 0 ] } ,
3449+ z : 3 ,
3450+ }
3451+ ]
3452+ } )
3453+ }
33853454 this . setRank_UA ( ) ;
33863455 this . setRank_Status ( ) ;
33873456 this . globalTimer = app . runTaskRepeat ( ( ) => {
@@ -3391,9 +3460,16 @@ app.$Menu.add("dashboard", new class {
33913460 this . drawGEO ( )
33923461 } )
33933462 } , 0 , 360000 )
3463+ /*this.detailSystemTimer = app.runTaskRepeat(() => {
3464+ $MainSocket.send("system_details").then((data) => {
3465+ this.detail_system = data
3466+ this.drawDetailSystem()
3467+ })
3468+ }, 0, 1000)*/
33943469 }
33953470 clearPro ( ) {
33963471 this . globalTimer ?. block ( )
3472+ this . detailSystemTimer ?. block ( )
33973473 this . _e_visits . clear ( )
33983474 this . _e_ua . clear ( )
33993475 this . pgeorank . setData ( )
@@ -3761,7 +3837,65 @@ app.$Menu.add("dashboard", new class {
37613837 this . basic [ 0 ] . getChildren ( ) [ 0 ] . getChildren ( ) [ 1 ] . getChildren ( ) [ 0 ] . getChildren ( ) [ 3 ] . getChildren ( ) [ 1 ] . setText ( this . system . cpu . toFixed ( 2 ) + "%" )
37623838 }
37633839 drawDetailSystem ( ) {
3764-
3840+ this . _e_cpu . setOption ( {
3841+ color : app . getThemeVar ( "main-color" ) ,
3842+ yAxis : {
3843+ max : Math . max ( ...Object . values ( this . detail_system . cpu ) , 100 )
3844+ } ,
3845+ xAxis : {
3846+ data : Object . keys ( this . detail_system . cpu )
3847+ } ,
3848+ series : [
3849+ {
3850+ name : $I18N . t ( "dashboard.cpu" ) ,
3851+ data : Object . values ( this . detail_system . cpu ) ,
3852+ type : 'line' ,
3853+ smooth : true ,
3854+ }
3855+ ]
3856+ } )
3857+ let memories = Object . values ( this . detail_system . memory ) . filter ( v => v != 0 )
3858+ let max = memories . reduce ( ( sum , i ) => sum + i , 0 )
3859+ let avg = max / memories . length
3860+ this . _e_memory . setOption ( {
3861+ color : app . getThemeVar ( "main-color" ) ,
3862+ yAxis : {
3863+ max : Math . max ( ( avg >= max / 2 ? max : avg * 2 ) / 1024 , 1 ) * 1024 ,
3864+ axisLabel : {
3865+ formatter : ( value ) => {
3866+ return this . _format_bytes ( value )
3867+ }
3868+ }
3869+ } ,
3870+ xAxis : {
3871+ data : Object . keys ( this . detail_system . memory )
3872+ } ,
3873+ series : [
3874+ {
3875+ name : $I18N . t ( "dashboard.memory" ) ,
3876+ data : Object . values ( this . detail_system . memory ) ,
3877+ type : 'line' ,
3878+ smooth : true ,
3879+ }
3880+ ]
3881+ } )
3882+ this . _e_connection . setOption ( {
3883+ color : app . getThemeVar ( "main-color" ) ,
3884+ yAxis : {
3885+ max : Math . max ( ...Object . values ( this . detail_system . connections ) . map ( v => parseInt ( v / 100 ) ) , 1 ) * 100
3886+ } ,
3887+ xAxis : {
3888+ data : Object . keys ( this . detail_system . connections )
3889+ } ,
3890+ series : [
3891+ {
3892+ name : $I18N . t ( "dashboard.connections" ) ,
3893+ data : Object . values ( this . detail_system . connections ) ,
3894+ type : 'line' ,
3895+ smooth : true ,
3896+ }
3897+ ]
3898+ } )
37653899 }
37663900 drawGlobals ( ) {
37673901 var visits = ( this . data_day_option <= 1 ? fillDateTimes ( this . pro_stats . distinct_ip , this . data_day_option == 1 ? 7 : 1 ) : fillDates ( this . pro_stats . distinct_ip ) )
0 commit comments