Hi all, When using the web components implementati...
# gooddata-cloud
j
Hi all, When using the web components implementation am I able to store the filter values when reloading the page. I been trying to find a way to keep the filters in the cookies
i
Hello Joaquim, thank you for reaching out to us. I would appreciate if you can share how you are managing storing the filter values. Code snippet responsible for that part would be enough. May I also ask the reason you would like to keep the filters in the cookies? The reason being, maybe there is another way of achieving your desired results with some other ways. Thank you for your cooperation.
j
Hello thank you for getting back to me. It doesnt have to be in cookies but anyway that we can persit filter values. If a user goes and changes the date range for example if they reload the page we want it to persist. The filter values are currently coming directly from the gooddata setup so only the default values.
Copy code
onDashboardLoaded(e: Event) {
		const detail = (e as CustomEvent).detail;
		const filters = detail?.dashboard?.filterContext?.filters;
		if (Array.isArray(filters)) {
			this.dashboardFilters.push(...filters);
		}
	}

	onDashboardFilterChange(e: Event) {
		const detail = (e as CustomEvent).detail;
		const filters = detail?.dashboard?.filterContext?.filters;
		if (Array.isArray(filters)) {
			this.dashboardFilters.push(...filters);
		}
	}

	ngOnInit(): void {
		this.globalDashboardSvc.activeDashboardSubject$
		.pipe(
			distinctUntilChanged((prevDashboard, currDashboard) => JSON.stringify(prevDashboard) === JSON.stringify(currDashboard)),
			tap(dashboard => {
				if(!dashboard) {
					this.dashboardConfigured.set(false);
					this.gdDashboardLoading$.next(false);
				}
			}),
			filter(dashboard => !!dashboard),
			untilDestroyed(this),
		)
		.subscribe(dashboard => {
			this.dashboardId = dashboard?.dashId;
			this.authenticateAndInjectGdScript(dashboard?.workspaceId);
		})

		this.globalDashboardSvc.activeCustomer$.pipe(
			filter(customer => !!customer),
			untilDestroyed(this),
		).subscribe(customer => {
			if(customer?.enableLegacyDashboard) {
				this.gdDashboardLoading$.next(false);
				this.dashboardConfigured.set(false);
			}
		})
	}

	cleanUpGdElements() {
		// Clean up existing elements
		document.getElementById('customDashScript')?.remove();
		document.getElementById('gdElement')?.remove();
	}
i
Thank you for the explanation. I am investigating this internally and will update you once I have more information.
Hello, thank you for your patience while we were investigating your question. In the portal mode, we support function
auto-save last state
which saves the filter configuration in the browser’s local storage. But this feature is unfortunately not available in the component embedding. Please let me know if you have further questions. Thank you
j
I see thank you for looking at that for me. So there is no other way to pass values into the web component from the web broswer?
i
Unfortunately not but I can offer to raise a product feedback. Would that be OK?
j
yes sure thank you
i
Thank you and have a nice day.
j
likewise
cc @Sameer Hasan