@chisquare-tech/origine-ngx-apps-services 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -281,6 +281,12 @@ const DAYS = [
|
|
|
281
281
|
{ id: 'sun', label: 'Sunday' }, { id: 'mon', label: 'Monday' }, { id: 'tue', label: 'Tuesday' }, { id: 'wed', label: 'Wednesday' },
|
|
282
282
|
{ id: 'thu', label: 'Thursday' }, { id: 'fri', label: 'Friday' }, { id: 'sat', label: 'Saturday' },
|
|
283
283
|
];
|
|
284
|
+
/** While the browser tab is hidden, the page's polls slow to once a minute (the cell is read for each). */
|
|
285
|
+
const HIDDEN_POLL_MS = 60_000;
|
|
286
|
+
/** The delay before the next poll: `visibleMs` while the page is seen, once a minute while it is hidden. */
|
|
287
|
+
function pollDelay(visibleMs) {
|
|
288
|
+
return typeof document !== 'undefined' && document.visibilityState === 'hidden' ? Math.max(visibleMs, HIDDEN_POLL_MS) : visibleMs;
|
|
289
|
+
}
|
|
284
290
|
|
|
285
291
|
// /{org}/{project}/services (prototype "services_list"): the project's instances with their state,
|
|
286
292
|
// what they are attached to, their backups and price, and the organization's quota line (SVC-01, 26).
|
|
@@ -1288,7 +1294,7 @@ class ServiceLogsTab {
|
|
|
1288
1294
|
this.lines.set(l.lines ?? []);
|
|
1289
1295
|
this.note.set(l.message ?? '');
|
|
1290
1296
|
this.loaded.set(true);
|
|
1291
|
-
this.timer = setTimeout(() => this.load(p, id, k), 10_000);
|
|
1297
|
+
this.timer = setTimeout(() => this.load(p, id, k), pollDelay(10_000));
|
|
1292
1298
|
},
|
|
1293
1299
|
error: (e) => {
|
|
1294
1300
|
this.loaded.set(true);
|
|
@@ -1688,7 +1694,19 @@ class ServicePage {
|
|
|
1688
1694
|
this.api.logs(this.key(), d, 'slow', 20).pipe(catchError(() => of(null))).subscribe((l) => this.slowLines.set(l?.lines ?? []));
|
|
1689
1695
|
});
|
|
1690
1696
|
});
|
|
1697
|
+
// Hidden, the polls slow to once a minute; seen again, the figures are read at once.
|
|
1698
|
+
const seen = () => {
|
|
1699
|
+
if (document.visibilityState !== 'visible' || !this.d())
|
|
1700
|
+
return;
|
|
1701
|
+
this.load();
|
|
1702
|
+
if (this.tab() !== 'overview' && this.tab() !== 'metrics')
|
|
1703
|
+
return;
|
|
1704
|
+
clearTimeout(this.metricsTimer);
|
|
1705
|
+
this.pollMetrics();
|
|
1706
|
+
};
|
|
1707
|
+
document.addEventListener('visibilitychange', seen);
|
|
1691
1708
|
inject(DestroyRef).onDestroy(() => {
|
|
1709
|
+
document.removeEventListener('visibilitychange', seen);
|
|
1692
1710
|
params.unsubscribe();
|
|
1693
1711
|
query.unsubscribe();
|
|
1694
1712
|
clearTimeout(this.loadTimer);
|
|
@@ -1729,7 +1747,7 @@ class ServicePage {
|
|
|
1729
1747
|
this.pitr.set(toLocalInput(new Date().toISOString()));
|
|
1730
1748
|
}
|
|
1731
1749
|
const settling = moving(d.state) || d.readyNodes < d.nodes || (d.dumps ?? []).some((x) => x.phase !== 'completed' && x.phase !== 'failed') || !!this.openRotation() || d.attachments.some((a) => a.state === 'pending') || (d.backups ?? []).some((b) => b.phase === 'running' || b.phase === 'pending');
|
|
1732
|
-
this.loadTimer = setTimeout(() => this.load(), settling ? 4000 : 30_000);
|
|
1750
|
+
this.loadTimer = setTimeout(() => this.load(), pollDelay(settling ? 4000 : 30_000));
|
|
1733
1751
|
},
|
|
1734
1752
|
error: (e) => {
|
|
1735
1753
|
this.error.set(e?.status === 404 ? 'No such service in this project.' : apiMessage(e, 'The service could not be loaded.'));
|
|
@@ -1743,9 +1761,9 @@ class ServicePage {
|
|
|
1743
1761
|
this.api.metrics(this.key(), d.id).subscribe({
|
|
1744
1762
|
next: (m) => {
|
|
1745
1763
|
this.readings.update((rs) => [...rs, m].slice(-90));
|
|
1746
|
-
this.metricsTimer = setTimeout(() => this.pollMetrics(), 10_000);
|
|
1764
|
+
this.metricsTimer = setTimeout(() => this.pollMetrics(), pollDelay(10_000));
|
|
1747
1765
|
},
|
|
1748
|
-
error: () => (this.metricsTimer = setTimeout(() => this.pollMetrics(), 30_000)),
|
|
1766
|
+
error: () => (this.metricsTimer = setTimeout(() => this.pollMetrics(), pollDelay(30_000))),
|
|
1749
1767
|
});
|
|
1750
1768
|
}
|
|
1751
1769
|
setTab(t) {
|
|
@@ -2659,5 +2677,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
|
|
|
2659
2677
|
* Generated bundle index. Do not edit.
|
|
2660
2678
|
*/
|
|
2661
2679
|
|
|
2662
|
-
export { DAYS, ENGINE_COLOUR, LIFECYCLE, PRESETS, ServiceConsoleTab, ServiceDumpsCard, ServiceLogsTab, ServiceMetricsTab, ServicePage, ServicesApi, ServicesHost, ServicesListPage, ServicesNewPage, apiMessage, backupKind, backupsLine, bytes, fromLocalInput, hhmm, hhmmss, money, moving, num, pct, presetChip, ratio, shortDate, spark, sparkPath, stateChip, stateDot, toLocalInput, utcHour, when };
|
|
2680
|
+
export { DAYS, ENGINE_COLOUR, HIDDEN_POLL_MS, LIFECYCLE, PRESETS, ServiceConsoleTab, ServiceDumpsCard, ServiceLogsTab, ServiceMetricsTab, ServicePage, ServicesApi, ServicesHost, ServicesListPage, ServicesNewPage, apiMessage, backupKind, backupsLine, bytes, fromLocalInput, hhmm, hhmmss, money, moving, num, pct, pollDelay, presetChip, ratio, shortDate, spark, sparkPath, stateChip, stateDot, toLocalInput, utcHour, when };
|
|
2663
2681
|
//# sourceMappingURL=chisquare-tech-origine-ngx-apps-services.mjs.map
|