Skip to content

Commit

Permalink
Merge pull request #1829 from DSD-DBS/trigger-feedback-after-login
Browse files Browse the repository at this point in the history
feat: Trigger feedback dialog after login
  • Loading branch information
MoritzWeber0 authored Sep 23, 2024
2 parents 8f6298e + 0405134 commit 0fa3727
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
18 changes: 2 additions & 16 deletions frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { NgIf, NgClass, AsyncPipe } from '@angular/common';
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
import { AfterViewInit, Component, ViewChild } from '@angular/core';
import {
MatSidenav,
MatDrawerContainer,
Expand All @@ -18,7 +18,6 @@ import { HeaderComponent } from './general/header/header.component';
import { NavBarMenuComponent } from './general/nav-bar-menu/nav-bar-menu.component';
import { NoticeComponent } from './general/notice/notice.component';
import { PageLayoutService } from './page-layout/page-layout.service';
import { AuthenticationWrapperService } from './services/auth/auth.service';
import { FeedbackWrapperService } from './sessions/feedback/feedback.service';
import { FullscreenService } from './sessions/service/fullscreen.service';

Expand All @@ -41,31 +40,18 @@ import { FullscreenService } from './sessions/service/fullscreen.service';
AsyncPipe,
],
})
export class AppComponent implements OnInit, AfterViewInit {
export class AppComponent implements AfterViewInit {
constructor(
public pageLayoutService: PageLayoutService,
public fullscreenService: FullscreenService,
private navBarService: NavBarService,
private feedbackService: FeedbackWrapperService,
private authService: AuthenticationWrapperService,
) {
slugify.extend({ '.': '-' });
}

@ViewChild('sidenav') private sidenav?: MatSidenav;

async ngOnInit() {
this.feedbackService.loadFeedbackConfig().subscribe(() => {
if (
this.feedbackService.shouldShowIntervalPrompt() &&
this.authService.isLoggedIn()
) {
this.feedbackService.showDialog([], 'On interval');
this.feedbackService.saveFeedbackPromptDate();
}
});
}

ngAfterViewInit(): void {
this.navBarService.sidenav = this.sidenav;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ToastService } from 'src/app/helpers/toast/toast.service';
import { AuthenticationService } from 'src/app/openapi';
import { AuthenticationWrapperService } from 'src/app/services/auth/auth.service';
import { OwnUserWrapperService } from 'src/app/services/user/user.service';
import { FeedbackWrapperService } from 'src/app/sessions/feedback/feedback.service';

@Component({
selector: 'app-auth-redirect',
Expand All @@ -22,6 +23,7 @@ export class AuthRedirectComponent implements OnInit {
private authenticationService: AuthenticationService,
private userService: OwnUserWrapperService,
private router: Router,
private feedbackService: FeedbackWrapperService,
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -78,6 +80,7 @@ export class AuthRedirectComponent implements OnInit {
next: () => {
localStorage.setItem(this.authService.LOGGED_IN_KEY, 'true');
this.userService.updateOwnUser();
this.feedbackService.triggerFeedbackPrompt();
this.router.navigateByUrl(redirectTo);
},
error: () => this.redirectToLogin(),
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/app/sessions/feedback/feedback.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { BehaviorSubject, Observable, tap } from 'rxjs';
import { AuthenticationWrapperService } from 'src/app/services/auth/auth.service';
import {
FeedbackConfigurationOutput,
FeedbackService as OpenAPIFeedbackService,
Expand All @@ -19,8 +20,9 @@ export class FeedbackWrapperService {
constructor(
private feedbackService: OpenAPIFeedbackService,
public dialog: MatDialog,
private authService: AuthenticationWrapperService,
) {
this.loadFeedbackConfig().subscribe();
this.loadFeedbackConfig().subscribe(() => this.triggerFeedbackPrompt());
}

private _feedbackConfig = new BehaviorSubject<
Expand All @@ -35,6 +37,13 @@ export class FeedbackWrapperService {
.pipe(tap((feedbackConf) => this._feedbackConfig.next(feedbackConf)));
}

triggerFeedbackPrompt(): void {
if (this.shouldShowIntervalPrompt() && this.authService.isLoggedIn()) {
this.showDialog([], 'On interval');
this.saveFeedbackPromptDate();
}
}

public showDialog(sessions: Session[], trigger: string) {
this.dialog.open(FeedbackDialogComponent, {
data: { sessions, trigger },
Expand Down

0 comments on commit 0fa3727

Please sign in to comment.