@@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core';
22import { equalArray } from 'src/app/util/util' ;
33import { LoaderService } from 'src/app/service/loader/data-loader.service' ;
44import * as d3 from 'd3' ;
5- import { Router } from '@angular/router' ;
5+ import { Router , ActivatedRoute } from '@angular/router' ;
6+ import { Location } from '@angular/common' ;
67import { MatChip } from '@angular/material/chips' ;
78import * as md from 'markdown-it' ;
89import {
@@ -56,6 +57,9 @@ export class CircularHeatmapComponent implements OnInit {
5657 private loader : LoaderService ,
5758 private sectorService : SectorService ,
5859 private themeService : ThemeService ,
60+ private router : Router ,
61+ private route : ActivatedRoute ,
62+ private location : Location ,
5963 public modal : ModalMessageComponent
6064 ) {
6165 this . theme = this . themeService . getTheme ( ) ;
@@ -110,6 +114,9 @@ export class CircularHeatmapComponent implements OnInit {
110114 // For now, just draw the sectors (no activities yet)
111115 this . loadCircularHeatMap ( '#chart' , this . allSectors , this . dimensionLabels , this . maxLevel ) ;
112116 console . log ( `${ perfNow ( ) } : Page loaded: Circular Heatmap` ) ;
117+
118+ // Check if there's a URL fragment and open the corresponding activity
119+ this . checkUrlFragmentForActivity ( ) ;
113120 } )
114121 . catch ( err => {
115122 this . displayMessage ( new DialogInfo ( err . message , 'An error occurred' ) ) ;
@@ -133,6 +140,15 @@ export class CircularHeatmapComponent implements OnInit {
133140 } ) ;
134141 }
135142
143+ checkUrlFragmentForActivity ( ) {
144+ // Check if there's a URL fragment that might be an activity UUID
145+ this . route . fragment . subscribe ( fragment => {
146+ if ( fragment && this . dataStore ) {
147+ this . navigateToActivityByUuid ( fragment ) ;
148+ }
149+ } ) ;
150+ }
151+
136152 displayMessage ( dialogInfo : DialogInfo ) {
137153 this . modal . openDialog ( dialogInfo ) ;
138154 }
@@ -237,6 +253,14 @@ export class CircularHeatmapComponent implements OnInit {
237253 return this . sectorService . getSectorProgress ( sector . activities ) ;
238254 }
239255
256+ onDependencyClicked ( activityName : string ) {
257+ console . log ( `${ perfNow ( ) } : Heat: Dependency clicked: '${ activityName } '` ) ;
258+ const activity = this . dataStore ?. activityStore ?. getActivityByName ( activityName ) ;
259+ if ( activity ?. uuid ) {
260+ this . navigateToActivityByUuid ( activity . uuid ) ;
261+ }
262+ }
263+
240264 loadCircularHeatMap (
241265 dom_element_to_append_to : string ,
242266 dataset : any ,
@@ -540,38 +564,65 @@ export class CircularHeatmapComponent implements OnInit {
540564 console . log ( `${ perfNow ( ) } : Heat: Card Panel closed: '${ activity . name } '` ) ;
541565 }
542566
543- openActivityDetails ( dimension : string , activityName : string ) {
567+ openActivityDetails ( uuid : string ) {
544568 // Find the activity in the selected sector
545- console . log ( `${ perfNow ( ) } : Heat: Open Overlay: '${ activityName } '` ) ;
546- if ( ! this . dataStore ) {
547- console . error ( `Data store is not initialized. Cannot open activity ${ activityName } ` ) ;
569+ if ( ! this . dataStore || ! this . dataStore . activityStore ) {
570+ console . error ( `Data store is not initialized. Cannot open activity ${ uuid } ` ) ;
548571 return ;
549572 }
550573 if ( ! this . showActivityCard || ! this . showActivityCard . activities ) {
551574 this . showOverlay = true ;
552575 return ;
553576 }
554- const activity = this . showActivityCard . activities . find (
555- ( a : any ) => a . activityName === activityName || a . name === activityName
556- ) ;
577+
578+ const activity : Activity = this . dataStore . activityStore . getActivityByUuid ( uuid ) ;
557579 if ( ! activity ) {
558580 this . showOverlay = true ;
559581 return ;
560582 }
583+
561584 // Prepare navigationExtras and details
562585 /* eslint-disable */
586+ console . log ( `${ perfNow ( ) } : Heat: Open Overlay: '${ activity . name } '` ) ;
563587 this . showActivityDetails = activity ;
564588 this . KnowledgeLabel = this . dataStore . getMetaString ( 'knowledgeLabels' , activity . difficultyOfImplementation . knowledge ) ;
565589 this . TimeLabel = this . dataStore . getMetaString ( 'labels' , activity . difficultyOfImplementation . time ) ;
566590 this . ResourceLabel = this . dataStore . getMetaString ( 'labels' , activity . difficultyOfImplementation . resources ) ;
567591 this . UsefulnessLabel = this . dataStore . getMetaString ( 'labels' , activity . usefulness ) ;
568592 this . showOverlay = true ;
593+
594+ // Update URL with activity UUID as fragment
595+ if ( activity . uuid ) {
596+ const url = this . router . createUrlTree ( [ ] , { fragment : activity . uuid } ) . toString ( ) ;
597+ this . location . go ( url ) ;
598+ }
569599 /* eslint-enable */
570600 }
571601
602+ navigateToActivityByUuid ( uuid : string ) {
603+ console . log ( `${ perfNow ( ) } : Heat: Attempting to open activity with UUID: ${ uuid } ` ) ;
604+ if ( ! this . dataStore || ! this . dataStore . activityStore ) {
605+ console . error ( 'Data store is not initialized. Cannot open activity by UUID' ) ;
606+ return ;
607+ }
608+ const activity : Activity = this . dataStore . activityStore . getActivityByUuid ( uuid ) ;
609+ const sector = this . allSectors . find ( s => s . activities . some ( a => a . uuid === uuid ) ) ;
610+ if ( activity && sector ) {
611+ this . selectedSector = sector ;
612+ this . showActivityCard = sector ;
613+ this . openActivityDetails ( activity . uuid ) ;
614+ } else {
615+ // Only close the overlay, do not update the URL
616+ this . showOverlay = false ;
617+ console . warn ( `Heat: Activity with UUID ${ uuid } not found.` ) ;
618+ }
619+ }
620+
572621 closeOverlay ( ) {
573622 this . showOverlay = false ;
574- // console.log(`${perfNow()}: Heat: Close Overlay: '${this.old_activityDetails.name}'`);
623+ // Clear the URL fragment when closing overlay
624+ const url = this . router . createUrlTree ( [ ] ) . toString ( ) ;
625+ this . location . go ( url ) ;
575626 }
576627
577628 toggleFilters ( ) {
0 commit comments