Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Fix dashboard issues #473

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export class Netquery {
},
{
observe: 'response',
responseType: 'text',
reportProgress: false,
}
)
Expand Down
31 changes: 19 additions & 12 deletions modules/portmaster/src/app/pages/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,30 @@ export class DashboardPageComponent implements OnInit, AfterViewInit {
.pipe(
takeUntilDestroyed(this.destroyRef)
)
.subscribe(profile => {
this.profile = profile;
.subscribe({
next: (profile) => {
this.profile = profile || null;
this.featureBw = profile?.current_plan?.feature_ids?.includes(FeatureID.Bandwidth) || false;
const featureSPN = profile?.current_plan?.feature_ids?.includes(FeatureID.SPN) || false;
this.featureSPN = profile?.current_plan?.feature_ids?.includes(FeatureID.SPN) || false;

if (featureSPN !== this.featureSPN) {
this.featureSPN = featureSPN;
// force a full change-detection cylce now!
this.cdr.detectChanges()

// force a full change-detection cylce now!
this.cdr.detectChanges()
// force re-draw of the charts after change-detection because the
// width may change now.
this.lineCharts?.forEach(chart => chart.redraw())

// force re-draw of the charts after change-detection because the
// width may change now.
this.lineCharts?.forEach(chart => chart.redraw())
}
this.cdr.markForCheck();
})
},
complete: () => {
// Database entry deletion will complete the observer.
this.profile = null;
this.featureBw = false;
this.featureSPN = false;

this.cdr.markForCheck();
},
})
}

async ngAfterViewInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class CountryFlagDirective implements AfterViewInit, OnChanges {
const flag = this.toUnicodeFlag(this.appCountryFlags);
this.renderer.setAttribute(span, 'data-before', flag);

span.innerHTML = `<img style="display: inline" src="${this.flagDir}/${this.appCountryFlags.toLocaleUpperCase()}.png">`;
span.innerHTML = `<img style="display: inline" src="${this.flagDir}${this.appCountryFlags.toLocaleUpperCase()}.png">`;
}

private toUnicodeFlag(code: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,20 @@ export class SPNAccountDetailsComponent implements OnInit {
takeUntilDestroyed(this.destroyRef),
catchError(err => of(null)),
)
.subscribe(profile => {
this.loadingProfile = false;
this.currentUser = profile || null;
.subscribe({
next: (profile) => {
this.loadingProfile = false;
this.currentUser = profile || null;

this.cdr.markForCheck();
this.cdr.markForCheck();
},
complete: () => {
// Database entry deletion will complete the observer.
this.loadingProfile = false;
this.currentUser = null;

this.cdr.markForCheck();
},
})
}
}
Loading