Files
impala/www/query_summary.tmpl
Surya Hebbar 37d4a4eb56 IMPALA-13389: Refactor webUI scripts to use ES6 syntax
Currently, the scripts in the entire webUI contain variable and function
declarations using the ES5 standard.

In such declarations, all the variables are attached to the browser's
window object, polluting the global scope. Additionally, many unnamed
functions can be represented with cleaner and concise syntax.

This patch refactors such declarations, using the ES6 syntax.
-> Replacing 'var' declarations with 'let' and 'const'
  - To improve browser's memory utilization
  - For better scoping, immutability and readability
-> Replacing unnamed function declarations with arrow functions
  - Better scoping by binding 'this' object to the surrounding context

These improve maintainability and browser's memory utilization.

Across many instances within the webUI scripts, no particular naming
scheme is being followed for variable and function identifiers.
Hence, they have been revised with the following naming scheme.
-> All function names have been declared using camel case.
-> All constant primitive values and strings have been declared
   in uppercase.
-> All other types of variables have been declared using snake case.

This naming scheme allows easier distinction between functions,
constants and other variables, based on the identifiers.

These changes to code style are further enforced during code review
through IMPALA-13473.

Change-Id: Ie38f2c642ede14956a2c6d551a58e42538204768
Reviewed-on: http://gerrit.cloudera.org:8080/21851
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2025-04-10 20:33:49 +00:00

80 lines
2.5 KiB
Cheetah

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
{{> www/common-header.tmpl }}
{{> www/query_detail_tabs.tmpl }}
<div>
<label>
<input type="checkbox" checked="true" id="toggle" onClick="toggleRefresh()"/>
<span id="refresh_on">Auto-refresh on</span>
</label> Last updated: <span id="last_updated"></span>
</div>
<h3>Timeline</h3>
<pre id="timeline">{{timeline}}</pre>
<h3>Exec Summary</h3>
<pre id="summary">{{summary}}</pre>
<script>
$("#summary-tab").addClass("active");
// Periodically refreshes the summary details
function refresh() {
const xhr = new XMLHttpRequest();
xhr.responseType = 'text';
xhr.timeout = 60000;
xhr.onload = (ignored_arg) => {
if (xhr.status != 200) {
return;
}
const blob = xhr.response;
json = JSON.parse(blob);
if (json.error) {
clearInterval(interval_id);
document.getElementById("toggle").checked = false;
return;
}
refresh_record(json.record_json);
document.getElementById("timeline").textContent = json["timeline"].trim();
document.getElementById("summary").textContent = json["summary"].trim();
document.getElementById("status").textContent = json["status"];
document.getElementById("last-updated").textContent = new Date();
}
xhr.open('GET', make_url("/query_summary?query_id={{query_id}}&json"), true);
xhr.send();
}
document.getElementById("last-updated").textContent = new Date();
let interval_id = setInterval(refresh, 1000);
function toggleRefresh() {
if (document.getElementById("toggle").checked === true) {
interval_id = setInterval(refresh, 1000);
document.getElementById("refresh_on").textContent = "Auto-refresh on";
} else {
clearInterval(interval_id);
document.getElementById("refresh_on").textContent = "Auto-refresh off";
}
}
</script>
{{> www/common-footer.tmpl}}