@@ -392,6 +392,7 @@ class SwitchElement extends Element {
392
392
this . _render_next_index = index ;
393
393
return this ;
394
394
} ;
395
+ var oldindex = this . index ;
395
396
this . index = index ;
396
397
var buttons_width = this . $buttons . map ( e => calcElementWidth ( e ) ) ;
397
398
var left = 0 ;
@@ -408,6 +409,7 @@ class SwitchElement extends Element {
408
409
} )
409
410
}
410
411
this . $bar . style ( "left" , `${ left } px` ) . style ( "width" , `${ width } px` ) ;
412
+ if ( oldindex == this . index ) return this ;
411
413
this . origin . dispatchEvent ( new CustomEvent ( "change" , {
412
414
detail : {
413
415
index : index ,
@@ -900,6 +902,9 @@ class Tools {
900
902
} )
901
903
return base
902
904
}
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
+ }
903
908
}
904
909
async function load ( ) {
905
910
const $dom_body = new Element ( document . body ) ;
@@ -1178,8 +1183,29 @@ async function load() {
1178
1183
data . daily_bytes , ( n ) => n , Tools . formatBytes , $i18n . t ( "dashboard.value.storage.bytes" )
1179
1184
]
1180
1185
} ) ) {
1181
- const [ value , key_unit , value_formatter , i18n ] = values ;
1186
+ var [ value , key_unit , value_formatter , i18n ] = values ;
1182
1187
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
+ }
1183
1209
var option = {
1184
1210
color : [
1185
1211
$style . getThemeValue ( "echarts-color-0" ) ,
@@ -1494,18 +1520,6 @@ async function load() {
1494
1520
var v = storage [ storage_id ] [ key_time ] [ val . _ ] || 0 ;
1495
1521
storage [ storage_id ] [ key_time ] [ val . _ ] = v + val [ key ]
1496
1522
}
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
- }
1509
1523
}
1510
1524
}
1511
1525
}
@@ -1525,7 +1539,7 @@ async function load() {
1525
1539
}
1526
1540
$dashboard_locals . statistics_data . total = total ;
1527
1541
$dashboard_locals . statistics_data . storages = storage ;
1528
- } , 1000 )
1542
+ } , 60000 )
1529
1543
clearInterval ( $dashboard_locals . basic_task_file_info )
1530
1544
$dashboard_locals . basic_task_file_info = Tools . runTask ( setInterval , async ( ) => {
1531
1545
var hourly = await $channel . send ( "cluster_statistics_hourly" )
0 commit comments