@@ -2,6 +2,7 @@ import React, { useEffect, useState, useRef } from 'react'
2
2
import { Model , Graph } from '@antv/x6'
3
3
import { register } from '@antv/x6-react-shape'
4
4
import Hierarchy from '@antv/hierarchy'
5
+ import { formatRedisReply } from 'redisinsight-plugin-sdk'
5
6
6
7
import {
7
8
EuiButtonIcon ,
@@ -72,6 +73,18 @@ export default function Explain(props: IExplain): JSX.Element {
72
73
73
74
const module = ModuleType . Search
74
75
76
+ const [ parsedRedisReply , setParsedRedisReply ] = useState ( '' )
77
+
78
+ useEffect ( ( ) => {
79
+ if ( command == 'ft.profile' ) {
80
+ const getParsedResponse = async ( ) => {
81
+ const formattedResponse = await formatRedisReply ( props . data [ 0 ] . response , props . command )
82
+ setParsedRedisReply ( formattedResponse )
83
+ }
84
+ getParsedResponse ( )
85
+ }
86
+ } )
87
+
75
88
if ( command == 'ft.profile' ) {
76
89
const info = props . data [ 0 ] . response [ 1 ]
77
90
@@ -82,6 +95,12 @@ export default function Explain(props: IExplain): JSX.Element {
82
95
let [ cluster , entityInfo ] = ParseProfileCluster ( info )
83
96
cluster [ 'Coordinator' ] . forEach ( ( kv : [ string , string ] ) => profilingTime [ kv [ 0 ] ] = kv [ 1 ] )
84
97
data = entityInfo
98
+ return (
99
+ < >
100
+ < div className = "responseFail" > Visualization is not supported for a clustered database.</ div >
101
+ < div className = "parsedRedisReply" > { parsedRedisReply } </ div >
102
+ </ >
103
+ )
85
104
} else if ( typeof info [ 0 ] === 'string' && info [ 0 ] . toLowerCase ( ) . startsWith ( 'coordinator' ) ) {
86
105
const resultsProfile = info [ 2 ]
87
106
data = ParseProfile ( resultsProfile )
@@ -91,6 +110,12 @@ export default function Explain(props: IExplain): JSX.Element {
91
110
'Parsing time' : resultsProfile [ 1 ] [ 1 ] ,
92
111
'Pipeline creation time' : resultsProfile [ 2 ] [ 1 ] ,
93
112
}
113
+ return (
114
+ < >
115
+ < div className = "responseFail" > Visualization is not supported for a clustered database.</ div >
116
+ < div className = "parsedRedisReply" > { parsedRedisReply } </ div >
117
+ </ >
118
+ )
94
119
} else {
95
120
data = ParseProfile ( info )
96
121
profilingTime = {
@@ -213,11 +238,6 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
213
238
line : {
214
239
stroke : edgeColor ,
215
240
strokeWidth : ( edge . getAttrs ( ) as any ) ?. line ?. strokeWidth ,
216
- targetMarker : {
217
- name : 'block' ,
218
- stroke : edgeColor ,
219
- fill : edgeColor ,
220
- } ,
221
241
} ,
222
242
} )
223
243
} )
@@ -234,11 +254,6 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
234
254
line : {
235
255
stroke : edgeColor ,
236
256
strokeWidth : ( edge . getAttrs ( ) as any ) ?. line ?. strokeWidth ,
237
- targetMarker : {
238
- name : 'block' ,
239
- fill : edgeColor ,
240
- stroke : edgeColor ,
241
- }
242
257
} ,
243
258
} )
244
259
} )
@@ -270,8 +285,14 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
270
285
if ( data ) {
271
286
const info = data . data as EntityInfo
272
287
273
- if ( ! info . snippet && info . parentSnippet && info . data ?. startsWith ( info . parentSnippet ) ) {
274
- info . data = info . data . substr ( info . parentSnippet . length )
288
+ // snippet if prefix with parent suffix will always be followed by ':'.
289
+ //
290
+ // Currently snippets are passed to child only for TAG
291
+ // expressions which has ':' at the center.
292
+ //
293
+ // Example child data with parent snippet: <PARENT_SNIPPET>:<DATA>
294
+ if ( ! info . snippet && info . parentSnippet && info . data ?. startsWith ( `${ info . parentSnippet } :` ) ) {
295
+ info . data = info . data . substr ( info . parentSnippet . length + 1 )
275
296
info . snippet = info . parentSnippet
276
297
}
277
298
@@ -375,11 +396,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
375
396
line : {
376
397
stroke : edgeColor ,
377
398
strokeWidth : getEdgeSize ( itemRecords ) ,
378
- targetMarker : {
379
- name : 'block' ,
380
- fill : edgeColor ,
381
- stroke : edgeColor ,
382
- } ,
399
+ targetMarker : null ,
383
400
} ,
384
401
} ,
385
402
} )
@@ -462,7 +479,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
462
479
name : 'Zoom In' ,
463
480
onClick : ( ) => {
464
481
setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
465
- core ?. zoom ( 0.5 )
482
+ core && Math . floor ( core . zoom ( ) ) <= 3 && core ?. zoom ( 0.5 )
466
483
core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
467
484
} ,
468
485
icon : 'magnifyWithPlus'
@@ -471,7 +488,11 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
471
488
name : 'Zoom Out' ,
472
489
onClick : ( ) => {
473
490
setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
474
- core && Math . floor ( core . zoom ( ) ) <= 0.5 ? core ?. zoom ( 0 ) : core ?. zoom ( - 0.5 )
491
+ if ( Math . floor ( core ?. zoom ( ) || 0 ) <= 0.5 ) {
492
+ core ?. centerContent ( )
493
+ } else {
494
+ core ?. zoom ( - 0.5 )
495
+ }
475
496
core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
476
497
} ,
477
498
icon : 'magnifyWithMinus'
0 commit comments