@@ -392,6 +392,7 @@ class SwitchElement extends Element {
392392 this . _render_next_index = index ;
393393 return this ;
394394 } ;
395+ var oldindex = this . index ;
395396 this . index = index ;
396397 var buttons_width = this . $buttons . map ( e => calcElementWidth ( e ) ) ;
397398 var left = 0 ;
@@ -408,6 +409,7 @@ class SwitchElement extends Element {
408409 } )
409410 }
410411 this . $bar . style ( "left" , `${ left } px` ) . style ( "width" , `${ width } px` ) ;
412+ if ( oldindex == this . index ) return this ;
411413 this . origin . dispatchEvent ( new CustomEvent ( "change" , {
412414 detail : {
413415 index : index ,
@@ -900,6 +902,9 @@ class Tools {
900902 } )
901903 return base
902904 }
905+ static formatDate ( d ) {
906+ return `${ d . getFullYear ( ) . toString ( ) . padStart ( 4 , "0" ) } -${ ( d . getMonth ( ) + 1 ) . toString ( ) . padStart ( 2 , "0" ) } -${ d . getDate ( ) . toString ( ) . padStart ( 2 , "0" ) } `
907+ }
903908}
904909async function load ( ) {
905910 const $dom_body = new Element ( document . body ) ;
@@ -1178,8 +1183,29 @@ async function load() {
11781183 data . daily_bytes , ( n ) => n , Tools . formatBytes , $i18n . t ( "dashboard.value.storage.bytes" )
11791184 ]
11801185 } ) ) {
1181- const [ value , key_unit , value_formatter , i18n ] = values ;
1186+ var [ value , key_unit , value_formatter , i18n ] = values ;
11821187 if ( ! value ) continue ;
1188+ if ( key . startsWith ( "today" ) ) {
1189+ for ( let i = 0 ; i < 24 ; i ++ ) {
1190+ if ( value [ i ] ) continue
1191+ value [ i ] = 0
1192+ }
1193+ value = Object . fromEntries (
1194+ Object . keys ( value ) . sort ( ( a , b ) => parseInt ( a ) - parseInt ( b ) ) . map ( v => [ v , value [ v ] ] )
1195+ )
1196+ } else {
1197+ var server_time = $dashboard_locals . info_runtime
1198+ // object.current_time - object.start_time - object.diff / 1000.0 + (+new Date() - object.resp_timestamp) / 1000.0;
1199+ var time = server_time . start_time - server_time . diff / 1000.0 + ( + new Date ( ) - server_time . resp_timestamp ) / 1000.0 ;
1200+ const previous = ( time - ( time % ( 24 * 3600 ) ) - 86400 * 30 ) ;
1201+ const res = { }
1202+ for ( let i = 0 ; i < 30 ; i ++ ) {
1203+ var d = Tools . formatDate ( new Date ( ( previous + i * 86400 ) * 1000.0 ) )
1204+ if ( value [ d ] ) res [ d ] = value [ d ]
1205+ else res [ d ] = 0
1206+ }
1207+ value = res
1208+ }
11831209 var option = {
11841210 color : [
11851211 $style . getThemeValue ( "echarts-color-0" ) ,
@@ -1494,18 +1520,6 @@ async function load() {
14941520 var v = storage [ storage_id ] [ key_time ] [ val . _ ] || 0 ;
14951521 storage [ storage_id ] [ key_time ] [ val . _ ] = v + val [ key ]
14961522 }
1497- if ( time == "hourly" ) {
1498- for ( let i = 0 ; i < 24 ; i ++ ) {
1499- if ( storage [ storage_id ] [ key_time ] [ i ] ) continue
1500- storage [ storage_id ] [ key_time ] [ i ] = 0
1501- }
1502- storage [ storage_id ] [ key_time ] = Object . fromEntries (
1503- Object . keys ( storage [ storage_id ] [ key_time ] ) . sort ( ( a , b ) => parseInt ( a ) - parseInt ( b ) ) . map ( v => [ v , storage [ storage_id ] [ key_time ] [ v ] ] )
1504- )
1505- } else {
1506- var server_time = $dashboard_locals . info . runtime
1507- console . log ( server_time )
1508- }
15091523 }
15101524 }
15111525 }
@@ -1525,7 +1539,7 @@ async function load() {
15251539 }
15261540 $dashboard_locals . statistics_data . total = total ;
15271541 $dashboard_locals . statistics_data . storages = storage ;
1528- } , 1000 )
1542+ } , 60000 )
15291543 clearInterval ( $dashboard_locals . basic_task_file_info )
15301544 $dashboard_locals . basic_task_file_info = Tools . runTask ( setInterval , async ( ) => {
15311545 var hourly = await $channel . send ( "cluster_statistics_hourly" )
0 commit comments