-
Notifications
You must be signed in to change notification settings - Fork 33
refactor: add hover content for metadata name & append human readable name with metadata key in one column #2081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…ing human name and raw name in one column
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and found some issues that need to be addressed.
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/app/shared/modules/scientific-metadata/metadata-view/metadata-view.component.ts:180-181` </location>
<code_context>
public prettyUnit: PrettyUnitPipe,
) {}
- getHumanReadableName(name: string): string {
- return this.titleCase.transform(this.replaceUnderscore.transform(name));
- }
-
</code_context>
<issue_to_address>
**issue:** Removal of fallback for human readable name may reduce robustness.
Please verify that all metadata objects consistently provide 'human_name' to avoid missing display names.
</issue_to_address>
### Comment 2
<location> `src/app/shared/modules/dynamic-material-table/table/dynamic-mat-table.component.html:167-162` </location>
<code_context>
- [innerHTML]="columnName(row, column)"
>
+ <ng-container *ngIf="column.hoverOnCell; else noHoverCell">
+ <span
+ #hoverOriginSpan="cdkOverlayOrigin"
+ cdkOverlayOrigin
+ (mouseenter)="hoverKey = makeKey(row, column)"
+ (mouseleave)="hoverKey = null"
+ [innerHTML]="columnName(row, column)"
+ ></span>
+ <ng-template
</code_context>
<issue_to_address>
**🚨 issue (security):** Using [innerHTML] for cell content may introduce XSS risk if content is not sanitized.
If columnName returns untrusted data, sanitize it before assigning to [innerHTML] to prevent XSS.
</issue_to_address>
### Comment 3
<location> `src/app/shared/modules/dynamic-material-table/table/dynamic-mat-table.component.ts:260` </location>
<code_context>
offsetX: 4,
},
];
+ /** Overlay positions for metadata hover */
+ metadataOverlayPositions: ConnectedPosition[] = [
+ {
</code_context>
<issue_to_address>
**issue (complexity):** Consider moving overlay position configuration and hover content formatting into shared constants and a pipe to separate presentation logic from component behavior.
Consider extracting the “presentation” bits out of your component and re-using them via a constant and a pipe (or template). This keeps your component’s TS focused on behavior and makes both the overlay positions and hover-content easy to share and test. For example:
1) Extract your overlay positions to a shared constant:
```ts
// src/app/shared/constants/overlay-positions.ts
import { ConnectedPosition } from '@angular/cdk/overlay';
export const METADATA_OVERLAY_POSITIONS: ConnectedPosition[] = [
{
originX: 'end',
originY: 'center',
overlayX: 'start',
overlayY: 'center',
offsetX: 8,
},
{
originX: 'start',
originY: 'center',
overlayX: 'end',
overlayY: 'center',
offsetX: -8,
},
];
```
```ts
// in your component
import { METADATA_OVERLAY_POSITIONS } from 'app/shared/constants/overlay-positions';
@Component({ … })
export class MyTableComponent<T> {
metadataOverlayPositions = METADATA_OVERLAY_POSITIONS;
…
}
```
2) Create a small pipe for your hover HTML:
```ts
// src/app/shared/pipes/metadata-hover.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'metadataHover' })
export class MetadataHoverPipe implements PipeTransform {
transform(row: any): string {
const raw = `<strong>Raw name:</strong> ${row.name}`;
if (!row.human_name) {
return raw;
}
return `<strong>Human readable name:</strong> ${row.human_name}<br>${raw}`;
}
}
```
3) In your template bind via `innerHTML` (or use it inside a `<ng-template>`):
```html
<ng-template #metadataTooltip let-row="row">
<div [innerHTML]="row | metadataHover"></div>
</ng-template>
<button
[cdkOverlayOrigin]="trigger"
[cdkConnectedOverlayPositions]="metadataOverlayPositions"
[cdkConnectedOverlayHasBackdrop]="false"
[cdkConnectedOverlayTemplate]="metadataTooltip"
[cdkConnectedOverlayContext]="{ row: row }">
{{ row.name }}
</button>
```
This removes manual string builds from your component class, centralizes the overlay config, and reuses logic consistently.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
src/app/shared/modules/scientific-metadata/metadata-view/metadata-view.component.ts
Show resolved
Hide resolved
| " | ||
| (click)="onLabelClick($event, row, column)" | ||
| [class.rtl-cell]="direction === 'rtl'" | ||
| [class.ltr-cell]="direction === 'ltr'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨 issue (security): Using [innerHTML] for cell content may introduce XSS risk if content is not sanitized.
If columnName returns untrusted data, sanitize it before assigning to [innerHTML] to prevent XSS.
|
@abdimo101 I made some changes in 8805a81, could you test them and let me know what do you think? Couple of changes including:
screenshots: |
|
Currently user can only search by raw name in search-parameters-dialog, could you make it works for both human readable name and raw name? Oct-31-2025.14-07-55.mp4 |
360d4aa to
a097192
Compare
Junjiequan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests for the issues I have mentioned
| this.datasets$.pipe(take(1)).subscribe((datasets) => { | ||
| if (datasets && datasets.length > 0) { | ||
| this.humanNameMap = {}; | ||
| this.fieldTypeMap = {}; | ||
|
|
||
| datasets.forEach((dataset) => { | ||
| const metadata = dataset.scientificMetadata; | ||
|
|
||
| Object.keys(metadata).forEach((key) => { | ||
| if (metadata[key]?.human_name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For condition filters and filter list dialog, humanName should not be mapped from datasets, it should only be fetched from the metadataKeys endpoint. However, since metadataKeys endpoint currently doesn’t return a human-readable name, we should display only metadataKeys. Please check all the files where it contains humen readable name map logic and remove them.
And also Metadata keys should be italic when no human readable name available, as we discussed
…/frontend into metadata_name_hoverContent
…/frontend into metadata_name_hoverContent








Description
This PR improves metadata field usability by adding support for searching and displaying both human-readable names and metadata keys (raw names).
Users can now search metadata fields using either human-readable names or metadata keys in the search parameters dialog. The dialog and condition panels display both human-readable names (primary) and metadata keys (secondary, italic) for better clarity.

An icon with hover card shows full details of both naming conventions both in search parameters dialog and in the condition section.
The UI includes condition chips with summary of the condition and empty spaces has been removed and fields are more compact.

Metadata-table:


Motivation
Fixes:
Please provide a list of the fixes implemented in this PR
Changes:
Please provide a list of the changes implemented by this PR
Tests included
Documentation
official documentation info
If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included
Backend version
Summary by Sourcery
Combine human-readable and raw metadata names into one responsive column and introduce hover overlays for detailed name display in metadata tables and search parameter dialogs.
New Features:
Enhancements:
Build: