Ver código fonte

Improvements to Tripal Jbo Daemon status block including a version admin can expose to users.

Lacey Sanderson 7 anos atrás
pai
commit
07b2c77656

+ 1 - 0
tripal/tripal.module

@@ -692,6 +692,7 @@ function tripal_block_info() {
  */
 function tripal_block_view($delta = ''){
   global $base_path;
+  $block = array();
 
   // The $delta parameter tells us which block is being requested.
   switch ($delta) {

+ 27 - 12
tripal_daemon/includes/tripal_daemon.blocks.inc

@@ -10,9 +10,13 @@
 function tripal_daemon_block_info() {
   $blocks = array();
 
-  $blocks['tripal_daemon_status'] = array(
+  $blocks['trpdaemon_status'] = array(
     'info' => t('Tripal Daemon Status'),
   );
+
+  $blocks['trpdaemon_status_admin'] = array(
+    'info' => t('Tripal Daemon Status: ADMIN'),
+  );
   
   return $blocks;
 }
@@ -24,9 +28,11 @@ function tripal_daemon_block_view($delta='') {
   $block = array();
 
   switch($delta) {
-    case 'tripal_daemon_status':
-      $is_running = drushd_is_daemon_running('tripal_daemon');
-      $status_class = ($is_running) ? 'active' : 'inactive';
+    case 'trpdaemon_status_admin':
+      $block['subject'] = t('Job Daemon Status');
+      $block['content'] = theme_tripal_daemon_status_block_content(TRUE);
+      break;
+    case 'trpdaemon_status':
       $block['subject'] = t('Job Daemon Status');
       $block['content'] = theme_tripal_daemon_status_block_content();
       break;
@@ -36,9 +42,14 @@ function tripal_daemon_block_view($delta='') {
 }
 
 /** 
+ * Provide markup for the Tripal Job Daemon Status block.
  *
+ * @param $show_all
+ *   A boolean indicating whether to show administrative detail (TRUE) or not (FALSE).
+ * @return
+ *   HTML to be rendered for the block.
  */
-function theme_tripal_daemon_status_block_content() {
+function theme_tripal_daemon_status_block_content($show_all = FALSE) {
   $output = '';
 
   // Get information.
@@ -51,6 +62,7 @@ function theme_tripal_daemon_status_block_content() {
   // Theme content.
   drupal_add_css(drupal_get_path('module','tripal_daemon') . '/theme/status_block.css');
 
+  // Display the status.
   $output .= '<div class="daemon-status">';
   if ($is_running) {
     $output .= theme_image(array(
@@ -68,15 +80,18 @@ function theme_tripal_daemon_status_block_content() {
   }
   $output .= '</div>';
 
-  $output .= '<ul>';
-  foreach ($status as $k => $v) {
-    if (is_bool($v)) {
-      $v = ($v) ? 'True' : 'False';
-    }
+  // If asked, show all the details.
+  if ($show_all) {
+    $output .= '<ul>';
+    foreach ($status as $k => $v) {
+      if (is_bool($v)) {
+        $v = ($v) ? 'True' : 'False';
+      }
 
-    $output .= '<li><strong>' . $k . '</strong>: ' . $v . '</li>';
+      $output .= '<li><strong>' . $k . '</strong>: ' . $v . '</li>';
+    }
+    $output .= '</ul>';
   }
-  $output .= '</ul>';
 
   return '<div class="inner '.$status_class.'">' . $output . '</div>';
 }

+ 9 - 7
tripal_daemon/theme/status_block.css

@@ -1,29 +1,31 @@
 /**
  * Tripal Daemon Status Block.
  */
-#dashboard #block-tripal-daemon-tripal-daemon-status div.content,
-  div#block-tripal-daemon-tripal-daemon-status div.content {
+#dashboard div.block.block-tripal-daemon div.content,
+  div.block-tripal-daemon div.content {
     padding: 0;
 }
-#block-tripal-daemon-tripal-daemon-status div.content div.inner {
+div.block-tripal-daemon div.content div.inner {
   padding: 15px; 
 }
-#block-tripal-daemon-tripal-daemon-status .active {
+
+div.block-tripal-daemon .active {
   background-color: #f8fff0; 
   color: #234600;
 }
-#block-tripal-daemon-tripal-daemon-status .inactive {
+div.block-tripal-daemon .inactive {
   background-color: #fef5f1;
   color: #8c2e0b;
 }
 
-#block-tripal-daemon-tripal-daemon-status .daemon-status {
+div.block-tripal-daemon .daemon-status {
   font-weight: bolder;
   font-size: 1.2em;
   margin-bottom: 15px;
 }
-#block-tripal-daemon-tripal-daemon-status .daemon-status img {
+div.block-tripal-daemon .daemon-status img {
   top: 6px;
   position: relative;
   padding-right: 5px;
+  border: 0;
 }