Skip to content

Commit 5d54e87

Browse files
committed
- Calculate edge size using log.
- Use outline instead of border to apply the box edge styling outside the box. - Add different profiling time for redisgraph PROFILE.
1 parent d8b3889 commit 5d54e87

File tree

4 files changed

+81
-101
lines changed

4 files changed

+81
-101
lines changed

redisinsight/ui/src/packages/ri-explain/src/Explain.tsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface IExplain {
2222
}
2323

2424
function getEdgeSize(c: number) {
25-
return (Math.log(c || 1) / Math.log(10)) + 1
25+
return Math.floor(Math.log(c || 1) + 1)
2626
}
2727

2828
export default function Explain(props: IExplain): JSX.Element {
@@ -151,7 +151,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
151151
const ancestors = GetAncestors(data, id, {found: false, pairs: []})
152152
ancestors.pairs.forEach(p => {
153153
// Highlight ancestor and their ancestor
154-
document.querySelector(`#node-${p[0]}`)?.setAttribute("style", "border: 1px solid #85A2FE !important;")
154+
document.querySelector(`#node-${p[0]}`)?.setAttribute("style", "outline: 1px solid #85A2FE !important;")
155155

156156
// Get edge size of parent ancestor to apply the right edge stroke
157157
const strokeSize = getEdgeSize(parseInt((document.querySelector(`#node-${p[1]}`) as HTMLElement)?.dataset?.size || '')) + 1
@@ -300,18 +300,26 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
300300
return (
301301
<div>
302302
<div style={{ margin: 0, width: '100vw' }} ref={container} id="container" />
303-
{ profilingTime && (
304-
<div style={{ width: infoWidth}} id="profile-time-info" className="ProfileTimeInfo">
305-
{
306-
Object.keys(profilingTime).map(key => (
307-
<div className="Item">
308-
<div className="Value">{profilingTime[key]}</div>
309-
<div className="Key">{key}</div>
303+
{ profilingTime &&
304+
(
305+
module === ModuleType.Search ?
306+
(
307+
<div style={{ width: infoWidth}} className="ProfileInfo ProfileTimeInfo">
308+
{
309+
Object.keys(profilingTime).map(key => (
310+
<div className="Item">
311+
<div className="Value">{profilingTime[key]}</div>
312+
<div className="Key">{key}</div>
313+
</div>
314+
))
315+
}
310316
</div>
311-
))
312-
}
313-
</div>
314-
)}
317+
)
318+
:
319+
type === CoreType.Profile && (
320+
<div style={{ width: infoWidth }} className="ProfileInfo ProfileTimeMini">Total execution time: {profilingTime['Total Execution Time']} ms</div>
321+
)
322+
)}
315323
</div>
316324
)
317325
}

redisinsight/ui/src/packages/ri-explain/src/Node.tsx

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ interface INodeProps {
1010
}
1111

1212

13+
function Snippet({content}: {content: string}) {
14+
return (
15+
<div className="FooterCommon Footer">
16+
<EuiToolTip delay='long' content={content}><span>{content}</span></EuiToolTip>
17+
</div>
18+
)
19+
}
20+
1321
export function ExplainNode(props: INodeProps) {
1422
const propData: EntityInfo = (props as any).node.getData()
1523
const { id, type, data, snippet, subType } = propData
@@ -22,11 +30,7 @@ export function ExplainNode(props: INodeProps) {
2230
</div>
2331
</div>
2432
{
25-
snippet && (
26-
<div className='Footer'>
27-
{snippet}
28-
</div>
29-
)
33+
snippet && <Snippet content={snippet} />
3034
}
3135
</div>
3236
)
@@ -76,28 +80,37 @@ export function ProfileNode(props: INodeProps) {
7680
}
7781

7882
const timeInFloat = parseFloat(time || '')
79-
const timeStyles = {
80-
fontWeight: 'bold',
83+
let timeStyles: React.CSSProperties = {
8184
color: 'white',
82-
backgroundColor: (timeInFloat > 45 ? 'red' : timeInFloat > 25 ? 'yellow' : ''),
8385
}
8486

87+
if (timeInFloat > 250) {
88+
timeStyles = {
89+
...timeStyles,
90+
backgroundColor: 'red',
91+
paddingRight: '4px',
92+
paddingLeft: '2px',
93+
borderRadius: '5px',
94+
}
95+
} else if (timeInFloat > 49) {
96+
timeStyles['color'] = 'red'
97+
} else if (timeInFloat > 24) {
98+
timeStyles['color'] = 'yellow'
99+
}
100+
101+
85102
return (
86103
<div className="ProfileContainer" id={`node-${id}`} data-size={counter || size || recordsProduced}>
87104
<div className="Main">
88105
<div>{data ? data : type}</div>
89106
<div className="Type">{[EntityType.GEO, EntityType.NUMERIC, EntityType.TEXT, EntityType.TAG].includes(type) ? type : ''}</div>
90107
</div>
91108
{
92-
snippet && (
93-
<div className='Footer'>
94-
{snippet}
95-
</div>
96-
)
109+
snippet && <Snippet content={snippet} />
97110
}
98111
<div className="MetaData">
99112
<EuiToolTip content={<NodeToolTipContent content={"Execution Time"} />}>
100-
<div className="Time" style={timeInFloat > 25 ? timeStyles : {}}>
113+
<div className="Time" style={timeStyles}>
101114
<div className="IconContainer"><EuiIcon className="NodeIcon" size="m" type="clock" /></div>
102115
<div>{time} ms</div>
103116
</div>

redisinsight/ui/src/packages/ri-explain/src/parser.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,6 @@ class Parser {
416416
this.CurrentToken = this.PeekToken
417417
this.PeekToken = this.L.NextToken()
418418

419-
console.log("NEXT TOKEN", this.CurrentToken)
420-
421419
if (this.CurrentToken.T === TokenType.EOF) {
422420
throw new Error("Didn't expect EOF token")
423421
}

redisinsight/ui/src/packages/ri-explain/src/styles/styles.less

Lines changed: 33 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,28 @@
8080
background-color: var(--tooltip-background) !important;
8181
}
8282

83+
84+
.euiToolTipAnchor {
85+
display: unset !important;
86+
}
87+
88+
.FooterCommon {
89+
white-space: nowrap;
90+
overflow: hidden;
91+
text-overflow: ellipsis;
92+
93+
color: var(--node-metadata-color);
94+
font-size: 12px;
95+
96+
97+
// Make text selectable
98+
-moz-user-select: text;
99+
-khtml-user-select: text;
100+
-webkit-user-select: text;
101+
-ms-user-select: text;
102+
user-select: text;
103+
}
104+
83105
.ProfileContainer {
84106
width: 320px;
85107
min-height: 84px;
@@ -100,7 +122,7 @@
100122
color: var(--text-color);
101123

102124
&:hover {
103-
border: 2px solid #85A2FE !important;
125+
outline: 2px solid #85A2FE !important;
104126
box-sizing: border-box;
105127
}
106128

@@ -123,11 +145,9 @@
123145
}
124146

125147
.Footer{
126-
font-size: 12px;
127148
padding-top: 4px;
128149
padding-bottom: 12px;
129150
height: auto;
130-
color: #B5B6C0;
131151
}
132152

133153
.MetaData {
@@ -192,7 +212,7 @@
192212
background-color: var(--node-background);
193213

194214
&:hover {
195-
border: 2px solid #85A2FE !important;
215+
outline: 2px solid #85A2FE !important;
196216
box-sizing: border-box;
197217
}
198218

@@ -214,87 +234,24 @@
214234

215235
.Footer{
216236
height: 24px;
217-
font-size: 12px;
218237
padding-top: 6px;
219-
color: #B5B6C0;
220238
}
221239
}
222240

223241

224-
.NodeContainer {
225-
width: 320px;
226-
height: 114px;
227-
228-
box-shadow: 0px 3px 12px #17336952;
229-
border: 1px solid #3D3D3D !important;
230-
border-radius: 4px;
231-
opacity: 1;
232-
233-
padding: 12px 18px 12px 18px !important;
234-
242+
.ProfileInfo {
235243
display: flex;
236-
flex-direction: column;
237-
justify-content: space-around;
238-
}
244+
justify-content: center;
245+
color: var(--text-color);
239246

240-
.NodeHeader {
241-
display: flex;
242-
flex-direction: column;
243-
justify-content: space-between;
247+
font-family: 'Graphik', sans-serif !important;
244248
font-size: 13px;
245-
height: 18px;
246-
247-
.NodeHeaderInfo {
248-
display: flex;
249-
justify-content: space-between;
250-
}
251-
252-
.NodeHeaderMetadata{
253-
display: flex;
254-
justify-content: space-between;
255-
256-
padding-top: 10px;
257-
padding-bottom: 10px;
258-
259-
.MetadataSnippet {
260-
font-family: monospace !important;
261-
}
262-
263-
.MetadataCount {
264-
display: flex;
265-
}
266-
267-
}
268-
269-
270-
.NodeIcon {
271-
height: 13px !important;
272-
width: 13px !important;
273-
}
274-
275-
276-
.NodeToolTip {
277-
display: flex;
278-
flex-direction: column;
279-
background-color: #333D4F;
280-
padding: 10px;
281-
282-
.NodeToolTipItem {
283-
background-color: inherit;
284-
}
285-
286-
}
287249

250+
padding-bottom: 13px !important;
288251
}
289252

290253
.ProfileTimeInfo {
291-
display: flex;
292-
justify-content: center;
293-
color: var(--text-color);
294-
295-
font-family: 'Graphik' Light, sans-serif !important;
296254
padding-top: 6px !important;
297-
padding-bottom: 13px !important;
298255

299256
.Item {
300257

@@ -313,6 +270,10 @@
313270
}
314271
}
315272

273+
.ProfileTimeMini {
274+
background-color: var(--svg-background);
275+
}
276+
316277
.NodeType {
317278
color: #CE915B;
318279
}

0 commit comments

Comments
 (0)