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
be67801e
Commit
be67801e
authored
Nov 22, 2018
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
react-panel: Trigger panel refresh when opening inspector. Add loading-message
parent
62423799
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
8 deletions
+50
-8
public/app/features/dashboard/dashgrid/QueriesTab.tsx
+50
-8
No files found.
public/app/features/dashboard/dashgrid/QueriesTab.tsx
View file @
be67801e
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
SFC
,
PureComponent
}
from
'react'
;
import
DataSourceOption
from
'./DataSourceOption'
;
import
DataSourceOption
from
'./DataSourceOption'
;
import
{
getAngularLoader
,
AngularComponent
}
from
'app/core/services/AngularLoader'
;
import
{
getAngularLoader
,
AngularComponent
}
from
'app/core/services/AngularLoader'
;
import
{
EditorTabBody
}
from
'./EditorTabBody'
;
import
{
EditorTabBody
}
from
'./EditorTabBody'
;
...
@@ -27,12 +27,23 @@ interface Help {
...
@@ -27,12 +27,23 @@ interface Help {
helpHtml
:
any
;
helpHtml
:
any
;
}
}
interface
DsQuery
{
isLoading
:
boolean
;
response
:
{};
}
interface
State
{
interface
State
{
currentDatasource
:
DataSourceSelectItem
;
currentDatasource
:
DataSourceSelectItem
;
help
:
Help
;
help
:
Help
;
dsQuery
:
{}
;
dsQuery
:
DsQuery
;
}
}
interface
LoadingPlaceholderProps
{
text
:
string
;
}
const
LoadingPlaceholder
:
SFC
<
LoadingPlaceholderProps
>
=
({
text
})
=>
<
h2
>
{
text
}
</
h2
>;
export
class
QueriesTab
extends
PureComponent
<
Props
,
State
>
{
export
class
QueriesTab
extends
PureComponent
<
Props
,
State
>
{
element
:
any
;
element
:
any
;
component
:
AngularComponent
;
component
:
AngularComponent
;
...
@@ -44,14 +55,18 @@ export class QueriesTab extends PureComponent<Props, State> {
...
@@ -44,14 +55,18 @@ export class QueriesTab extends PureComponent<Props, State> {
const
{
panel
}
=
props
;
const
{
panel
}
=
props
;
this
.
state
=
{
this
.
state
=
{
dsQuery
:
{},
currentDatasource
:
this
.
datasources
.
find
(
datasource
=>
datasource
.
value
===
panel
.
datasource
),
currentDatasource
:
this
.
datasources
.
find
(
datasource
=>
datasource
.
value
===
panel
.
datasource
),
help
:
{
help
:
{
isLoading
:
false
,
isLoading
:
false
,
helpHtml
:
null
,
helpHtml
:
null
,
},
},
dsQuery
:
{
isLoading
:
false
,
response
:
{},
},
};
};
appEvents
.
on
(
'ds-request-response'
,
this
.
onDataSourceResponse
);
appEvents
.
on
(
'ds-request-response'
,
this
.
onDataSourceResponse
);
panel
.
events
.
on
(
'refresh'
,
this
.
onPanelRefresh
);
}
}
componentDidMount
()
{
componentDidMount
()
{
...
@@ -74,13 +89,25 @@ export class QueriesTab extends PureComponent<Props, State> {
...
@@ -74,13 +89,25 @@ export class QueriesTab extends PureComponent<Props, State> {
}
}
componentWillUnmount
()
{
componentWillUnmount
()
{
const
{
panel
}
=
this
.
props
;
appEvents
.
off
(
'ds-request-response'
,
this
.
onDataSourceResponse
);
appEvents
.
off
(
'ds-request-response'
,
this
.
onDataSourceResponse
);
panel
.
events
.
off
(
'refresh'
,
this
.
onPanelRefresh
);
if
(
this
.
component
)
{
if
(
this
.
component
)
{
this
.
component
.
destroy
();
this
.
component
.
destroy
();
}
}
}
}
onPanelRefresh
=
()
=>
{
this
.
setState
(
prevState
=>
({
...
prevState
,
dsQuery
:
{
isLoading
:
true
,
response
:
{},
},
}));
};
onDataSourceResponse
=
(
response
:
any
=
{})
=>
{
onDataSourceResponse
=
(
response
:
any
=
{})
=>
{
// ignore if closed
// ignore if closed
// if (!this.isOpen) {
// if (!this.isOpen) {
...
@@ -94,6 +121,7 @@ export class QueriesTab extends PureComponent<Props, State> {
...
@@ -94,6 +121,7 @@ export class QueriesTab extends PureComponent<Props, State> {
// this.isLoading = false;
// this.isLoading = false;
// data = _.cloneDeep(data);
// data = _.cloneDeep(data);
response
=
{
...
response
};
// clone
if
(
response
.
headers
)
{
if
(
response
.
headers
)
{
delete
response
.
headers
;
delete
response
.
headers
;
...
@@ -132,7 +160,10 @@ export class QueriesTab extends PureComponent<Props, State> {
...
@@ -132,7 +160,10 @@ export class QueriesTab extends PureComponent<Props, State> {
}
}
this
.
setState
(
prevState
=>
({
this
.
setState
(
prevState
=>
({
...
prevState
,
...
prevState
,
dsQuery
:
response
,
dsQuery
:
{
isLoading
:
false
,
response
:
response
,
},
}));
}));
};
};
...
@@ -260,14 +291,24 @@ export class QueriesTab extends PureComponent<Props, State> {
...
@@ -260,14 +291,24 @@ export class QueriesTab extends PureComponent<Props, State> {
});
});
};
};
loadQueryInspector
=
()
=>
{
const
{
panel
}
=
this
.
props
;
panel
.
refresh
();
};
renderQueryInspector
=
()
=>
{
renderQueryInspector
=
()
=>
{
const
{
dsQuery
}
=
this
.
state
;
const
{
response
,
isLoading
}
=
this
.
state
.
dsQuery
;
return
<
JSONFormatter
json=
{
dsQuery
}
/>;
return
isLoading
?
<
LoadingPlaceholder
text=
"Loading query inspector..."
/>
:
<
JSONFormatter
json=
{
response
}
/>;
};
renderHelp
=
()
=>
{
const
{
helpHtml
,
isLoading
}
=
this
.
state
.
help
;
return
isLoading
?
<
LoadingPlaceholder
text=
"Loading help..."
/>
:
helpHtml
;
};
};
render
()
{
render
()
{
const
{
currentDatasource
}
=
this
.
state
;
const
{
currentDatasource
}
=
this
.
state
;
const
{
helpHtml
}
=
this
.
state
.
help
;
const
{
hasQueryHelp
,
queryOptions
}
=
currentDatasource
.
meta
;
const
{
hasQueryHelp
,
queryOptions
}
=
currentDatasource
.
meta
;
const
hasQueryOptions
=
!!
queryOptions
;
const
hasQueryOptions
=
!!
queryOptions
;
const
dsInformation
=
{
const
dsInformation
=
{
...
@@ -286,6 +327,7 @@ export class QueriesTab extends PureComponent<Props, State> {
...
@@ -286,6 +327,7 @@ export class QueriesTab extends PureComponent<Props, State> {
const
queryInspector
=
{
const
queryInspector
=
{
title
:
'Query Inspector'
,
title
:
'Query Inspector'
,
onClick
:
this
.
loadQueryInspector
,
render
:
this
.
renderQueryInspector
,
render
:
this
.
renderQueryInspector
,
};
};
...
@@ -294,7 +336,7 @@ export class QueriesTab extends PureComponent<Props, State> {
...
@@ -294,7 +336,7 @@ export class QueriesTab extends PureComponent<Props, State> {
icon
:
'fa fa-question'
,
icon
:
'fa fa-question'
,
disabled
:
!
hasQueryHelp
,
disabled
:
!
hasQueryHelp
,
onClick
:
this
.
loadHelp
,
onClick
:
this
.
loadHelp
,
render
:
()
=>
helpHtml
,
render
:
this
.
renderHelp
,
};
};
const
options
=
{
const
options
=
{
...
...
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