Skip to content

Commit

Permalink
Add option to disable connection closing on inactivity (#3634)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianjoel authored and peb-adr committed Apr 30, 2024
1 parent 64282ea commit ed88d7b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ <h2 mat-dialog-title class="flex-container padding-top-16">
*ngSwitchCase="menuItemsRef.CHANGE_PASSWORD"
[ngTemplateOutlet]="changePasswordView"
></ng-container>
<ng-container
*ngSwitchCase="menuItemsRef.CLIENT_SETTINGS"
[ngTemplateOutlet]="clientSettingsView"
></ng-container>
</ng-container>
</div>
</div>
Expand Down Expand Up @@ -95,3 +99,17 @@ <h2>{{ 'Change password' | translate }}</h2>
</button>
</div>
</ng-template>

<ng-template #clientSettingsView>
<h2>{{ 'Settings' | translate }}</h2>
<form [formGroup]="clientSettingsForm">
<mat-checkbox formControlName="disablePauseAuConnections">
{{ 'Disable connection closing on inactivity' | translate }}
</mat-checkbox>
</form>
<div>
<button mat-button [disabled]="!clientSettingsForm.dirty" (click)="saveClientSettings()">
{{ 'Save' | translate }}
</button>
</div>
</ng-template>
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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({
Expand All @@ -42,6 +45,9 @@ export class AccountDialogComponent extends BaseUiComponent implements OnInit {
},
{
name: MenuItems.CHANGE_PASSWORD
},
{
name: MenuItems.CLIENT_SETTINGS
}
];

Expand Down Expand Up @@ -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;
Expand All @@ -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();
}
Expand All @@ -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();
}
});
}

/**
Expand Down Expand Up @@ -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[] {
Expand Down Expand Up @@ -183,6 +203,11 @@ export class AccountDialogComponent extends BaseUiComponent implements OnInit {
this.isEditing = false;
}

public async saveClientSettings(): Promise<void> {
this.store.set(`clientSettings`, this.clientSettingsForm.getRawValue());
this.clientSettingsForm.markAsPristine();
}

private async updateIsUserInScope(): Promise<void> {
if (this.operator.operatorId !== null) {
this._isUserInScope = await this.userService.hasScopeManagePerms(this.operator.operatorId);
Expand Down
14 changes: 10 additions & 4 deletions client/src/app/site/services/autoupdate/autoupdate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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`
Expand All @@ -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(
Expand All @@ -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();
}
});
})
);

Expand Down

0 comments on commit ed88d7b

Please sign in to comment.