From 8ae5fbf489a60dd5b3c3f02c8529a34c15562a02 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 13 Nov 2017 10:10:20 +0000 Subject: [PATCH] output: improve html table Update DataTables and Bootstrap versions. Add free IP counts to table. Replace yellow as warning with magenta that is easier to read from white background. Use italic and bold to emphasis warning and critical. Remove strips. Use ascent percent sort by default. Signed-off-by: Sami Kerola --- TODO | 1 + src/output.c | 43 ++++++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/TODO b/TODO index 7a7b5aa..a3fb5b3 100644 --- a/TODO +++ b/TODO @@ -19,6 +19,7 @@ o Add lease time histogram support. o Update gnulib o Update bootstrap +o Update DataTables, and bootstrap versions; see https://datatables.net/download/index o Update NEWS, webpages/index.html dateModified & version (remove old doxygen before uploading new). o Make annotated git tag diff --git a/src/output.c b/src/output.c index 55853c9..21d67f4 100644 --- a/src/output.c +++ b/src/output.c @@ -61,11 +61,11 @@ static const char *color_tags[][NUM_OF_OUT_FORMS] = { [STATUS_OK] = { "", "" }, - [STATUS_WARN] = { "\033[1;33m", "" }, - [STATUS_CRIT] = { "\033[1;31m", "" }, - [STATUS_IGNORED] = { "\033[1;32m", "" }, - [STATUS_SUPPRESSED] = { "\033[1;34m", "" }, - [COLOR_RESET] = { "\033[0m", "" } + [STATUS_WARN] = { "\033[1;33m", " style=\"color:magenta;font-style:italic\"" }, + [STATUS_CRIT] = { "\033[1;31m", " style=\"color:red;font-weight:bold\"" }, + [STATUS_IGNORED] = { "\033[1;32m", " style=\"color:green\"" }, + [STATUS_SUPPRESSED] = { "\033[1;34m", " style=\"color:blue\"" }, + [COLOR_RESET] = { "\033[0m", "" } }; @@ -586,8 +586,8 @@ static void html_header(struct conf_t *state, FILE *restrict f) fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "\n"); - fprintf(f, "\n"); - fprintf(f, ""); + fprintf(f, "\n"); + fprintf(f, "\n"); fprintf(f, "\n"); @@ -609,11 +609,10 @@ static void html_footer(FILE *restrict f) fprintf(f, "Generated using %s
\n", PACKAGE_STRING); fprintf(f, "More info at %s\n", PACKAGE_URL, PACKAGE_URL); fprintf(f, "
\n"); - fprintf(f, "\n"); - fprintf(f, "\n"); - fprintf(f, "\n"); - fprintf(f, "\n"); - fprintf(f, "\n"); + fprintf(f, "\n"); + fprintf(f, "\n"); + fprintf(f, "\n"); + fprintf(f, "\n"); fprintf(f, "\n"); } @@ -671,14 +670,10 @@ static void output_double_color(struct conf_t *state, struct output_helper_t *oh, FILE *restrict f, char const *restrict type) { - int color_set = 0; - - fprintf(f, "<%s>", type); + fprintf(f, "<%s", type); if (state->color_mode == color_on) - color_set = start_color(state, oh, f); - fprintf(f, "%g", oh->percent); - if (color_set) - fputs(color_tags[COLOR_RESET][state->output_format], f); + start_color(state, oh, f); + fprintf(f, ">%g", oh->percent); fprintf(f, "\n", type); } @@ -699,7 +694,7 @@ static void output_float(FILE *restrict f, char const *restrict type, float fl) */ static void table_start(FILE *restrict f, char const *restrict id, char const *restrict summary) { - fprintf(f, "\n", id, summary); + fprintf(f, "
\n", id, summary); } /*! \brief End table in html output format. @@ -741,6 +736,7 @@ static int output_html(struct conf_t *state) output_line(outfile, "th", "name"); output_line(outfile, "th", "max"); output_line(outfile, "th", "cur"); + output_line(outfile, "th", "free"); output_line(outfile, "th", "percent"); output_line(outfile, "th", "touch"); output_line(outfile, "th", "t+c"); @@ -759,6 +755,7 @@ static int output_html(struct conf_t *state) output_line(outfile, "td", state->shared_net_root->name); output_double(outfile, "td", state->shared_net_root->available); output_double(outfile, "td", state->shared_net_root->used); + output_double(outfile, "td", state->shared_net_root->available - state->shared_net_root->used); output_float(outfile, "td", oh.percent); output_double(outfile, "td", state->shared_net_root->touched); output_double(outfile, "td", oh.tc); @@ -779,6 +776,7 @@ static int output_html(struct conf_t *state) output_line(outfile, "th", "name"); output_line(outfile, "th", "max"); output_line(outfile, "th", "cur"); + output_line(outfile, "th", "free"); output_line(outfile, "th", "percent"); output_line(outfile, "th", "touch"); output_line(outfile, "th", "t+c"); @@ -799,6 +797,7 @@ static int output_html(struct conf_t *state) output_line(outfile, "td", shared_p->name); output_double(outfile, "td", shared_p->available); output_double(outfile, "td", shared_p->used); + output_double(outfile, "td", shared_p->available - shared_p->used); output_double_color(state, &oh, outfile, "td"); output_double(outfile, "td", shared_p->touched); output_double(outfile, "td", oh.tc); @@ -822,7 +821,8 @@ static int output_html(struct conf_t *state) output_line(outfile, "th", "last ip"); output_line(outfile, "th", "max"); output_line(outfile, "th", "cur"); - output_double_color(state, &oh, outfile, "td"); + output_line(outfile, "th", "free"); + output_line(outfile, "th", "percent"); output_line(outfile, "th", "touch"); output_line(outfile, "th", "t+c"); output_line(outfile, "th", "t+c perc"); @@ -850,6 +850,7 @@ static int output_html(struct conf_t *state) output_line(outfile, "td", ntop_ipaddr(&range_p->last_ip)); output_double(outfile, "td", oh.range_size); output_double(outfile, "td", range_p->count); + output_double(outfile, "td", oh.range_size - range_p->count); output_double_color(state, &oh, outfile, "td"); output_double(outfile, "td", range_p->touched); output_double(outfile, "td", oh.tc);