From bdc3c6d64f6164fdfa62a3fbe1ecc453589c3553 Mon Sep 17 00:00:00 2001 From: wyattb Date: Sun, 11 Jan 2026 16:49:31 -0500 Subject: [PATCH] #463 - added topic url's to graph page --- .../pages/graph-page/graph-page.component.ts | 36 ++++++++++++++++++- .../graph-sidebar/graph-sidebar.component.ts | 2 +- compose/compose.calypso.yml | 20 +++++------ 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/angular-client/src/pages/graph-page/graph-page.component.ts b/angular-client/src/pages/graph-page/graph-page.component.ts index 6d396a0e..90d6cf56 100644 --- a/angular-client/src/pages/graph-page/graph-page.component.ts +++ b/angular-client/src/pages/graph-page/graph-page.component.ts @@ -1,5 +1,5 @@ import { Component, OnDestroy, OnInit, inject } from '@angular/core'; -import { Router } from '@angular/router'; +import { ActivatedRoute, ParamMap, Router } from '@angular/router'; import { MessageService } from 'primeng/api'; import { BehaviorSubject, Subscription } from 'rxjs'; import { getDataByDatatTypeNameAndTiming, getDataByDataTypeNameAndRunId } from 'src/api/data.api'; @@ -51,6 +51,7 @@ export default class GraphPageComponent implements OnInit, OnDestroy { private faultService = inject(FaultService); private topicSelectionService = inject(TopicSelectionService); private router = inject(Router); // for fault page navigation + private route = inject(ActivatedRoute); // keep track of the subscriptions, that way we cancel all subs anywhere anytime subscriptions: Subscription[] = []; @@ -182,6 +183,14 @@ export default class GraphPageComponent implements OnInit, OnDestroy { if (dataTypes.length > 0 || this.selectedDataTypes.length > 0) { this.processDataTypeSelection(dataTypes); } + this.updateUrl(dataTypes); + }) + ); + + // Subscribe to URL changes to sync back to service + this.persistentSubscriptions.push( + this.route.queryParamMap.subscribe((params) => { + this.syncUrlToService(params); }) ); @@ -332,11 +341,36 @@ export default class GraphPageComponent implements OnInit, OnDestroy { dataTypesQueryResponse.data.subscribe((data) => { if (data) { this.dataTypes = data; + // Once the datatypes are actually loaded, sync to url + this.syncUrlToService(this.route.snapshot.queryParamMap); + this.updateUrl(this.topicSelectionService.getSelectedDataTypes().value); } }) ); } + private syncUrlToService(params: ParamMap) { + if (this.dataTypes.length === 0) return; + + const topicNames = new Set(params.get('topics')?.split(',') ?? []); + const topics = this.dataTypes.filter((dt) => topicNames.has(dt.name)); + + this.topicSelectionService.setSelectedDataTypes(topics); + } + + private updateUrl(selectedDataTypes: DataType[]) { + if (this.dataTypes.length === 0) return; + + const topics = selectedDataTypes.map((dt) => dt.name).join(',') || null; + + this.router.navigate([], { + relativeTo: this.route, + queryParams: { topics }, + queryParamsHandling: 'merge', + replaceUrl: true + }); + } + private processRealTimeDataTypeSelection = (dataTypes: DataType[]) => { const dataTypeValues = this.selectedDataTypeValuesSubject.map((subject) => subject.getValue()); diff --git a/angular-client/src/pages/graph-page/graph-sidebar/graph-sidebar.component.ts b/angular-client/src/pages/graph-page/graph-sidebar/graph-sidebar.component.ts index 5381f31d..7a6fb496 100644 --- a/angular-client/src/pages/graph-page/graph-sidebar/graph-sidebar.component.ts +++ b/angular-client/src/pages/graph-page/graph-sidebar/graph-sidebar.component.ts @@ -25,7 +25,7 @@ export default class GraphSidebarComponent implements OnInit { this.isMobile = window.innerWidth <= this.mobileThreshold; } - @HostListener('window:resize', ['$event']) + @HostListener('window:resize') onResize() { this.isMobile = window.innerWidth <= this.mobileThreshold; } diff --git a/compose/compose.calypso.yml b/compose/compose.calypso.yml index c27b4418..6042fde0 100644 --- a/compose/compose.calypso.yml +++ b/compose/compose.calypso.yml @@ -1,11 +1,11 @@ services: - calypso: - container_name: calypso - image: ghcr.io/northeastern-electric-racing/calypso:m1calypso - restart: unless-stopped - environment: - # in prod mode - #- CALYPSO_CAN_ENCODE=false - #- CALYPSO_SOCKETCAN_IFACE=vcan0 - # in sim or prod mode - - CALYPSO_SIREN_HOST_URL=siren:1883 + calypso: + container_name: calypso + image: ghcr.io/northeastern-electric-racing/calypso:Develop + restart: unless-stopped + environment: + # in prod mode + #- CALYPSO_CAN_ENCODE=false + #- CALYPSO_SOCKETCAN_IFACE=vcan0 + # in sim or prod mode + - CALYPSO_SIREN_HOST_URL=siren:1883