Browse Source

Improve usability by eliminating page reloads

pull/7518/head
Thomas Kaul 4 weeks ago
parent
commit
46208f73ca
  1. 37
      apps/client/src/app/components/admin-overview/admin-overview.component.ts
  2. 8
      apps/client/src/app/components/admin-overview/admin-overview.html

37
apps/client/src/app/components/admin-overview/admin-overview.component.ts

@ -64,6 +64,7 @@ import {
} from 'ionicons/icons'; } from 'ionicons/icons';
import ms, { StringValue } from 'ms'; import ms, { StringValue } from 'ms';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { switchMap } from 'rxjs';
@Component({ @Component({
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@ -105,6 +106,8 @@ export class GfAdminOverviewComponent implements OnInit {
protected readonly info: InfoItem; protected readonly info: InfoItem;
protected isDataGatheringEnabled: boolean; protected isDataGatheringEnabled: boolean;
protected isLoading = false; protected isLoading = false;
protected isReadOnlyMode: boolean;
protected isUserSignupEnabled: boolean;
protected readonly permissions = permissions; protected readonly permissions = permissions;
protected systemMessage: SystemMessage; protected systemMessage: SystemMessage;
protected userCount: number; protected userCount: number;
@ -179,6 +182,8 @@ export class GfAdminOverviewComponent implements OnInit {
} }
public ngOnInit() { public ngOnInit() {
this.isLoading = true;
this.fetchAdminData(); this.fetchAdminData();
} }
@ -270,9 +275,15 @@ export class GfAdminOverviewComponent implements OnInit {
.flush() .flush()
.pipe(takeUntilDestroyed(this.destroyRef)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => { .subscribe(() => {
setTimeout(() => { this.dataService.updateInfo();
window.location.reload();
}, 300); this.snackBar.open(
'✅ ' + $localize`Cache has been flushed.`,
undefined,
{
duration: ms('3 seconds')
}
);
}); });
}, },
confirmType: ConfirmationDialogType.Warn, confirmType: ConfirmationDialogType.Warn,
@ -330,8 +341,6 @@ export class GfAdminOverviewComponent implements OnInit {
} }
private fetchAdminData() { private fetchAdminData() {
this.isLoading = true;
this.adminService this.adminService
.fetchAdminData() .fetchAdminData()
.pipe(takeUntilDestroyed(this.destroyRef)) .pipe(takeUntilDestroyed(this.destroyRef))
@ -344,6 +353,11 @@ export class GfAdminOverviewComponent implements OnInit {
this.isDataGatheringEnabled = this.isDataGatheringEnabled =
settings[PROPERTY_IS_DATA_GATHERING_ENABLED] === false ? false : true; settings[PROPERTY_IS_DATA_GATHERING_ENABLED] === false ? false : true;
this.isReadOnlyMode = settings[PROPERTY_IS_READ_ONLY_MODE] === true;
this.isUserSignupEnabled =
settings[PROPERTY_IS_USER_SIGNUP_ENABLED] === false ? false : true;
this.systemMessage = settings[PROPERTY_SYSTEM_MESSAGE] as SystemMessage; this.systemMessage = settings[PROPERTY_SYSTEM_MESSAGE] as SystemMessage;
this.userCount = userCount; this.userCount = userCount;
this.version = version; this.version = version;
@ -372,11 +386,16 @@ export class GfAdminOverviewComponent implements OnInit {
.putAdminSetting(key, { .putAdminSetting(key, {
value: value || value === false ? JSON.stringify(value) : undefined value: value || value === false ? JSON.stringify(value) : undefined
}) })
.pipe(takeUntilDestroyed(this.destroyRef)) .pipe(
switchMap(() => {
return this.userService.get(true);
}),
takeUntilDestroyed(this.destroyRef)
)
.subscribe(() => { .subscribe(() => {
setTimeout(() => { this.dataService.updateInfo();
window.location.reload();
}, 300); this.fetchAdminData();
}); });
} }

8
apps/client/src/app/components/admin-overview/admin-overview.html

@ -52,9 +52,7 @@
<mat-slide-toggle <mat-slide-toggle
color="primary" color="primary"
hideIcon="true" hideIcon="true"
[checked]=" [checked]="isUserSignupEnabled"
info.globalPermissions.includes(permissions.createUserAccount)
"
(change)="onEnableUserSignupModeChange($event)" (change)="onEnableUserSignupModeChange($event)"
/> />
</div> </div>
@ -66,7 +64,7 @@
<mat-slide-toggle <mat-slide-toggle
color="primary" color="primary"
hideIcon="true" hideIcon="true"
[checked]="info?.isReadOnlyMode" [checked]="isReadOnlyMode"
(change)="onReadOnlyModeChange($event)" (change)="onReadOnlyModeChange($event)"
/> />
</div> </div>
@ -99,7 +97,7 @@
</button> </button>
</div> </div>
} }
@if (!info?.systemMessage) { @if (!systemMessage) {
<button <button
class="mt-2" class="mt-2"
color="accent" color="accent"

Loading…
Cancel
Save