Skip to content

Commit 5e32490

Browse files
committed
Show Index Queue status as progress bar
* replaces the pie chart with a progress bar * only show the error table if there actually are errors Change-Id: I04a0f9bb0749b788a7007a920bb58ac34cdb2cd7
1 parent 111df70 commit 5e32490

File tree

7 files changed

+97
-138
lines changed

7 files changed

+97
-138
lines changed

Classes/Backend/SolrModule/IndexQueueModuleController.php

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ class IndexQueueModuleController extends AbstractModuleController {
5757
* @return void
5858
*/
5959
public function indexAction() {
60-
$this->view->assign('indexQueueInitializationSelector', $this->getIndexQueueInitializationSelector());
61-
$this->view->assign('indexqueue_stats', json_encode($this->getIndexQueueStats()));
62-
$this->view->assign('indexqueue_errors', $this->getIndexQueueErrors());
60+
$statisticsCounts = $this->getIndexQueueStatistics();
61+
$statisticsPercentages = $this->getIndexQueueStatisticsPercentages($statisticsCounts);
62+
63+
$this->view->assign('indexQueueInitializationSelector', $this->getIndexQueueInitializationSelector());
64+
$this->view->assign('indexqueue_statistics_counts', $statisticsCounts);
65+
$this->view->assign('indexqueue_statistics_percentages', $statisticsPercentages);
66+
$this->view->assign('indexqueue_errors', $this->getIndexQueueErrors());
6367
}
6468

6569
/**
@@ -180,28 +184,60 @@ protected function getIndexQueueInitializationSelector() {
180184
*
181185
* @return array
182186
*/
183-
protected function getIndexQueueStats() {
187+
protected function getIndexQueueStatistics() {
184188
$indexQueueStats = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
185189
'indexed < changed as pending,'
186-
. '(errors not like "") as erroneous,'
190+
. '(errors not like "") as failed,'
187191
. 'COUNT(*) as count',
188192
'tx_solr_indexqueue_item',
189193
'root = ' . $this->site->getRootPageId() ,
190-
'pending, erroneous'
194+
'pending, failed'
191195
);
192196

193-
$stats = array();
197+
$statistics = array(
198+
'errors' => 0,
199+
'pending' => 0,
200+
'indexed' => 0
201+
);
194202
foreach($indexQueueStats as $row) {
195-
if($row['erroneous'] == 1) {
196-
$stats['erroneous'] = $row['count'];
203+
if($row['failed'] == 1) {
204+
$statistics['errors'] = $row['count'];
197205
} elseif($row['pending'] == 1) {
198-
$stats['pending'] = $row['count'];
206+
$statistics['pending'] = $row['count'];
199207
} else {
200-
$stats['indexed'] = $row['count'];
208+
$statistics['indexed'] = $row['count'];
209+
}
210+
}
211+
212+
$total = 0;
213+
foreach ($statistics as $count) {
214+
$total += $count;
215+
}
216+
$statistics['total'] = $total;
217+
218+
return $statistics;
219+
}
220+
221+
/**
222+
* Gets the Index Queue statistics as percentages
223+
*
224+
* @param array $statistics Input from getIndexQueueStatistics()
225+
* @return array
226+
*/
227+
protected function getIndexQueueStatisticsPercentages($statistics) {
228+
$percentages = array(
229+
'errors' => 0,
230+
'pending' => 0,
231+
'indexed' => 0
232+
);
233+
234+
if ($statistics['total'] > 0) {
235+
foreach ($statistics as $key => $count) {
236+
$percentages[$key] = round(($count * 100 / $statistics['total']), 0);
201237
}
202238
}
203239

204-
return $stats;
240+
return $percentages;
205241
}
206242

207243
/**

Resources/Private/Language/locallang.xlf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@
5151
<source>Initializing the Index Queue is the most complete way to force re-indexing, or to build the Index Queue for the first time. The Index Queue Worker scheduler task will then index the items listed in the Index Queue.</source>
5252
</trans-unit>
5353
<trans-unit id="solr.backend.index_queue_module.status.errors" xml:space="preserve">
54-
<source> Errors:</source>
54+
<source> Errors</source>
5555
</trans-unit>
5656
<trans-unit id="solr.backend.index_queue_module.status.header" xml:space="preserve">
5757
<source>Indexing Progress</source>
5858
</trans-unit>
5959
<trans-unit id="solr.backend.index_queue_module.status.indexed" xml:space="preserve">
60-
<source> Indexed:</source>
60+
<source> Indexed</source>
6161
</trans-unit>
6262
<trans-unit id="solr.backend.index_queue_module.status.pending" xml:space="preserve">
63-
<source> Pending:</source>
63+
<source> Pending</source>
6464
</trans-unit>
6565
<trans-unit id="solr.backend.index_queue_module.header_init" xml:space="preserve">
6666
<source>Index Queue Initialization</source>

Resources/Private/Templates/IndexQueueModule/Index.html

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{namespace solr=ApacheSolrForTypo3\Solr\ViewHelpers}
22

3-
<solr:backend.script file="{f:uri.resource(path:'JavaScripts/jquery-1.9.1.min.js')}"/>
4-
<solr:backend.script file="{f:uri.resource(path:'JavaScripts/chart.js')}"/>
5-
<solr:backend.script file="{f:uri.resource(path:'JavaScripts/IndexQueueModule.js')}"/>
6-
73
<solr:backend.style file="{f:uri.resource(path:'StyleSheets/Backend/IndexQueueModule.css')}" />
84

95

@@ -31,17 +27,40 @@ <h2>
3127
</div>
3228

3329

30+
<f:if condition="{indexqueue_statistics_counts.total} > 0">
3431
<div class="row-fluid section-with-header">
35-
<script type="text/json" id="indexqueue_stats">
36-
<f:format.raw>{indexqueue_stats}</f:format.raw>
37-
</script>
38-
3932
<h2>
4033
<f:translate key="solr.backend.index_queue_module.header_status"/>
4134
</h2>
4235

4336
<div class="row-fluid">
44-
<div class="span8 well">
37+
<div class="progress">
38+
<f:if condition="{indexqueue_statistics_counts.indexed} > 0">
39+
<div class="bar bar-success" style="width: {indexqueue_statistics_percentages.indexed}%"
40+
title="{f:translate(key:'solr.backend.index_queue_module.status.indexed')}: {indexqueue_statistics_counts.indexed}/{indexqueue_statistics_counts.total} ({indexqueue_statistics_percentages.indexed}%)">
41+
<f:translate key="solr.backend.index_queue_module.status.indexed"/>
42+
</div>
43+
</f:if>
44+
45+
<f:if condition="{indexqueue_statistics_counts.pending} > 0">
46+
<div class="bar bar-warning" style="width: {indexqueue_statistics_percentages.pending}%"
47+
title="{f:translate(key:'solr.backend.index_queue_module.status.pending')}: {indexqueue_statistics_counts.pending}/{indexqueue_statistics_counts.total} ({indexqueue_statistics_percentages.pending}%)">
48+
<f:translate key="solr.backend.index_queue_module.status.pending"/>
49+
</div>
50+
</f:if>
51+
52+
<f:if condition="{indexqueue_statistics_counts.errors} > 0">
53+
<div class="bar bar-danger" style="width: {indexqueue_statistics_percentages.errors}%"
54+
title="{f:translate(key:'solr.backend.index_queue_module.status.errors')}: {indexqueue_statistics_counts.errors}/{indexqueue_statistics_counts.total} ({indexqueue_statistics_percentages.errors}%)">
55+
<f:translate key="solr.backend.index_queue_module.status.errors"/>
56+
</div>
57+
</f:if>
58+
</div>
59+
</div>
60+
61+
<f:if condition="{indexqueue_errors}">
62+
<div class="row-fluid">
63+
<div class="span12 well">
4564
<h2>
4665
<f:translate key="solr.backend.index_queue_module.errors.headline" />
4766
</h2>
@@ -77,42 +96,17 @@ <h2>
7796
</f:for>
7897
</table>
7998

80-
<f:if condition="{indexqueue_errors}">
81-
<solr:backend.button.ActionButton
82-
action="resetLogErrors"
83-
label="{f:translate(key:'solr.backend.index_queue_module.errors.reset_button')}"
84-
class="btn-sm btn-default"
85-
/>
86-
</f:if>
87-
</div>
88-
89-
<div class="span4 well stats_container">
90-
<h2>
91-
<f:translate key="solr.backend.index_queue_module.status.header" />
92-
</h2>
93-
94-
<canvas id="indexqueue_stats_chart" width="100" height="100"></canvas>
95-
96-
<div style="clear: both;"></div>
99+
<solr:backend.button.ActionButton
100+
action="resetLogErrors"
101+
label="{f:translate(key:'solr.backend.index_queue_module.errors.reset_button')}"
102+
class="btn-sm btn-default"
103+
/>
97104

98-
<div class="legend">
99-
<span class="color" style="background: #EB813F;"></span>
100-
<f:translate key="solr.backend.index_queue_module.status.pending" />
101-
<span id="pending_numbers"></span>
102-
</div>
103-
<div class="legend">
104-
<span class="color" style="background: #FF3D3D;"></span>
105-
<f:translate key="solr.backend.index_queue_module.status.errors" />
106-
<span id="error_numbers"></span>
107-
</div>
108-
<div class="legend">
109-
<span class="color" style="background: #9FC299;"></span>
110-
<f:translate key="solr.backend.index_queue_module.status.indexed" />
111-
<span id="indexed_numbers"></span>
112-
</div>
113105
</div>
114106
</div>
107+
</f:if>
115108
</div>
109+
</f:if>
116110

117111

118112
<div class="row-fluid section-with-header danger-zone">

Resources/Public/JavaScripts/IndexQueueModule.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)