share/collection.js: Keep visibility when redrawing graphs.
[collection4.git] / src / action_list_graphs.c
index 89c5d62..6f919e3 100644 (file)
 #include <fcgiapp.h>
 #include <fcgi_stdio.h>
 
+static int left_menu (__attribute__((unused)) void *user_data) /* {{{ */
+{
+  printf ("\n<ul class=\"menu left\">\n"
+      "  <li><a href=\"%s?action=search\">Search</a></li>\n"
+      "  <li><a href=\"%s?action=list_hosts\">All hosts</a></li>\n"
+      "</ul>\n",
+      script_name (), script_name ());
+
+  return (0);
+} /* }}} int left_menu */
+
 static int print_one_graph (graph_config_t *cfg, /* {{{ */
     __attribute__((unused)) void *user_data)
 {
@@ -55,7 +66,7 @@ static int print_one_graph (graph_config_t *cfg, /* {{{ */
   html_escape_buffer (params, sizeof (params));
 
   printf ("      <li class=\"graph\"><a href=\"%s?action=show_graph;%s\">"
-      "%s</a> <span class=\"num_instances\">(%lu %s)</span></li>\n",
+      "%s</a> <span class=\"num_instances\">(%lu&nbsp;%s)</span></li>\n",
       script_name (), params, title,
       (unsigned long) num_instances,
       (num_instances == 1) ? "instance" : "instances");
@@ -65,17 +76,30 @@ static int print_one_graph (graph_config_t *cfg, /* {{{ */
 
 static int print_all_graphs (__attribute__((unused)) void *user_data) /* {{{ */
 {
-  printf ("    <ul id=\"search-output\" class=\"graph_list\">\n");
-  gl_graph_get_all (print_one_graph, /* user_data = */ NULL);
+  const char *dynamic;
+  _Bool include_dynamic = 0;
+
+  dynamic = param ("dynamic");
+  if ((dynamic != NULL)
+      && (strcmp ("true", dynamic) == 0))
+    include_dynamic = 1;
+
+  printf ("    <ul class=\"graph_list\">\n");
+  gl_graph_get_all (include_dynamic, print_one_graph, /* user_data = */ NULL);
   printf ("    </ul>\n");
 
+  if (!include_dynamic)
+  {
+    printf ("    <div><a href=\"%s?action=list_graphs;dynamic=true\">"
+        "List dynamic graphs, too."
+        "</a></div>\n", script_name ());
+  }
+
   return (0);
 } /* }}} int print_all_graphs */
 
 int action_list_graphs (void) /* {{{ */
 {
-  gl_update ();
-
   page_callbacks_t pg_callbacks = PAGE_CALLBACKS_INIT;
   char title[512];
 
@@ -83,6 +107,7 @@ int action_list_graphs (void) /* {{{ */
   title[sizeof (title) - 1] = 0;
 
   pg_callbacks.top_right = html_print_search_box;
+  pg_callbacks.middle_left = left_menu;
   pg_callbacks.middle_center = print_all_graphs;
 
   html_print_page (title, &pg_callbacks, /* user data = */ NULL);