diff --git a/src/redux/apiPath.ts b/src/redux/apiPath.ts index 423aefbfbe19d9c5ab79eb7077d6cd0af7e0b2e0..944cfa00adaa176e99eb468559a8e841fac84832 100644 --- a/src/redux/apiPath.ts +++ b/src/redux/apiPath.ts @@ -63,7 +63,7 @@ export const apiPath = { getConfigurationOptions: (): string => 'configuration/options/', getConfiguration: (): string => 'configuration/', getOverlayBioEntity: ({ overlayId, modelId }: { overlayId: number; modelId: number }): string => - `projects/${PROJECT_ID}/overlays/${overlayId}/models/${modelId}/bioEntities/?includeIndirect=true`, + `projects/${PROJECT_ID}/overlays/${overlayId}/models/${modelId}/bioEntities/`, createOverlay: (projectId: string): string => `projects/${projectId}/overlays/`, createOverlayFile: (): string => `files/`, uploadOverlayFileContent: (fileId: number): string => `files/${fileId}:uploadContent`, diff --git a/src/redux/overlayBioEntity/overlayBioEntity.selector.ts b/src/redux/overlayBioEntity/overlayBioEntity.selector.ts index f6ad669d69dad1723460c82f8764112db4ee87cd..2b96a5389302e6acce4f654a67fb7ed4d23abe98 100644 --- a/src/redux/overlayBioEntity/overlayBioEntity.selector.ts +++ b/src/redux/overlayBioEntity/overlayBioEntity.selector.ts @@ -1,5 +1,6 @@ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { createSelector } from '@reduxjs/toolkit'; +import { allSubmapConnectionsBioEntitySelector } from '@/redux/bioEntity/bioEntity.selectors'; import { currentSearchedBioEntityId } from '../drawer/drawer.selectors'; import { currentModelIdSelector } from '../models/models.selectors'; import { @@ -34,7 +35,8 @@ export const overlayBioEntitiesForCurrentModelSelector = createSelector( overlayBioEntityDataSelector, activeOverlaysIdSelector, currentModelIdSelector, - (data, activeOverlaysIds, currentModelId) => { + allSubmapConnectionsBioEntitySelector, + (data, activeOverlaysIds, currentModelId, submapConnections) => { const result: OverlayBioEntityRender[] = []; activeOverlaysIds.forEach(overlayId => { @@ -43,6 +45,37 @@ export const overlayBioEntitiesForCurrentModelSelector = createSelector( } }); + submapConnections.forEach(submapConnection => { + if (submapConnection.model === currentModelId) { + const submapId = submapConnection?.submodel?.mapId; + if (submapId) { + activeOverlaysIds.forEach(overlayId => { + if (data[overlayId]?.[submapId]) { + data[overlayId][submapId].forEach(overlayBioEntityRender => { + const newOverlayBioEntityRender = { + id: submapConnection.id, + modelId: submapConnection.model, + x1: submapConnection.x, + y2: submapConnection.y, + x2: submapConnection.x + submapConnection.width, + y1: submapConnection.y + submapConnection.height, + width: submapConnection.width, + height: submapConnection.height, + value: overlayBioEntityRender.value, + overlayId: overlayBioEntityRender.overlayId, + color: overlayBioEntityRender.color, + hexColor: overlayBioEntityRender.hexColor, + type: overlayBioEntityRender.type, + geneVariants: overlayBioEntityRender.geneVariants, + name: overlayBioEntityRender.name, + }; + result.push(newOverlayBioEntityRender); + }); + } + }); + } + } + }); return result; }, ); diff --git a/src/redux/root/init.thunks.ts b/src/redux/root/init.thunks.ts index 1d8a39b5d373ed210a37fc0184a0e28ca18369ff..20a722afb23f2b73870dea3ee777170a060f1ac9 100644 --- a/src/redux/root/init.thunks.ts +++ b/src/redux/root/init.thunks.ts @@ -14,6 +14,7 @@ import { } from '@/redux/autocomplete/autocomplete.thunks'; import { openSelectProjectModal } from '@/redux/modal/modal.slice'; import { getProjects } from '@/redux/projects/projects.thunks'; +import { getSubmapConnectionsBioEntity } from '@/redux/bioEntity/thunks/getSubmapConnectionsBioEntity'; import { getAllBackgroundsByProjectId } from '../backgrounds/backgrounds.thunks'; import { getConfiguration, getConfigurationOptions } from '../configuration/configuration.thunks'; import { @@ -98,6 +99,8 @@ export const fetchInitialAppData = createAsyncThunk< dispatch(getDrugAutocomplete()); dispatch(getChemicalAutocomplete()); + dispatch(getSubmapConnectionsBioEntity()); + /** Trigger search */ if (queryData.searchValue) { dispatch(setPerfectMatch(queryData.perfectMatch)); diff --git a/src/redux/user/user.thunks.ts b/src/redux/user/user.thunks.ts index 6abb07c34200d96522c4c69c59586f950b44b160..3e1f7bc1079e8524940facf371cd28bf14511fb1 100644 --- a/src/redux/user/user.thunks.ts +++ b/src/redux/user/user.thunks.ts @@ -8,6 +8,7 @@ import { USER_ROLE } from '@/constants/user'; import { getError } from '@/utils/error-report/getError'; import axios, { HttpStatusCode } from 'axios'; import { showToast } from '@/utils/showToast'; +import { setLoginForOldMinerva } from '@/utils/setLoginForOldMinerva'; import { apiPath } from '../apiPath'; import { closeModal, openLoggedInMenuModal } from '../modal/modal.slice'; import { hasPrivilege } from './user.utils'; @@ -44,6 +45,8 @@ export const login = createAsyncThunk( const loginName = response.data.login; if (isDataValid) { + setLoginForOldMinerva(loginName); + const userData = await getUserData(loginName); const role = getUserRole(userData.privileges); @@ -91,6 +94,8 @@ export const getSessionValid = createAsyncThunk('user/getSessionValid', async () const role = getUserRole(userData.privileges); if (isDataValid) { + setLoginForOldMinerva(loginName); + return { login: loginName, userData, @@ -107,6 +112,7 @@ export const logout = createAsyncThunk('user/logout', async () => { withCredentials: true, }); + setLoginForOldMinerva(undefined); return undefined; } catch (error) { return Promise.reject(getError({ error, prefix: 'Log out' })); diff --git a/src/types/OLrendering.ts b/src/types/OLrendering.ts index a117dea712eac055fab31a6b96d1965bac0cdc5e..bb96d0c1619680cf7ada55150ee2ca59e7aa971d 100644 --- a/src/types/OLrendering.ts +++ b/src/types/OLrendering.ts @@ -5,9 +5,9 @@ export type OverlayBioEntityRenderType = 'line' | 'rectangle' | 'submap-link'; export type OverlayBioEntityRender = { id: number | string; modelId: number; - /** bottom left corner of whole element, Xmin */ + /** bottom left corner of whole element, xMin */ x1: number; - /** bottom left corner of whole element, Ymin */ + /** bottom left corner of whole element, yMin */ y1: number; /** top right corner of whole element, xMax */ x2: number; diff --git a/src/utils/setLoginForOldMinerva.ts b/src/utils/setLoginForOldMinerva.ts new file mode 100644 index 0000000000000000000000000000000000000000..db31cda390acbaec5925981afb26788bebf144ce --- /dev/null +++ b/src/utils/setLoginForOldMinerva.ts @@ -0,0 +1,8 @@ +export const setLoginForOldMinerva = (loginName: string | undefined): void => { + // old minerva require this information + if (loginName) { + window.localStorage.setItem('LOGIN', loginName); + } else { + window.localStorage.removeItem('LOGIN'); + } +};