Skip to content

Commit 1c43927

Browse files
authored
Package all resources into query_view_spa.html (prestodb#24486)
* Package all resources into query_view_spa.html * refactor filename for query_view_spa.html * Resolve conflicts and fix spa page styles
1 parent 0370282 commit 1c43927

File tree

6 files changed

+67
-41
lines changed

6 files changed

+67
-41
lines changed

presto-ui/src/components/QueryPlanView.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default function PlanView({show, data}) {
114114
widgets.current.svg = d3.select("#plan-canvas");
115115
}
116116
updateD3Graph();
117-
$('[data-bs-toggle="tooltip"]')?.tooltip()
117+
$('[data-bs-toggle="tooltip"]')?.tooltip?.()
118118
}, [data, show]);
119119

120120
return (

presto-ui/src/components/QueryViewer.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import StaticQueryHeader from './StaticQueryHeader';
2323
// A form to select a JSON file and read
2424
const FileForm = ({ onChange }) => (
2525
<div className="row">
26-
<div className="col-4 offset-1 fs-6">
26+
<div className="col-4 offset-1 fs-6 mb-2">
2727
<div id="title">Select a JSON file of SQL query to process</div>
2828
<form id='form' className="form-inline">
2929
<div className="form-group">

presto-ui/src/components/StaticQueryHeader.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default function StaticQueryHeader({ query, tabs, switchTab, tabIndex = 0
121121
</a>
122122
</h3>
123123
</div>
124-
<div className="col-6">
124+
<div className="col-6 d-flex justify-content-end">
125125
<nav className="nav nav-tabs">
126126
<QueryHeaderTabs tabs={tabs} current={state.tab} clickHandler={clickHandler} />
127127
</nav>

presto-ui/src/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"scripts": {
4141
"install": "webpack --env=production --config webpack.config.js",
4242
"watch": "webpack --config webpack.config.js --watch",
43-
"serve": "webpack serve --config webpack.config.js"
43+
"serve": "webpack serve --config webpack.config.js",
44+
"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"
4445
},
4546
"resolutions": {
4647
"d3-color": "3.1.0"

presto-ui/src/query_viewer.jsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { createRoot } from 'react-dom/client';
2-
import lazy from "./lazy";
2+
import QueryViewer from "./components/QueryViewer";
33
import { PageTitle } from "./components/PageTitle";
44

5-
const QueryViewer = lazy('QueryViewer');
6-
75
const title = createRoot(document.getElementById('title'));
86
title.render(<PageTitle titles={["Query Viewer"]} path='..'/>);
97

presto-ui/src/webpack.config.js

+61-34
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,22 @@ module.exports = (env) => {
1111
const apiHost = env.apiHost || 'localhost';
1212
const apiPort = env.apiPort || '8080';
1313
const outputDir = 'target/webapp';
14-
return {
14+
const baseConfig = {
1515
entry: {
16-
'index': './index.jsx',
17-
'query': './query.jsx',
18-
'plan': './plan.jsx',
19-
'query_viewer': {import: './query_viewer.jsx', filename: path.join('dev', '[name].js')},
20-
'embedded_plan': './embedded_plan.jsx',
21-
'stage': './stage.jsx',
22-
'worker': './worker.jsx',
23-
'timeline': './timeline.jsx',
24-
'res_groups': './res_groups.jsx',
25-
'sql_client': './sql_client.jsx',
2616
'css_loader': path.join(__dirname, 'static', 'vendor', 'css-loaders', 'loader.css'),
2717
'css_presto': path.join(__dirname, 'static', 'assets', 'presto.css'),
2818
},
2919
externals: {
3020
// substitutes `require('vis-timeline/standalone')` to `global.vis`
3121
'vis-timeline/standalone': 'vis',
3222
},
33-
plugins: [
34-
new CopyPlugin({
35-
patterns: [
36-
{from: "static", to: path.join(__dirname, "..", outputDir)},
37-
]
38-
}),
39-
new HtmlWebpackPlugin({
40-
inject: 'body',
41-
filename: path.join(__dirname, '..', outputDir, 'dev', 'query_viewer_spa.html'),
42-
template: 'templates/query_viewer.html',
43-
chunks: [
44-
'query_viewer',
45-
'css_loader',
46-
'css_presto',
47-
]
48-
}),
49-
new HtmlInlineScriptPlugin({
50-
htmlMatchPattern: [/query_viewer_spa.html$/],
51-
assetPreservePattern: [
52-
/.*.js$/,
53-
]
54-
}),
55-
],
23+
plugins: [
24+
new CopyPlugin({
25+
patterns: [
26+
{from: "static", to: path.join(__dirname, "..", outputDir)},
27+
]
28+
}),
29+
],
5630
mode,
5731
module: {
5832
rules: [
@@ -97,6 +71,25 @@ module.exports = (env) => {
9771
extractComments: false,
9872
}),
9973
'...'],
74+
},
75+
};
76+
77+
const mainConfig = {
78+
...baseConfig,
79+
entry: {
80+
'index': './index.jsx',
81+
'query': './query.jsx',
82+
'plan': './plan.jsx',
83+
'embedded_plan': './embedded_plan.jsx',
84+
'stage': './stage.jsx',
85+
'worker': './worker.jsx',
86+
'timeline': './timeline.jsx',
87+
'res_groups': './res_groups.jsx',
88+
'sql_client': './sql_client.jsx',
89+
...baseConfig.entry,
90+
},
91+
optimization: {
92+
...baseConfig.optimization,
10093
splitChunks: {
10194
chunks: 'async',
10295
maxSize: 244000,
@@ -107,6 +100,7 @@ module.exports = (env) => {
107100
test: /[\\/]node_modules[\\/]/,
108101
priority: -10,
109102
reuseExistingChunk: true,
103+
filename: '[name].vendor.js',
110104
},
111105
default: {
112106
minChunks: 2,
@@ -130,4 +124,37 @@ module.exports = (env) => {
130124
],
131125
},
132126
};
127+
128+
const spaConfig = {
129+
...baseConfig,
130+
plugins: [
131+
...baseConfig.plugins,
132+
new HtmlWebpackPlugin({
133+
inject: 'body',
134+
filename: path.join('dev', 'query_viewer_spa.html'),
135+
template: 'templates/query_viewer.html',
136+
chunks: [
137+
'query_viewer',
138+
'bootstrap_css',
139+
'css_loader',
140+
'css_presto',
141+
]
142+
}),
143+
new HtmlInlineScriptPlugin({
144+
htmlMatchPattern: [/query_viewer_spa.html$/],
145+
assetPreservePattern: [
146+
/.*.js$/,
147+
]
148+
}),
149+
],
150+
entry: {
151+
'query_viewer': {import: './query_viewer.jsx', filename: path.join('dev', '[name].js')},
152+
...baseConfig.entry,
153+
},
154+
optimization: {
155+
...baseConfig.optimization,
156+
splitChunks: false,
157+
}
158+
};
159+
return [mainConfig, spaConfig]
133160
};

0 commit comments

Comments
 (0)