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
327d1d75
Unverified
Commit
327d1d75
authored
Mar 07, 2019
by
Torkel Ödegaard
Committed by
GitHub
Mar 07, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15841 from ryantxu/fix-15840
return the same panelData unless it changes
parents
10d50ea7
82326fed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
18 deletions
+37
-18
public/app/features/dashboard/dashgrid/DataPanel.tsx
+6
-6
public/app/plugins/panel/gauge/GaugePanel.tsx
+31
-12
No files found.
public/app/features/dashboard/dashgrid/DataPanel.tsx
View file @
327d1d75
...
@@ -44,6 +44,7 @@ export interface State {
...
@@ -44,6 +44,7 @@ export interface State {
isFirstLoad
:
boolean
;
isFirstLoad
:
boolean
;
loading
:
LoadingState
;
loading
:
LoadingState
;
response
:
DataQueryResponse
;
response
:
DataQueryResponse
;
panelData
:
PanelData
;
}
}
export
class
DataPanel
extends
Component
<
Props
,
State
>
{
export
class
DataPanel
extends
Component
<
Props
,
State
>
{
...
@@ -63,6 +64,7 @@ export class DataPanel extends Component<Props, State> {
...
@@ -63,6 +64,7 @@ export class DataPanel extends Component<Props, State> {
response
:
{
response
:
{
data
:
[],
data
:
[],
},
},
panelData
:
{},
isFirstLoad
:
true
,
isFirstLoad
:
true
,
};
};
}
}
...
@@ -147,6 +149,7 @@ export class DataPanel extends Component<Props, State> {
...
@@ -147,6 +149,7 @@ export class DataPanel extends Component<Props, State> {
this
.
setState
({
this
.
setState
({
loading
:
LoadingState
.
Done
,
loading
:
LoadingState
.
Done
,
response
:
resp
,
response
:
resp
,
panelData
:
this
.
getPanelData
(
resp
),
isFirstLoad
:
false
,
isFirstLoad
:
false
,
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -169,9 +172,7 @@ export class DataPanel extends Component<Props, State> {
...
@@ -169,9 +172,7 @@ export class DataPanel extends Component<Props, State> {
}
}
};
};
getPanelData
=
()
=>
{
getPanelData
(
response
:
DataQueryResponse
)
{
const
{
response
}
=
this
.
state
;
if
(
response
.
data
.
length
>
0
&&
(
response
.
data
[
0
]
as
TableData
).
type
===
'table'
)
{
if
(
response
.
data
.
length
>
0
&&
(
response
.
data
[
0
]
as
TableData
).
type
===
'table'
)
{
return
{
return
{
tableData
:
response
.
data
[
0
]
as
TableData
,
tableData
:
response
.
data
[
0
]
as
TableData
,
...
@@ -183,12 +184,11 @@ export class DataPanel extends Component<Props, State> {
...
@@ -183,12 +184,11 @@ export class DataPanel extends Component<Props, State> {
timeSeries
:
response
.
data
as
TimeSeries
[],
timeSeries
:
response
.
data
as
TimeSeries
[],
tableData
:
null
,
tableData
:
null
,
};
};
}
;
}
render
()
{
render
()
{
const
{
queries
}
=
this
.
props
;
const
{
queries
}
=
this
.
props
;
const
{
loading
,
isFirstLoad
}
=
this
.
state
;
const
{
loading
,
isFirstLoad
,
panelData
}
=
this
.
state
;
const
panelData
=
this
.
getPanelData
();
// do not render component until we have first data
// do not render component until we have first data
if
(
isFirstLoad
&&
(
loading
===
LoadingState
.
Loading
||
loading
===
LoadingState
.
NotStarted
))
{
if
(
isFirstLoad
&&
(
loading
===
LoadingState
.
Loading
||
loading
===
LoadingState
.
NotStarted
))
{
...
...
public/app/plugins/panel/gauge/GaugePanel.tsx
View file @
327d1d75
// Libraries
// Libraries
import
React
,
{
Pure
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
// Services & Utils
// Services & Utils
import
{
processTimeSeries
,
ThemeContext
}
from
'@grafana/ui'
;
import
{
processTimeSeries
,
ThemeContext
}
from
'@grafana/ui'
;
...
@@ -12,15 +12,27 @@ import { GaugeOptions } from './types';
...
@@ -12,15 +12,27 @@ import { GaugeOptions } from './types';
import
{
PanelProps
,
NullValueMode
,
TimeSeriesValue
}
from
'@grafana/ui/src/types'
;
import
{
PanelProps
,
NullValueMode
,
TimeSeriesValue
}
from
'@grafana/ui/src/types'
;
interface
Props
extends
PanelProps
<
GaugeOptions
>
{}
interface
Props
extends
PanelProps
<
GaugeOptions
>
{}
interface
State
{
value
:
TimeSeriesValue
;
}
export
class
GaugePanel
extends
PureComponent
<
Props
>
{
export
class
GaugePanel
extends
Component
<
Props
,
State
>
{
render
()
{
constructor
(
props
:
Props
)
{
const
{
panelData
,
width
,
height
,
replaceVariables
,
options
}
=
this
.
props
;
super
(
props
);
const
{
valueOptions
}
=
options
;
this
.
state
=
{
value
:
this
.
findValue
(
props
),
};
}
const
prefix
=
replaceVariables
(
valueOptions
.
prefix
);
componentDidUpdate
(
prevProps
:
Props
)
{
const
suffix
=
replaceVariables
(
valueOptions
.
suffix
);
if
(
this
.
props
.
panelData
!==
prevProps
.
panelData
)
{
let
value
:
TimeSeriesValue
;
this
.
setState
({
value
:
this
.
findValue
(
this
.
props
)
});
}
}
findValue
(
props
:
Props
):
number
|
null
{
const
{
panelData
,
options
}
=
props
;
const
{
valueOptions
}
=
options
;
if
(
panelData
.
timeSeries
)
{
if
(
panelData
.
timeSeries
)
{
const
vmSeries
=
processTimeSeries
({
const
vmSeries
=
processTimeSeries
({
...
@@ -29,14 +41,21 @@ export class GaugePanel extends PureComponent<Props> {
...
@@ -29,14 +41,21 @@ export class GaugePanel extends PureComponent<Props> {
});
});
if
(
vmSeries
[
0
])
{
if
(
vmSeries
[
0
])
{
value
=
vmSeries
[
0
].
stats
[
valueOptions
.
stat
];
return
vmSeries
[
0
].
stats
[
valueOptions
.
stat
];
}
else
{
value
=
null
;
}
}
}
else
if
(
panelData
.
tableData
)
{
}
else
if
(
panelData
.
tableData
)
{
value
=
panelData
.
tableData
.
rows
[
0
].
find
(
prop
=>
prop
>
0
);
return
panelData
.
tableData
.
rows
[
0
].
find
(
prop
=>
prop
>
0
);
}
}
return
null
;
}
render
()
{
const
{
width
,
height
,
replaceVariables
,
options
}
=
this
.
props
;
const
{
valueOptions
}
=
options
;
const
{
value
}
=
this
.
state
;
const
prefix
=
replaceVariables
(
valueOptions
.
prefix
);
const
suffix
=
replaceVariables
(
valueOptions
.
suffix
);
return
(
return
(
<
ThemeContext
.
Consumer
>
<
ThemeContext
.
Consumer
>
{
theme
=>
(
{
theme
=>
(
...
...
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