Skip to content

Commit 4eb0495

Browse files
committed
Heatmap: Include activity uuid in URL
1 parent f1eb441 commit 4eb0495

File tree

3 files changed

+65
-14
lines changed

3 files changed

+65
-14
lines changed

src/app/pages/circular-heatmap/circular-heatmap.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ <h2>Nothing to show</h2>
106106
<b>Dependencies</b>
107107
</mat-panel-title>
108108
</mat-expansion-panel-header>
109-
<app-dependency-graph [activityName]="showActivityDetails?.name || ''">
109+
<app-dependency-graph
110+
[activityName]="showActivityDetails?.name || ''"
111+
(activityClicked)="onDependencyClicked($event)">
110112
</app-dependency-graph>
111113
</mat-expansion-panel>
112114

@@ -248,9 +250,7 @@ <h2>Nothing to show</h2>
248250
(closed)="onPanelClosed(activity)">
249251
<mat-expansion-panel-header>
250252
<mat-panel-title>
251-
<button
252-
class="title-button"
253-
(click)="openActivityDetails(showActivityCard.dimension, activity['name'])">
253+
<button class="title-button" (click)="openActivityDetails(activity['uuid'])">
254254
{{ activity['name'] }}
255255
</button>
256256
</mat-panel-title>

src/app/pages/circular-heatmap/circular-heatmap.component.ts

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core';
22
import { equalArray } from 'src/app/util/util';
33
import { LoaderService } from 'src/app/service/loader/data-loader.service';
44
import * as d3 from 'd3';
5-
import { Router } from '@angular/router';
5+
import { Router, ActivatedRoute } from '@angular/router';
6+
import { Location } from '@angular/common';
67
import { MatChip } from '@angular/material/chips';
78
import * as md from 'markdown-it';
89
import {
@@ -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() {

src/assets/Markdown Files/TODO-v4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
- Teams: Bug: Editing name, pushes the item last
2121
- Teams: Allow editing dates for progress stages
2222
### Heatmap:
23-
- Heatmap: Add #uuid to URL, and allow navigation on clicks in dependencies
2423
- Heatmap: Fix: asterisk marks when modified
2524
- ViewController needs to know about changes vs temp storage
2625
- Heatmap: Bug: Clicking on grey sector leaves cursor on that sector
@@ -69,6 +68,7 @@
6968
- Meta.yaml: Allow admins to customize the terms 'Team' and 'Group' (e.g. to 'App' and 'Portfolio')
7069

7170
# Done
71+
- Heatmap: Add #uuid to URL, and allow navigation on clicks in dependencies
7272
- Dependency: Make connecting nodes clickable for navigation
7373
- Dependency: Handle dependsOn uuid, not just name
7474
- Matrix: Dependency graph: Render in center of page

0 commit comments

Comments
 (0)