From 6c0e8c0d017aedf28b9ab75a1ffaa3186f2a8ae9 Mon Sep 17 00:00:00 2001 From: "hamza.hramchi" <hamza.hramchi@xelians.fr> Date: Thu, 29 Oct 2020 16:23:33 +0100 Subject: [PATCH] FEAT #14324 TIME 1:10 add feature_tour to the database --- src/frontend/service/auth.service.ts | 3 ++- src/frontend/service/featureTour.service.ts | 22 +++++++++++++++++---- src/frontend/service/header.service.ts | 5 +++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/frontend/service/auth.service.ts b/src/frontend/service/auth.service.ts index fd1e63a528f..5ec62241612 100644 --- a/src/frontend/service/auth.service.ts +++ b/src/frontend/service/auth.service.ts @@ -278,7 +278,8 @@ export class AuthService { entities: data.entities, groups: data.groups, preferences: data.preferences, - privileges: data.privileges[0] === 'ALL_PRIVILEGES' ? this.privilegeService.getAllPrivileges(!data.lockAdvancedPrivileges) : data.privileges + privileges: data.privileges[0] === 'ALL_PRIVILEGES' ? this.privilegeService.getAllPrivileges(!data.lockAdvancedPrivileges) : data.privileges, + featureTour: data.featureTour }; this.headerService.nbResourcesFollowed = data.nbFollowedResources; this.privilegeService.resfreshUserShortcuts(); diff --git a/src/frontend/service/featureTour.service.ts b/src/frontend/service/featureTour.service.ts index da86046d624..58953afdd10 100644 --- a/src/frontend/service/featureTour.service.ts +++ b/src/frontend/service/featureTour.service.ts @@ -5,6 +5,10 @@ import { LocalStorageService } from './local-storage.service'; import { HeaderService } from './header.service'; import { FunctionsService } from './functions.service'; import { Router } from '@angular/router'; +import { HttpClient } from '@angular/common/http'; +import { catchError, tap } from 'rxjs/operators'; +import { of } from 'rxjs'; +import { NotificationService } from './notification/notification.service'; @Injectable({ providedIn: 'root' @@ -96,7 +100,9 @@ export class FeatureTourService { private localStorage: LocalStorageService, private headerService: HeaderService, private functionService: FunctionsService, - private router: Router + private router: Router, + private http: HttpClient, + private notify: NotificationService, ) { this.getCurrentStepType(); } @@ -138,8 +144,8 @@ export class FeatureTourService { } getCurrentStepType() { - if (this.localStorage.get(`featureTourEnd_${this.headerService.user.id}`) !== null) { - this.featureTourEnd = JSON.parse(this.localStorage.get(`featureTourEnd_${this.headerService.user.id}`)); + if (this.headerService.user.userId !== null) { + this.featureTourEnd = this.headerService.user.featureTour; } const unique = [...new Set(this.tour.map(item => item.type))]; @@ -147,8 +153,16 @@ export class FeatureTourService { } endTour() { + console.log(this.currentStepType); this.featureTourEnd.push(this.currentStepType); - this.localStorage.save(`featureTourEnd_${this.headerService.user.id}`, JSON.stringify(this.featureTourEnd)); + this.http.put('../rest/currentUser/profile/featureTour', {featureTour : this.featureTourEnd}).pipe( + tap(() => { + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); this.getCurrentStepType(); } diff --git a/src/frontend/service/header.service.ts b/src/frontend/service/header.service.ts index 8cfef391839..74e7164abc3 100755 --- a/src/frontend/service/header.service.ts +++ b/src/frontend/service/header.service.ts @@ -30,7 +30,7 @@ export class HeaderService { headerMessageIcon: string = ''; headerMessage: string = ''; subHeaderMessage: string = ''; - user: any = { firstname: '', lastname: '', groups: [], privileges: [], preferences: [] }; + user: any = { firstname: '', lastname: '', groups: [], privileges: [], preferences: [], featureTour: [] }; nbResourcesFollowed: number = 0; base64: string = null; @@ -76,7 +76,8 @@ export class HeaderService { entities: data.entities, groups: data.groups, preferences: data.preferences, - privileges: data.privileges[0] === 'ALL_PRIVILEGES' ? this.user.privileges : data.privileges + privileges: data.privileges[0] === 'ALL_PRIVILEGES' ? this.user.privileges : data.privileges, + featureTour: data.featureTour }; this.nbResourcesFollowed = data.nbFollowedResources; resolve(true); -- GitLab