diff --git a/src/components/Main.js b/src/components/Main.js index e7350b29..735e475a 100644 --- a/src/components/Main.js +++ b/src/components/Main.js @@ -13,10 +13,8 @@ import MetaDiagram, { } from '@metacell/meta-diagram'; import CustomLinkWidget from './views/projections/CustomLinkWidget'; import { generateMetaGraph } from '../model/utils'; -import CompositionDrawer from './views/CompositionDrawer'; import { sideBarNodes } from './views/sidebar/nodes'; -import { Sidebar } from './views/Sidebar/Sidebar'; -import { buildModel } from '../model/utils'; +import { Sidebar } from './views/sidebar/Sidebar'; const mockModel = require('../resources/model').mockModel; diff --git a/src/components/common/Breadcrumbs.js b/src/components/common/Breadcrumbs.js index ecc8da79..0a845362 100644 --- a/src/components/common/Breadcrumbs.js +++ b/src/components/common/Breadcrumbs.js @@ -77,7 +77,7 @@ const useStyles = makeStyles(() => ({ }, })); -const expand = 'expand'; +const EXPAND_ID = 'expand'; function Crumb({ id, text, handleClick, href, last = false }) { const classes = useStyles(); @@ -137,7 +137,7 @@ export const CustomBreadcrumbsWithMenu = ({ breadcrumbs }) => { const lastFourCrumbs = breadcrumbs.slice(-4); const newBreadCrumbs = firstItemCrumbs.concat( - [{ id: expand }], + [{ id: EXPAND_ID }], lastFourCrumbs ); setCollapsedCrumbs(restCrumbs); @@ -179,7 +179,7 @@ export const CustomBreadcrumbsWithMenu = ({ breadcrumbs }) => { _breadcrumbs.map((crumb, idx) => { const index = idx + 1; - if (crumb.id === expand) { + if (crumb.id === EXPAND_ID) { return ( { const handleClick = (event, value) => { if (event) { - if (value === 'Composition') { + if (value === COMPOSITION) { setAnchorEl(event.currentTarget); } } + + setSelected(value); }; const handleClose = () => { diff --git a/src/components/views/Sidebar/Sidebar.js b/src/components/views/Sidebar/Sidebar.js index 6ab5952d..94883137 100644 --- a/src/components/views/Sidebar/Sidebar.js +++ b/src/components/views/Sidebar/Sidebar.js @@ -1,93 +1,112 @@ -import { Box, Drawer, Popper, Portal, Typography } from '@mui/material'; -import React, { useState } from 'react'; +import { Box, Drawer, Typography } from '@mui/material'; +import React from 'react'; import { v4 as uuidv4 } from 'uuid'; import InstancesTreeView from './TreeView/InstanceTreeView'; +export const COMPOSITION_DTO = { + id: uuidv4(), + label: 'Composition 2', + type: 'CombinationFunction', + detail: 'CombinationFunction Detailing', + info: { + title: 'function', + pnl: ' =pnl.', + sub: 'Logistic', + calc: '(gain=1.0, bias=-4)' + }, + stats: [ + {label:'Pertinencity', value: '12' }, + {label:'Prosistensy', value: '8.90' } + ] +}; + +const COMPOSITION_EXAMPLE = { + id: uuidv4(), + label: 'Composition 2', + tooltip: 'Composition 2', + type: 'composition', + items: [ + { + id: uuidv4(), + label: 'A2', + tooltip: 'Stimulus', + type: 'mechanism', + }, + { + id: uuidv4(), + label: 'Projection A2 --> B2 Projection A2 --> B2', + tooltip: 'Projection A2 --> B2', + type: 'projection', + }, + { + id: uuidv4(), + label: 'B2', + tooltip: 'Stimulus', + type: 'mechanism', + }, + ], +}; + const datasets = [ { id: uuidv4(), label: 'Stimulus', tooltip: 'Stimulus', - type: 'MECHANISM', + type: 'mechanism', }, { id: uuidv4(), label: 'Projection Stimulus --> Composition', tooltip: 'Projection Stimulus --> Composition', - type: 'PROJECTION', + type: 'projection', }, { id: uuidv4(), label: 'Composition 1 Composition 1Composition 1', tooltip: 'Composition 1', - type: 'COMPOSITION', + type: 'composition', items: [ { id: uuidv4(), label: 'A1', tooltip: 'Stimulus', - type: 'MECHANISM', + type: 'mechanism', }, { id: uuidv4(), label: 'Projection A1 --> B1', tooltip: 'Projection A1 --> B1', - type: 'PROJECTION', + type: 'projection', }, { id: uuidv4(), label: 'B1', tooltip: 'Stimulus', - type: 'MECHANISM', - }, - ], - }, - { - id: uuidv4(), - label: 'Composition 2', - tooltip: 'Composition 2', - type: 'COMPOSITION', - items: [ - { - id: uuidv4(), - label: 'A2', - tooltip: 'Stimulus', - type: 'MECHANISM', - }, - { - id: uuidv4(), - label: 'Projection A2 --> B2 Projection A2 --> B2', - tooltip: 'Projection A2 --> B2', - type: 'PROJECTION', - }, - { - id: uuidv4(), - label: 'B2', - tooltip: 'Stimulus', - type: 'MECHANISM', + type: 'mechanism', items: [ { id: uuidv4(), label: 'A1', tooltip: 'Stimulus', - type: 'MECHANISM', + type: 'mechanism', }, { id: uuidv4(), label: 'Projection A1 --> B1', tooltip: 'Projection A1 --> B1', - type: 'PROJECTION', + type: 'projection', }, { id: uuidv4(), label: 'B1', tooltip: 'Stimulus', - type: 'MECHANISM', + type: 'mechanism', }, ], }, ], - }, + }, + COMPOSITION_EXAMPLE ]; const sidebarOpened = true; diff --git a/src/components/views/sidebar/TreeView/InstanceTreeView.js b/src/components/views/sidebar/TreeView/InstanceTreeView.js index e44f6223..f4a591af 100644 --- a/src/components/views/sidebar/TreeView/InstanceTreeView.js +++ b/src/components/views/sidebar/TreeView/InstanceTreeView.js @@ -22,9 +22,15 @@ import { import vars from '../../../../assets/styles/variables'; import { makeStyles } from '@mui/styles'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; +import { COMPOSITION_DTO } from '../Sidebar'; export const GRAPH_SOURCE = 'GRAPH'; export const TREE_SOURCE = 'TREE'; +export const COMPOSITION = 'composition'; +export const MECHANISM = 'mechanism'; +export const PROJECTION = 'projection'; + + const { popperBG, listSelectedTextColor, @@ -151,6 +157,7 @@ const initialRightClickStateCreator = () => ({ mouseY: null, }); + const InstancesTreeView = (props) => { const { datasets } = props; const classes = useStyles(); @@ -186,6 +193,7 @@ const InstancesTreeView = (props) => { setNodes(nodeIds); }; + function handleClick(e, nodes_ids) { if (e.target.className == 'MuiTreeItem-label') setSelectedNodes(nodes_ids); } @@ -193,7 +201,7 @@ const InstancesTreeView = (props) => { function onRightClick(event, node) { event.preventDefault(); event.stopPropagation(); - if (node.type === 'COMPOSITION') { + if (node.type === COMPOSITION) { setRight({ mouseX: event.clientX - 360, mouseY: event.clientY - 8, @@ -228,12 +236,12 @@ const InstancesTreeView = (props) => { const hidden = !nodes.includes(treeItemData?.id) && selectedNodeId !== treeItemData?.id && - treeItemData?.type === 'COMPOSITION'; + treeItemData?.type === COMPOSITION; const labelIcon = - treeItemData?.type === 'MECHANISM' ? ( + treeItemData?.type === MECHANISM ? ( - ) : treeItemData?.type === 'COMPOSITION' ? ( + ) : treeItemData?.type === COMPOSITION ? ( ) : ( @@ -318,7 +326,7 @@ const InstancesTreeView = (props) => { - Composition 2 + {COMPOSITION_DTO.label} @@ -345,35 +353,34 @@ const InstancesTreeView = (props) => { Function type - CombinationFunction + {COMPOSITION_DTO.type} - CombinationFunction Detailing + {COMPOSITION_DTO.detail} - {functionValues('ID', 'Composition 2')} + {functionValues('ID', COMPOSITION_DTO.label)} Function - function + {COMPOSITION_DTO.info.title} - =pnl. + {COMPOSITION_DTO.info.pnl} - Logistic + {COMPOSITION_DTO.info.sub} - (gain=1.0, bias=-4) + {COMPOSITION_DTO.info.calc} - {functionValues('Pertinencity', '12')} - {functionValues('Prosistensy', '8.90')} + {COMPOSITION_DTO.stats.map(stats => functionValues(stats.label, stats.value))}