From afa53d2f87a9d60bb542960c4aca025019d325a8 Mon Sep 17 00:00:00 2001 From: Bastian Rihm Date: Tue, 30 Apr 2024 17:29:59 +0200 Subject: [PATCH] Add option to disable connection closing on inactivity (#3634) --- .../account-dialog.component.html | 18 +++++++++++ .../account-dialog.component.ts | 31 +++++++++++++++++-- .../services/autoupdate/autoupdate.service.ts | 14 ++++++--- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.html b/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.html index 427f42b862..7a64b3506c 100644 --- a/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.html +++ b/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.html @@ -36,6 +36,10 @@

*ngSwitchCase="menuItemsRef.CHANGE_PASSWORD" [ngTemplateOutlet]="changePasswordView" > + @@ -95,3 +99,17 @@

{{ 'Change password' | translate }}

+ + +

{{ 'Settings' | translate }}

+
+ + {{ 'Disable connection closing on inactivity' | translate }} + +
+
+ +
+
diff --git a/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.ts b/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.ts index 0522a2d0dd..8df09e61e3 100644 --- a/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.ts +++ b/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.ts @@ -1,8 +1,10 @@ import { Component, OnInit, ViewChild } from '@angular/core'; +import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; import { MatDialogRef } from '@angular/material/dialog'; import { MatSnackBar } from '@angular/material/snack-bar'; import { TranslateService } from '@ngx-translate/core'; import { Permission } from 'src/app/domain/definitions/permission'; +import { StorageService } from 'src/app/gateways/storage.service'; import { PasswordForm, PasswordFormComponent } from 'src/app/site/modules/user-components'; import { ViewGroup } from 'src/app/site/pages/meetings/pages/participants'; import { MeetingControllerService } from 'src/app/site/pages/meetings/services/meeting-controller.service'; @@ -21,7 +23,8 @@ interface MenuItem { enum MenuItems { CHANGE_PASSWORD = `Change password`, SHOW_PROFILE = `My profile`, - SHOW_MEETINGS = `My meetings` + SHOW_MEETINGS = `My meetings`, + CLIENT_SETTINGS = `Settings` } @Component({ @@ -42,6 +45,9 @@ export class AccountDialogComponent extends BaseUiComponent implements OnInit { }, { name: MenuItems.CHANGE_PASSWORD + }, + { + name: MenuItems.CLIENT_SETTINGS } ]; @@ -89,6 +95,7 @@ export class AccountDialogComponent extends BaseUiComponent implements OnInit { public isUserPasswordValid = false; public userPersonalForm: any; public userPasswordForm!: PasswordForm; + public clientSettingsForm!: UntypedFormGroup; private _self: ViewUser | null = null; private _isUserInScope = false; @@ -102,7 +109,9 @@ export class AccountDialogComponent extends BaseUiComponent implements OnInit { private userService: UserService, private snackbar: MatSnackBar, private authService: AuthService, - private translate: TranslateService + private translate: TranslateService, + private fb: UntypedFormBuilder, + private store: StorageService ) { super(); } @@ -112,6 +121,17 @@ export class AccountDialogComponent extends BaseUiComponent implements OnInit { this.repo.getViewModelObservable(this.operator.operatorId!).subscribe(user => (this._self = user)), this.operator.operatorUpdated.subscribe(() => this.updateIsUserInScope()) ); + + this.clientSettingsForm = this.fb.group({ + disablePauseAuConnections: [false] + }); + + this.store.get(`clientSettings`).then((val: any) => { + if (val) { + this.clientSettingsForm.patchValue(val); + this.clientSettingsForm.markAsUntouched(); + } + }); } /** @@ -143,7 +163,7 @@ export class AccountDialogComponent extends BaseUiComponent implements OnInit { const meetingIds = this.self.ensuredMeetingIds; return meetingIds .map(id => this.meetingRepo.getViewModel(id) as ViewMeeting) - .sort((meetingA, meetingB) => meetingA.name.localeCompare(meetingB.name)); + .sort((meetingA, meetingB) => meetingA.name.localeCompare(meetingB?.name)); } public getGroupsForMeeting(meeting: ViewMeeting): ViewGroup[] { @@ -183,6 +203,11 @@ export class AccountDialogComponent extends BaseUiComponent implements OnInit { this.isEditing = false; } + public async saveClientSettings(): Promise { + this.store.set(`clientSettings`, this.clientSettingsForm.getRawValue()); + this.clientSettingsForm.markAsPristine(); + } + private async updateIsUserInScope(): Promise { if (this.operator.operatorId !== null) { this._isUserInScope = await this.userService.hasScopeManagePerms(this.operator.operatorId); diff --git a/client/src/app/site/services/autoupdate/autoupdate.service.ts b/client/src/app/site/services/autoupdate/autoupdate.service.ts index da753b6ac7..3c22cd109d 100644 --- a/client/src/app/site/services/autoupdate/autoupdate.service.ts +++ b/client/src/app/site/services/autoupdate/autoupdate.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { marker as _ } from '@colsen1991/ngx-translate-extract-marker'; import { firstValueFrom } from 'rxjs'; import { ModelRequest } from 'src/app/domain/interfaces/model-request'; +import { StorageService } from 'src/app/gateways/storage.service'; import { Collection, Id, Ids } from '../../../domain/definitions/key-types'; import { HttpStreamEndpointService } from '../../../gateways/http-stream'; @@ -68,7 +69,7 @@ export const OUT_OF_SYNC_BANNER: BannerDefinition = { icon: `sync_disabled` }; -const PAUSE_ON_INACTIVITY_TIMEOUT = 5 * 60 * 1000; // 5 Minutes +export const AU_PAUSE_ON_INACTIVITY_TIMEOUT = 5 * 60 * 1000; // 5 Minutes @Injectable({ providedIn: `root` @@ -85,7 +86,8 @@ export class AutoupdateService { private communication: AutoupdateCommunicationService, private bannerService: BannerService, private visibilityService: WindowVisibilityService, - private lifecycle: LifecycleService + private lifecycle: LifecycleService, + private store: StorageService ) { this.setAutoupdateConfig(null); this.httpEndpointService.registerEndpoint( @@ -102,8 +104,12 @@ export class AutoupdateService { }); firstValueFrom(this.lifecycle.appLoaded).then(() => - this.visibilityService.hiddenFor(PAUSE_ON_INACTIVITY_TIMEOUT).subscribe(() => { - this.pauseUntilVisible(); + this.visibilityService.hiddenFor(AU_PAUSE_ON_INACTIVITY_TIMEOUT).subscribe(() => { + this.store.get(`clientSettings`).then((settings: any) => { + if (!settings || !settings?.disablePauseAuConnections) { + this.pauseUntilVisible(); + } + }); }) );