]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix the charts in the statistics channel
authorAram Sargsyan <aram@isc.org>
Fri, 26 Sep 2025 12:51:37 +0000 (12:51 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Wed, 10 Dec 2025 17:30:43 +0000 (17:30 +0000)
The statistics channel's HTML presentation has charts, but it has
a couple of problems.

1. Because of an inconsistent condition, a chart's JS code might have
   been executed, while the HTML markup wasn't present, and this is
   causing a JS error.
2. The feature is turned off on Mozilla-based browsers.

Fix the inconsistency in conditions, remove the conditional rendering
which disabled the feature for Mozilla-based browsers by looking at
the XSLT processor's name, and fix indentation inconsistencies.

bin/named/bind9.xsl

index ae1820de0d50669a9307aea7a05c45bbb18c0fc9..359c2d99e4e1a0adb68f90b12e08adc73fb37e49 100644 (file)
           });
         </script>
 
-        <xsl:if test="system-property('xsl:vendor')!='Transformiix'">
-          <!-- Non Mozilla specific markup -->
-          <script type="text/javascript" src="https://www.google.com/jsapi"/>
-          <script type="text/javascript">
-
-           google.load("visualization", "1", {packages:["corechart"]});
-           google.setOnLoadCallback(loadGraphs);
-
-           var graphs=[];
-
-           function drawChart(chart_title,target,style,data) {
-             var data = google.visualization.arrayToDataTable(data);
-
-             var options = {
-               title: chart_title
-             };
-
-             var chart;
-             if (style == "barchart") {
-               chart = new google.visualization.BarChart(document.getElementById(target));
-               chart.draw(data, options);
-             } else if (style == "piechart") {
-               chart = new google.visualization.PieChart(document.getElementById(target));
-               chart.draw(data, options);
-             }
-           }
-
-           function loadGraphs(){
-             var g;
-
-             while(g = graphs.shift()){
-               // alert("going for: " + g.target);
-               if(g.data.length > 1){
-                 drawChart(g.title,g.target,g.style,g.data);
-               }
-             }
-           }
+        <script type="text/javascript" src="https://www.google.com/jsapi"/>
+        <script type="text/javascript">
+          google.load("visualization", "1", {packages:["corechart"]});
+          google.setOnLoadCallback(loadGraphs);
+
+          var graphs=[];
+
+          function drawChart(chart_title,target,style,data) {
+            var data = google.visualization.arrayToDataTable(data);
+
+            var options = {
+              title: chart_title
+            };
+
+            var chart;
+            if (style == "barchart") {
+              chart = new google.visualization.BarChart(document.getElementById(target));
+              chart.draw(data, options);
+            } else if (style == "piechart") {
+              chart = new google.visualization.PieChart(document.getElementById(target));
+              chart.draw(data, options);
+            }
+          }
+
+          function loadGraphs(){
+            var g;
+
+            while (g = graphs.shift()) {
+              if (g.data.length > 1) {
+                drawChart(g.title,g.target,g.style,g.data);
+              }
+            }
+          }
+
+          <xsl:if test="server/counters[@type=&quot;qtype&quot;]/counter[. &gt; 0]">
+            // Server Incoming Query Types
+            graphs.push({
+              'title' : "Server Incoming Query Types",
+              'target': 'chart_incoming_qtypes',
+              'style': 'barchart',
+              'data': [['Type','Counter'],<xsl:for-each select="server/counters[@type=&quot;qtype&quot;]/counter">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
+            });
+          </xsl:if>
 
-           <xsl:if test="server/counters[@type=&quot;qtype&quot;]/counter">
-             // Server Incoming Query Types
-             graphs.push({
-                          'title' : "Server Incoming Query Types",
-                          'target': 'chart_incoming_qtypes',
-                          'style': 'barchart',
-                          'data': [['Type','Counter'],<xsl:for-each select="server/counters[@type=&quot;qtype&quot;]/counter">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
-                          });
-           </xsl:if>
+          <xsl:if test="server/counters[@type=&quot;opcode&quot;]/counter[. &gt; 0]">
+            // Server Incoming Requests by opcode
+            graphs.push({
+              'title' : "Server Incoming Requests by DNS Opcode",
+              'target': 'chart_incoming_opcodes',
+              'style': 'barchart',
+              'data': [['Opcode','Counter'],<xsl:for-each select="server/counters[@type=&quot;opcode&quot;]/counter[. &gt; 0 or substring(@name,1,3) != 'RES']">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
+            });
+          </xsl:if>
+        </script>
 
-           <xsl:if test="server/counters[@type=&quot;opcode&quot;]/counter">
-             // Server Incoming Requests by opcode
-             graphs.push({
-                          'title' : "Server Incoming Requests by DNS Opcode",
-                          'target': 'chart_incoming_opcodes',
-                          'style': 'barchart',
-                          'data': [['Opcode','Counter'],<xsl:for-each select="server/counters[@type=&quot;opcode&quot;]/counter[. &gt; 0 or substring(@name,1,3) != 'RES']">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]});
-           </xsl:if>
-         </script>
-        </xsl:if>
         <style type="text/css">
      body {
       font-family: sans-serif;
         </table>
         <br/>
         <xsl:if test="server/counters[@type=&quot;opcode&quot;]/counter[. &gt; 0]">
-          <xsl:if test="system-property('xsl:vendor')!='Transformiix'">
-            <h2>Incoming Requests by DNS Opcode</h2>
-            <!-- Non Mozilla specific markup -->
-            <div class="pie" id="chart_incoming_opcodes">
-             [cannot display chart]
-           </div>
-          </xsl:if>
+          <h2>Incoming Requests by DNS Opcode</h2>
+          <div class="pie" id="chart_incoming_opcodes">
+           [cannot display chart]
+         </div>
           <table class="counters">
             <xsl:for-each select="server/counters[@type=&quot;opcode&quot;]/counter[. &gt; 0 or substring(@name,1,3) != 'RES']">
               <xsl:sort select="." data-type="number" order="descending"/>
           </table>
           <br/>
         </xsl:if>
-        <xsl:if test="server/counters[@type=&quot;qtype&quot;]/counter">
-          <xsl:if test="system-property('xsl:vendor')!='Transformiix'">
-            <!-- Non Mozilla specific markup -->
-            <h3>Incoming Queries by Query Type</h3>
-            <div class="pie" id="chart_incoming_qtypes">
-             [cannot display chart]
-           </div>
-          </xsl:if>
+        <xsl:if test="server/counters[@type=&quot;qtype&quot;]/counter[. &gt; 0]">
+          <h3>Incoming Queries by Query Type</h3>
+          <div class="pie" id="chart_incoming_qtypes">
+           [cannot display chart]
+         </div>
           <table class="counters">
             <xsl:for-each select="server/counters[@type=&quot;qtype&quot;]/counter">
               <xsl:sort select="." data-type="number" order="descending"/>
           <h2>Outgoing Queries per view</h2>
           <xsl:for-each select="views/view[count(counters[@type=&quot;resqtype&quot;]/counter) &gt; 0]">
             <h3>View <xsl:value-of select="@name"/></h3>
-            <xsl:if test="system-property('xsl:vendor')!='Transformiix'">
-              <!-- Non Mozilla specific markup -->
-              <script type="text/javascript">
-                 graphs.push({
-                               'title': "Outgoing Queries for view: <xsl:value-of select="@name"/>",
-                               'target': 'chart_outgoing_queries_view_<xsl:value-of select="@name"/>',
-                               'style': 'barchart',
-                               'data': [['Type','Counter'],<xsl:for-each select="counters[@type=&quot;resqtype&quot;]/counter">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
-                               });
-             </script>
-              <xsl:variable name="target">
-                <xsl:value-of select="@name"/>
-              </xsl:variable>
-              <div class="pie" id="chart_outgoing_queries_view_{$target}">[no data to display]</div>
-            </xsl:if>
+            <script type="text/javascript">
+             graphs.push({
+                'title': "Outgoing Queries for view: <xsl:value-of select="@name"/>",
+                'target': 'chart_outgoing_queries_view_<xsl:value-of select="@name"/>',
+                'style': 'barchart',
+                'data': [['Type','Counter'],<xsl:for-each select="counters[@type=&quot;resqtype&quot;]/counter">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
+             });
+            </script>
+            <xsl:variable name="target">
+              <xsl:value-of select="@name"/>
+            </xsl:variable>
+            <div class="pie" id="chart_outgoing_queries_view_{$target}">[no data to display]</div>
             <table class="counters">
               <xsl:for-each select="counters[@type=&quot;resqtype&quot;]/counter">
                 <xsl:sort select="." data-type="number" order="descending"/>
         </xsl:if>
         <xsl:if test="server/counters[@type=&quot;nsstat&quot;]/counter[.&gt;0]">
           <h2>Server Statistics</h2>
-          <xsl:if test="system-property('xsl:vendor')!='Transformiix'">
-            <!-- Non Mozilla specific markup -->
             <script type="text/javascript">
-                 graphs.push({
-                               'title' : "Server Counters",
-                               'target': 'chart_server_nsstat_restype',
-                               'style': 'barchart',
-                               'data': [['Type','Counter'],<xsl:for-each select="server/counters[@type=&quot;nsstat&quot;]/counter[.&gt;0]">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
-                               });
-             </script>
-            <div class="pie" id="chart_server_nsstat_restype">[no data to display]</div>
-          </xsl:if>
+              graphs.push({
+                'title' : "Server Counters",
+                'target': 'chart_server_nsstat_restype',
+                'style': 'barchart',
+                'data': [['Type','Counter'],<xsl:for-each select="server/counters[@type=&quot;nsstat&quot;]/counter[.&gt;0]">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
+              });
+            </script>
+          <div class="pie" id="chart_server_nsstat_restype">[no data to display]</div>
           <table class="counters">
             <xsl:for-each select="server/counters[@type=&quot;nsstat&quot;]/counter[.&gt;0]">
               <xsl:sort select="." data-type="number" order="descending"/>
           <br/>
         </xsl:if>
         <xsl:if test="server/counters[@type=&quot;zonestat&quot;]/counter[.&gt;0]">
-          <xsl:if test="system-property('xsl:vendor')!='Transformiix'">
-            <h2>Zone Maintenance Statistics</h2>
-            <script type="text/javascript">
-                 graphs.push({
-                               'title' : "Zone Maintenance Stats",
-                               'target': 'chart_server_zone_maint',
-                               'style': 'barchart',
-                               'data': [['Type','Counter'],<xsl:for-each select="server/counters[@type=&quot;zonestat&quot;]/counter[.&gt;0]">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
-                               });
-           </script>
-            <!-- Non Mozilla specific markup -->
-            <div class="pie" id="chart_server_zone_maint">[no data to display]</div>
-          </xsl:if>
+          <h2>Zone Maintenance Statistics</h2>
+          <script type="text/javascript">
+            graphs.push({
+              'title' : "Zone Maintenance Stats",
+              'target': 'chart_server_zone_maint',
+              'style': 'barchart',
+              'data': [['Type','Counter'],<xsl:for-each select="server/counters[@type=&quot;zonestat&quot;]/counter[.&gt;0]">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
+            });
+          </script>
+          <div class="pie" id="chart_server_zone_maint">[no data to display]</div>
           <table class="counters">
             <xsl:for-each select="server/counters[@type=&quot;zonestat&quot;]/counter">
               <xsl:sort select="." data-type="number" order="descending"/>
             <xsl:for-each select="zones/zone">
               <xsl:if test="counters[@type=&quot;qtype&quot;]/counter[count(.) &gt; 0]">
                 <h4>Zone <xsl:value-of select="@name"/></h4>
-                <xsl:if test="system-property('xsl:vendor')!='Transformiix'">
-                  <!-- Non Mozilla specific markup -->
-                  <script type="text/javascript">
-                       graphs.push({
-                                     'title': "Query types for zone <xsl:value-of select="@name"/>",
-                                     'target': 'chart_qtype_<xsl:value-of select="../../@name"/>_<xsl:value-of select="@name"/>',
-                                     'style': 'barchart',
-                                     'data': [['Type','Counter'],<xsl:for-each select="counters[@type=&quot;qtype&quot;]/counter[.&gt;0 and @name != &quot;QryAuthAns&quot;]">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
-                                     });
-
-                   </script>
-                  <xsl:variable name="target">
-                    <xsl:value-of select="@name"/>
-                  </xsl:variable>
-                  <div class="pie" id="chart_qtype_{$thisview}_{$target}">[no data to display]</div>
-                </xsl:if>
+                <script type="text/javascript">
+                  graphs.push({
+                    'title': "Query types for zone <xsl:value-of select="@name"/>",
+                    'target': 'chart_qtype_<xsl:value-of select="../../@name"/>_<xsl:value-of select="@name"/>',
+                    'style': 'barchart',
+                    'data': [['Type','Counter'],<xsl:for-each select="counters[@type=&quot;qtype&quot;]/counter[.&gt;0 and @name != &quot;QryAuthAns&quot;]">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
+                  });
+                </script>
+                <xsl:variable name="target">
+                  <xsl:value-of select="@name"/>
+                </xsl:variable>
+                <div class="pie" id="chart_qtype_{$thisview}_{$target}">[no data to display]</div>
                 <table class="counters">
                   <xsl:for-each select="counters[@type=&quot;qtype&quot;]/counter">
                     <xsl:sort select="."/>
             <xsl:for-each select="zones/zone">
               <xsl:if test="counters[@type=&quot;rcode&quot;]/counter[. &gt; 0]">
                 <h4>Zone <xsl:value-of select="@name"/></h4>
-                <xsl:if test="system-property('xsl:vendor')!='Transformiix'">
-                  <!-- Non Mozilla specific markup -->
-                  <script type="text/javascript">
-                       graphs.push({
-                                     'title': "Response codes for zone <xsl:value-of select="@name"/>",
-                                     'target': 'chart_rescode_<xsl:value-of select="../../@name"/>_<xsl:value-of select="@name"/>',
-                                     'style': 'barchart',
-                                     'data': [['Type','Counter'],<xsl:for-each select="counters[@type=&quot;rcode&quot;]/counter[.&gt;0 and @name != &quot;QryAuthAns&quot;]">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
-                                     });
-
-               </script>
-                  <xsl:variable name="target">
-                    <xsl:value-of select="@name"/>
-                  </xsl:variable>
-                  <div class="pie" id="chart_rescode_{$thisview2}_{$target}">[no data to display]</div>
-                </xsl:if>
+                <script type="text/javascript">
+                  graphs.push({
+                    'title': "Response codes for zone <xsl:value-of select="@name"/>",
+                    'target': 'chart_rescode_<xsl:value-of select="../../@name"/>_<xsl:value-of select="@name"/>',
+                    'style': 'barchart',
+                    'data': [['Type','Counter'],<xsl:for-each select="counters[@type=&quot;rcode&quot;]/counter[.&gt;0 and @name != &quot;QryAuthAns&quot;]">['<xsl:value-of select="@name"/>',<xsl:value-of select="."/>],</xsl:for-each>]
+                  });
+                </script>
+                <xsl:variable name="target">
+                  <xsl:value-of select="@name"/>
+                </xsl:variable>
+                <div class="pie" id="chart_rescode_{$thisview2}_{$target}">[no data to display]</div>
                 <table class="counters">
                   <xsl:for-each select="counters[@type=&quot;rcode&quot;]/counter[.&gt;0 and @name != &quot;QryAuthAns&quot;]">
                     <xsl:sort select="."/>