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
6edc4e9f
Unverified
Commit
6edc4e9f
authored
Jan 16, 2019
by
Torkel Ödegaard
Committed by
GitHub
Jan 16, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14898 from grafana/hughag/template-variable-support-for-react-panels
Template variable support for react panels
parents
25e6d075
5c9c0244
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
7 deletions
+24
-7
packages/grafana-ui/src/types/panel.ts
+3
-0
public/app/features/dashboard/dashgrid/PanelChrome.tsx
+7
-1
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.tsx
+5
-2
public/app/features/templating/variable_srv.ts
+1
-1
public/app/plugins/panel/gauge/GaugePanel.tsx
+6
-1
public/app/viz/Gauge.tsx
+2
-2
No files found.
packages/grafana-ui/src/types/panel.ts
View file @
6edc4e9f
import
{
TimeSeries
,
LoadingState
}
from
'./series'
;
import
{
TimeRange
}
from
'./time'
;
export
type
InterpolateFunction
=
(
value
:
string
,
format
?:
string
|
Function
)
=>
string
;
export
interface
PanelProps
<
T
=
any
>
{
timeSeries
:
TimeSeries
[];
timeRange
:
TimeRange
;
...
...
@@ -9,6 +11,7 @@ export interface PanelProps<T = any> {
renderCounter
:
number
;
width
:
number
;
height
:
number
;
onInterpolate
:
InterpolateFunction
;
}
export
interface
PanelOptionsProps
<
T
=
any
>
{
...
...
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
6edc4e9f
...
...
@@ -20,6 +20,7 @@ import { PanelPlugin } from 'app/types';
import
{
TimeRange
}
from
'@grafana/ui'
;
import
variables
from
'sass/_variables.scss'
;
import
templateSrv
from
'app/features/templating/template_srv'
;
export
interface
Props
{
panel
:
PanelModel
;
...
...
@@ -78,6 +79,10 @@ export class PanelChrome extends PureComponent<Props, State> {
});
};
onInterpolate
=
(
value
:
string
,
format
?:
string
)
=>
{
return
templateSrv
.
replace
(
value
,
this
.
props
.
panel
.
scopedVars
,
format
);
};
get
isVisible
()
{
return
!
this
.
props
.
dashboard
.
otherPanelInFullscreen
(
this
.
props
.
panel
);
}
...
...
@@ -124,9 +129,10 @@ export class PanelChrome extends PureComponent<Props, State> {
timeSeries=
{
timeSeries
}
timeRange=
{
timeRange
}
options=
{
panel
.
getOptions
(
plugin
.
exports
.
PanelDefaults
)
}
width=
{
width
-
2
*
variables
.
panelHorizontalPadding
}
width=
{
width
-
2
*
variables
.
panelHorizontalPadding
}
height=
{
height
-
PANEL_HEADER_HEIGHT
-
variables
.
panelVerticalPadding
}
renderCounter=
{
renderCounter
}
onInterpolate=
{
this
.
onInterpolate
}
/>
</
div
>
);
...
...
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.tsx
View file @
6edc4e9f
...
...
@@ -3,6 +3,7 @@ import classNames from 'classnames';
import
PanelHeaderCorner
from
'./PanelHeaderCorner'
;
import
{
PanelHeaderMenu
}
from
'./PanelHeaderMenu'
;
import
templateSrv
from
'app/features/templating/template_srv'
;
import
{
DashboardModel
}
from
'app/features/dashboard/dashboard_model'
;
import
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
...
...
@@ -45,7 +46,9 @@ export class PanelHeader extends Component<Props, State> {
const
isFullscreen
=
false
;
const
isLoading
=
false
;
const
panelHeaderClass
=
classNames
({
'panel-header'
:
true
,
'grid-drag-handle'
:
!
isFullscreen
});
const
{
panel
,
dashboard
,
timeInfo
}
=
this
.
props
;
const
{
panel
,
dashboard
,
timeInfo
,
scopedVars
}
=
this
.
props
;
const
title
=
templateSrv
.
replaceWithText
(
panel
.
title
,
scopedVars
);
return
(
<>
<
PanelHeaderCorner
...
...
@@ -65,7 +68,7 @@ export class PanelHeader extends Component<Props, State> {
<
div
className=
"panel-title"
>
<
span
className=
"icon-gf panel-alert-icon"
/>
<
span
className=
"panel-title-text"
>
{
panel
.
title
}
<
span
className=
"fa fa-caret-down panel-menu-toggle"
/>
{
title
}
<
span
className=
"fa fa-caret-down panel-menu-toggle"
/>
</
span
>
{
this
.
state
.
panelMenuOpen
&&
(
...
...
public/app/features/templating/variable_srv.ts
View file @
6edc4e9f
...
...
@@ -132,7 +132,7 @@ export class VariableSrv {
return
this
.
$q
.
all
(
promises
).
then
(()
=>
{
if
(
emitChangeEvents
)
{
this
.
$rootScope
.
$emi
t
(
'template-variable-value-updated'
);
this
.
$rootScope
.
appEven
t
(
'template-variable-value-updated'
);
this
.
dashboard
.
startRefresh
();
}
});
...
...
public/app/plugins/panel/gauge/GaugePanel.tsx
View file @
6edc4e9f
...
...
@@ -8,7 +8,10 @@ interface Props extends PanelProps<GaugeOptions> {}
export
class
GaugePanel
extends
PureComponent
<
Props
>
{
render
()
{
const
{
timeSeries
,
width
,
height
}
=
this
.
props
;
const
{
timeSeries
,
width
,
height
,
onInterpolate
,
options
}
=
this
.
props
;
const
prefix
=
onInterpolate
(
options
.
prefix
);
const
suffix
=
onInterpolate
(
options
.
suffix
);
const
vmSeries
=
getTimeSeriesVMs
({
timeSeries
:
timeSeries
,
...
...
@@ -21,6 +24,8 @@ export class GaugePanel extends PureComponent<Props> {
{
...
this
.
props
.
options
}
width=
{
width
}
height=
{
height
}
prefix=
{
prefix
}
suffix=
{
suffix
}
/>
);
}
...
...
public/app/viz/Gauge.tsx
View file @
6edc4e9f
...
...
@@ -80,9 +80,9 @@ export class Gauge extends PureComponent<Props> {
const
{
rangeMap
,
valueMap
}
=
this
.
formatWithMappings
(
mappings
,
formattedValue
);
if
(
valueMap
)
{
return
valueMap
;
return
`
${
prefix
}
${
valueMap
}
${
suffix
}
`
;
}
else
if
(
rangeMap
)
{
return
rangeMap
;
return
`
${
prefix
}
${
rangeMap
}
${
suffix
}
`
;
}
}
...
...
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