1
1
/* globals window */
2
2
import React , { Component } from 'react' ;
3
- import { Spin , Button } from 'antd' ;
3
+ import { Spin , Button , Alert } from 'antd' ;
4
+ import { Link } from "react-router-dom" ;
4
5
import DashboardSource from "./DashboardSource" ;
5
6
import fetch from './playgroundFetch' ;
6
7
@@ -29,7 +30,8 @@ class DashboardPage extends Component {
29
30
const dashboardStatus = await ( await fetch ( '/playground/dashboard-app-status' ) ) . json ( ) ;
30
31
this . setState ( {
31
32
dashboardRunning : dashboardStatus . running ,
32
- dashboardPort : dashboardStatus . dashboardPort
33
+ dashboardPort : dashboardStatus . dashboardPort ,
34
+ dashboardAppPath : dashboardStatus . dashboardAppPath
33
35
} ) ;
34
36
}
35
37
@@ -43,7 +45,7 @@ class DashboardPage extends Component {
43
45
44
46
render ( ) {
45
47
const {
46
- appCode, dashboardPort, loadError, dashboardRunning, dashboardStarting
48
+ appCode, dashboardPort, loadError, dashboardRunning, dashboardStarting, dashboardAppPath
47
49
} = this . state ;
48
50
if ( loadError ) {
49
51
return (
@@ -67,7 +69,7 @@ class DashboardPage extends Component {
67
69
return (
68
70
< h2 style = { { textAlign : 'center' } } >
69
71
< Spin />
70
- Creating dashboard react-app. It may take several minutes...
72
+ Creating dashboard react-app. It may take several minutes. Please check console for progress. ..
71
73
</ h2 >
72
74
) ;
73
75
}
@@ -77,7 +79,9 @@ class DashboardPage extends Component {
77
79
< h2 >
78
80
Dashboard App is not running.
79
81
< br />
80
- Please start dashboard app or run it manually using `$ npm run start` in dashboard-app directory.
82
+ Please start dashboard app or run it manually using `$ npm run start` in
83
+ < b > { dashboardAppPath } </ b >
84
+ directory.
81
85
</ h2 >
82
86
< p style = { { textAlign : 'center' } } >
83
87
< Button
@@ -86,21 +90,40 @@ class DashboardPage extends Component {
86
90
loading = { dashboardStarting }
87
91
onClick = { ( ) => this . startDashboardApp ( true ) }
88
92
>
89
- Start dashboard app
93
+ { dashboardStarting ? 'Dashboard app is starting. It may take a while. Please check console for progress...' : ' Start dashboard app' }
90
94
</ Button >
91
95
</ p >
92
96
</ div >
93
97
) ;
94
98
}
99
+ const devServerUrl = `http://${ window . location . hostname } :${ dashboardPort } ` ;
95
100
return (
96
- < iframe
97
- src = { `http://${ window . location . hostname } :${ dashboardPort } ` }
98
- style = { {
99
- width : '100%' , height : '100%' , border : 0 , borderRadius : 4 , overflow : 'hidden'
100
- } }
101
- sandbox = "allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
102
- title = "Dashboard"
103
- />
101
+ < div style = { { height : '100%' , width : '100%' } } >
102
+ < Alert
103
+ message = { (
104
+ < span >
105
+ This dashboard app can be edited at
106
+ < b > { dashboardAppPath } </ b >
107
+ .
108
+ Dev server is running at
109
+ < a href = { devServerUrl } target = "_blank" rel = "noopener noreferrer" > { devServerUrl } </ a >
110
+ . Add charts to dashboard using
111
+ < Link to = "/explore" > Explore</ Link >
112
+ .
113
+ </ span >
114
+ ) }
115
+ type = "info"
116
+ closable
117
+ />
118
+ < iframe
119
+ src = { devServerUrl }
120
+ style = { {
121
+ width : '100%' , height : '100%' , border : 0 , borderRadius : 4 , overflow : 'hidden'
122
+ } }
123
+ sandbox = "allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
124
+ title = "Dashboard"
125
+ />
126
+ </ div >
104
127
) ;
105
128
}
106
129
}
0 commit comments