Skip to content

Commit 3a162d5

Browse files
unidevelyingsu00
authored andcommitted
Add separate build/serve command for query_viewer_spa page
1 parent 64c0e38 commit 3a162d5

File tree

3 files changed

+49
-20
lines changed

3 files changed

+49
-20
lines changed

presto-ui/src/components/PageTitle.jsx

+19-6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ function ClusterResourceGroupNavBar({titles, urls, current = 0} : Props) {
4646
<>{navBarItems}</>
4747
);
4848
}
49+
50+
function isOffline() {
51+
return window.location.protocol === 'file:';
52+
}
53+
4954
export class PageTitle extends React.Component<Props, State> {
5055
timeoutId: TimeoutID;
5156

@@ -98,7 +103,15 @@ export class PageTitle extends React.Component<Props, State> {
98103
}
99104

100105
componentDidMount() {
101-
this.refreshLoop();
106+
if ( isOffline() ) {
107+
this.setState({
108+
noConnection: true,
109+
lightShown: true,
110+
});
111+
}
112+
else {
113+
this.refreshLoop();
114+
}
102115
}
103116

104117
renderStatusLight(): any {
@@ -115,7 +128,7 @@ export class PageTitle extends React.Component<Props, State> {
115128

116129
render(): any {
117130
const info = this.state.info;
118-
if (!info) {
131+
if (!isOffline() && !info) {
119132
return null;
120133
}
121134

@@ -137,19 +150,19 @@ export class PageTitle extends React.Component<Props, State> {
137150
</div>
138151
<button className="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
139152
<span className="navbar-toggler-icon"></span>
140-
</button>
153+
</button>
141154
<div id="navbar" className="navbar-collapse collapse">
142155
<ul className="nav navbar-nav navbar-right ms-auto">
143156
<li>
144157
<span className="navbar-cluster-info">
145158
<span className="uppercase">Version</span><br/>
146-
<span className="text" id="version-number">{info.nodeVersion.version}</span>
159+
<span className="text" id="version-number">{isOffline() ? 'N/A' : info.nodeVersion.version}</span>
147160
</span>
148161
</li>
149162
<li>
150163
<span className="navbar-cluster-info">
151164
<span className="uppercase">Environment</span><br/>
152-
<span className="text" id="environment">{info.environment}</span>
165+
<span className="text" id="environment">{isOffline() ? 'N/A' : info.environment}</span>
153166
</span>
154167
</li>
155168
<li>
@@ -159,7 +172,7 @@ export class PageTitle extends React.Component<Props, State> {
159172
{this.renderStatusLight()}
160173
</span>
161174
&nbsp;
162-
<span className="text" id="uptime">{info.uptime}</span>
175+
<span className="text" id="uptime">{isOffline() ? 'Offline' : info.uptime}</span>
163176
</span>
164177
</li>
165178
</ul>

presto-ui/src/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
"install": "webpack --env=production --config webpack.config.js",
4242
"watch": "webpack --config webpack.config.js --watch",
4343
"serve": "webpack serve --config webpack.config.js",
44+
"build:spa": "webpack --config webpack.config.js --env production --env config=spa",
45+
"serve:spa": "webpack serve --config webpack.config.js --env config=spa",
46+
"watch:spa": "webpack --config webpack.config.js --env config=spa --watch",
4447
"analyze": "webpack --env=production --config webpack.config.js --profile --json > stats.json && mv stats.json ../target/webapp/ && npx webpack-bundle-analyzer ../target/webapp/stats.json"
4548
},
4649
"resolutions": {

presto-ui/src/webpack.config.js

+27-14
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ module.exports = (env) => {
7474
},
7575
};
7676

77+
const devServer = {
78+
static: {
79+
directory: path.join(__dirname, '..', outputDir),
80+
},
81+
proxy: [
82+
{
83+
context: ['/v1'],
84+
target: `http://${apiHost}:${apiPort}`,
85+
// secure: false, // when using http
86+
// changeOrigin: true, // Modify the Origin header to match the target
87+
},
88+
],
89+
}
90+
7791
const mainConfig = {
7892
...baseConfig,
7993
entry: {
@@ -86,6 +100,7 @@ module.exports = (env) => {
86100
'timeline': './timeline.jsx',
87101
'res_groups': './res_groups.jsx',
88102
'sql_client': './sql_client.jsx',
103+
'dev/query_viewer': './query_viewer.jsx',
89104
...baseConfig.entry,
90105
},
91106
optimization: {
@@ -110,19 +125,7 @@ module.exports = (env) => {
110125
},
111126
},
112127
},
113-
devServer: {
114-
static: {
115-
directory: path.join(__dirname, '..', outputDir),
116-
},
117-
proxy: [
118-
{
119-
context: ['/v1'],
120-
target: `http://${apiHost}:${apiPort}`,
121-
// secure: false, // when using http
122-
// changeOrigin: true, // Modify the Origin header to match the target
123-
},
124-
],
125-
},
128+
devServer,
126129
};
127130

128131
const spaConfig = {
@@ -156,5 +159,15 @@ module.exports = (env) => {
156159
splitChunks: false,
157160
}
158161
};
159-
return [mainConfig, spaConfig]
162+
163+
if (env.config === 'all') {
164+
return [mainConfig, spaConfig];
165+
}
166+
if (env.config === 'spa') {
167+
return {
168+
...spaConfig,
169+
devServer,
170+
}
171+
}
172+
return mainConfig;
160173
};

0 commit comments

Comments
 (0)