PluginProbe
Disk Usage Insights / trunk
Disk Usage Insights vtrunk
trunk 1.0 1.10 1.11 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
← All changes | src/Frontend/Controller/ScanStatusController.php +32 -9 1.3trunk View file →
@@ -1,8 +1,9 @@
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;
5 6 use Mgleis\DiskUsageInsights\Plugin;
6 7
7 8 class ScanStatusController {
8 9
@@ -20,20 +21,42 @@
20 21 http_response_code(286); // htmx stops timer
21 22 header('HX-Redirect: ' . admin_url('tools.php?page=disk-usage-insights&snapshot=' . $snapshotName));
22 23 exit;
23 24 }
25 + $currentPhase = $_snapshot->phase;
24 26
25 - $job = $database->q->top();
26 - if ($job !== null) {
27 + echo "<br>\n";
28 + foreach(PhaseCoordinatorJob::PHASES as $idx => $phaseText) {
27 29
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 - );
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";
35 52 }
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";
36 59
37 60 wp_die(); // All ajax handlers should die when finished
38 61 }
39 62