MINOR: stats: get rid of the STAT_SHOWADMIN flag

This flag is used to decide to show the check box in front of a proxy
on the HTML stat page. It is always equal to STAT_ADMIN except when the
proxy has no backend capability (i.e. a pure frontend) or has no server,
in which case it's only used to avoid leaving an empty column at the
beginning of the table. Not only this is pretty useless, but it also
causes the columns not to align well when mixing multiple proxies with
or without servers.

Let's simply always use STAT_ADMIN and get rid of this flag.
This commit is contained in:
Willy Tarreau 2019-10-09 11:11:46 +02:00
parent 578d6e4360
commit ab02b3f345
2 changed files with 6 additions and 9 deletions

View File

@ -34,7 +34,6 @@
#define STAT_SHNODE 0x00000200 /* conf: show node name */ #define STAT_SHNODE 0x00000200 /* conf: show node name */
#define STAT_SHDESC 0x00000400 /* conf: show description */ #define STAT_SHDESC 0x00000400 /* conf: show description */
#define STAT_SHLGNDS 0x00000800 /* conf: show legends */ #define STAT_SHLGNDS 0x00000800 /* conf: show legends */
#define STAT_SHOWADMIN 0x00001000 /* conf: show the admin column */
#define STAT_BOUND 0x00800000 /* bound statistics to selected proxies/types/services */ #define STAT_BOUND 0x00800000 /* bound statistics to selected proxies/types/services */
#define STAT_STARTED 0x01000000 /* some output has occurred */ #define STAT_STARTED 0x01000000 /* some output has occurred */

View File

@ -670,7 +670,7 @@ err:
} }
/* Dump all fields from <stats> into <out> using the HTML format. A column is /* Dump all fields from <stats> into <out> using the HTML format. A column is
* reserved for the checkbox is STAT_SHOWADMIN is set in <flags>. Some extra info * reserved for the checkbox is STAT_ADMIN is set in <flags>. Some extra info
* are provided if STAT_SHLGNDS is present in <flags>. * are provided if STAT_SHLGNDS is present in <flags>.
*/ */
static int stats_dump_fields_html(struct buffer *out, static int stats_dump_fields_html(struct buffer *out,
@ -684,7 +684,7 @@ static int stats_dump_fields_html(struct buffer *out,
/* name, queue */ /* name, queue */
"<tr class=\"frontend\">"); "<tr class=\"frontend\">");
if (flags & STAT_SHOWADMIN) { if (flags & STAT_ADMIN) {
/* Column sub-heading for Enable or Disable server */ /* Column sub-heading for Enable or Disable server */
chunk_appendf(out, "<td></td>"); chunk_appendf(out, "<td></td>");
} }
@ -827,7 +827,7 @@ static int stats_dump_fields_html(struct buffer *out,
} }
else if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_SO) { else if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_SO) {
chunk_appendf(out, "<tr class=socket>"); chunk_appendf(out, "<tr class=socket>");
if (flags & STAT_SHOWADMIN) { if (flags & STAT_ADMIN) {
/* Column sub-heading for Enable or Disable server */ /* Column sub-heading for Enable or Disable server */
chunk_appendf(out, "<td></td>"); chunk_appendf(out, "<td></td>");
} }
@ -932,7 +932,7 @@ static int stats_dump_fields_html(struct buffer *out,
(stats[ST_F_BCK].u.u32) ? "backup" : "active", style); (stats[ST_F_BCK].u.u32) ? "backup" : "active", style);
if (flags & STAT_SHOWADMIN) if (flags & STAT_ADMIN)
chunk_appendf(out, chunk_appendf(out,
"<td><input class='%s-checkbox' type=\"checkbox\" name=\"s\" value=\"%s\"></td>", "<td><input class='%s-checkbox' type=\"checkbox\" name=\"s\" value=\"%s\"></td>",
field_str(stats, ST_F_PXNAME), field_str(stats, ST_F_PXNAME),
@ -1188,7 +1188,7 @@ static int stats_dump_fields_html(struct buffer *out,
} }
else if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_BE) { else if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_BE) {
chunk_appendf(out, "<tr class=\"backend\">"); chunk_appendf(out, "<tr class=\"backend\">");
if (flags & STAT_SHOWADMIN) { if (flags & STAT_ADMIN) {
/* Column sub-heading for Enable or Disable server */ /* Column sub-heading for Enable or Disable server */
chunk_appendf(out, "<td></td>"); chunk_appendf(out, "<td></td>");
} }
@ -1356,9 +1356,7 @@ int stats_dump_one_line(const struct field *stats, unsigned int flags, struct pr
{ {
int ret; int ret;
if ((px->cap & PR_CAP_BE) && px->srv && (appctx->ctx.stats.flags & STAT_ADMIN)) flags |= appctx->ctx.stats.flags & STAT_ADMIN;
flags |= STAT_SHOWADMIN;
if (appctx->ctx.stats.flags & STAT_FMT_HTML) if (appctx->ctx.stats.flags & STAT_FMT_HTML)
ret = stats_dump_fields_html(&trash, stats, flags); ret = stats_dump_fields_html(&trash, stats, flags);
else if (appctx->ctx.stats.flags & STAT_FMT_TYPED) else if (appctx->ctx.stats.flags & STAT_FMT_TYPED)