From: Florian Forster Date: Mon, 21 Jun 2010 10:31:27 +0000 (+0200) Subject: "show graph" action: Implement displaying _graphs_ (rather than instances). X-Git-Tag: v4.0.0~210 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=173727f52463a5e2f60e7363456f90905d67e669;p=collection4.git "show graph" action: Implement displaying _graphs_ (rather than instances). A "breadcrump" field has been added, too. --- diff --git a/src/action_show_graph.c b/src/action_show_graph.c index 40ebcd3..5aaf25a 100644 --- a/src/action_show_graph.c +++ b/src/action_show_graph.c @@ -8,6 +8,7 @@ #include "action_show_graph.h" #include "common.h" +#include "graph_ident.h" #include "graph_list.h" #include "utils_cgi.h" @@ -27,6 +28,54 @@ struct show_graph_data_s }; typedef struct show_graph_data_s show_graph_data_t; +static void show_breadcrump_field (const char *str) /* {{{ */ +{ + if ((str == NULL) || (str[0] == 0)) + printf ("none"); + else if (IS_ANY (str)) + printf ("any"); + else if (IS_ALL (str)) + printf ("all"); + else + { + char *str_html = html_escape (str); + printf ("%s", + script_name (), str_html, str_html); + free (str_html); + } +} /* }}} void show_breadcrump_field */ + +static int show_breadcrump (show_graph_data_t *data) /* {{{ */ +{ + graph_ident_t *ident; + char *prefix; + + if (data->inst != NULL) + { + prefix = "Instance"; + ident = inst_get_selector (data->inst); + } + else + { + prefix = "Graph"; + ident = graph_get_selector (data->cfg); + } + + printf ("
%s: "", prefix); + show_breadcrump_field (ident_get_host (ident)); + printf (" / "); + show_breadcrump_field (ident_get_plugin (ident)); + printf (" – "); + show_breadcrump_field (ident_get_plugin_instance (ident)); + printf (" / "); + show_breadcrump_field (ident_get_type (ident)); + printf (" – "); + show_breadcrump_field (ident_get_type_instance (ident)); + printf (""
\n"); + + return (0); +} /* }}} int show_breadcrump */ + static int show_instance_list_cb (graph_instance_t *inst, /* {{{ */ void *user_data) { @@ -48,7 +97,8 @@ static int show_instance_list_cb (graph_instance_t *inst, /* {{{ */ inst_get_params (data->cfg, inst, params, sizeof (params)); html_escape_buffer (params, sizeof (params)); - printf ("
  • %s
  • \n", + printf ("
  • " + "%s
  • \n", script_name (), params, descr); return (0); @@ -57,19 +107,23 @@ static int show_instance_list_cb (graph_instance_t *inst, /* {{{ */ static int show_instance_list (void *user_data) /* {{{ */ { show_graph_data_t *data = user_data; - graph_instance_t *inst; char title[128]; + char params[1024]; memset (title, 0, sizeof (title)); graph_get_title (data->cfg, title, sizeof (title)); html_escape_buffer (title, sizeof (title)); + memset (params, 0, sizeof (params)); + graph_get_params (data->cfg, params, sizeof (params)); + html_escape_buffer (params, sizeof (params)); + printf ("