]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: do not display empty stat module title on html
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 3 Nov 2020 14:04:46 +0000 (15:04 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 3 Nov 2020 16:04:22 +0000 (17:04 +0100)
If a stat module is not available on the current proxy scope, do not
display its title on the related html box. This is clearer for the user.

src/stats.c

index 82e2b1f6d9fab16eda36755ba34e1acfdd9abcae..762672f45e5d43719a9e9d44da736931fb87ebf2 100644 (file)
@@ -949,22 +949,24 @@ static int stats_dump_fields_html(struct buffer *out,
 
                if (flags & STAT_SHMODULES) {
                        list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
-                               chunk_appendf(out,
-                                             "<td><u>%s<div class=tips><table class=det>",
-                                             mod->name);
+                               chunk_appendf(out, "<td>");
+
                                if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_FE) {
+                                       chunk_appendf(out,
+                                                     "<u>%s<div class=tips><table class=det>",
+                                                     mod->name);
                                        for (j = 0; j < mod->stats_count; ++j) {
                                                chunk_appendf(out,
                                                              "<tr><th>%s</th><td>%s</td></tr>",
                                                              mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i]));
                                                ++i;
                                        }
+                                       chunk_appendf(out, "</table></div></u>");
                                } else {
                                        i += mod->stats_count;
                                }
 
-                               chunk_appendf(out,
-                                             "</table></div></u></td>");
+                               chunk_appendf(out, "</td>");
                        }
                }
 
@@ -1033,22 +1035,24 @@ static int stats_dump_fields_html(struct buffer *out,
 
                if (flags & STAT_SHMODULES) {
                        list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
-                               chunk_appendf(out,
-                                             "<td><u>%s<div class=tips><table class=det>",
-                                             mod->name);
+                               chunk_appendf(out, "<td>");
+
                                if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_LI) {
+                                       chunk_appendf(out,
+                                                     "<u>%s<div class=tips><table class=det>",
+                                                     mod->name);
                                        for (j = 0; j < mod->stats_count; ++j) {
                                                chunk_appendf(out,
                                                              "<tr><th>%s</th><td>%s</td></tr>",
                                                              mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i]));
                                                ++i;
                                        }
+                                       chunk_appendf(out, "</table></div></u>");
                                } else {
                                        i += mod->stats_count;
                                }
 
-                               chunk_appendf(out,
-                                             "</table></div></u></td>");
+                               chunk_appendf(out, "</td>");
                        }
                }
 
@@ -1371,22 +1375,24 @@ static int stats_dump_fields_html(struct buffer *out,
 
                if (flags & STAT_SHMODULES) {
                        list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
-                               chunk_appendf(out,
-                                             "<td><u>%s<div class=tips><table class=det>",
-                                             mod->name);
+                               chunk_appendf(out, "<td>");
+
                                if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_SRV) {
+                                       chunk_appendf(out,
+                                                     "<u>%s<div class=tips><table class=det>",
+                                                     mod->name);
                                        for (j = 0; j < mod->stats_count; ++j) {
                                                chunk_appendf(out,
                                                              "<tr><th>%s</th><td>%s</td></tr>",
                                                              mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i]));
                                                ++i;
                                        }
+                                       chunk_appendf(out, "</table></div></u>");
                                } else {
                                        i += mod->stats_count;
                                }
 
-                               chunk_appendf(out,
-                                             "</table></div></u></td>");
+                               chunk_appendf(out, "</td>");
                        }
                }
 
@@ -1562,21 +1568,24 @@ static int stats_dump_fields_html(struct buffer *out,
 
                if (flags & STAT_SHMODULES) {
                        list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
-                               chunk_appendf(out,
-                                             "<td><u>%s<div class=tips><table class=det>",
-                                             mod->name);
+                               chunk_appendf(out, "<td>");
+
                                if (stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_BE) {
+                                       chunk_appendf(out,
+                                                     "<u>%s<div class=tips><table class=det>",
+                                                     mod->name);
                                        for (j = 0; j < mod->stats_count; ++j) {
                                                chunk_appendf(out,
                                                              "<tr><th>%s</th><td>%s</td></tr>",
                                                              mod->stats[j].desc, field_to_html_str(&stats[ST_F_TOTAL_FIELDS + i]));
                                                ++i;
                                        }
+                                       chunk_appendf(out, "</table></div></u>");
                                } else {
                                        i += mod->stats_count;
                                }
-                               chunk_appendf(out,
-                                             "</table></div></u></td>");
+
+                               chunk_appendf(out, "</td>");
                        }
                }