|
1 | 1 | import { |
2 | 2 | readAdminSystemHealthStatus, |
3 | 3 | runAdminSystemHealthAction, |
4 | | - runAdminSystemHealthStorageConnectivityAction, |
| 4 | + runAdminSystemHealthStorageExpandedValidation, |
5 | 5 | } from "../../../src/api/admin-system-health-api-client.js"; |
6 | 6 | import { |
7 | 7 | applyStatusNode, |
@@ -54,6 +54,10 @@ class AdminSystemHealthController { |
54 | 54 | node.dataset.adminSystemHealthStorageStatus, |
55 | 55 | node, |
56 | 56 | ])); |
| 57 | + this.storageTimings = new Map(Array.from(root.querySelectorAll("[data-admin-system-health-storage-timing]")).map((node) => [ |
| 58 | + node.dataset.adminSystemHealthStorageTiming, |
| 59 | + node, |
| 60 | + ])); |
57 | 61 | this.runtimeHealthValues = new Map(Array.from(root.querySelectorAll("[data-admin-system-health-runtime-health-value]")).map((node) => [ |
58 | 62 | node.dataset.adminSystemHealthRuntimeHealthValue, |
59 | 63 | node, |
@@ -122,6 +126,13 @@ class AdminSystemHealthController { |
122 | 126 | this.setStatusNode(node, status, reason); |
123 | 127 | } |
124 | 128 |
|
| 129 | + setStorageTiming(key, value, fallback) { |
| 130 | + const node = this.storageTimings.get(key); |
| 131 | + if (node) { |
| 132 | + node.textContent = asText(value, fallback); |
| 133 | + } |
| 134 | + } |
| 135 | + |
125 | 136 | setRuntimeHealthValue(key, value, fallback) { |
126 | 137 | const node = this.runtimeHealthValues.get(key); |
127 | 138 | if (node) { |
@@ -195,6 +206,7 @@ class AdminSystemHealthController { |
195 | 206 | renderStoragePending(reason) { |
196 | 207 | ["bucket", "list", "upload", "read", "delete", "lastChecked"].forEach((key) => { |
197 | 208 | this.setStorageStatus(key, "PENDING", reason); |
| 209 | + this.setStorageTiming(key, "not available"); |
198 | 210 | }); |
199 | 211 | this.renderRuntimePending(reason); |
200 | 212 | } |
@@ -261,8 +273,10 @@ class AdminSystemHealthController { |
261 | 273 | const reason = storageStatus.message || "Cloudflare R2 configuration status returned by the safe Admin System Health API."; |
262 | 274 | this.setStorageValue("bucket", storageStatus.environmentFolder ? `${storageStatus.bucket || "not configured"} ${storageStatus.environmentFolder}` : storageStatus.bucket, "not configured"); |
263 | 275 | this.setStorageStatus("bucket", storageStatus.bucketStatus || storageStatus.status, reason); |
| 276 | + this.setStorageTiming("bucket", storageStatus.lastChecked ? "configuration status" : "not available"); |
264 | 277 | this.setStorageValue("lastChecked", storageStatus.lastChecked, "not available"); |
265 | 278 | this.setStorageStatus("lastChecked", storageStatus.lastChecked ? "PASS" : "WARN", reason); |
| 279 | + this.setStorageTiming("lastChecked", storageStatus.lastChecked ? "configuration status" : "not available"); |
266 | 280 | } |
267 | 281 |
|
268 | 282 | renderRuntimeHealthPending(reason) { |
@@ -684,9 +698,11 @@ class AdminSystemHealthController { |
684 | 698 | } |
685 | 699 | this.setStorageValue(key, this.storageResultTarget(result)); |
686 | 700 | this.setStorageStatus(key, result.status, result.message || "R2 diagnostic returned without a message."); |
| 701 | + this.setStorageTiming(key, Number.isFinite(Number(result.durationMs)) ? `${result.durationMs} ms` : "not available"); |
687 | 702 | if (result.lastChecked) { |
688 | 703 | this.setStorageValue("lastChecked", result.lastChecked); |
689 | 704 | this.setStorageStatus("lastChecked", "PASS", "Most recent current-environment R2 health check timestamp."); |
| 705 | + this.setStorageTiming("lastChecked", Number.isFinite(Number(result.durationMs)) ? `${result.durationMs} ms` : "not available"); |
690 | 706 | } |
691 | 707 | } |
692 | 708 |
|
@@ -732,15 +748,24 @@ class AdminSystemHealthController { |
732 | 748 | runStorageDiagnostics() { |
733 | 749 | STORAGE_DIAGNOSTIC_ACTIONS.forEach(({ key }) => { |
734 | 750 | this.setStorageStatus(key, "PENDING", "R2 diagnostic is running through the safe Admin System Health API."); |
| 751 | + this.setStorageTiming(key, "running"); |
735 | 752 | }); |
736 | | - STORAGE_DIAGNOSTIC_ACTIONS.forEach(({ actionId, key }) => { |
737 | | - try { |
738 | | - this.renderStorageResult(key, runAdminSystemHealthStorageConnectivityAction(actionId)); |
739 | | - } catch (error) { |
740 | | - const message = error instanceof Error ? error.message : "Safe R2 diagnostic API is unavailable."; |
| 753 | + try { |
| 754 | + const validation = runAdminSystemHealthStorageExpandedValidation(); |
| 755 | + const diagnostics = Array.isArray(validation.storageDiagnostics) ? validation.storageDiagnostics : []; |
| 756 | + diagnostics.forEach((storageResult) => { |
| 757 | + const key = STORAGE_DIAGNOSTIC_ACTION_KEY_BY_ID.get(storageResult.actionId); |
| 758 | + if (key) { |
| 759 | + this.renderStorageResult(key, storageResult); |
| 760 | + } |
| 761 | + }); |
| 762 | + } catch (error) { |
| 763 | + const message = error instanceof Error ? error.message : "Safe R2 diagnostic API is unavailable."; |
| 764 | + STORAGE_DIAGNOSTIC_ACTIONS.forEach(({ key }) => { |
741 | 765 | this.setStorageStatus(key, "PENDING", message); |
742 | | - } |
743 | | - }); |
| 766 | + this.setStorageTiming(key, "not available"); |
| 767 | + }); |
| 768 | + } |
744 | 769 | } |
745 | 770 |
|
746 | 771 | createCell(text) { |
|
0 commit comments