Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
857bd3d8
Commit
857bd3d8
authored
Nov 26, 2018
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
react-panel: Toggle Expand/Collapse json nodes in Query Inspector
parent
8254086e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
2 deletions
+39
-2
public/app/features/dashboard/dashgrid/QueryInspector.tsx
+39
-2
No files found.
public/app/features/dashboard/dashgrid/QueryInspector.tsx
View file @
857bd3d8
...
@@ -7,12 +7,20 @@ interface Props {
...
@@ -7,12 +7,20 @@ interface Props {
response
:
any
;
response
:
any
;
}
}
export
class
QueryInspector
extends
PureComponent
<
Props
>
{
interface
State
{
allNodesExpanded
:
boolean
;
}
export
class
QueryInspector
extends
PureComponent
<
Props
,
State
>
{
formattedJson
:
any
;
formattedJson
:
any
;
clipboard
:
any
;
clipboard
:
any
;
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
this
.
state
=
{
allNodesExpanded
:
null
,
};
}
}
setFormattedJson
=
formattedJson
=>
{
setFormattedJson
=
formattedJson
=>
{
...
@@ -27,8 +35,26 @@ export class QueryInspector extends PureComponent<Props> {
...
@@ -27,8 +35,26 @@ export class QueryInspector extends PureComponent<Props> {
appEvents
.
emit
(
'alert-success'
,
[
'Content copied to clipboard'
]);
appEvents
.
emit
(
'alert-success'
,
[
'Content copied to clipboard'
]);
};
};
onToggleExpand
=
()
=>
{
this
.
setState
(
prevState
=>
({
...
prevState
,
allNodesExpanded
:
!
this
.
state
.
allNodesExpanded
,
}));
};
getNrOfOpenNodes
=
()
=>
{
if
(
this
.
state
.
allNodesExpanded
===
null
)
{
return
3
;
}
else
if
(
this
.
state
.
allNodesExpanded
)
{
return
20
;
}
return
1
;
};
render
()
{
render
()
{
const
{
response
}
=
this
.
props
;
const
{
response
}
=
this
.
props
;
const
{
allNodesExpanded
}
=
this
.
state
;
const
openNodes
=
this
.
getNrOfOpenNodes
();
return
(
return
(
<>
<>
{
/* <div className="query-troubleshooter__header">
{
/* <div className="query-troubleshooter__header">
...
@@ -44,6 +70,17 @@ export class QueryInspector extends PureComponent<Props> {
...
@@ -44,6 +70,17 @@ export class QueryInspector extends PureComponent<Props> {
</div> */
}
</div> */
}
{
/* <button onClick={this.copyToClipboard}>Copy</button>
{
/* <button onClick={this.copyToClipboard}>Copy</button>
<button ref={this.copyButtonRef}>Copy2</button> */
}
<button ref={this.copyButtonRef}>Copy2</button> */
}
<
button
className=
"btn btn-transparent"
onClick=
{
this
.
onToggleExpand
}
>
{
allNodesExpanded
?
(
<>
<
i
className=
"fa fa-minus-square-o"
/>
Collapse All
</>
)
:
(
<>
<
i
className=
"fa fa-plus-square-o"
/>
Expand All
</>
)
}
</
button
>
<
CopyToClipboard
<
CopyToClipboard
className=
"btn btn-transparent"
className=
"btn btn-transparent"
...
@@ -54,7 +91,7 @@ export class QueryInspector extends PureComponent<Props> {
...
@@ -54,7 +91,7 @@ export class QueryInspector extends PureComponent<Props> {
<
i
className=
"fa fa-clipboard"
/>
Copy to Clipboard
<
i
className=
"fa fa-clipboard"
/>
Copy to Clipboard
</>
</>
</
CopyToClipboard
>
</
CopyToClipboard
>
<
JSONFormatter
json=
{
response
}
onDidRender=
{
this
.
setFormattedJson
}
/>
<
JSONFormatter
json=
{
response
}
o
pen=
{
openNodes
}
o
nDidRender=
{
this
.
setFormattedJson
}
/>
</>
</>
);
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment