Bläddra i källkod

Simplify instance report, config error reporting

- display graph data on instance report page, do not require one more click
- reduce report width by one column
- report extra fields made available on data fetches and missing from config
Frederic G. MARAND 13 år sedan
förälder
incheckning
aaa0907a2f
1 ändrade filer med 18 tillägg och 5 borttagningar
  1. 18 5
      munin_api.module

+ 18 - 5
munin_api.module

@@ -171,7 +171,7 @@ function munin_api_page_config($module_name, $graph_name) {
 function munin_api_page_fetch($module_name, $module, $graph_name) {
   $data = module_invoke($module_name, 'munin_api_fetch', $graph_name);
   if (!is_array($data)) {
-    return _munin_report_hook_error('munin_api_fetch', $module);
+    return _munin_report_hook_error('munin_api_fetch', $module_name);
   }
 
   $ret = '';
@@ -231,24 +231,29 @@ function munin_api_page_report_global() {
  */
 function munin_api_page_report_instance($module_name, $module_info) {
   if (!is_array($module_info)) {
-    return _munin_report_hook_error('munin_api_info', $module);
+    return _munin_report_hook_error('munin_api_info', $module_name);
   }
 
   $header = array(
     t('Name'),
     t('Title / Description'),
     t('Type'),
-    array('data' => t('Debug'), 'colspan' => 2),
+    t('Debug'),
   );
+  $error = array('class' => 'error');
   $rows = array();
   foreach (element_children($module_info) as $graph_name) {
+    $data = module_invoke($module_name, 'munin_api_fetch', $graph_name);
+    if (!is_array($data)) {
+      return _munin_report_hook_error('munin_api_fetch', $module_name);
+    }
+
     $rows[] = array(
       array(
         'data' => $module_info[$graph_name]['#title'] ? $module_info[$graph_name]['#title'] : $graph_name,
         'colspan' => 3,
       ),
     l(t('config'), 'munin_api/'. $graph_name .'/config'),
-    l(t('data'), 'munin_api/'. $graph_name),
     );
 
     foreach (element_children($module_info[$graph_name]) as $field_name) {
@@ -256,8 +261,16 @@ function munin_api_page_report_instance($module_name, $module_info) {
         ' ',
         isset($module_info[$graph_name][$field_name]['#label']) ? $module_info[$graph_name][$field_name]['#label'] : t('<missing>'),
         $module_info[$graph_name][$field_name]['#type'],
+        $data[$field_name],
+        );
+      unset($data[$field_name]);
+    }
+    foreach ($data as $field_name => $field_value) {
+      $rows[] = array(
         ' ',
-        ' ',
+        $error + array('data' => $field_name),
+        $error + array('data' => check_plain('<unconfigured>')),
+        $error + array('data' => $field_value),
         );
     }
   }