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
9914071c
Commit
9914071c
authored
Oct 01, 2018
by
David Kaltschmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dont rebuild datasource options on each render
parent
9ae6f685
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
7 deletions
+17
-7
public/app/core/utils/explore.test.ts
+1
-0
public/app/features/explore/Explore.tsx
+10
-7
public/app/types/explore.ts
+6
-0
No files found.
public/app/core/utils/explore.test.ts
View file @
9914071c
...
...
@@ -7,6 +7,7 @@ const DEFAULT_EXPLORE_STATE: ExploreState = {
datasourceLoading
:
null
,
datasourceMissing
:
false
,
datasourceName
:
''
,
exploreDatasources
:
[],
graphResult
:
null
,
history
:
[],
latency
:
0
,
...
...
public/app/features/explore/Explore.tsx
View file @
9914071c
...
...
@@ -73,6 +73,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
datasourceLoading
:
null
,
datasourceMissing
:
false
,
datasourceName
:
datasource
,
exploreDatasources
:
[],
graphResult
:
null
,
history
:
[],
latency
:
0
,
...
...
@@ -101,8 +102,13 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
throw
new
Error
(
'No datasource service passed as props.'
);
}
const
datasources
=
datasourceSrv
.
getExploreSources
();
const
exploreDatasources
=
datasources
.
map
(
ds
=>
({
value
:
ds
.
name
,
label
:
ds
.
name
,
}));
if
(
datasources
.
length
>
0
)
{
this
.
setState
({
datasourceLoading
:
true
});
this
.
setState
({
datasourceLoading
:
true
,
exploreDatasources
});
// Priority: datasource in url, default datasource, first explore datasource
let
datasource
;
if
(
datasourceName
)
{
...
...
@@ -461,12 +467,13 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
};
render
()
{
const
{
datasourceSrv
,
position
,
split
}
=
this
.
props
;
const
{
position
,
split
}
=
this
.
props
;
const
{
datasource
,
datasourceError
,
datasourceLoading
,
datasourceMissing
,
exploreDatasources
,
graphResult
,
history
,
latency
,
...
...
@@ -491,10 +498,6 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
const
logsButtonActive
=
showingLogs
?
'active'
:
''
;
const
tableButtonActive
=
showingBoth
||
showingTable
?
'active'
:
''
;
const
exploreClass
=
split
?
'explore explore-split'
:
'explore'
;
const
datasources
=
datasourceSrv
.
getExploreSources
().
map
(
ds
=>
({
value
:
ds
.
name
,
label
:
ds
.
name
,
}));
const
selectedDatasource
=
datasource
?
datasource
.
name
:
undefined
;
return
(
...
...
@@ -520,7 +523,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
clearable=
{
false
}
className=
"gf-form-input gf-form-input--form-dropdown datasource-picker"
onChange=
{
this
.
onChangeDatasource
}
options=
{
d
atasources
}
options=
{
exploreD
atasources
}
isOpen=
{
true
}
placeholder=
"Loading datasources..."
value=
{
selectedDatasource
}
...
...
public/app/types/explore.ts
View file @
9914071c
interface
ExploreDatasource
{
value
:
string
;
label
:
string
;
}
export
interface
Range
{
from
:
string
;
to
:
string
;
...
...
@@ -15,6 +20,7 @@ export interface ExploreState {
datasourceLoading
:
boolean
|
null
;
datasourceMissing
:
boolean
;
datasourceName
?:
string
;
exploreDatasources
:
ExploreDatasource
[];
graphResult
:
any
;
history
:
any
[];
latency
:
number
;
...
...
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