| @@ -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,42 +20,20 @@ | ||
| 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', esc_html($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 | - | |
| 54 | - // debug counter | |
| 55 | - $counter = (int) sanitize_text_field(wp_unslash($_POST['counter'] ?? 0)); | |
| 56 | - $counter++; | |
| 57 | - echo '<input type="hidden" name="counter" value="' . esc_attr($counter) . '">'; | |
| 58 | - echo "<br>\nRunning for " . esc_html($counter) . " seconds...<br>\n"; | |
| 59 | 36 | |
| 60 | 37 | wp_die(); // All ajax handlers should die when finished |
| 61 | 38 | } |
| 62 | 39 | |