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
36a2b9c0
Unverified
Commit
36a2b9c0
authored
Jan 31, 2019
by
Torkel Ödegaard
Committed by
GitHub
Jan 31, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15136 from grafana/react-snapshots
React snapshots
parents
f643e2ab
4b47e857
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
36 deletions
+71
-36
public/app/features/dashboard/dashboard_model.ts
+4
-0
public/app/features/dashboard/dashgrid/DataPanel.tsx
+18
-6
public/app/features/dashboard/dashgrid/PanelChrome.tsx
+47
-28
public/app/features/dashboard/panel_model.ts
+2
-2
No files found.
public/app/features/dashboard/dashboard_model.ts
View file @
36a2b9c0
...
...
@@ -811,6 +811,10 @@ export class DashboardModel {
return
this
.
getTimezone
()
===
'utc'
;
}
isSnapshot
()
{
return
this
.
snapshot
!==
undefined
;
}
getTimezone
()
{
return
this
.
timezone
?
this
.
timezone
:
contextSrv
.
user
.
timezone
;
}
...
...
public/app/features/dashboard/dashgrid/DataPanel.tsx
View file @
36a2b9c0
...
...
@@ -3,15 +3,12 @@ import React, { Component } from 'react';
import
{
Tooltip
}
from
'@grafana/ui'
;
import
ErrorBoundary
from
'app/core/components/ErrorBoundary/ErrorBoundary'
;
// Services
import
{
getDatasourceSrv
,
DatasourceSrv
}
from
'app/features/plugins/datasource_srv'
;
import
{
DatasourceSrv
,
getDatasourceSrv
}
from
'app/features/plugins/datasource_srv'
;
// Utils
import
kbn
from
'app/core/utils/kbn'
;
// Types
import
{
TimeRange
,
TimeSeries
,
LoadingState
,
DataQueryResponse
,
DataQueryOption
s
}
from
'@grafana/ui/src/types'
;
import
{
DataQueryOptions
,
DataQueryResponse
,
LoadingState
,
TimeRange
,
TimeSerie
s
}
from
'@grafana/ui/src/types'
;
const
DEFAULT_PLUGIN_ERROR
=
'Error in plugin'
;
...
...
@@ -32,6 +29,7 @@ export interface Props {
minInterval
?:
string
;
maxDataPoints
?:
number
;
children
:
(
r
:
RenderProps
)
=>
JSX
.
Element
;
onDataResponse
?:
(
data
:
DataQueryResponse
)
=>
void
;
}
export
interface
State
{
...
...
@@ -85,7 +83,17 @@ export class DataPanel extends Component<Props, State> {
}
private
issueQueries
=
async
()
=>
{
const
{
isVisible
,
queries
,
datasource
,
panelId
,
dashboardId
,
timeRange
,
widthPixels
,
maxDataPoints
}
=
this
.
props
;
const
{
isVisible
,
queries
,
datasource
,
panelId
,
dashboardId
,
timeRange
,
widthPixels
,
maxDataPoints
,
onDataResponse
,
}
=
this
.
props
;
if
(
!
isVisible
)
{
return
;
...
...
@@ -127,6 +135,10 @@ export class DataPanel extends Component<Props, State> {
return
;
}
if
(
onDataResponse
)
{
onDataResponse
(
resp
);
}
this
.
setState
({
loading
:
LoadingState
.
Done
,
response
:
resp
,
...
...
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
36a2b9c0
...
...
@@ -21,6 +21,7 @@ import { TimeRange } from '@grafana/ui';
import
variables
from
'sass/_variables.scss'
;
import
templateSrv
from
'app/features/templating/template_srv'
;
import
{
DataQueryResponse
}
from
'@grafana/ui/src'
;
export
interface
Props
{
panel
:
PanelModel
;
...
...
@@ -83,16 +84,42 @@ export class PanelChrome extends PureComponent<Props, State> {
return
templateSrv
.
replace
(
value
,
this
.
props
.
panel
.
scopedVars
,
format
);
};
onDataResponse
=
(
dataQueryResponse
:
DataQueryResponse
)
=>
{
if
(
this
.
props
.
dashboard
.
isSnapshot
())
{
this
.
props
.
panel
.
snapshotData
=
dataQueryResponse
.
data
;
}
};
get
isVisible
()
{
return
!
this
.
props
.
dashboard
.
otherPanelInFullscreen
(
this
.
props
.
panel
);
}
renderPanel
(
loading
,
timeSeries
,
width
,
height
):
JSX
.
Element
{
const
{
panel
,
plugin
}
=
this
.
props
;
const
{
timeRange
,
renderCounter
}
=
this
.
state
;
const
PanelComponent
=
plugin
.
exports
.
Panel
;
return
(
<
div
className=
"panel-content"
>
<
PanelComponent
loading=
{
loading
}
timeSeries=
{
timeSeries
}
timeRange=
{
timeRange
}
options=
{
panel
.
getOptions
(
plugin
.
exports
.
PanelDefaults
)
}
width=
{
width
-
2
*
variables
.
panelHorizontalPadding
}
height=
{
height
-
PANEL_HEADER_HEIGHT
-
variables
.
panelVerticalPadding
}
renderCounter=
{
renderCounter
}
onInterpolate=
{
this
.
onInterpolate
}
/>
</
div
>
);
}
render
()
{
const
{
panel
,
dashboard
,
plugin
}
=
this
.
props
;
const
{
refreshCounter
,
timeRange
,
timeInfo
,
renderCounter
}
=
this
.
state
;
const
{
panel
,
dashboard
}
=
this
.
props
;
const
{
refreshCounter
,
timeRange
,
timeInfo
}
=
this
.
state
;
const
{
datasource
,
targets
,
transparent
}
=
panel
;
const
PanelComponent
=
plugin
.
exports
.
Panel
;
const
containerClassNames
=
`panel-container panel-container--absolute
${
transparent
?
'panel-transparent'
:
''
}
`
;
return
(
<
AutoSizer
>
...
...
@@ -113,31 +140,23 @@ export class PanelChrome extends PureComponent<Props, State> {
links=
{
panel
.
links
}
/>
<
DataPanel
datasource=
{
datasource
}
queries=
{
targets
}
timeRange=
{
timeRange
}
isVisible=
{
this
.
isVisible
}
widthPixels=
{
width
}
refreshCounter=
{
refreshCounter
}
>
{
({
loading
,
timeSeries
})
=>
{
return
(
<
div
className=
"panel-content"
>
<
PanelComponent
loading=
{
loading
}
timeSeries=
{
timeSeries
}
timeRange=
{
timeRange
}
options=
{
panel
.
getOptions
(
plugin
.
exports
.
PanelDefaults
)
}
width=
{
width
-
2
*
variables
.
panelHorizontalPadding
}
height=
{
height
-
PANEL_HEADER_HEIGHT
-
variables
.
panelVerticalPadding
}
renderCounter=
{
renderCounter
}
onInterpolate=
{
this
.
onInterpolate
}
/>
</
div
>
);
}
}
</
DataPanel
>
{
panel
.
snapshotData
?
(
this
.
renderPanel
(
false
,
panel
.
snapshotData
,
width
,
height
)
)
:
(
<
DataPanel
datasource=
{
datasource
}
queries=
{
targets
}
timeRange=
{
timeRange
}
isVisible=
{
this
.
isVisible
}
widthPixels=
{
width
}
refreshCounter=
{
refreshCounter
}
onDataResponse=
{
this
.
onDataResponse
}
>
{
({
loading
,
timeSeries
})
=>
{
return
this
.
renderPanel
(
loading
,
timeSeries
,
width
,
height
);
}
}
</
DataPanel
>
)
}
</
div
>
);
}
}
...
...
public/app/features/dashboard/panel_model.ts
View file @
36a2b9c0
...
...
@@ -4,7 +4,7 @@ import _ from 'lodash';
// Types
import
{
Emitter
}
from
'app/core/utils/emitter'
;
import
{
PANEL_OPTIONS_KEY_PREFIX
}
from
'app/core/constants'
;
import
{
DataQuery
}
from
'@grafana/ui/src/types
'
;
import
{
DataQuery
,
TimeSeries
}
from
'@grafana/ui
'
;
export
interface
GridPos
{
x
:
number
;
...
...
@@ -87,7 +87,7 @@ export class PanelModel {
datasource
:
string
;
thresholds
?:
any
;
snapshotData
?:
any
;
snapshotData
?:
TimeSeries
[]
;
timeFrom
?:
any
;
timeShift
?:
any
;
hideTimeOverride
?:
any
;
...
...
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