From 09de8635b1ea56b337a6fd41b9469267982cbda1 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 11 May 2022 12:12:20 +0200 Subject: [PATCH] added storage information to support panel --- .../core/support/support/support.component.html | 1 + src/app/core/support/support/support.component.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/app/core/support/support/support.component.html b/src/app/core/support/support/support.component.html index 666d9233d7..d1a10dc781 100644 --- a/src/app/core/support/support/support.component.html +++ b/src/app/core/support/support/support.component.html @@ -11,6 +11,7 @@

Technical User Support Details

Current sync state: {{ currentSyncState }}

Last sync: {{ lastSync }}

Last remote login: {{ lastRemoteLogin }}

+

Storage usage: {{ storageInfo }}

Service Worker: {{ swStatus }}

diff --git a/src/app/core/support/support/support.component.ts b/src/app/core/support/support/support.component.ts index e38559e824..888899554a 100644 --- a/src/app/core/support/support/support.component.ts +++ b/src/app/core/support/support/support.component.ts @@ -24,6 +24,7 @@ export class SupportComponent implements OnInit { currentSyncState: string; lastSync: string; lastRemoteLogin: string; + storageInfo: string; swStatus: string; swLog = "not available"; userAgent = this.window.navigator.userAgent; @@ -43,6 +44,7 @@ export class SupportComponent implements OnInit { this.initCurrentSyncState(); this.initLastSync(); this.initLastRemoteLogin(); + this.initStorageInfo(); this.initSwStatus(); } @@ -69,6 +71,17 @@ export class SupportComponent implements OnInit { localStorage.getItem(RemoteSession.LAST_LOGIN_KEY) || "never"; } + private initStorageInfo() { + const storage = this.window.navigator?.storage; + if (storage && "estimate" in storage) { + storage.estimate().then((estimate) => { + const used = estimate.usage / 1048576; + const available = estimate.quota / 1048576; + this.storageInfo = `${used.toFixed(2)}MBs / ${available.toFixed(2)}MBs`; + }); + } + } + private initSwStatus() { if (this.sw.isEnabled) { this.swStatus = "enabled"; @@ -94,6 +107,7 @@ export class SupportComponent implements OnInit { swStatus: this.swStatus, userAgent: this.userAgent, swLog: this.swLog, + storageInfo: this.storageInfo, }, }); Sentry.showReportDialog({