This is an automated email from the ASF dual-hosted git repository.

pifta pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new c83bd0885c HDDS-9732. SCM WebUI incorrectly renders DN links (#5642)
c83bd0885c is described below

commit c83bd0885cec2d4d5e8897d1e9ddfe630a33738f
Author: Istvan Fajth <[email protected]>
AuthorDate: Wed Nov 22 15:18:00 2023 +0100

    HDDS-9732. SCM WebUI incorrectly renders DN links (#5642)
---
 .../main/resources/webapps/scm/scm-overview.html   |  9 ++++-
 .../src/main/resources/webapps/scm/scm.js          | 47 +++++++++++++---------
 2 files changed, 37 insertions(+), 19 deletions(-)

diff --git 
a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html 
b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html
index af032160e7..f16187ff44 100644
--- a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html
+++ b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html
@@ -56,7 +56,14 @@
     </thead>
     <tbody>
         <tr ng-repeat="typestat in 
nodeStatus|filter:search|orderBy:columnName:reverse">
-            <td><a 
href="{{typestat.portval.toLowerCase()}}://{{typestat.hostname}}:{{typestat.portno}}"
 target="_blank">{{typestat.hostname}}</a></td>
+            <td ng-switch="typestat.port > 0">
+                <span ng-switch-when="true">
+                    <a 
href="{{typestat.protocol}}://{{typestat.hostname}}:{{typestat.port}}" 
target="_blank">{{typestat.hostname}}</a>
+                </span>
+                <span ng-switch-when="false">
+                    {{typestat.hostname}}
+                </span>
+            </td>
             <td>{{typestat.opstate}}</td>
             <td>{{typestat.comstate}}</td>
        </tr>
diff --git a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js 
b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js
index 367253916c..8669528b43 100644
--- a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js
+++ b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js
@@ -32,8 +32,25 @@
             $scope.RecordsToDisplay = "10";
             $scope.currentPage = 1;
             $scope.lastIndex = 0;
-            var protocol = "";
-            var portNo = "";
+
+            function get_protocol(URLScheme, value, baseProto, fallbackProto) {
+                let protocol = "unknown"
+                let port = -1;
+                if (URLScheme.toLowerCase() === baseProto) {
+                    let portSpec = value && value.find((element) => 
element.key.toLowerCase() === baseProto)
+                    if (portSpec) {
+                        port = portSpec.value
+                        protocol = baseProto
+                        return { proto : protocol, port: port }
+                    }
+                    portSpec = value && value.find((element) => 
element.key.toLowerCase() === fallbackProto);
+                    if (portSpec) {
+                        port = portSpec.value
+                        protocol = fallbackProto
+                    }
+                }
+                return { proto : protocol, port: port }
+            }
 
             
$http.get("jmx?qry=Hadoop:service=SCMNodeManager,name=SCMNodeManagerInfo")
                 .then(function (result) {
@@ -42,24 +59,18 @@
 
                     $scope.nodeStatus = ctrl.nodemanagermetrics
                         && ctrl.nodemanagermetrics.NodeStatusInfo
-                        && ctrl.nodemanagermetrics.NodeStatusInfo.map(
-                            ({ key, value }) => {
-                                value.map(({key, value}) => {
-                                    if (key == "HTTP") {
-                                        protocol = key;
-                                        portNo = value;
-                                    }
-                                    if (key == "HTTPS"){
-                                        protocol = key.toLowerCase() === 
URLScheme ? key : "HTTP";
-                                        portNo = value;
-                                    }
-                                });
+                        && ctrl.nodemanagermetrics.NodeStatusInfo
+                            .map(({ key, value }) => {
+                                let portSpec = get_protocol(URLScheme, value, 
"https", "http")
+                                if (portSpec.port === -1) {
+                                    portSpec = get_protocol(URLScheme, value, 
"http", "https")
+                                }
                                 return {
                                     hostname: key,
-                                    opstate: value && value.find((element) => 
element.key == "OPSTATE").value,
-                                    comstate: value && value.find((element) => 
element.key == "COMSTATE").value,
-                                    portno: portNo,
-                                    portval: protocol
+                                    opstate: value && value.find((element) => 
element.key === "OPSTATE").value,
+                                    comstate: value && value.find((element) => 
element.key === "COMSTATE").value,
+                                    port: portSpec.port,
+                                    protocol: portSpec.proto
                                 }
                             });
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to