Skip to content

Commit

Permalink
added storage information to support panel
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSlimvReal committed May 11, 2022
1 parent 97a7ecd commit 09de863
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/core/support/support/support.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ <h1>Technical User Support Details</h1>
<p>Current sync state: {{ currentSyncState }}</p>
<p>Last sync: {{ lastSync }}</p>
<p>Last remote login: {{ lastRemoteLogin }}</p>
<p>Storage usage: {{ storageInfo }}</p>
<p>Service Worker: {{ swStatus }}</p>
<p>
<mat-expansion-panel class="mat-elevation-z0">
Expand Down
14 changes: 14 additions & 0 deletions src/app/core/support/support/support.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,6 +44,7 @@ export class SupportComponent implements OnInit {
this.initCurrentSyncState();
this.initLastSync();
this.initLastRemoteLogin();
this.initStorageInfo();
this.initSwStatus();
}

Expand All @@ -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";
Expand All @@ -94,6 +107,7 @@ export class SupportComponent implements OnInit {
swStatus: this.swStatus,
userAgent: this.userAgent,
swLog: this.swLog,
storageInfo: this.storageInfo,
},
});
Sentry.showReportDialog({
Expand Down

0 comments on commit 09de863

Please sign in to comment.