summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 012faa5)
raw | patch | inline | side by side (parent: 012faa5)
author | Florian Forster <ff@octo.it> | |
Tue, 6 Jul 2010 15:55:03 +0000 (17:55 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 6 Jul 2010 15:55:03 +0000 (17:55 +0200) |
src/action_show_graph.c | patch | blob | history | |
src/action_show_instance.c | patch | blob | history |
index 9b9f5da500085b6c33d2061d50642b0e8e614b57..47d22c928c1e057b253f4f6d2a32db1a664736a2 100644 (file)
--- a/src/action_show_graph.c
+++ b/src/action_show_graph.c
struct show_graph_data_s
{
graph_config_t *cfg;
+ const char *search_term;
};
typedef struct show_graph_data_s show_graph_data_t;
@@ -83,10 +84,26 @@ static int show_time_selector (__attribute__((unused)) void *user_data) /* {{{ *
return (0);
} /* }}} int show_time_selector */
-static int left_menu (__attribute__((unused)) void *user_data) /* {{{ */
+static int left_menu (void *user_data) /* {{{ */
{
- printf ("\n<ul class=\"menu left\">\n"
- " <li><a href=\"%s?action=list_graphs\">All graphs</a></li>\n"
+ show_graph_data_t *data = user_data;
+
+ printf ("\n<ul class=\"menu left\">\n");
+
+ if ((data->search_term != NULL) && (data->search_term[0] != 0))
+ {
+ char params[1024];
+
+ memset (params, 0, sizeof (params));
+ graph_get_params (data->cfg, params, sizeof (params));
+ html_escape_buffer (params, sizeof (params));
+
+ printf (" <li><a href=\"%s?action=show_graph;%s\">"
+ "All instances</a></li>\n",
+ script_name (), params);
+ }
+
+ printf (" <li><a href=\"%s?action=list_graphs\">All graphs</a></li>\n"
"</ul>\n",
script_name ());
char descr[128];
char params[1024];
+ if ((data->search_term != NULL) && (data->search_term[0] != 0))
+ {
+ _Bool matches = 0;
+ char *term_lc = strtolower_copy (data->search_term);
+
+ if (strncmp ("host:", term_lc, strlen ("host:")) == 0)
+ {
+ if (inst_matches_field (inst, GIF_HOST, term_lc + strlen ("host:")))
+ matches = 1;
+ }
+ else if (strncmp ("plugin:", term_lc, strlen ("plugin:")) == 0)
+ {
+ if (inst_matches_field (inst, GIF_PLUGIN, term_lc + strlen ("plugin:")))
+ matches = 1;
+ }
+ else if (strncmp ("plugin_instance:", term_lc,
+ strlen ("plugin_instance:")) == 0)
+ {
+ if (inst_matches_field (inst, GIF_PLUGIN_INSTANCE,
+ term_lc + strlen ("plugin_instance:")))
+ matches = 1;
+ }
+ else if (strncmp ("type:", term_lc, strlen ("type:")) == 0)
+ {
+ if (inst_matches_field (inst, GIF_TYPE, term_lc + strlen ("type:")))
+ matches = 1;
+ }
+ else if (strncmp ("type_instance:", term_lc,
+ strlen ("type_instance:")) == 0)
+ {
+ if (inst_matches_field (inst, GIF_TYPE_INSTANCE,
+ term_lc + strlen ("type_instance:")))
+ matches = 1;
+ }
+ else if (inst_matches_string (data->cfg, inst, term_lc))
+ {
+ matches = 1;
+ }
+
+ free (term_lc);
+
+ if (!matches)
+ return (0);
+ } /* if (data->search_term) */
+
memset (descr, 0, sizeof (descr));
inst_describe (data->cfg, inst, descr, sizeof (descr));
html_escape_buffer (descr, sizeof (descr));
{
show_graph_data_t *data = user_data;
- printf ("<h2>Available instances</h2>\n");
+ if ((data->search_term == NULL) || (data->search_term[0] == 0))
+ printf ("<h2>All instances</h2>\n");
+ else
+ {
+ char *search_term_html = html_escape (data->search_term);
+ printf ("<h2>Instances matching "%s"</h2>\n",
+ search_term_html);
+ free (search_term_html);
+ }
+
printf ("<ul class=\"instance_list\">\n");
graph_inst_foreach (data->cfg, show_instance_cb, data);
printf ("</ul>\n");
if (pg_data.cfg == NULL)
OUTPUT_ERROR ("gl_graph_get_selected () failed.\n");
+ pg_data.search_term = param ("q");
+
memset (tmp, 0, sizeof (tmp));
graph_get_title (pg_data.cfg, tmp, sizeof (tmp));
snprintf (title, sizeof (title), "Graph \"%s\"", tmp);
index 0f44fca0ff3e0ee4dcdd24eeaa9ac8d19c87166c..86a565496c627344c85db68e614bf5eec3b29396 100644 (file)
html_escape_buffer (params, sizeof (params));
printf ("\n<ul class=\"menu left\">\n"
- " <li><a href=\"%s?action=show_graph;%s\">"
- "Available instances</a></li>\n"
+ " <li><a href=\"%s?action=show_graph;%s\">All instances</a></li>\n"
" <li><a href=\"%s?action=list_graphs\">All graphs</a></li>\n"
"</ul>\n",
script_name (), params,