You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ja...@apache.org on 2024/02/08 09:22:37 UTC

(solr) branch branch_9x updated: SOLR-17152: Better alignment of Admin UI graph (#2249)

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

janhoy pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 95685388cf3 SOLR-17152: Better alignment of Admin UI graph (#2249)
95685388cf3 is described below

commit 95685388cf3ed0e2bfdd5ed6bd836bd9b619ee7f
Author: Jan Høydahl <ja...@apache.org>
AuthorDate: Thu Feb 8 10:16:35 2024 +0100

    SOLR-17152: Better alignment of Admin UI graph (#2249)
    
    (cherry picked from commit 4e62f98d8c2c64b0a2f296edfc795f2fbc6b9aa0)
---
 solr/CHANGES.txt                                |  2 +-
 solr/webapp/web/js/angular/controllers/cloud.js | 22 ++++++++++++++--------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 84a2b40ac5f..cff3ad08e06 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -31,7 +31,7 @@ Optimizations
 
 Bug Fixes
 ---------------------
-(No changes)
+* SOLR-17152: Better alignment of Admin UI graph (janhoy)
 
 Dependency Upgrades
 ---------------------
diff --git a/solr/webapp/web/js/angular/controllers/cloud.js b/solr/webapp/web/js/angular/controllers/cloud.js
index 70b89611614..75eef23dae5 100644
--- a/solr/webapp/web/js/angular/controllers/cloud.js
+++ b/solr/webapp/web/js/angular/controllers/cloud.js
@@ -929,18 +929,21 @@ solrAdminApp.directive('graph', function(Constants) {
                 return name;
             };
 
-            scope.$watch("data", function(newValue, oldValue) {
+            var drawGraph = function(newValue, oldValue) {
                 if (newValue) {
-                    flatGraph(element, scope.data, scope.leafCount);
+                  flatGraph(element, scope.data, scope.leafCount);
                 }
 
                 $('text').tooltip({
-                    content: function() {
-                        return $(this).attr('title');
-                    }
+                  content: function() {
+                    return $(this).attr('title');
+                  }
                 });
-            });
+              };
+
+            scope.$watch("data", drawGraph);
 
+            window.onresize = drawGraph;
 
             function setNodeNavigationBehavior(node, view){
                 node
@@ -971,7 +974,10 @@ solrAdminApp.directive('graph', function(Constants) {
                 var w = element.width(),
                     h = leafCount * 20;
 
-                var tree = d3.layout.tree().size([h, w - 400]);
+                // Calculate roughly the width of host name to align the graph
+                var hostnameWidth = graphData.children.length > 0 ?
+                  graphData.children[0].children[0].children[0].name.length * 5.5 : 400;
+                var tree = d3.layout.tree().size([h, Math.max(w - 140 - hostnameWidth, 100)]);
 
                 var diagonal = d3.svg.diagonal().projection(function (d) {
                     return [d.y, d.x];
@@ -982,7 +988,7 @@ solrAdminApp.directive('graph', function(Constants) {
                     .attr('width', w)
                     .attr('height', h)
                     .append('g')
-                    .attr('transform', 'translate(100, 0)');
+                    .attr('transform', 'translate(10, 0)');
 
                 var nodes = tree.nodes(graphData);