@@ -48,7 +48,6 @@ function getEdgeColor(isDarkTheme: boolean) {
48
48
49
49
export default function Explain ( props : IExplain ) : JSX . Element {
50
50
const command = props . command . split ( ' ' ) [ 0 ] . toLowerCase ( )
51
-
52
51
if ( command . startsWith ( 'graph' ) ) {
53
52
const info = props . data [ 0 ] . response
54
53
const resp = ParseGraphV2 ( info )
@@ -83,6 +82,15 @@ export default function Explain(props: IExplain): JSX.Element {
83
82
let [ cluster , entityInfo ] = ParseProfileCluster ( info )
84
83
cluster [ 'Coordinator' ] . forEach ( ( kv : [ string , string ] ) => profilingTime [ kv [ 0 ] ] = kv [ 1 ] )
85
84
data = entityInfo
85
+ } else if ( typeof info [ 0 ] === 'string' && info [ 0 ] . toLowerCase ( ) . startsWith ( 'coordinator' ) ) {
86
+ const resultsProfile = info [ 2 ]
87
+ data = ParseProfile ( resultsProfile )
88
+ profilingTime = {
89
+ 'Total Coordinator time' : info [ 4 ] ,
90
+ 'Total profile time' : resultsProfile [ 0 ] [ 1 ] ,
91
+ 'Parsing time' : resultsProfile [ 1 ] [ 1 ] ,
92
+ 'Pipeline creation time' : resultsProfile [ 2 ] [ 1 ] ,
93
+ }
86
94
} else {
87
95
data = ParseProfile ( info )
88
96
profilingTime = {
@@ -140,7 +148,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
140
148
const container = useRef < HTMLDivElement | null > ( null )
141
149
142
150
const [ done , setDone ] = useState ( false )
143
- const [ collapse , setCollapse ] = useState ( true )
151
+ const [ collapse , setCollapse ] = useState ( type !== CoreType . Profile )
144
152
const [ isFullScreen , setIsFullScreen ] = useState ( false )
145
153
const [ core , setCore ] = useState < Graph > ( )
146
154
@@ -151,15 +159,15 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
151
159
if ( isFullScreen ) {
152
160
setIsFullScreen ( true )
153
161
const height = Math . max ( ( b ?. height || 585 ) + 100 , parent . document . body . offsetHeight )
154
- if ( collapse ) {
162
+ if ( type !== CoreType . Profile && collapse ) {
155
163
core ?. resize ( width , window . outerHeight - 250 )
156
164
core ?. positionContent ( "top" )
157
165
} else {
158
166
core ?. resize ( width , height )
159
167
}
160
168
} else {
161
169
setIsFullScreen ( false )
162
- if ( collapse ) {
170
+ if ( type !== CoreType . Profile && collapse ) {
163
171
core ?. resize ( width , 400 )
164
172
core ?. positionContent ( "top" )
165
173
} else {
@@ -236,45 +244,6 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
236
244
} )
237
245
} )
238
246
239
- const ele = document . querySelector ( "#container-parent" )
240
-
241
- let pos = { top : 0 , left : 0 , x : 0 , y : 0 }
242
-
243
- const mouseMoveHandler = function ( e ) {
244
- // How far the mouse has been moved
245
- const dx = e . clientX - pos . x
246
- const dy = e . clientY - pos . y
247
-
248
- // Scroll the element
249
- if ( ele ) {
250
- ele . scrollTop = pos . top - dy
251
- ele . scrollLeft = pos . left - dx
252
- }
253
- }
254
-
255
-
256
- const mouseUpHandler = function ( ) {
257
- document . removeEventListener ( 'mousemove' , mouseMoveHandler )
258
- document . removeEventListener ( 'mouseup' , mouseUpHandler )
259
- }
260
-
261
-
262
- const mouseDownHandler = function ( e ) {
263
- pos = {
264
- // The current scroll
265
- left : ele ?. scrollLeft || 0 ,
266
- top : ele ?. scrollTop || 0 ,
267
- // Get the current mouse position
268
- x : e . clientX ,
269
- y : e . clientY ,
270
- }
271
-
272
- document . addEventListener ( 'mousemove' , mouseMoveHandler )
273
- setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
274
- }
275
-
276
- ele ?. addEventListener ( 'mousedown' , mouseDownHandler )
277
-
278
247
resize ( )
279
248
280
249
const result = Hierarchy . compactBox ( data , {
@@ -426,7 +395,47 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
426
395
427
396
} , [ done ] )
428
397
429
- if ( collapse ) {
398
+ const ele = document . querySelector ( "#container-parent" )
399
+
400
+ let pos = { top : 0 , left : 0 , x : 0 , y : 0 }
401
+
402
+ const mouseMoveHandler = function ( e ) {
403
+ // How far the mouse has been moved
404
+ const dx = e . clientX - pos . x
405
+ const dy = e . clientY - pos . y
406
+
407
+ // Scroll the element
408
+ if ( ele ) {
409
+ ele . scrollTop = pos . top - dy
410
+ ele . scrollLeft = pos . left - dx
411
+ }
412
+ }
413
+
414
+
415
+ const mouseUpHandler = function ( ) {
416
+ document . removeEventListener ( 'mousemove' , mouseMoveHandler )
417
+ document . removeEventListener ( 'mouseup' , mouseUpHandler )
418
+ }
419
+
420
+
421
+ const mouseDownHandler = function ( e ) {
422
+ pos = {
423
+ // The current scroll
424
+ left : ele ?. scrollLeft || 0 ,
425
+ top : ele ?. scrollTop || 0 ,
426
+ // Get the current mouse position
427
+ x : e . clientX ,
428
+ y : e . clientY ,
429
+ }
430
+
431
+ document . addEventListener ( 'mousemove' , mouseMoveHandler )
432
+ setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
433
+ }
434
+
435
+ ele ?. addEventListener ( 'mousedown' , mouseDownHandler )
436
+
437
+
438
+ if ( type !== CoreType . Profile && collapse ) {
430
439
core ?. resize ( undefined , isFullScreen ? ( window . outerHeight - 250 ) : 400 )
431
440
core ?. positionContent ( "top" )
432
441
} else {
@@ -435,23 +444,24 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
435
444
436
445
return (
437
446
< div >
438
- { collapse && < div style = { { paddingTop : '50px' } } > </ div > }
447
+ { type !== CoreType . Profile && collapse && < div style = { { paddingTop : '50px' } } > </ div > }
439
448
< div
440
449
id = "container-parent"
441
450
style = { {
442
- height : isFullScreen ? ( window . outerHeight - 170 ) + 'px' : collapse ? '500px' : '585px' ,
451
+ height : isFullScreen ? ( window . outerHeight - 170 ) + 'px' : type !== CoreType . Profile && collapse ? '500px' : '585px' ,
443
452
width : '100%' ,
444
453
overflow : 'auto' ,
445
454
} }
446
455
>
447
456
< div style = { { margin : 0 , width : '100vw' } } ref = { container } id = "container" />
448
- { ! collapse && (
457
+ { ! ( collapse ) && (
449
458
< div className = "ZoomMenu" >
450
459
{
451
460
[
452
461
{
453
462
name : 'Zoom In' ,
454
463
onClick : ( ) => {
464
+ setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
455
465
core ?. zoom ( 0.5 )
456
466
core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
457
467
} ,
@@ -460,6 +470,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
460
470
{
461
471
name : 'Zoom Out' ,
462
472
onClick : ( ) => {
473
+ setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
463
474
core && Math . floor ( core . zoom ( ) ) <= 0.5 ? core ?. zoom ( 0 ) : core ?. zoom ( - 0.5 )
464
475
core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
465
476
} ,
@@ -468,6 +479,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
468
479
{
469
480
name : 'Reset Zoom' ,
470
481
onClick : ( ) => {
482
+ setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
471
483
core ?. zoomTo ( 1 )
472
484
core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
473
485
} ,
@@ -486,32 +498,35 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
486
498
}
487
499
</ div >
488
500
) }
489
- < div
490
- style = { { paddingBottom : ( isFullScreen && profilingTime && ModuleType . Search ? '60px' : '35px' ) } }
491
- className = "CollapseButton"
492
- onClick = { e => {
493
- e . preventDefault ( )
494
- if ( ! collapse ) { // About to collapse?
495
- core ?. zoomTo ( 1 )
496
- core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
501
+ { type !== CoreType . Profile &&
502
+ < div
503
+ style = { { paddingBottom : ( isFullScreen && profilingTime && ModuleType . Search ? '60px' : '35px' ) } }
504
+ className = "CollapseButton"
505
+ onClick = { e => {
506
+ e . preventDefault ( )
507
+ setTimeout ( ( ) => document . addEventListener ( 'mouseup' , mouseUpHandler ) , 100 )
508
+ if ( ! collapse ) { // About to collapse?
509
+ core ?. zoomTo ( 1 )
510
+ core ?. resize ( undefined , core ?. getContentBBox ( ) . height + 50 )
511
+ }
512
+ setCollapse ( ! collapse )
513
+ } }
514
+ >
515
+ {
516
+ collapse
517
+ ?
518
+ < >
519
+ < div > Expand</ div >
520
+ < EuiIcon className = "NodeIcon" size = "m" type = "arrowDown" />
521
+ </ >
522
+ :
523
+ < >
524
+ < div > Collapse</ div >
525
+ < EuiIcon className = "NodeIcon" size = "m" type = "arrowUp" />
526
+ </ >
497
527
}
498
- setCollapse ( ! collapse )
499
- } }
500
- >
501
- {
502
- collapse
503
- ?
504
- < >
505
- < div > Expand</ div >
506
- < EuiIcon className = "NodeIcon" size = "m" type = "arrowDown" />
507
- </ >
508
- :
509
- < >
510
- < div > Collapse</ div >
511
- < EuiIcon className = "NodeIcon" size = "m" type = "arrowUp" />
512
- </ >
513
- }
514
- </ div >
528
+ </ div >
529
+ }
515
530
{ profilingTime &&
516
531
(
517
532
module === ModuleType . Search &&
0 commit comments