You are here

function elasticsearch_connector_status_page in Elasticsearch Connector 7.2

Same name and namespace in other branches
  1. 7.5 elasticsearch_connector.admin.inc \elasticsearch_connector_status_page()
  2. 7 elasticsearch_connector.admin.inc \elasticsearch_connector_status_page()

Cluster status page callback.

Return value

array A Drupal render array.

1 string reference to 'elasticsearch_connector_status_page'
elasticsearch_connector_menu in ./elasticsearch_connector.module
Implements hook_menu().

File

./elasticsearch_connector.admin.inc, line 17
Created on Dec 23, 2013

Code

function elasticsearch_connector_status_page() {
  $headers = array(
    array(
      'data' => t('Cluster name'),
    ),
    array(
      'data' => t('Status'),
    ),
    array(
      'data' => t('Cluster Status'),
    ),
    array(
      'data' => t('Operations'),
    ),
  );
  $rows = array();
  $clusters = elasticsearch_connector_clusters();
  foreach ($clusters as $cluster) {
    $cluster_info = elasticsearch_connector_get_cluster_info($cluster);
    $edit_link_title = $cluster->export_type & EXPORT_IN_CODE ? t('Override') : t('Edit');
    if ($cluster->type == 'Overridden') {
      $edit_link_title = $cluster->type;
    }
    $operations = theme('links__ctools_dropbutton', array(
      'links' => array(
        array(
          'title' => $edit_link_title,
          'href' => elasticsearch_connector_main_settings_path() . '/clusters/' . $cluster->cluster_id . '/edit',
        ),
        array(
          'title' => t('Info'),
          'href' => elasticsearch_connector_main_settings_path() . '/clusters/' . $cluster->cluster_id . '/info',
        ),
        array(
          'title' => t('Indices'),
          'href' => elasticsearch_connector_main_settings_path() . '/clusters/' . $cluster->cluster_id . '/indices',
        ),
        array(
          'title' => t('Delete'),
          'href' => elasticsearch_connector_main_settings_path() . '/clusters/' . $cluster->cluster_id . '/delete',
        ),
      ),
      'attributes' => array(
        'class' => array(
          'links',
          'inline',
        ),
      ),
    ));
    if (!empty($cluster_info['info']) && elasticsearch_connector_check_status($cluster_info['info'])) {
      $info = $cluster_info['health']['status'];
      $version = $cluster_info['info']['version']['number'];
    }
    else {
      $info = t('Not available');
      $version = '';
    }
    $row = array();
    $row[] = $cluster->name . ($version ? ' (' . t('server version: @ver', array(
      '@ver' => $version,
    )) . ')' : '');
    $row[] = !empty($cluster->status) ? t('Active') : t('Inactive');
    $row[] = $info;
    $row[] = $operations;
    $rows[] = $row;
  }
  $output['elasticsearch_connector']['table'] = array(
    '#theme' => 'table',
    '#header' => $headers,
    '#rows' => $rows,
    '#attributes' => array(
      'class' => array(
        'admin-elasticsearch-connector',
      ),
    ),
  );
  return $output;
}