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
4f943687
Commit
4f943687
authored
Jan 08, 2019
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Display error when plot fail to render
parent
0b89f816
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
20 deletions
+42
-20
packages/grafana-ui/src/types/panel.ts
+1
-0
packages/grafana-ui/src/visualizations/Graph/Graph.tsx
+3
-1
public/app/core/components/Tooltip/Popper.tsx
+6
-6
public/app/core/components/Tooltip/withPopper.tsx
+3
-3
public/app/features/dashboard/dashgrid/DataPanel.tsx
+22
-4
public/app/features/dashboard/dashgrid/PanelChrome.tsx
+2
-2
public/app/plugins/panel/graph2/GraphPanel.tsx
+4
-3
public/sass/pages/_dashboard.scss
+1
-1
No files found.
packages/grafana-ui/src/types/panel.ts
View file @
4f943687
...
...
@@ -9,6 +9,7 @@ export interface PanelProps<T = any> {
renderCounter
:
number
;
width
:
number
;
height
:
number
;
onRenderError
:
()
=>
void
;
}
export
interface
PanelOptionsProps
<
T
=
any
>
{
...
...
packages/grafana-ui/src/visualizations/Graph/Graph.tsx
View file @
4f943687
...
...
@@ -13,6 +13,7 @@ interface GraphProps {
showBars
?:
boolean
;
width
:
number
;
height
:
number
;
onRenderError
:
()
=>
void
;
}
export
class
Graph
extends
PureComponent
<
GraphProps
>
{
...
...
@@ -37,7 +38,7 @@ export class Graph extends PureComponent<GraphProps> {
return
;
}
const
{
width
,
timeSeries
,
timeRange
,
showLines
,
showBars
,
showPoints
}
=
this
.
props
;
const
{
width
,
timeSeries
,
timeRange
,
showLines
,
showBars
,
showPoints
,
onRenderError
}
=
this
.
props
;
if
(
!
width
)
{
return
;
...
...
@@ -98,6 +99,7 @@ export class Graph extends PureComponent<GraphProps> {
$
.
plot
(
this
.
element
,
timeSeries
,
flotOptions
);
}
catch
(
err
)
{
console
.
log
(
'Graph rendering error'
,
err
,
flotOptions
,
timeSeries
);
onRenderError
();
}
}
...
...
public/app/core/components/Tooltip/Popper.tsx
View file @
4f943687
...
...
@@ -3,6 +3,11 @@ import Portal from 'app/core/components/Portal/Portal';
import
{
Manager
,
Popper
as
ReactPopper
,
Reference
}
from
'react-popper'
;
import
Transition
from
'react-transition-group/Transition'
;
export
enum
Themes
{
Default
=
'popper__background--default'
,
Error
=
'popper__background--error'
,
}
const
defaultTransitionStyles
=
{
transition
:
'opacity 200ms linear'
,
opacity
:
0
,
...
...
@@ -21,12 +26,7 @@ interface Props {
placement
?:
any
;
content
:
string
|
((
props
:
any
)
=>
JSX
.
Element
);
refClassName
?:
string
;
theme
?:
string
;
}
export
enum
Themes
{
Default
=
'popper__background--default'
,
Error
=
'popper__background--error'
,
theme
?:
Themes
;
}
class
Popper
extends
PureComponent
<
Props
>
{
...
...
public/app/core/components/Tooltip/withPopper.tsx
View file @
4f943687
import
React
from
'react'
;
import
{
Themes
}
from
'./Popper'
;
export
interface
UsingPopperProps
{
showPopper
:
(
prevState
:
object
)
=>
void
;
hidePopper
:
(
prevState
:
object
)
=>
void
;
...
...
@@ -9,7 +9,7 @@ export interface UsingPopperProps {
content
:
string
|
((
props
:
any
)
=>
JSX
.
Element
);
className
?:
string
;
refClassName
?:
string
;
theme
?:
string
;
theme
?:
Themes
;
}
interface
Props
{
...
...
@@ -17,7 +17,7 @@ interface Props {
className
?:
string
;
refClassName
?:
string
;
content
:
string
|
((
props
:
any
)
=>
JSX
.
Element
);
theme
?:
string
;
theme
?:
Themes
;
}
interface
State
{
...
...
public/app/features/dashboard/dashgrid/DataPanel.tsx
View file @
4f943687
...
...
@@ -16,6 +16,7 @@ import { Themes } from 'app/core/components/Tooltip/Popper';
interface
RenderProps
{
loading
:
LoadingState
;
timeSeries
:
TimeSeries
[];
onRenderError
:
()
=>
void
;
}
export
interface
Props
{
...
...
@@ -35,6 +36,7 @@ export interface Props {
export
interface
State
{
isFirstLoad
:
boolean
;
loading
:
LoadingState
;
errorMessage
:
string
;
response
:
DataQueryResponse
;
}
...
...
@@ -53,6 +55,7 @@ export class DataPanel extends Component<Props, State> {
this
.
state
=
{
loading
:
LoadingState
.
NotStarted
,
errorMessage
:
''
,
response
:
{
data
:
[],
},
...
...
@@ -92,7 +95,7 @@ export class DataPanel extends Component<Props, State> {
return
;
}
this
.
setState
({
loading
:
LoadingState
.
Loading
});
this
.
setState
({
loading
:
LoadingState
.
Loading
,
errorMessage
:
''
});
try
{
const
ds
=
await
this
.
dataSourceSrv
.
get
(
datasource
);
...
...
@@ -130,10 +133,24 @@ export class DataPanel extends Component<Props, State> {
});
}
catch
(
err
)
{
console
.
log
(
'Loading error'
,
err
);
this
.
setState
({
loading
:
LoadingState
.
Error
,
isFirstLoad
:
false
}
);
this
.
onError
(
'Request Error'
);
}
};
onError
=
(
errorMessage
:
string
)
=>
{
if
(
this
.
state
.
loading
!==
LoadingState
.
Error
||
this
.
state
.
errorMessage
!==
errorMessage
)
{
this
.
setState
({
loading
:
LoadingState
.
Error
,
isFirstLoad
:
false
,
errorMessage
:
errorMessage
});
}
}
onRenderError
=
()
=>
{
this
.
onError
(
'Error rendering panel'
);
}
render
()
{
const
{
queries
}
=
this
.
props
;
const
{
response
,
loading
,
isFirstLoad
}
=
this
.
state
;
...
...
@@ -158,13 +175,14 @@ export class DataPanel extends Component<Props, State> {
{
this
.
props
.
children
({
timeSeries
,
loading
,
onRenderError
:
this
.
onRenderError
})
}
</>
);
}
private
renderLoadingStates
():
JSX
.
Element
{
const
{
loading
}
=
this
.
state
;
const
{
loading
,
errorMessage
}
=
this
.
state
;
if
(
loading
===
LoadingState
.
Loading
)
{
return
(
<
div
className=
"panel-loading"
>
...
...
@@ -174,7 +192,7 @@ export class DataPanel extends Component<Props, State> {
}
else
if
(
loading
===
LoadingState
.
Error
)
{
return
(
<
Tooltip
content=
"Request Error"
content=
{
errorMessage
}
className=
"popper__manager--block"
refClassName=
{
`panel-info-corner panel-info-corner--error`
}
placement=
"bottom-start"
...
...
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
4f943687
...
...
@@ -87,7 +87,6 @@ export class PanelChrome extends PureComponent<Props, State> {
const
{
datasource
,
targets
,
transparent
}
=
panel
;
const
PanelComponent
=
plugin
.
exports
.
Panel
;
const
containerClassNames
=
`panel-container panel-container--absolute
${
transparent
?
'panel-transparent'
:
''
}
`
;
return
(
<
AutoSizer
>
{
({
width
,
height
})
=>
{
...
...
@@ -115,7 +114,7 @@ export class PanelChrome extends PureComponent<Props, State> {
widthPixels=
{
width
}
refreshCounter=
{
refreshCounter
}
>
{
({
loading
,
timeSeries
})
=>
{
{
({
loading
,
timeSeries
,
onRenderError
})
=>
{
return
(
<
div
className=
"panel-content"
>
<
PanelComponent
...
...
@@ -126,6 +125,7 @@ export class PanelChrome extends PureComponent<Props, State> {
width=
{
width
}
height=
{
height
-
PANEL_HEADER_HEIGHT
}
renderCounter=
{
renderCounter
}
onRenderError=
{
onRenderError
}
/>
</
div
>
);
...
...
public/app/plugins/panel/graph2/GraphPanel.tsx
View file @
4f943687
// Libraries
import
_
from
'lodash'
;
import
React
,
{
Pure
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
colors
from
'app/core/utils/colors'
;
// Components & Types
...
...
@@ -9,13 +9,13 @@ import { Options } from './types';
interface
Props
extends
PanelProps
<
Options
>
{}
export
class
GraphPanel
extends
Pure
Component
<
Props
>
{
export
class
GraphPanel
extends
Component
<
Props
>
{
constructor
(
props
)
{
super
(
props
);
}
render
()
{
const
{
timeSeries
,
timeRange
,
width
,
height
}
=
this
.
props
;
const
{
timeSeries
,
timeRange
,
width
,
height
,
onRenderError
}
=
this
.
props
;
const
{
showLines
,
showBars
,
showPoints
}
=
this
.
props
.
options
;
const
vmSeries
=
processTimeSeries
({
...
...
@@ -33,6 +33,7 @@ export class GraphPanel extends PureComponent<Props> {
showBars=
{
showBars
}
width=
{
width
}
height=
{
height
}
onRenderError=
{
onRenderError
}
/>
);
}
...
...
public/sass/pages/_dashboard.scss
View file @
4f943687
...
...
@@ -233,7 +233,7 @@ div.flot-text {
&
--error
{
display
:
block
;
color
:
$
text-color
;
color
:
$
white
;
@include
panel-corner-color
(
$popover-error-bg
);
.fa
:before
{
content
:
'\f12a'
;
...
...
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