Skip to content

Commit eed2b55

Browse files
committed
feat(playground): Various dashboard hints
1 parent 4104903 commit eed2b55

File tree

4 files changed

+43
-18
lines changed

4 files changed

+43
-18
lines changed

packages/cubejs-playground/src/ChartContainer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class ChartContainer extends React.Component {
158158
loading={addingToDashboard}
159159
disabled={!!frameworkItem.docsLink}
160160
>
161-
{addingToDashboard ? 'Creating app and installing modules...' : 'Add to Dashboard'}
161+
{addingToDashboard ? 'Installing modules. It may take a while. Please check console for progress...' : 'Add to Dashboard'}
162162
</Button>
163163
)}
164164
<Dropdown overlay={frameworkMenu}>

packages/cubejs-playground/src/DashboardPage.js

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* globals window */
22
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";
45
import DashboardSource from "./DashboardSource";
56
import fetch from './playgroundFetch';
67

@@ -29,7 +30,8 @@ class DashboardPage extends Component {
2930
const dashboardStatus = await (await fetch('/playground/dashboard-app-status')).json();
3031
this.setState({
3132
dashboardRunning: dashboardStatus.running,
32-
dashboardPort: dashboardStatus.dashboardPort
33+
dashboardPort: dashboardStatus.dashboardPort,
34+
dashboardAppPath: dashboardStatus.dashboardAppPath
3335
});
3436
}
3537

@@ -43,7 +45,7 @@ class DashboardPage extends Component {
4345

4446
render() {
4547
const {
46-
appCode, dashboardPort, loadError, dashboardRunning, dashboardStarting
48+
appCode, dashboardPort, loadError, dashboardRunning, dashboardStarting, dashboardAppPath
4749
} = this.state;
4850
if (loadError) {
4951
return (
@@ -67,7 +69,7 @@ class DashboardPage extends Component {
6769
return (
6870
<h2 style={{ textAlign: 'center' }}>
6971
<Spin />
70-
&nbsp;Creating dashboard react-app. It may take several minutes...
72+
&nbsp;Creating dashboard react-app. It may take several minutes. Please check console for progress...
7173
</h2>
7274
);
7375
}
@@ -77,7 +79,9 @@ class DashboardPage extends Component {
7779
<h2>
7880
Dashboard App is not running.
7981
<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&nbsp;
83+
<b>{dashboardAppPath}</b>
84+
&nbsp;directory.
8185
</h2>
8286
<p style={{ textAlign: 'center' }}>
8387
<Button
@@ -86,21 +90,40 @@ class DashboardPage extends Component {
8690
loading={dashboardStarting}
8791
onClick={() => this.startDashboardApp(true)}
8892
>
89-
Start dashboard app
93+
{dashboardStarting ? 'Dashboard app is starting. It may take a while. Please check console for progress...' : 'Start dashboard app'}
9094
</Button>
9195
</p>
9296
</div>
9397
);
9498
}
99+
const devServerUrl = `http://${window.location.hostname}:${dashboardPort}`;
95100
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&nbsp;
106+
<b>{dashboardAppPath}</b>
107+
.
108+
Dev server is running at&nbsp;
109+
<a href={devServerUrl} target="_blank" rel="noopener noreferrer">{devServerUrl}</a>
110+
. Add charts to dashboard using&nbsp;
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>
104127
);
105128
}
106129
}

packages/cubejs-playground/src/DashboardSource.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const fetchWithRetry = (url, options, retries) => fetch(url, { ...options, retri
6262

6363
class DashboardSource {
6464
async load(createApp) {
65+
this.loadError = null;
6566
if (createApp) {
6667
await fetchWithRetry('/playground/ensure-dashboard-app', undefined, 5);
6768
}

packages/cubejs-server-core/core/DevServer.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ class DevServer {
121121
if (!(await fs.pathExists(sourcePath))) {
122122
res.status(404).json({
123123
error: await fs.pathExists(dashboardAppPath) ?
124-
`Dashboard app corrupted. Please remove '${dashboardAppPath}' directory and recreate it` :
125-
`Dashboard app not found in '${dashboardAppPath}' directory`
124+
`Dashboard app corrupted. Please remove '${path.resolve(dashboardAppPath)}' directory and recreate it` :
125+
`Dashboard app not found in '${path.resolve(dashboardAppPath)}' directory`
126126
});
127127
return;
128128
}
@@ -236,7 +236,8 @@ class DevServer {
236236
const dashboardPort = this.dashboardAppProcess && await this.dashboardAppProcess.dashboardUrlPromise;
237237
res.json({
238238
running: !!dashboardPort,
239-
dashboardPort
239+
dashboardPort,
240+
dashboardAppPath: path.resolve(dashboardAppPath)
240241
});
241242
}));
242243

0 commit comments

Comments
 (0)