Skip to content
Snippets Groups Projects
Commit 962ef514 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '332-plugin-does-not-provide-info-about-overlays' into 'main'

Resolve "plugin does not provide info about overlays"

See merge request !334
parents 64605b1b 67167619
No related branches found
No related tags found
2 merge requests!341Resolve "Export graphics - add "Current view"",!334Resolve "plugin does not provide info about overlays"
Pipeline #99237 passed
minerva-front (18.0.7) stable; urgency=medium
* Bug fix: export to image did not include overlays (#326)
* Bug fix: missing logos added (#329)
* Bug fix: plugin API did not provide overlay entries when returning list of
visible overlays (#332)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 11 Dec 2024 13:00:00 +0200
......
......@@ -3,6 +3,7 @@ import { overlaysFixture } from '@/models/fixtures/overlaysFixture';
import { OVERLAYS_INITIAL_STATE_MOCK } from '@/redux/overlays/overlays.mock';
import { RootState, store } from '@/redux/store';
import { OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK } from '@/redux/overlayBioEntity/overlayBioEntity.mock';
import { DataOverlay } from '@/services/pluginsManager/map/overlays/types/DataOverlay';
import { getVisibleDataOverlays } from './getVisibleDataOverlays';
const ACTIVE_OVERLAYS_IDS = overlaysFixture.map(overlay => overlay.idObject);
......@@ -34,7 +35,9 @@ describe('getVisibleDataOverlays', () => {
}) as RootState,
);
expect(getVisibleDataOverlays()).toEqual(overlaysFixture);
expect(getVisibleDataOverlays()).toEqual(
overlaysFixture.map(overlay => new DataOverlay(overlay)),
);
});
it('should return empty array if no active overlays', () => {
......
import { activeOverlaysSelector } from '@/redux/overlayBioEntity/overlayBioEntity.selector';
import {
activeOverlaysSelector,
overlayBioEntityDataSelector,
} from '@/redux/overlayBioEntity/overlayBioEntity.selector';
import { store } from '@/redux/store';
import { MapOverlay } from '@/types/models';
import { DataOverlay } from '@/services/pluginsManager/map/overlays/types/DataOverlay';
import { modelsDataSelector } from '@/redux/models/models.selectors';
import { DataOverlayEntry } from '@/services/pluginsManager/map/overlays/types/DataOverlayEntry';
export const getVisibleDataOverlays = (): MapOverlay[] => {
export const getVisibleDataOverlays = (): DataOverlay[] => {
const activeOverlays = activeOverlaysSelector(store.getState());
const overlayData = overlayBioEntityDataSelector(store.getState());
return activeOverlays;
const models = modelsDataSelector(store.getState());
const dataOverlays = activeOverlays.map(mapOverlay => new DataOverlay(mapOverlay));
dataOverlays.forEach(dataOverlay => {
const mapOverlayData = overlayData[dataOverlay.id];
if (mapOverlayData) {
models.forEach(model => {
const entries = mapOverlayData[model.idObject];
if (entries) {
entries.forEach(dataEntry => {
if (dataEntry.type === 'submap-link') {
dataOverlay.addEntry(
new DataOverlayEntry(
Number(dataEntry.id),
'ALIAS',
dataEntry.modelId,
dataEntry.color,
dataEntry.value,
),
);
} else {
// eslint-disable-next-line no-console
console.log(`${dataEntry.type} not supported`);
}
});
}
});
}
});
return dataOverlays;
};
import { MapOverlay } from '@/types/models';
import { DataOverlayEntry } from '@/services/pluginsManager/map/overlays/types/DataOverlayEntry';
export class DataOverlay {
id: number;
idObject: number;
name: string;
order: number;
creator: string;
description: string;
genomeType: string | null;
genomeVersion: string | null;
publicOverlay: boolean;
type: string;
entries: DataOverlayEntry[];
constructor(mapOverlay: MapOverlay) {
this.id = mapOverlay.idObject;
this.idObject = mapOverlay.idObject;
this.name = mapOverlay.name;
this.order = mapOverlay.order;
this.creator = mapOverlay.creator;
this.description = mapOverlay.description;
this.genomeType = mapOverlay.genomeType;
this.genomeVersion = mapOverlay.genomeVersion;
this.publicOverlay = mapOverlay.publicOverlay;
this.type = mapOverlay.type;
this.entries = [];
}
public addEntry(entry: DataOverlayEntry): void {
this.entries.push(entry);
}
}
import { Color } from '@/types/models';
export class DataOverlayEntry {
bioEntityId: number;
bioEntityType: string;
bioEntityModelId: number;
color: Color | null;
value: number | null;
constructor(
bioEntityId: number,
bioEntityType: string,
bioEntityModelId: number,
color: Color | null,
value: number | null,
) {
this.bioEntityId = bioEntityId;
this.color = color;
this.value = value;
this.bioEntityType = bioEntityType;
this.bioEntityModelId = bioEntityModelId;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment