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
ae0b9692
Commit
ae0b9692
authored
Jan 30, 2019
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first implementation
parent
a21f6777
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
25 deletions
+60
-25
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
+36
-17
public/app/features/dashboard/panel_model.ts
+2
-2
No files found.
public/app/features/dashboard/dashboard_model.ts
View file @
ae0b9692
...
...
@@ -810,6 +810,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 @
ae0b9692
...
...
@@ -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 @
ae0b9692
...
...
@@ -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
;
}
};
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,6 +140,9 @@ export class PanelChrome extends PureComponent<Props, State> {
links=
{
panel
.
links
}
/>
{
panel
.
snapshotData
?
(
this
.
renderPanel
(
false
,
panel
.
snapshotData
,
width
,
height
)
)
:
(
<
DataPanel
datasource=
{
datasource
}
queries=
{
targets
}
...
...
@@ -120,24 +150,13 @@ export class PanelChrome extends PureComponent<Props, State> {
isVisible=
{
this
.
isVisible
}
widthPixels=
{
width
}
refreshCounter=
{
refreshCounter
}
onDataResponse=
{
this
.
onDataResponse
}
>
{
({
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
>
);
return
this
.
renderPanel
(
loading
,
timeSeries
,
width
,
height
);
}
}
</
DataPanel
>
)
}
</
div
>
);
}
}
...
...
public/app/features/dashboard/panel_model.ts
View file @
ae0b9692
...
...
@@ -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
,
DataQueryResponse
}
from
'@grafana/ui/src/types'
;
export
interface
GridPos
{
x
:
number
;
...
...
@@ -87,7 +87,7 @@ export class PanelModel {
datasource
:
string
;
thresholds
?:
any
;
snapshotData
?:
any
;
snapshotData
?:
DataQueryResponse
;
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