@@ -33,57 +33,54 @@ export function VDiskTablets({nodeId, pDiskId, vDiskSlotId, className}: VDiskTab
3333 } ) ;
3434
3535 const loading = isFetching && currentData === undefined ;
36-
37- // Debug: Log the actual response to understand the structure
38- React . useEffect ( ( ) => {
39- if ( currentData ) {
40- console . log ( 'VDisk BlobIndexStat Response:' , currentData ) ;
41- console . log ( 'Response keys:' , Object . keys ( currentData ) ) ;
42- console . log ( 'BlobIndexStat field:' , currentData . BlobIndexStat ) ;
43- console . log ( 'blobIndexStat field:' , currentData . blobIndexStat ) ;
44- console . log ( 'blobindexstat field:' , currentData . blobindexstat ) ;
45- console . log ( 'result field:' , currentData . result ) ;
46- console . log ( 'data field:' , currentData . data ) ;
47- }
48- } , [ currentData ] ) ;
49-
50- // Try multiple possible field names for the data array
36+
37+ // Transform the actual API response structure into the expected flat table format
5138 const tableData : VDiskBlobIndexItem [ ] = React . useMemo ( ( ) => {
52- if ( ! currentData ) return [ ] ;
53-
54- // Try different possible field names
55- const possibleFields = [
56- currentData . BlobIndexStat ,
57- currentData . blobIndexStat ,
58- currentData . blobindexstat ,
59- currentData . result ,
60- currentData . data ,
61- ] ;
62-
63- for ( const field of possibleFields ) {
64- if ( Array . isArray ( field ) ) {
65- console . log ( 'Using field:' , field ) ;
66- return field ;
67- }
39+ if ( ! currentData ) {
40+ return [ ] ;
6841 }
69-
70- // If none of the expected fields work, try to find any array in the response
71- for ( const [ key , value ] of Object . entries ( currentData ) ) {
72- if ( Array . isArray ( value ) ) {
73- console . log ( 'Found array field:' , key , value ) ;
74- return value ;
75- }
42+
43+ // Debug: Log the actual response structure
44+ console . info ( 'VDisk BlobIndexStat Response:' , currentData ) ;
45+
46+ // Check if we have the expected structure: {stat: {tablets: [...]}}
47+ const stat = currentData . stat ;
48+ if ( ! stat || ! Array . isArray ( stat . tablets ) ) {
49+ console . info ( 'No stat.tablets array found in response' ) ;
50+ return [ ] ;
7651 }
77-
78- console . log ( 'No array found in response, returning empty array' ) ;
79- return [ ] ;
52+
53+ // Transform the nested structure into flat table rows
54+ const flatData : VDiskBlobIndexItem [ ] = [ ] ;
55+
56+ stat . tablets . forEach ( ( tablet : any ) => {
57+ const tabletId = tablet . tablet_id ;
58+ if ( ! tabletId || ! Array . isArray ( tablet . channels ) ) {
59+ return ; // Skip tablets without ID or channels
60+ }
61+
62+ tablet . channels . forEach ( ( channel : any , channelIndex : number ) => {
63+ // Only include channels that have count and data_size
64+ if ( channel . count && channel . data_size ) {
65+ flatData . push ( {
66+ TabletId : tabletId ,
67+ ChannelId : channelIndex ,
68+ Count : parseInt ( channel . count , 10 ) || 0 ,
69+ Size : parseInt ( channel . data_size , 10 ) || 0 ,
70+ } ) ;
71+ }
72+ } ) ;
73+ } ) ;
74+
75+ console . info ( 'Transformed data:' , flatData ) ;
76+ return flatData ;
8077 } , [ currentData ] ) ;
8178
8279 // Sort by size descending by default
8380 const sortedData = React . useMemo ( ( ) => {
8481 return [ ...tableData ] . sort ( ( a , b ) => {
85- const sizeA = Number ( a . Size ?? a . size ) || 0 ;
86- const sizeB = Number ( b . Size ?? b . size ) || 0 ;
82+ const sizeA = Number ( a . Size ) || 0 ;
83+ const sizeB = Number ( b . Size ) || 0 ;
8784 return sizeB - sizeA ;
8885 } ) ;
8986 } , [ tableData ] ) ;
0 commit comments