Skip to content

Commit

Permalink
fixed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukthiw committed Mar 19, 2024
1 parent d254628 commit c2066ae
Showing 12 changed files with 52 additions and 194 deletions.
1 change: 1 addition & 0 deletions Eplant/UI/Layout/ViewContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -235,6 +235,7 @@ export function ViewContainer<T, S, A>({
),
[view.id, gene?.id, loading, activeData, state, dispatch]
)

return (
<Box {...props} display='flex' flexDirection='column'>
<Modal open={viewingCitations} onClose={() => setViewingCitations(false)}>
4 changes: 3 additions & 1 deletion Eplant/View/viewData.ts
Original file line number Diff line number Diff line change
@@ -89,7 +89,6 @@ export function useViewData<T, S, A>(
const id = view?.id ?? 'generic-view'
const [viewData, setViewData] = useAtom(getViewAtom(key))
const [viewState, setViewState] = useAtom(getViewStateAtom(id))
// console.log(viewData)

// If there is no cached viewData then load it using the view's loader
const loadData = async () => {
@@ -114,11 +113,14 @@ export function useViewData<T, S, A>(
}
})
})

const newData = {
...defaultViewData,
activeData: data ?? null,
loading: false,
}
console.log(newData)

setViewData(newData)
viewDataStorage.set(key, newData)
} catch (e) {
2 changes: 1 addition & 1 deletion Eplant/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'

import CellEFP from './views/CellEFP Viewer/CellEFPDataObject'
import CellEFP from './views/CellEFP'
import DebugView from './views/DebugView'
import ExperimentEFP from './views/ExperimentEFP'
import FallbackView from './views/FallbackView'
90 changes: 0 additions & 90 deletions Eplant/views/CellEFP Viewer/MaskModal.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions Eplant/views/CellEFP Viewer/util.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { useEffect, useLayoutEffect, useMemo, useState } from 'react'
import { useEffect, useLayoutEffect, useMemo, useState } from 'react'
import _ from 'lodash'

import GeneticElement from '@eplant/GeneticElement'
import { ViewDataError } from '@eplant/View/viewData'
import { CircularProgress, Typography } from '@mui/material'

import EFP, { getEFPSampleData } from '../../eFP'
import { getEFPSampleData } from '../../eFP'
import { useEFPSVG, useStyles } from '../../eFP/svg'
import CellSVGTooltip from '../../eFP/Tooltips/cellEFPTooltip'
import { EFPData, EFPGroup, EFPId, EFPState, EFPTissue } from '../../eFP/types'
import { CellEFPViewerData, CellEFPViewerState } from '../types'
import { EFPData, EFPGroup, EFPTissue } from '../../eFP/types'
import CellEFPTooltip from '../tooltip'
import { CellEFPViewerData } from '../types'

interface CellEFPDataObjectComponentProps {
geneticElement: GeneticElement | null
@@ -37,7 +37,7 @@ export const CellEFPDataObject: CellEFPDataObject = {
): Promise<EFPData> {
if (!gene) throw ViewDataError.UNSUPPORTED_GENE
const parser = new DOMParser()
const xml = await fetch(this.xmlURL).then(async (res) =>
const xml = await fetch(CellEFPDataObject.xmlURL).then(async (res) =>
parser.parseFromString(await res.text(), 'text/xml')
)
const webservice = 'https://bar.utoronto.ca/eplant/cgi-bin/groupsuba4.php'
@@ -122,8 +122,8 @@ export const CellEFPDataObject: CellEFPDataObject = {
component({ geneticElement, data }: CellEFPDataObjectComponentProps) {
const { view } = useEFPSVG(
{
svgURL: this.svgURL,
xmlURL: this.xmlURL,
svgURL: CellEFPDataObject.svgURL,
xmlURL: CellEFPDataObject.xmlURL,
id: 'Cell EFP',
},
{
@@ -139,6 +139,7 @@ export const CellEFPDataObject: CellEFPDataObject = {
'-' +
useMemo(() => Math.random().toString(16).slice(3), [])
const styles = useStyles(id, data.viewData, 'absolute')
console.log(styles)
useEffect(() => {
const el = document.createElement('style')
el.innerHTML = styles
@@ -230,7 +231,7 @@ export const CellEFPDataObject: CellEFPDataObject = {
>
{svgDiv}
{svgElements.map(({ el, group, tissue }) => (
<CellSVGTooltip
<CellEFPTooltip
data={data.viewData}
key={tissue.id}
el={el}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styled } from '@mui/material'
export default styled((props) => {
export default styled(function CellEFPIcon(props) {
return (
<svg
xmlns='http://www.w3.org/2000/svg'
Original file line number Diff line number Diff line change
@@ -1,55 +1,25 @@
import {
memo,
startTransition,
useEffect,
useMemo,
useRef,
useState,
} from 'react'
import {
areEqual,
FixedSizeList as List,
ListChildComponentProps,
} from 'react-window'
import { useEffect, useMemo, useRef, useState } from 'react'

import GeneticElement from '@eplant/GeneticElement'
import Dropdown from '@eplant/UI/Dropdown'
import NotSupported from '@eplant/UI/Layout/ViewNotSupported'
import { getCitation } from '@eplant/util/citations'
import PanZoom from '@eplant/util/PanZoom'
import useDimensions from '@eplant/util/useDimensions'
import { View, ViewProps } from '@eplant/View'
import { ViewDataError } from '@eplant/View/viewData'
import { Box, MenuItem, Tooltip, Typography } from '@mui/material'
import { Box, Typography } from '@mui/material'

import EFP from '../eFP'
import EFPPreview from '../eFP/EFPPreview'
import { EFPData } from '../eFP/types'
import { EFPListMemoized } from '../eFP/Viewer'
import EFPViewerCitation from '../eFP/Viewer/EFPViewerCitation'
import GeneDistributionChart from '../eFP/Viewer/GeneDistributionChart'
import {
EFPViewerAction,
EFPViewerData,
EFPViewerState,
} from '../eFP/Viewer/types'
import Legend from '../eFP/Viewer/legend'

import CellEFP, { CellEFPDataObject } from './CellEFPDataObject'
import MaskModal from './MaskModal'
import { CellEFPDataObject } from './CellEFPDataObject'
import CellEFPIcon from './icon'
import {
CellEFPViewerAction,
CellEFPViewerData,
CellEFPViewerState,
} from './types'
import Legend from '../eFP/Viewer/legend'

interface ICitationProps {
activeData?: EFPViewerData
state?: EFPViewerState
gene?: GeneticElement | null
}

const CellEFPViewer: View<
const CellEFP: View<
CellEFPViewerData,
CellEFPViewerState,
CellEFPViewerAction
@@ -73,19 +43,18 @@ const CellEFPViewer: View<
loadEvent: (progress: number) => void
) {
if (!gene) throw ViewDataError.UNSUPPORTED_GENE
let loadingProgress = 0

let totalLoaded = 0
const viewData = await CellEFPDataObject.getInitialData(
gene,
(progress) => {
totalLoaded -= loadingProgress
loadingProgress = progress
totalLoaded += loadingProgress
totalLoaded += progress
loadEvent(totalLoaded)
}
)

return {
activeView: this.id,
activeView: CellEFP.id,
transform: {
offset: { x: 0, y: 0 },
zoom: 1,
@@ -122,9 +91,6 @@ const CellEFPViewer: View<
const Component = CellEFPDataObject.component
return <Component data={activeData} geneticElement={geneticElement} />
}, [geneticElement?.id])
const ref = useRef<HTMLDivElement>(null)
const dimensions = useDimensions(ref)

if (!geneticElement) return <></>
return (
<Box
@@ -133,8 +99,12 @@ const CellEFPViewer: View<
height: '100%',
position: 'relative',
}}
ref={ref}
>
<Typography variant='h6'>
{CellEFP.name}
{': '}
{geneticElement?.id}
</Typography>
<Box
sx={{
width: '100%',
@@ -198,7 +168,7 @@ const CellEFPViewer: View<
>
<NotSupported
geneticElement={geneticElement}
view={sortedEfps[activeViewIndex]}
view={CellEFP}
></NotSupported>
</div>
)}
@@ -217,23 +187,18 @@ const CellEFPViewer: View<
header: (props) => {
return (
<Typography variant='h6'>
{
props.activeData.views.find((v) => v.id == props.state.activeView)
?.name
}
cell efp
{': '}
{props.geneticElement?.id}
</Typography>
)
},

citation = ({ activeData, state, gene }: ICitationProps) => {
citation() {
const [xmlData, setXMLData] = useState<string[]>([])

const viewID = activeData?.views.find((v) => v.id == state?.activeView)
?.name
const viewXML = activeData?.views.find((v) => v.id == state?.activeView)
?.xmlURL
const viewID = CellEFP.name
const viewXML = CellEFPDataObject.xmlURL
useEffect(() => {
const xmlLoad = async () => {
let xmlString = ''
@@ -247,7 +212,6 @@ const CellEFPViewer: View<
}
}

// Extract <li> tags
if (xmlString !== '') {
const parser = new DOMParser()
const xmlDoc = parser.parseFromString(xmlString, 'text/xml')
@@ -261,19 +225,17 @@ const CellEFPViewer: View<
}
}
xmlLoad()
}, [viewXML])
})

if (viewID) {
const citation = getCitation(viewID) as { [key: string]: string }
return (
<EFPViewerCitation
viewID={viewID}
citation={citation}
xmlData={xmlData}
></EFPViewerCitation>
)
} else {
return <p>No Citation information provided.</p>
}
const citation = getCitation(viewID) as { [key: string]: string }
return (
<EFPViewerCitation
viewID={viewID}
citation={citation}
xmlData={xmlData}
></EFPViewerCitation>
)
},
}

export default CellEFP
Loading

0 comments on commit c2066ae

Please sign in to comment.