Skip to content

Commit 2cbe13b

Browse files
committed
Migrate index page for WebUI to new javascript workflow
Mark `dist` directory as containing generated files that should not show up on GitHub by default.
1 parent fdace9d commit 2cbe13b

File tree

10 files changed

+4443
-143
lines changed

10 files changed

+4443
-143
lines changed

Diff for: .gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/ linguist-generated=true

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ benchmark_outputs
2424
.checkstyle
2525
.mvn/timing.properties
2626
.editorconfig
27+
node_modules

Diff for: presto-main/src/main/resources/webapp/dist/index.js

+377
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: presto-main/src/main/resources/webapp/index.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@
109109
window.setInterval(updateClusterInfo, 1000)
110110
</script>
111111

112-
<script src="vendor/react/browser.min.js"></script>
113-
<script type="text/babel" src="assets/cluster-hud.js"></script>
114-
<script type="text/babel" src="assets/query-list.js"></script>
112+
<script type="text/javascript" src="dist/index.js"></script>
115113

116114
<!-- Fonts -->
117115
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700" rel="stylesheet">

Diff for: presto-main/src/main/resources/webapp/assets/cluster-hud.js renamed to presto-main/src/main/resources/webapp/src/components/cluster-hud.js

+24-18
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* limitations under the License.
1313
*/
1414

15+
import React from "react";
16+
1517
const SPARKLINE_PROPERTIES = {
1618
width:'100%',
1719
height: '75px',
@@ -22,9 +24,10 @@ const SPARKLINE_PROPERTIES = {
2224
disableHiddenCheck: true,
2325
};
2426

25-
let ClusterHUD = React.createClass({
26-
getInitialState: function() {
27-
return {
27+
export class ClusterHUD extends React.Component {
28+
constructor(props) {
29+
super(props);
30+
this.state = {
2831
runningQueries: [],
2932
queuedQueries: [],
3033
blockedQueries: [],
@@ -44,15 +47,19 @@ let ClusterHUD = React.createClass({
4447

4548
initialized: false,
4649
};
47-
},
48-
resetTimer: function() {
50+
51+
this.refreshLoop = this.refreshLoop.bind(this);
52+
}
53+
54+
resetTimer() {
4955
clearTimeout(this.timeoutId);
5056
// stop refreshing when query finishes or fails
5157
if (this.state.query === null || !this.state.ended) {
5258
this.timeoutId = setTimeout(this.refreshLoop, 1000);
5359
}
54-
},
55-
refreshLoop: function() {
60+
}
61+
62+
refreshLoop() {
5663
clearTimeout(this.timeoutId); // to stop multiple series of refreshLoop from going on simultaneously
5764
$.get('/v1/cluster', function (clusterState) {
5865

@@ -99,11 +106,13 @@ let ClusterHUD = React.createClass({
99106
.error(function() {
100107
this.resetTimer();
101108
}.bind(this));
102-
},
103-
componentDidMount: function() {
109+
}
110+
111+
componentDidMount() {
104112
this.refreshLoop();
105-
},
106-
componentDidUpdate: function() {
113+
}
114+
115+
componentDidUpdate() {
107116
// prevent multiple calls to componentDidUpdate (resulting from calls to setState or otherwise) within the refresh interval from re-rendering sparklines/charts
108117
if (this.state.lastRender === null || (Date.now() - this.state.lastRender) >= 1000) {
109118
const renderTimestamp = Date.now();
@@ -125,8 +134,9 @@ let ClusterHUD = React.createClass({
125134
}
126135

127136
$('[data-toggle="tooltip"]').tooltip();
128-
},
129-
render: function() {
137+
}
138+
139+
render() {
130140
return (<div className="row">
131141
<div className="col-xs-12">
132142
<div className="row">
@@ -279,9 +289,5 @@ let ClusterHUD = React.createClass({
279289
</div>
280290
</div>);
281291
}
282-
});
292+
}
283293

284-
ReactDOM.render(
285-
<ClusterHUD />,
286-
document.getElementById('cluster-hud')
287-
);

0 commit comments

Comments
 (0)