DRILL-6044: Fixed shutdown button in Web UI when ssl,auth are enabled This closes #1153
Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/cac2882d Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/cac2882d Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/cac2882d Branch: refs/heads/master Commit: cac2882d5a9e22fbc251e4caf622fe30242ad557 Parents: 920a12a Author: dvjyothsna <jyothsna....@gmail.com> Authored: Tue Mar 6 18:10:22 2018 -0800 Committer: Parth Chandra <par...@apache.org> Committed: Sun Mar 11 11:35:50 2018 +0530 ---------------------------------------------------------------------- .../java-exec/src/main/resources/rest/index.ftl | 34 ++++++++++++-------- 1 file changed, 21 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/cac2882d/exec/java-exec/src/main/resources/rest/index.ftl ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/resources/rest/index.ftl b/exec/java-exec/src/main/resources/rest/index.ftl index 449ea04..e2924fa 100644 --- a/exec/java-exec/src/main/resources/rest/index.ftl +++ b/exec/java-exec/src/main/resources/rest/index.ftl @@ -66,7 +66,7 @@ <tr id="row-${i}"> <td>${i}</td> <td id="address" >${drillbit.getAddress()}<#if drillbit.isCurrent()> - <span class="label label-info">Current</span> + <span class="label label-info" id="current">Current</span> </#if> </td> <td id="port" >${drillbit.getUserPort()}</td> @@ -79,9 +79,9 @@ </span> </td> <td id="status" >${drillbit.getState()}</td> - <#if model.shouldShowAdminInfo() || !model.isAuthEnabled() > + <#if (model.shouldShowAdminInfo() || !model.isAuthEnabled()) && drillbit.isCurrent() > <td> - <button type="button" id="shutdown" onClick="shutdown('${drillbit.getAddress()}',$(this));"> SHUTDOWN </button> + <button type="button" id="shutdown" onClick="shutdown($(this));"> SHUTDOWN </button> </td> </#if> <td id="queriesCount"> </td> @@ -143,7 +143,6 @@ </div> </div> </#if> - <#assign queueInfo = model.queueInfo() /> <div class="row"> <div class="col-md-12"> @@ -194,7 +193,6 @@ var timeout; var size = $("#size").html(); - function getPortNum() { var port = $.ajax({ type: 'GET', @@ -247,19 +245,22 @@ $("#row-"+i).find("#queriesCount").text(""); } else { - if( status_map[key] == "ONLINE") { + if (status_map[key] == "ONLINE") { $("#row-"+i).find("#status").text(status_map[key]); } else { - fillQueryCount(address,i); + if ($("#row-"+i).find("#current").html() == "Current") { + fillQueryCount(i); + } $("#row-"+i).find("#status").text(status_map[key]); } } } } - function fillQueryCount(address,row_id) { - url = "http://"+address+":"+portNum+"/queriesCount"; - var result = $.ajax({ + function fillQueryCount(row_id) { + var requestPath = "/queriesCount"; + var url = getRequestUrl(requestPath); + var result = $.ajax({ type: 'GET', url: url, complete: function(data) { @@ -269,9 +270,10 @@ } }); } - <#if model.shouldShowAdminInfo() || !model.isAuthEnabled() > - function shutdown(address,button) { - url = "http://"+address+":"+portNum+"/gracefulShutdown"; + <#if model.shouldShowAdminInfo() || !model.isAuthEnabled()> + function shutdown(button) { + var requestPath = "/gracefulShutdown"; + var url = getRequestUrl(requestPath); var result = $.ajax({ type: 'POST', url: url, @@ -283,6 +285,12 @@ }); } </#if> + function getRequestUrl(requestPath) { + var protocol = location.protocol; + var host = location.host; + var url = protocol + "//" + host + requestPath; + return url; + } </script> </#macro>