Skip to content

Commit

Permalink
fix: added storage information to support panel (#1264)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Leidig <sebastian.leidig@gmail.com>
  • Loading branch information
TheSlimvReal and sleidig authored May 12, 2022
1 parent 5bb93f8 commit 10f88bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/core/support/support/support.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ <h1>Technical User Support Details</h1>

<div fxFlex class="tech-details">
<p>Username: {{ currentUser.name }}</p>
<p>App version: {{ appVersion }}</p>
<p>Device info: {{ userAgent }}</p>
<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
17 changes: 17 additions & 0 deletions src/app/core/support/support/support.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { RouteTarget } from "../../../app.routing";
import { ConfirmationDialogService } from "../../confirmation-dialog/confirmation-dialog.service";
import { HttpClient } from "@angular/common/http";
import { SyncedSessionService } from "../../session/session-service/synced-session.service";
import { environment } from "../../../../environments/environment";

@RouteTarget("Support")
@Component({
Expand All @@ -24,9 +25,11 @@ export class SupportComponent implements OnInit {
currentSyncState: string;
lastSync: string;
lastRemoteLogin: string;
storageInfo: string;
swStatus: string;
swLog = "not available";
userAgent = this.window.navigator.userAgent;
appVersion: string;

constructor(
private sessionService: SessionService,
Expand All @@ -40,9 +43,11 @@ export class SupportComponent implements OnInit {

ngOnInit(): void {
this.currentUser = this.sessionService.getCurrentUser();
this.appVersion = environment.appVersion;
this.initCurrentSyncState();
this.initLastSync();
this.initLastRemoteLogin();
this.initStorageInfo();
this.initSwStatus();
}

Expand All @@ -69,6 +74,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 +110,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 10f88bb

Please sign in to comment.