@@ -2779,14 +2779,29 @@ app.$Menu.add("dashboard", new class {
27792779 this . data_day_option = parseInt ( index + "" )
27802780 if ( this . get_globals_stats ) {
27812781 $progress . set ( 60 )
2782+ var percent = 0
2783+ var total = 6
2784+ var percent_func = ( n ) => {
2785+ percent += n
2786+ $progress . set ( 60 + ( percent / total ) * 100 )
2787+ }
27822788 $MainSocket . send ( "pro_stats" , { type : this . data_day_option } ) . then ( ( data ) => {
2783- $progress . set ( 90 )
2789+ percent_func ( 1 )
27842790 this . pro_stats = data
27852791 this . drawGlobals ( )
27862792 this . drawGEO ( )
27872793 } ) . finally ( ( ) => {
2788- $progress . set ( 100 )
2794+ percent_func ( 2 )
2795+ } )
2796+ $MainSocket . send ( "geo_stats" , { type : this . data_day_option } ) . then ( ( data ) => {
2797+ percent_func ( 1 )
2798+ this . geo_stats = data
2799+ this . drawGlobals ( )
2800+ this . drawGEO ( )
2801+ } ) . finally ( ( ) => {
2802+ percent_func ( 2 )
27892803 } )
2804+ $progress . set ( 100 )
27902805 }
27912806 } )
27922807 this . _be_qps = app . createEcharts ( ) . style ( "min-height: 162px;" )
@@ -3474,6 +3489,11 @@ app.$Menu.add("dashboard", new class {
34743489 this . drawGlobals ( )
34753490 this . drawGEO ( )
34763491 } )
3492+ $MainSocket . send ( "geo_stats" , { type : this . data_day_option } ) . then ( ( data ) => {
3493+ this . geo_stats = data
3494+ this . drawGlobals ( )
3495+ this . drawGEO ( )
3496+ } )
34773497 } , 0 , 360000 )
34783498 this . detailSystemTimer = app . runTaskRepeat ( ( ) => {
34793499 $MainSocket . send ( "system_details" ) . then ( ( data ) => {
@@ -3751,12 +3771,12 @@ app.$Menu.add("dashboard", new class {
37513771 }
37523772 }
37533773 drawGEO ( ) {
3754- if ( this . pro_stats == null ) return
3774+ if ( this . geo_stats == null ) return
37553775 var data = [ ]
37563776 if ( this . geo_type == "world" ) {
37573777 var other = [ ]
37583778 var cn_data = 0
3759- this . pro_stats . addresses . forEach ( e => {
3779+ this . geo_stats . addresses . forEach ( e => {
37603780 if ( e . country == "CN" ) cn_data += e . value
37613781 else other . push ( e )
37623782 } )
@@ -3836,6 +3856,49 @@ app.$Menu.add("dashboard", new class {
38363856 value : e . value
38373857 }
38383858 } ) )
3859+ var visits = ( this . data_day_option <= 1 ? fillDateTimes ( this . geo_stats . distinct_ip , this . data_day_option == 1 ? 7 : 1 ) : fillDates ( this . geo_stats . distinct_ip ) )
3860+ this . _e_visits . setOption ( {
3861+ color : app . getThemeVar ( "main-color" ) ,
3862+ xAxis : {
3863+ data : Object . keys ( visits )
3864+ } ,
3865+ series : [
3866+ {
3867+ name : $I18N . t ( "dashboard.distincts" ) ,
3868+ data : Object . values ( visits ) ,
3869+ type : 'line' ,
3870+ smooth : true ,
3871+ }
3872+ ]
3873+ } )
3874+ this . pro [ 1 ] . getChildren ( ) [ 1 ] . getChildren ( ) [ 0 ] . getChildren ( ) [ 0 ] . getChildren ( ) [ 1 ] . t18n ( { peer : Math . max ( ...Object . values ( visits ) ) } )
3875+ this . pro [ 0 ] . getChildren ( ) [ 2 ] . getChildren ( ) [ 1 ] . setText ( this . geo_stats . distinct_ip_count + "" )
3876+ var data = [ ]
3877+ for ( const key in this . geo_stats . useragents ) {
3878+ data . push ( {
3879+ label : key ,
3880+ value : this . geo_stats . useragents [ key ]
3881+ } )
3882+ }
3883+ data = data . sort ( ( a , b ) => b . value - a . value )
3884+ this . _e_ua . setOption ( {
3885+ color : [
3886+ app . getThemeVar ( "echarts-color-0" ) ,
3887+ app . getThemeVar ( "echarts-color-1" ) ,
3888+ app . getThemeVar ( "echarts-color-2" ) ,
3889+ app . getThemeVar ( "echarts-color-3" ) ,
3890+ app . getThemeVar ( "echarts-color-4" )
3891+ ] ,
3892+ series : [
3893+ {
3894+ itemStyle :{
3895+ borderColor :app . getThemeVar ( "dark-color" ) ,
3896+ } ,
3897+ data : data . slice ( 0 , 5 )
3898+ }
3899+ ]
3900+ } )
3901+ this . setRank_UA ( ) ;
38393902 }
38403903 drawSystem ( ) {
38413904 var hits , bytes ;
@@ -3919,48 +3982,6 @@ app.$Menu.add("dashboard", new class {
39193982 this . pro [ 3 ] . getChildren ( ) [ 2 ] . getChildren ( ) [ 0 ] . getChildren ( ) [ 1 ] . t18n ( { peer : Math . max ( ...Object . values ( this . detail_system . connections ) , 0 ) } )
39203983 }
39213984 drawGlobals ( ) {
3922- 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 ) )
3923- this . _e_visits . setOption ( {
3924- color : app . getThemeVar ( "main-color" ) ,
3925- xAxis : {
3926- data : Object . keys ( visits )
3927- } ,
3928- series : [
3929- {
3930- name : $I18N . t ( "dashboard.distincts" ) ,
3931- data : Object . values ( visits ) ,
3932- type : 'line' ,
3933- smooth : true ,
3934- }
3935- ]
3936- } )
3937- this . pro [ 1 ] . getChildren ( ) [ 1 ] . getChildren ( ) [ 0 ] . getChildren ( ) [ 0 ] . getChildren ( ) [ 1 ] . t18n ( { peer : Math . max ( ...Object . values ( visits ) ) } )
3938- this . pro [ 0 ] . getChildren ( ) [ 2 ] . getChildren ( ) [ 1 ] . setText ( this . pro_stats . distinct_ip_count + "" )
3939- var data = [ ]
3940- for ( const key in this . pro_stats . useragents ) {
3941- data . push ( {
3942- label : key ,
3943- value : this . pro_stats . useragents [ key ]
3944- } )
3945- }
3946- data = data . sort ( ( a , b ) => b . value - a . value )
3947- this . _e_ua . setOption ( {
3948- color : [
3949- app . getThemeVar ( "echarts-color-0" ) ,
3950- app . getThemeVar ( "echarts-color-1" ) ,
3951- app . getThemeVar ( "echarts-color-2" ) ,
3952- app . getThemeVar ( "echarts-color-3" ) ,
3953- app . getThemeVar ( "echarts-color-4" )
3954- ] ,
3955- series : [
3956- {
3957- itemStyle :{
3958- borderColor :app . getThemeVar ( "dark-color" ) ,
3959- } ,
3960- data : data . slice ( 0 , 5 )
3961- }
3962- ]
3963- } )
39643985 this . pro [ 0 ] . getChildren ( ) [ 0 ] . getChildren ( ) [ 1 ] . setText ( this . _format_number_unit ( this . pro_stats . downloads ) )
39653986 this . pro [ 0 ] . getChildren ( ) [ 1 ] . getChildren ( ) [ 1 ] . setText ( this . _format_bytes ( this . pro_stats . bytes ) )
39663987 var data = [ ]
@@ -3988,15 +4009,14 @@ app.$Menu.add("dashboard", new class {
39884009 }
39894010 ]
39904011 } )
3991- this . setRank_UA ( ) ;
39924012 this . setRank_Status ( ) ;
39934013 }
39944014 setRank_UA ( ) {
39954015 var data = [ ] ;
3996- for ( const key in this . pro_stats != null && this . pro_stats . useragents != null ? this . pro_stats . useragents : { } ) {
4016+ for ( const key in this . geo_stats != null && this . geo_stats . useragents != null ? this . geo_stats . useragents : { } ) {
39974017 data . push ( {
39984018 label : key ,
3999- value : this . pro_stats . useragents [ key ]
4019+ value : this . geo_stats . useragents [ key ]
40004020 } )
40014021 }
40024022 data = data . sort ( ( a , b ) => b . value - a . value )
0 commit comments