| @@ -1,9 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Mgleis\DiskUsageInsights\Frontend\Controller; |
| 3 | 3 | |
| 4 | 4 | use Mgleis\DiskUsageInsights\Domain\DatabaseRepository; |
| 5 | -use Mgleis\DiskUsageInsights\Domain\Jobs\PhaseCoordinatorJob; | |
| 6 | 5 | use Mgleis\DiskUsageInsights\Plugin; |
| 7 | 6 | |
| 8 | 7 | class ScanStatusController { |
| 9 | 8 | |
| @@ -21,35 +20,19 @@ | ||
| 21 | 20 | http_response_code(286); // htmx stops timer |
| 22 | 21 | header('HX-Redirect: ' . admin_url('tools.php?page=disk-usage-insights&snapshot=' . $snapshotName)); |
| 23 | 22 | exit; |
| 24 | 23 | } |
| 25 | - $currentPhase = $_snapshot->phase; | |
| 26 | 24 | |
| 27 | - echo "<br>\n"; | |
| 28 | - foreach(PhaseCoordinatorJob::PHASES as $idx => $phaseText) { | |
| 25 | + $job = $database->q->top(); | |
| 26 | + if ($job !== null) { | |
| 29 | 27 | |
| 30 | - $phaseStatus = $currentPhase > $idx ? '✓ ' : ''; | |
| 31 | - $taskDescription = ''; | |
| 32 | - | |
| 33 | - if ($currentPhase == $idx) { | |
| 34 | - | |
| 35 | - $job = $database->q->peek(); | |
| 36 | - if ($job !== null) { | |
| 37 | - $reflect = new \ReflectionClass($job->payload['type']); | |
| 38 | - $instance = $reflect->newInstanceArgs($job->payload['args']); | |
| 39 | - | |
| 40 | - $taskDescription = ' -- ' . $instance->toDescription(); | |
| 41 | - } | |
| 42 | - | |
| 43 | - } | |
| 44 | - if ($idx == $currentPhase) { | |
| 45 | - echo "<b>"; | |
| 46 | - } | |
| 47 | - echo sprintf('%s%s%s', $phaseStatus, esc_html($phaseText), esc_html($taskDescription)); | |
| 48 | - if ($idx == $currentPhase) { | |
| 49 | - echo "</b>"; | |
| 50 | - } | |
| 51 | - echo "<br>\n"; | |
| 28 | + $reflect = new \ReflectionClass($job->payload['type']); | |
| 29 | + $instance = $reflect->newInstanceArgs($job->payload['args']); | |
| 30 | + echo sprintf('Phase %s / %s<br>%s', | |
| 31 | + $_snapshot->phase + 1, | |
| 32 | + 10, | |
| 33 | + $instance->toDescription() | |
| 34 | + ); | |
| 52 | 35 | } |
| 53 | 36 | |
| 54 | 37 | wp_die(); // All ajax handlers should die when finished |
| 55 | 38 | } |