-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add detail view to hotspot treemap
- Loading branch information
1 parent
bfc6cd6
commit 0292893
Showing
10 changed files
with
296 additions
and
186 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
4 changes: 4 additions & 0 deletions
4
apps/frontend/src/app/features/hotspot/hotspot-detail/hotspot-detail.component.css
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.title { | ||
margin-left: 15px; | ||
margin-top: 10px; | ||
} |
53 changes: 53 additions & 0 deletions
53
apps/frontend/src/app/features/hotspot/hotspot-detail/hotspot-detail.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<h2 class="title mat-dialog-title"> | ||
<div | ||
[ngStyle]="{ 'border-bottom-color': color() }" | ||
style="border-bottom: 4px solid; display: inline-block" | ||
> | ||
{{ module() }} | ||
</div> | ||
</h2> | ||
|
||
<div class="detail" style="height: 640px"> | ||
<div class="p10"> | ||
@if (loadingHotspots()) { Determining Hotspots ... | ||
<mat-progress-bar mode="indeterminate"></mat-progress-bar> | ||
} @else if (hotspotResult().hotspots.length > 0) { | ||
<div xclass="mat-elevation-z8"> | ||
<table mat-table [dataSource]="detailDataSource"> | ||
<ng-container matColumnDef="fileName"> | ||
<th mat-header-cell *matHeaderCellDef>Module</th> | ||
<td mat-cell *matCellDef="let element">{{ element.fileName }}</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="commits"> | ||
<th mat-header-cell *matHeaderCellDef class="metric-cell">Commits</th> | ||
<td mat-cell *matCellDef="let element" class="metric-cell"> | ||
{{ element.commits }} | ||
</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="complexity"> | ||
<th mat-header-cell *matHeaderCellDef class="metric-cell"> | ||
Complexity | ||
</th> | ||
<td mat-cell *matCellDef="let element" class="metric-cell"> | ||
{{ element.complexity }} | ||
</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="score"> | ||
<th mat-header-cell *matHeaderCellDef class="metric-cell">Score</th> | ||
<td mat-cell *matCellDef="let element" class="metric-cell"> | ||
{{ element.score }} | ||
</td> | ||
</ng-container> | ||
|
||
<tr mat-header-row *matHeaderRowDef="detailColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: detailColumns"></tr> | ||
</table> | ||
</div> | ||
} | ||
</div> | ||
</div> | ||
|
||
<mat-paginator [pageSize]="10" showFirstLastButtons></mat-paginator> |
87 changes: 87 additions & 0 deletions
87
apps/frontend/src/app/features/hotspot/hotspot-detail/hotspot-detail.component.ts
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { | ||
Component, | ||
computed, | ||
effect, | ||
inject, | ||
untracked, | ||
viewChild, | ||
} from '@angular/core'; | ||
import { MatDialogModule } from '@angular/material/dialog'; | ||
import { MatPaginator } from '@angular/material/paginator'; | ||
import { MatProgressBar } from '@angular/material/progress-bar'; | ||
import { MatSortModule } from '@angular/material/sort'; | ||
import { MatTableDataSource, MatTableModule } from '@angular/material/table'; | ||
|
||
import { FlatHotspot } from '../../../model/hotspot-result'; | ||
import { getScoreTypeColor } from '../hotspot-adapter'; | ||
import { HotspotStore } from '../hotspot.store'; | ||
|
||
@Component({ | ||
selector: 'app-hotspot-detail', | ||
standalone: true, | ||
imports: [ | ||
CommonModule, | ||
MatTableModule, | ||
MatSortModule, | ||
MatPaginator, | ||
MatProgressBar, | ||
MatDialogModule, | ||
], | ||
templateUrl: './hotspot-detail.component.html', | ||
styleUrl: './hotspot-detail.component.css', | ||
}) | ||
export class HotspotDetailComponent { | ||
private hotspotStore = inject(HotspotStore); | ||
|
||
module = this.hotspotStore.filter.module; | ||
color = computed(() => getScoreTypeColor(this.hotspotStore.scoreType())); | ||
|
||
paginator = viewChild(MatPaginator); | ||
detailDataSource = new MatTableDataSource<FlatHotspot>(); | ||
detailColumns = ['fileName', 'commits', 'complexity', 'score']; | ||
|
||
loadingAggregated = this.hotspotStore.loadingAggregated; | ||
loadingHotspots = this.hotspotStore.loadingHotspots; | ||
|
||
aggregatedResult = this.hotspotStore.aggregatedResult; | ||
hotspotResult = this.hotspotStore.hotspotResult; | ||
|
||
formattedHotspots = computed(() => | ||
formatHotspots( | ||
this.hotspotResult().hotspots, | ||
untracked(() => this.hotspotStore.filter.module()) | ||
) | ||
); | ||
|
||
constructor() { | ||
effect(() => { | ||
const hotspots = this.formattedHotspots(); | ||
this.detailDataSource.data = hotspots; | ||
}); | ||
|
||
effect(() => { | ||
const paginator = this.paginator(); | ||
if (paginator) { | ||
this.detailDataSource.paginator = paginator; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
function formatHotspots( | ||
hotspot: FlatHotspot[], | ||
selectedModule: string | ||
): FlatHotspot[] { | ||
return hotspot.map((hs) => ({ | ||
...hs, | ||
fileName: trimSegments(hs.fileName, selectedModule), | ||
})); | ||
} | ||
|
||
function trimSegments(fileName: string, prefix: string): string { | ||
if (fileName.startsWith(prefix)) { | ||
return fileName.substring(prefix.length + 1); | ||
} | ||
return fileName; | ||
} |
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.