diff --git a/applications/visualizer/frontend/src/components/ViewerContainer/CustomListItem.tsx b/applications/visualizer/frontend/src/components/ViewerContainer/CustomListItem.tsx index aa751522..a0893968 100644 --- a/applications/visualizer/frontend/src/components/ViewerContainer/CustomListItem.tsx +++ b/applications/visualizer/frontend/src/components/ViewerContainer/CustomListItem.tsx @@ -137,11 +137,13 @@ const CustomListItem = ({ - - - - - + {isNeurons && ( + + + + + + )} )} diff --git a/applications/visualizer/frontend/src/components/ViewerContainer/Neurons.tsx b/applications/visualizer/frontend/src/components/ViewerContainer/Neurons.tsx index c799035c..a7b4b676 100644 --- a/applications/visualizer/frontend/src/components/ViewerContainer/Neurons.tsx +++ b/applications/visualizer/frontend/src/components/ViewerContainer/Neurons.tsx @@ -10,12 +10,13 @@ import CustomEntitiesDropdown from "./CustomEntitiesDropdown.tsx"; import CustomListItem from "./CustomListItem.tsx"; const { gray900, gray500 } = vars; -const mapNeuronsToListItem = (neuron: string, visibility: ViewerData) => ({ +const mapToListItem = (neuron: string, visibility: ViewerData) => ({ id: neuron, label: neuron, checked: Object.values(visibility).every((e) => e === undefined || e.visibility === Visibility.Visible), }); -const mapNeuronsAvailableNeuronsToOptions = (neuron: Neuron) => ({ + +const neuronToOption = (neuron: Neuron) => ({ id: neuron.name, label: neuron.name, content: [], @@ -60,7 +61,7 @@ const Neurons = ({ children }) => { }; const autoCompleteOptions = Object.values(neurons) - .map((neuron: Neuron) => mapNeuronsAvailableNeuronsToOptions(neuron)) + .map((neuron: Neuron) => neuronToOption(neuron)) .sort((a, b) => a.label.localeCompare(b.label)); return ( @@ -115,7 +116,7 @@ const Neurons = ({ children }) => { {Array.from(activeNeurons).map((neuronId) => ( { {Array.from(Object.keys(groups)).map((groupId) => ( console.log("switch")} + onSwitchChange={handleSwitchChange} onDelete={() => console.log("delete")} deleteTooltipTitle="Remove group from the workspace" /> diff --git a/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDViewer.tsx b/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDViewer.tsx index b1068cc5..a75e01bd 100644 --- a/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDViewer.tsx +++ b/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDViewer.tsx @@ -83,8 +83,8 @@ const TwoDViewer = () => { const hiddenNeurons = useMemo(() => { return getHiddenNeuronsIn2D(workspace); }, [ - Object.keys(workspace.availableNeurons) - .map((neuronId) => workspace.visibilities[neuronId]?.[ViewerType.Graph]?.visibility || "") + Object.entries(workspace.visibilities) + .map(([name, data]) => `${name}-${data[ViewerType.Graph].visibility}`) .join(","), ]); diff --git a/applications/visualizer/frontend/src/helpers/twoD/groupHelper.ts b/applications/visualizer/frontend/src/helpers/twoD/groupHelper.ts index c4b9f641..edd96f80 100644 --- a/applications/visualizer/frontend/src/helpers/twoD/groupHelper.ts +++ b/applications/visualizer/frontend/src/helpers/twoD/groupHelper.ts @@ -48,6 +48,7 @@ export const groupNeurons = (selectedNeurons: Set, workspace: Workspace) name: originalGroupName || newGroupId, color: originalGroupColor, neurons: newGroupNeurons, + visible: true, }; return { newGroupId, newGroup, groupsToDelete }; diff --git a/applications/visualizer/frontend/src/helpers/twoD/twoDHelpers.ts b/applications/visualizer/frontend/src/helpers/twoD/twoDHelpers.ts index 03e78c2b..280c8356 100644 --- a/applications/visualizer/frontend/src/helpers/twoD/twoDHelpers.ts +++ b/applications/visualizer/frontend/src/helpers/twoD/twoDHelpers.ts @@ -234,17 +234,12 @@ export const updateWorkspaceNeurons2DViewerData = (workspace: Workspace, cy: Cor }; export function getVisibleActiveNeuronsIn2D(workspace: Workspace): Set { - const activeVisibleNeurons = Array.from(workspace.activeNeurons).filter((neuronId) => { - return workspace.visibilities[neuronId]?.[ViewerType.Graph]?.visibility === Visibility.Visible; - }); + const activeVisibleNeurons = Array.from(workspace.activeNeurons).filter( + (neuronId) => workspace.visibilities[neuronId]?.[ViewerType.Graph]?.visibility === Visibility.Visible, + ); // Create a set to store the class neurons that are active and visible - const activeVisibleClasses = new Set( - activeVisibleNeurons.filter((neuronId) => { - const neuron = workspace.availableNeurons[neuronId]; - return neuron && isNeuronClass(neuronId, workspace); - }), - ); + const activeVisibleClasses = new Set(activeVisibleNeurons.filter((neuronId) => workspace.availableNeurons[neuronId] && isNeuronClass(neuronId, workspace))); // Filter out individual cells if their class neuron is active and visible return new Set( diff --git a/applications/visualizer/frontend/src/models/models.ts b/applications/visualizer/frontend/src/models/models.ts index c5c769a7..f726fe5e 100644 --- a/applications/visualizer/frontend/src/models/models.ts +++ b/applications/visualizer/frontend/src/models/models.ts @@ -24,6 +24,7 @@ export interface NeuronGroup { name: string; color: string; neurons: Set; + visible: boolean; } export interface GraphViewerData { diff --git a/applications/visualizer/frontend/src/models/workspace.ts b/applications/visualizer/frontend/src/models/workspace.ts index 5f4096c1..8cef28e5 100644 --- a/applications/visualizer/frontend/src/models/workspace.ts +++ b/applications/visualizer/frontend/src/models/workspace.ts @@ -79,7 +79,6 @@ export class Workspace { }); this.updateContext(updated); } - hideNeuron(neuronId: string): void { const updated = produce(this, (draft: Workspace) => { if (!(neuronId in draft.visibilities)) {