| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for ElasticPress Index health page |
| 4 |
* |
| 5 |
* @since 3.1 |
| 6 |
* @package elasticpress |
| 7 |
*/ |
| 8 |
|
| 9 |
use ElasticPress\Stats as Stats; |
| 10 |
use ElasticPress\Elasticsearch as Elasticsearch; |
| 11 |
|
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; // Exit if accessed directly. |
| 14 |
} |
| 15 |
|
| 16 |
require_once __DIR__ . '/header.php'; |
| 17 |
|
| 18 |
if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { |
| 19 |
$index_meta = get_site_option( 'ep_index_meta', false ); |
| 20 |
$sync_url = network_admin_url( 'admin.php?page=elasticpress-sync' ); |
| 21 |
} else { |
| 22 |
$index_meta = get_option( 'ep_index_meta', false ); |
| 23 |
$sync_url = admin_url( 'admin.php?page=elasticpress-sync' ); |
| 24 |
} |
| 25 |
|
| 26 |
Stats::factory()->build_stats(); |
| 27 |
|
| 28 |
$index_health = Stats::factory()->get_health(); |
| 29 |
$totals = Stats::factory()->get_totals(); |
| 30 |
?> |
| 31 |
|
| 32 |
<div class="error-overlay <?php if ( ! empty( $index_meta ) ) : ?>syncing<?php endif; ?>"></div> |
| 33 |
<div class="wrap metabox-holder"> |
| 34 |
<h1><?php esc_html_e( 'Index Health', 'elasticpress' ); ?></h1> |
| 35 |
|
| 36 |
<?php if ( ! empty( $index_health ) ) : ?> |
| 37 |
<div class="ep-flex-container"> |
| 38 |
<div class="stats-list postbox"> |
| 39 |
<h2 class="hndle stats-list-th"><span><?php esc_html_e( 'Index list', 'elasticpress' ); ?></span><span><?php esc_html_e( 'Health', 'elasticpress' ); ?></span></h2> |
| 40 |
<?php |
| 41 |
foreach ( $index_health as $index_stat ) : |
| 42 |
?> |
| 43 |
<p class="inside"><?php echo esc_html( $index_stat['name'] ); ?> |
| 44 |
<span class="status-circle <?php echo esc_attr( $index_stat['health'] ); ?>-status"> |
| 45 |
<?php echo esc_html( $index_stat['health'] ); ?> |
| 46 |
</span> |
| 47 |
</p> |
| 48 |
<?php endforeach; ?> |
| 49 |
</div> |
| 50 |
<div class="stats-queries postbox"> |
| 51 |
<h2 class="hndle"><?php esc_html_e( 'Queries & Indexing total', 'elasticpress' ); ?></h2> |
| 52 |
<div class="ep-qchart-container"> |
| 53 |
<div class="inside"> |
| 54 |
<canvas id="queriesTotalChart" width="400" height="400"></canvas> |
| 55 |
</div> |
| 56 |
</div> |
| 57 |
</div> |
| 58 |
<div class="postbox doc-chart"> |
| 59 |
<h2 class="hndle"><?php esc_html_e( 'Documents', 'elasticpress' ); ?></h2> |
| 60 |
<div class="inside"> |
| 61 |
<canvas id="documentChart" width="800" height="450"></canvas> |
| 62 |
</div> |
| 63 |
</div> |
| 64 |
<div class="postbox ep-totals"> |
| 65 |
<h2 class="hndle">Totals</h2> |
| 66 |
<div class="ep-flex-container"> |
| 67 |
<div class="ep-totals-column inside"> |
| 68 |
<p class="ep-totals-title"><?php esc_html_e( 'Total Documents', 'elasticpress' ); ?></p> |
| 69 |
<p class="ep-totals-data"><?php echo esc_html( $totals['docs'] ); ?></p> |
| 70 |
</div> |
| 71 |
<div class="ep-totals-column inside"> |
| 72 |
<p class="ep-totals-title"><?php esc_html_e( 'Total Size', 'elasticpress' ); ?></p> |
| 73 |
<p class="ep-totals-data"><?php echo esc_html( Stats::factory()->convert_to_readable_size( $totals['size'] ) ); ?></p> |
| 74 |
</div> |
| 75 |
<div class="ep-totals-column inside"> |
| 76 |
<p class="ep-totals-title"><?php esc_html_e( 'Total Memory', 'elasticpress' ); ?></p> |
| 77 |
<p class="ep-totals-data"><?php echo esc_html( Stats::factory()->convert_to_readable_size( $totals['memory'] ) ); ?></p> |
| 78 |
</div> |
| 79 |
</div> |
| 80 |
</div> |
| 81 |
<div class="stats-queries postbox"> |
| 82 |
<h2 class="hndle"><?php esc_html_e( 'Queries & Indexing Time', 'elasticpress' ); ?></h2> |
| 83 |
<div class="ep-qchart-container"> |
| 84 |
<div class="inside"> |
| 85 |
<canvas id="queriesTimeChart" width="400" height="400"></canvas> |
| 86 |
</div> |
| 87 |
</div> |
| 88 |
</div> |
| 89 |
</div> |
| 90 |
<?php else : ?> |
| 91 |
<p> |
| 92 |
<?php |
| 93 |
printf( |
| 94 |
/* translators: %s: Sync page link. */ |
| 95 |
esc_html__( 'We could not find any data for your Elasticsearch indices. Maybe you need to %s?', 'elasticpress' ), |
| 96 |
sprintf( |
| 97 |
'<a href="%1$s">%2$s</a>', |
| 98 |
esc_url( $sync_url ), |
| 99 |
esc_html__( 'sync your content', 'elasticpress' ) |
| 100 |
) |
| 101 |
); |
| 102 |
?> |
| 103 |
</p> |
| 104 |
<?php endif; ?> |
| 105 |
</div> |
| 106 |
|