-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a single-page application for Query Viewer
Add another webpack config to generate a single-page application for the `Query Viewer` and related artifacts, including: - a template file for the single-page application - a bootstrap css using external links for the fonts Signed-off-by: Yihong Wang <yh.wang@ibm.com>
- Loading branch information
Showing
6 changed files
with
438 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
presto-main/src/main/resources/webapp/src/templates/query_viewer.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
|
||
<meta name="description" content="Plan Viewer - Presto"> | ||
<title>Plan Viewer - Presto</title> | ||
|
||
<link rel="icon" href="http://prestodb.io/docs/current/_static/favicon.ico"> | ||
|
||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> | ||
<!--[if lt IE 9]> | ||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> | ||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | ||
<![endif]--> | ||
|
||
<!-- jQuery --> | ||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script> | ||
|
||
<!-- Bootstrap JS --> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> | ||
|
||
<!-- Sparkline --> | ||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-sparklines/2.1.2/jquery.sparkline.min.js"></script> | ||
|
||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-timeline/7.7.2/vis-timeline-graph2d.min.css"> | ||
<!-- vis-timeline --> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis-timeline/7.7.2/vis-timeline-graph2d.min.js"></script> | ||
|
||
<style type="text/css"> | ||
.vis-timeline .item { | ||
padding: 0px; | ||
} | ||
.vis-timeline .labelset .vlabel .inner { | ||
padding: 0px; | ||
} | ||
.vis-timeline .item.range { | ||
height: 3px; | ||
} | ||
.vis-timeline .red { | ||
background-color: #F2DEDE; | ||
border-color: #F2AEAE; | ||
} | ||
.vis-timeline .green { | ||
background-color: #DFF0DB; | ||
border-color: #B8F0AA; | ||
} | ||
.vis-timeline .blue { | ||
background-color: #E3E9FC; | ||
border-color: #B0C3FC; | ||
} | ||
.vis-timeline .orange { | ||
background-color: #FFA500; | ||
border-color: #B0C3FC; | ||
} | ||
#legend { | ||
padding: 10px 40px; | ||
display: grid; | ||
grid-template-columns: 1fr 200px 200px 200px 200px 1fr; | ||
} | ||
#legend .bar { | ||
border-style: solid; | ||
border-width: 1px; | ||
width: 200px; | ||
height: 4px; | ||
} | ||
#legend .text { | ||
margin-left: -20px; | ||
} | ||
#legend .red { | ||
background-color: #F2DEDE; | ||
border-color: #F2AEAE; | ||
} | ||
#legend .green { | ||
background-color: #DFF0DB; | ||
border-color: #B8F0AA; | ||
} | ||
#legend .blue { | ||
background-color: #E3E9FC; | ||
border-color: #B0C3FC; | ||
} | ||
#legend .orange { | ||
background-color: #FFA500; | ||
border-color: #B0C3FC; | ||
} | ||
#legend .empty { | ||
border-style: none; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
|
||
<div class="container"> | ||
<div id="title"></div> | ||
|
||
<div id="query-view-container" style="margin-top: -20px"> | ||
</div> | ||
</div> <!-- /container --> | ||
|
||
<!-- Fonts --> | ||
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700" rel="stylesheet"> | ||
|
||
</body> | ||
</html> |
74 changes: 74 additions & 0 deletions
74
presto-main/src/main/resources/webapp/src/webpack-single-page.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* global __dirname */ | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const HtmlInlineScriptPlugin = require('html-inline-script-webpack-plugin'); | ||
const path = require('node:path'); | ||
const TerserPlugin = require("terser-webpack-plugin"); | ||
|
||
module.exports = (env) => { | ||
const mode = env.production ? 'production' : 'development'; | ||
return { | ||
entry: { | ||
'query_viewer': { import: path.join(__dirname, 'query_viewer.jsx'), filename: path.join('dev', '[name].js')}, | ||
'bootstrap_css': path.join(__dirname, '..', 'vendor', 'bootstrap', 'css', 'bootstrap.min.external-fonts.css'), | ||
'css_loader': path.join(__dirname, '..', 'vendor', 'css-loaders', 'loader.css'), | ||
'css_loader': path.join(__dirname, '..', 'assets', 'presto.css'), | ||
}, | ||
externals: { | ||
// substitutes `require('vis-timeline/standalone')` to `global.vis` | ||
'vis-timeline/standalone': 'vis', | ||
}, | ||
mode, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(?:js|jsx)$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
presets: [ | ||
['@babel/preset-env', { targets: "defaults" }], | ||
['@babel/preset-react', {runtime: "automatic"}], | ||
['@babel/preset-flow'] | ||
], | ||
}, | ||
} | ||
}, | ||
{ | ||
test: /\.css$/i, | ||
use: ["style-loader", "css-loader"], | ||
}, | ||
] | ||
}, | ||
resolve: { | ||
extensions: ['.*', '.js', '.jsx'] | ||
}, | ||
output: { | ||
path: __dirname, | ||
}, | ||
optimization: { | ||
minimize: mode === 'production', | ||
minimizer: [ | ||
new TerserPlugin({ | ||
// do not genreate *.LICENSE.txt files | ||
terserOptions: { | ||
format: { | ||
comments: false, | ||
}, | ||
}, | ||
extractComments: false, | ||
}), | ||
, '...'], | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
inject: 'body', | ||
filename: 'query_viewer.html', | ||
template: 'templates/query_viewer.html', | ||
}), | ||
new HtmlInlineScriptPlugin({ | ||
htmlMatchPattern: [/query_viewer.html$/], | ||
}), | ||
], | ||
}; | ||
}; |
Oops, something went wrong.