-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
661b860
commit 034bbc2
Showing
10 changed files
with
199 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,98 @@ | ||
|
||
import { computed, Injectable, Signal, signal } from '@angular/core'; | ||
import { computed, Injectable, signal } from '@angular/core'; | ||
import { CookieService } from 'ngx-cookie-service'; | ||
import { DESIGNER_COOKIE_VARIABLE } from './shared/constants/common.constant'; | ||
import { | ||
Router, | ||
NavigationEnd, | ||
Params, | ||
NavigationStart | ||
NavigationStart, | ||
ActivatedRoute | ||
} from '@angular/router'; | ||
import { Observable } from 'rxjs'; | ||
import { filter } from 'rxjs/operators'; | ||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class CookieManagementService { | ||
private isDesigner = signal(false); | ||
isDesigner = signal(false); | ||
isDesignerEnv = computed(() => this.isDesigner()); | ||
designerVersion = signal(''); | ||
resultsOnly = WritableS | ||
isResultsOnly = computed(() => this.resultsOnly()); | ||
|
||
constructor(private cookieService: CookieService, private router: Router) { | ||
this.getNavigationStartEvent().subscribe(()=> { | ||
constructor( | ||
private cookieService: CookieService, | ||
private router: Router, | ||
private route: ActivatedRoute | ||
) { | ||
this.getNavigationStartEvent().subscribe(() => { | ||
if (!this.isDesigner()) { | ||
this.isDesigner.set(this.cookieService.get(DESIGNER_COOKIE_VARIABLE.ivyViewerParamName) == DESIGNER_COOKIE_VARIABLE.defaultDesignerViewer); | ||
this.isDesigner.set( | ||
this.cookieService.get(DESIGNER_COOKIE_VARIABLE.ivyViewerParamName) == | ||
DESIGNER_COOKIE_VARIABLE.defaultDesignerViewer | ||
); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
ngOnInit(): void { | ||
// Accessing query parameters | ||
this.resultsOnly = this.route.snapshot.queryParamMap.has('resultsOnly'); | ||
console.log('resultsOnly:', this.resultsOnly); | ||
} | ||
|
||
// ngOnInit(): void { | ||
// this.route.queryParams.subscribe(params => { | ||
// if (params['resultsOnly']) { | ||
// this.resultsOnly.set(true); | ||
// console.log('resultsOnly:', this.resultsOnly); | ||
// } | ||
// }); | ||
// } | ||
|
||
checkCookieForDesignerVersion(params: Params) { | ||
const versionParam = params[DESIGNER_COOKIE_VARIABLE.ivyVersionParamName]; | ||
if (versionParam != undefined) { | ||
this.cookieService.set(DESIGNER_COOKIE_VARIABLE.ivyVersionParamName, versionParam); | ||
this.cookieService.set( | ||
DESIGNER_COOKIE_VARIABLE.ivyVersionParamName, | ||
versionParam | ||
); | ||
this.designerVersion.set(versionParam); | ||
} | ||
} | ||
|
||
checkCookieForDesignerEnv(params: Params) { | ||
const ivyViewerParam = params[DESIGNER_COOKIE_VARIABLE.ivyViewerParamName]; | ||
if (ivyViewerParam == DESIGNER_COOKIE_VARIABLE.defaultDesignerViewer) { | ||
this.cookieService.set(DESIGNER_COOKIE_VARIABLE.ivyViewerParamName, ivyViewerParam); | ||
this.cookieService.set( | ||
DESIGNER_COOKIE_VARIABLE.ivyViewerParamName, | ||
ivyViewerParam | ||
); | ||
this.isDesigner.set(true); | ||
} | ||
} | ||
|
||
getDesignerVersionFromCookie() { | ||
if (this.designerVersion() == '') { | ||
this.designerVersion.set(this.cookieService.get(DESIGNER_COOKIE_VARIABLE.ivyVersionParamName)) | ||
this.designerVersion.set( | ||
this.cookieService.get(DESIGNER_COOKIE_VARIABLE.ivyVersionParamName) | ||
); | ||
} | ||
return this.designerVersion(); | ||
} | ||
|
||
isDesignerViewer() { | ||
if (!this.isDesigner()) { | ||
this.isDesigner.set(this.cookieService.get(DESIGNER_COOKIE_VARIABLE.ivyViewerParamName) == DESIGNER_COOKIE_VARIABLE.defaultDesignerViewer); | ||
this.isDesigner.set( | ||
this.cookieService.get(DESIGNER_COOKIE_VARIABLE.ivyViewerParamName) == | ||
DESIGNER_COOKIE_VARIABLE.defaultDesignerViewer | ||
); | ||
} | ||
return this.isDesigner(); | ||
} | ||
|
||
getNavigationStartEvent():Observable<NavigationStart>{ | ||
getNavigationStartEvent(): Observable<NavigationStart> { | ||
return this.router.events.pipe( | ||
filter(event => event instanceof NavigationStart) | ||
) as Observable<NavigationStart>; | ||
} | ||
} | ||
} |
48 changes: 25 additions & 23 deletions
48
marketplace-ui/src/app/modules/product/product.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.