Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@abdimo101
Copy link
Member

@abdimo101 abdimo101 commented Oct 29, 2025

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.
image

An icon with hover card shows full details of both naming conventions both in search parameters dialog and in the condition section.

image image

The UI includes condition chips with summary of the condition and empty spaces has been removed and fields are more compact.
image

Metadata-table:
image
image

Motivation

Fixes:

Please provide a list of the fixes implemented in this PR

  • Items added

Changes:

Please provide a list of the changes implemented by this PR

  • changes made

Tests included

  • Included for each change/fix?
  • Passing? (Merge will not be approved unless this is checked)

Documentation

  • swagger documentation updated [required]
  • official documentation updated [nice-to-have]

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

  • Does it require a specific version of the backend
  • which version of the backend is required:

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:

  • Add hover cards to display both human-readable and raw metadata names on hover in dynamic tables and the search parameters dialog
  • Combine human-readable and raw metadata names into a single column with ellipsis styling

Enhancements:

  • Merge raw and human-readable metadata name columns into one and adjust SCSS for consistent hover-card appearance
  • Introduce hoverOnCell and hoverContent flags with configurable overlay positions in the dynamic-material-table
  • Adjust dialog dimensions and styling for improved user experience in metadata and condition dialogs

Build:

  • Import MatCardModule and OverlayModule in SearchParametersDialogModule

@abdimo101 abdimo101 requested a review from a team as a code owner October 29, 2025 10:46
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

"
(click)="onLabelClick($event, row, column)"
[class.rtl-cell]="direction === 'rtl'"
[class.ltr-cell]="direction === 'ltr'"
Copy link
Contributor

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 abdimo101 requested a review from Junjiequan October 29, 2025 14:38
@Junjiequan
Copy link
Member

Junjiequan commented Oct 31, 2025

@abdimo101 I made some changes in 8805a81, could you test them and let me know what do you think?

Couple of changes including:

  1. Added icon for hoverOnCell. Previously hover was applied to the text, which was unclear to me if the content can be hovered or not
  2. Removed font-family for all the hover-card-content. Previously 2 different font family was used for the same hover-content modal
  3. Reduced row gap for items displayed in search-parameters-dialog list
  4. Fully extended the text in search-parameters-dialog and only invisible part will become .... Previously the text was cut off before reaching the edge and leaving a big empty space.

screenshots:

Search-parameters-dialog:
image
image

Metadata-table:
image
image

@Junjiequan
Copy link
Member

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

@abdimo101 abdimo101 force-pushed the metadata_name_hoverContent branch from 360d4aa to a097192 Compare November 5, 2025 12:07
@Junjiequan
Copy link
Member

few issues I found:

  1. is equal to sign = do not appear on the preview, while others appear normally.
image image
  1. is in range do not show text properly on the preview. to replicate, type anything with is equal to and switch to the range
image
  1. is in range condition not working, it returns all dataset no matter the value
image

Copy link
Member

@Junjiequan Junjiequan left a 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

@Junjiequan Junjiequan added the ESS label Nov 6, 2025
Comment on lines 838 to 847
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) {
Copy link
Member

@Junjiequan Junjiequan Nov 12, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants