Skip to content

Commit

Permalink
Merge branch 'metacell' of https://github.com/MetaCell/PsyNeuLinkView
Browse files Browse the repository at this point in the history
…into feature/PSYNEU-51
  • Loading branch information
Salam Dalloul committed Jun 5, 2023
2 parents 0fed2c1 + c6fa1df commit e5e8608
Show file tree
Hide file tree
Showing 11 changed files with 461 additions and 497 deletions.
410 changes: 217 additions & 193 deletions src/client/components/common/Breadcrumbs.js

Large diffs are not rendered by default.

17 changes: 3 additions & 14 deletions src/client/components/common/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const useStyles = makeStyles(() => ({
display: 'flex',
alignItems: 'center',
border: `1px solid ${headerBorderColor}`,
inset: '1rem auto auto 0 !important',
position: 'relative',
zIndex: 9999,
},

leftSection: {
Expand Down Expand Up @@ -91,18 +92,6 @@ const useStyles = makeStyles(() => ({
},
}));

const breadcrumbs = [
{ id: 'home', text: 'Home' },
{ id: 'breadSubItem1', text: 'breadSubItem1' },
{ id: 'breadSubItem2', text: 'breadSubItem2' },
{ id: 'breadSubItem3', text: 'breadSubItem3' },
{ id: 'breadSubItem4', text: 'breadSubItem4' },
{ id: 'breadSubItem5', text: 'breadSubItem5' },
{ id: 'breadSubItem6', text: 'breadSubItem6' },
{ id: 'breadSubItem7', text: 'breadSubItem7' },
{ id: 'composition2', text: 'Composition 2' },
];

const listItems = [
{ label: 'Build', value: 'build', soon: false, action: GUIViews.EDIT},
{ label: 'Visualise', value: 'visualise', soon: false, action: GUIViews.VIEW},
Expand All @@ -127,7 +116,7 @@ const Header = () => {
<Box className={classes.root}>
<Box className={classes.leftSection}>
<img src={PSYLOGO} alt="new-logo" aria-describedby="logo" />
<CustomBreadcrumbsWithMenu breadcrumbs={breadcrumbs} />
<CustomBreadcrumbsWithMenu />
</Box>
<Box className={classes.middleSection}>
<List className="headerSwitch" component="nav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class GenericMechanism extends React.Component {
}

changeVisibility() {
this.props.model.isExpanded = !this.state.expanded;
this.setState({expanded: !this.state.expanded});
}

Expand Down
23 changes: 13 additions & 10 deletions src/client/components/views/editView/mechanisms/InputOutputNode.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import * as React from "react";
import { Box, Typography } from "@mui/material";
import {PortWidget} from "@projectstorm/react-diagrams";

class InputOutputNode extends React.Component {
render() {
const { text, direction } = this.props;
const nodeClass = direction === 'right' ? 'block reverse' : 'block';
render() {
const { text, direction, engine, port } = this.props;
const nodeClass = direction === 'right' ? 'block reverse' : 'block';

return (
<Box className={nodeClass}>
<Box className="disc" />
<Typography>{text}</Typography>
</Box>
);
}
return (
<Box className={nodeClass}>
<PortWidget engine={engine} port={port} className="disc">
<Box/>
</PortWidget>
<Typography>{text}</Typography>
</Box>
);
}
}

export default InputOutputNode;
181 changes: 95 additions & 86 deletions src/client/components/views/editView/mechanisms/MechMetadata.js
Original file line number Diff line number Diff line change
@@ -1,108 +1,117 @@
import * as React from "react";
import Box from "@mui/material/Box";
import { withStyles } from "@mui/styles";
import {withStyles} from "@mui/styles";
import NodeSelection from "./NodeSelection";
import InputOutputNode from "./InputOutputNode";
// import TextField from '@mui/material/TextField';
import Typography from "@mui/material/Typography";
import { PortTypes, PortWidget } from "@metacell/meta-diagram";
import {PortTypes} from "@metacell/meta-diagram";
import vars from "../../../../assets/styles/variables";

const styles = {
textColor: {
color: vars.functionTextColor
},
codeColor: {
color: vars.functionCodeColor
}
textColor: {
color: vars.functionTextColor
},
codeColor: {
color: vars.functionCodeColor
},
};

class MechMetadata extends React.Component {
render() {
const { classes, model, model: { options }, engine, changeVisibility } = this.props;
console.log(classes)
const functionValues = (label, value) => (
<Box className="block">
<Typography component="label">{label}</Typography>
{/* <TextField
id="outlined-multiline-flexible"
maxRows={4}
value={value}
onChange={ (e) => {console.log(e)} }
variant="outlined"
style={{ zIndex: 11 }}
/> */}
<Typography>{value}</Typography>
</Box>
)

return (
<Box className={`primary-node rounded ${options.variant}`}>
{options.selected && (
<NodeSelection node={model} engine={engine} text={"Hide properties"} changeVisibility={changeVisibility} />
)}
<Box className="primary-node_header">
<Box className="icon" />
<Typography component="p">
{options.name}
</Typography>
</Box>
constructor() {
super();
this.elementRef = React.createRef();
}

<Box>
{ options.ports.map(port => {
switch (port.getType()) {
case PortTypes.INPUT_PORT:
return (
<PortWidget key={model.getID() + '_' + port.getId()} engine={engine} port={model.getPort(port.getId())}>
<InputOutputNode text={port.getId()} />
</PortWidget>
);
default:
return <></>
}
})}
</Box>
componentDidMount() {
this.forceUpdate() // so that we get the ref to the element
}

<Box className="seprator" />
componentDidUpdate(prevProps, prevState, snapshot) {
const parentElement = this.elementRef.current.parentElement;
parentElement.style.clipPath = '';
parentElement.style.zIndex = 10000;
}

<Box className="block-wrapper">
{
functionValues('Context', '12')
}
{
functionValues('Size', '8.90')
}
{
functionValues('Prefs', '44')
}
render() {
const {classes, model, model: {options}, engine, changeVisibility} = this.props;
const functionValues = (label, value) => (
<Box className="block">
<Typography component="label">Function</Typography>
<Typography className="function">
<Typography component="strong" className={classes?.textColor} >
function
</Typography>=pnl.<Typography className={classes?.codeColor} component="strong">Logistic</Typography>(gain=1.0, bias=-4)</Typography>
<Typography component="label">{label}</Typography>
<Typography>{value}</Typography>
</Box>
</Box>
)

return (
<Box ref={this.elementRef} className={`primary-node rounded ${options.variant}`}>
{options.selected && (
<NodeSelection node={model} engine={engine} text={"Hide properties"}
changeVisibility={changeVisibility}/>
)}
<Box className="primary-node_header">
<Box className="icon"/>
<Typography component="p">
{options.name}
</Typography>
</Box>

<Box className="seprator" />
<Box>
{options.ports.map(port => {
switch (port.getType()) {
case PortTypes.INPUT_PORT:
return (
<InputOutputNode key={model.getID() + '_' + port.getId()} engine={engine}
port={model.getPort(port.getId())} text={port.getId()}/>
);
default:
return <></>
}
})}
</Box>

<Box>
{ options.ports.map(port => {
switch (port.getType()) {
case PortTypes.OUTPUT_PORT:
return (
<PortWidget key={model.getID() + '_' + port.getId()} engine={engine} port={model.getPort(port.getId())}>
<InputOutputNode text={port.getId()} direction="right" />
</PortWidget>
);
default:
return <></>
}
})}
</Box>
</Box>
);
}
<Box className="seprator"/>

<Box className="block-wrapper">
{
functionValues('Context', '12')
}
{
functionValues('Size', '8.90')
}
{
functionValues('Prefs', '44')
}
<Box className="block">
<Typography component="label">Function</Typography>
<Typography className="function">
<Typography component="strong" className={classes?.textColor}>
function
</Typography>=pnl.<Typography className={classes?.codeColor}
component="strong">Logistic</Typography>(gain=1.0,
bias=-4)</Typography>
</Box>
</Box>

<Box className="separator"/>

<Box>
{options.ports.map(port => {
switch (port.getType()) {
case PortTypes.OUTPUT_PORT:
return (
<InputOutputNode key={model.getID() + '_' + port.getId()} engine={engine}
port={model.getPort(port.getId())} text={port.getId()}
direction="right"/>
)
;
default:
return <></>
}
})}
</Box>
</Box>
);
}
}

export default withStyles(styles)(MechMetadata);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from "react";
import NodeSelection from "./NodeSelection";
import {Box, Typography} from "@mui/material";
import {PortWidget, PortTypes, CallbackTypes} from "@metacell/meta-diagram";
import {clipPathBorderSize} from "../../../../../constants";
import {getClipPath} from "../../../../services/clippingService";
import ModelSingleton from "../../../../model/ModelSingleton";

Expand Down Expand Up @@ -59,7 +58,7 @@ class MechSimple extends React.Component {

getMechClipPath(parentNode) {
const {model} = this.props;
return parentNode ? getClipPath(parentNode, model, clipPathBorderSize) : null
return parentNode ? getClipPath(parentNode, model) : null
}

getListenerID(node) {
Expand Down
Loading

0 comments on commit e5e8608

Please sign in to comment.