File tree 2 files changed +67
-11
lines changed 2 files changed +67
-11
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,13 @@ import { PanelEditor } from './PanelEditor';
9
9
const TITLE_HEIGHT = 27 ;
10
10
const PANEL_BORDER = 2 ;
11
11
12
- export interface PanelChromeProps {
12
+ export interface Props {
13
13
panel : PanelModel ;
14
14
dashboard : DashboardModel ;
15
15
component : any ;
16
16
}
17
17
18
- export class PanelChrome extends React . Component < PanelChromeProps , any > {
18
+ export class PanelChrome extends React . Component < Props , any > {
19
19
constructor ( props ) {
20
20
super ( props ) ;
21
21
Original file line number Diff line number Diff line change 1
1
import React , { Component , ComponentClass } from 'react' ;
2
2
import _ from 'lodash' ;
3
3
4
- export interface Props {
4
+ export interface OuterProps {
5
5
type : string ;
6
- queries : Query [ ] ;
6
+ queries : any [ ] ;
7
+ isVisible : boolean ;
7
8
}
8
9
9
- interface State {
10
- isLoading : boolean ;
11
- timeSeries : TimeSeriesServerResponse [ ] ;
10
+ export interface AddedProps {
11
+ data : any [ ] ;
12
12
}
13
13
14
- export interface OriginalProps {
15
- data : TimeSeriesServerResponse [ ] ;
14
+ interface State {
16
15
isLoading : boolean ;
16
+ data : any [ ] ;
17
17
}
18
18
19
- const DataPanel = ( ComposedComponent : ComponentClass < OriginalProps & Props > ) => {
20
- class Wrapper extends Component < Props , State > { }
19
+ const DataPanel = ( ComposedComponent : ComponentClass < AddedProps & OuterProps > ) => {
20
+ class Wrapper extends Component < OuterProps , State > {
21
+ public static defaultProps = {
22
+ isVisible : true ,
23
+ } ;
24
+
25
+ constructor ( props : OuterProps ) {
26
+ super ( props ) ;
27
+
28
+ this . state = {
29
+ isLoading : false ,
30
+ data : [ ] ,
31
+ } ;
32
+ }
33
+
34
+ public componentDidMount ( ) {
35
+ this . issueQueries ( ) ;
36
+ }
37
+
38
+ public issueQueries = ( ) => {
39
+ const { queries, isVisible } = this . props ;
40
+
41
+ if ( ! isVisible ) {
42
+ return ;
43
+ }
44
+
45
+ if ( ! queries . length ) {
46
+ this . setState ( { data : [ { message : 'no queries' } ] } ) ;
47
+ return ;
48
+ }
49
+
50
+ this . setState ( { isLoading : true } ) ;
51
+ } ;
52
+
53
+ public render ( ) {
54
+ const { data, isLoading } = this . state ;
55
+
56
+ if ( ! data . length ) {
57
+ return (
58
+ < div className = "no-data" >
59
+ < p > No Data</ p >
60
+ </ div >
61
+ ) ;
62
+ }
63
+
64
+ if ( isLoading ) {
65
+ return (
66
+ < div className = "loading" >
67
+ < p > Loading</ p >
68
+ </ div >
69
+ ) ;
70
+ }
71
+
72
+ return < ComposedComponent { ...this . props } data = { data } /> ;
73
+ }
74
+ }
21
75
22
76
return Wrapper ;
23
77
} ;
78
+
79
+ export default DataPanel ;
You can’t perform that action at this time.
0 commit comments