Skip to content

Commit 322cd77

Browse files
#1565 Homepage / target table improvements (#497)
* #1408 initial commit * #1408 fixed some on hover behaviors * #1408 removed username tooltip from peer review table, filter out default quality statuses * #1408 updated LightCircle to be able to receive all component props, added onClick functionality for main quality status light and updated its hover events * - fixes issue when main observation is no longer part of the target * Squashed commit of the following: commit 1d4bcf7 Author: boriskovar-m2ms <boris.kovar@m2ms.sk> Date: Thu Apr 3 14:02:03 2025 +0200 - implements first batch of optimizations: local rdkit rendering and progress dialogs for data download and * Squashed commit of the following: commit 238bc95 Author: boriskovar-m2ms <boris.kovar@m2ms.sk> Date: Tue Mar 25 13:13:29 2025 +0100 - now only main observation is displayed * Squashed commit of the following: commit 880b8ee Author: boriskovar-m2ms <boris.kovar@m2ms.sk> Date: Tue Apr 8 08:27:39 2025 +0200 - first implementation * Squashed commit of the following: commit 68edd73 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Fri Apr 25 08:29:18 2025 +0200 - implements #1761 * #1565 target list split into three separate lists, fixed filters --------- Co-authored-by: boriskovar-m2ms <boris.kovar@m2ms.sk>
1 parent 03cb818 commit 322cd77

6 files changed

Lines changed: 819 additions & 1906 deletions

File tree

js/components/landing/Landing.js

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,32 @@ const Landing = memo(
3232
const dispatch = useDispatch();
3333
const classes = useStyles();
3434

35-
const projectWidth = window.innerWidth;
3635
const [isResizing, setIsResizing] = useState(false);
37-
const [targetListWidth, setTargetListWidth] = useState(450);
38-
const [projectListWidth, setProjectListWidth] = useState(projectWidth);
36+
const [resizer, setResizer] = useState(null);
37+
// const [targetListWidth, setTargetListWidth] = useState(450);
38+
const [publicTargetListWidth, setPublicTargetListWidth] = useState(window.innerWidth * 0.4);
39+
const [privateTargetListWidth, setPrivateTargetListWidth] = useState(window.innerWidth * 0.4);
40+
const [legacyTargetListWidth, setLegacyTargetListWidth] = useState(window.innerWidth * 0.2);
41+
42+
const [privateTargets, setPrivateTargets] = useState([]);
43+
const [publicTargets, setPublicTargets] = useState([]);
44+
45+
const target_id_list = useSelector(state => state.apiReducers.target_id_list);
46+
const legacy_target_id_list = useSelector(state => state.apiReducers.legacy_target_id_list);
47+
48+
useEffect(() => {
49+
let tempPrivateTargets = [];
50+
let tempPublicTargets = [];
51+
target_id_list?.forEach(target => {
52+
if (target.project.open_to_public === false) {
53+
tempPrivateTargets.push(target);
54+
} else {
55+
tempPublicTargets.push(target);
56+
}
57+
});
58+
setPrivateTargets(tempPrivateTargets);
59+
setPublicTargets(tempPublicTargets);
60+
}, [target_id_list]);
3961

4062
const { toast, toastSuccess, toastError, toastInfo, toastWarning } = useContext(ToastContext);
4163
const [loginText, setLoginText] = useState(
@@ -99,23 +121,30 @@ const Landing = memo(
99121
resetProjectsReducer();
100122
}, [resetTargetState, resetSelectionState, toast, loginText, resetCurrentCompoundsSettings, resetProjectsReducer]);
101123

102-
const handleMouseDownResizer = () => {
124+
const handleMouseDownResizer = (resizer) => {
103125
setIsResizing(true);
126+
setResizer(resizer);
104127
};
105128

106129
const handleMouseMove = useCallback(
107130
e => {
108-
if (!isResizing) return;
109-
const targetListWidth = e.clientX;
110-
const projectListWidth = window.innerWidth - targetListWidth;
111-
setTargetListWidth(targetListWidth);
112-
setProjectListWidth(projectListWidth);
131+
if (!isResizing || resizer === null) return;
132+
const leftPartWidth = e.clientX;
133+
const rightPartWidth = window.innerWidth - leftPartWidth;
134+
if (resizer === 1) {
135+
setPublicTargetListWidth(leftPartWidth);
136+
setPrivateTargetListWidth(rightPartWidth);
137+
} else if (resizer === 2) {
138+
setPrivateTargetListWidth(leftPartWidth);
139+
setLegacyTargetListWidth(rightPartWidth);
140+
}
113141
},
114-
[isResizing]
142+
[isResizing, resizer]
115143
);
116144

117145
const handleMouseUp = useCallback(() => {
118146
setIsResizing(false);
147+
setResizer(null);
119148
window.removeEventListener('mousemove', handleMouseMove);
120149
window.removeEventListener('mouseup', handleMouseUp);
121150
}, [handleMouseMove]);
@@ -133,8 +162,22 @@ const Landing = memo(
133162
return (
134163
<>
135164
<Grid container className={classes.root}>
136-
<Grid item style={{ width: targetListWidth }}>
137-
<TargetList />
165+
<Grid item style={{ width: publicTargetListWidth }}>
166+
<TargetList list={publicTargets} title={'Public targets'} />
167+
</Grid>
168+
<div
169+
style={{
170+
cursor: 'col-resize',
171+
width: 3,
172+
height: '100%',
173+
backgroundColor: '#eeeeee',
174+
borderRadius: '3px'
175+
}}
176+
className='resizer-left'
177+
onMouseDown={() => handleMouseDownResizer(1)}
178+
></div>
179+
<Grid item style={{ width: privateTargetListWidth }}>
180+
<TargetList list={privateTargets} title={'Private targets'} authRequired={true} />
138181
</Grid>
139182
<div
140183
style={{
@@ -144,10 +187,11 @@ const Landing = memo(
144187
backgroundColor: '#eeeeee',
145188
borderRadius: '3px'
146189
}}
147-
onMouseDown={handleMouseDownResizer}
190+
className='resizer-right'
191+
onMouseDown={() => handleMouseDownResizer(2)}
148192
></div>
149-
<Grid item style={{ width: projectListWidth }}>
150-
<Projects />
193+
<Grid item style={{ width: legacyTargetListWidth }}>
194+
<TargetList list={legacy_target_id_list} title={'Legacy targets'} legacy={true} />
151195
</Grid>
152196
</Grid>
153197
<TargetSettingsModal openModal={isEditTargetDialogOpen} onModalClose={onModalClose} isTargetOn={false} />

js/components/target/redux/dispatchActions.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ export const loadTargetList = onCancel => (dispatch, getState) => {
3030
dispatch(setIsTargetLoading(false));
3131
},
3232
old_url: oldUrl,
33-
setObjectList: params => dispatch(setTargetIdList(params)),
33+
setObjectList: async params => {
34+
const experiments = await loadExperimentList();
35+
params?.forEach(target => {
36+
const experiment = experiments.sort((a, b) => a.commit_datetime > b.commit_datetime ? -1 : 1).find(experiment => experiment.target === target.id);
37+
if (experiment) {
38+
target.last_updated = experiment.commit_datetime;
39+
}
40+
});
41+
dispatch(setTargetIdList(params))
42+
},
3443
list_type,
3544
cancel: onCancel
3645
});
@@ -52,6 +61,12 @@ export const loadLegacyTargetList = () => async (dispatch, getState) => {
5261
}
5362
};
5463

64+
export const loadExperimentList = async () => {
65+
const url = `${base_url}/api/target_experiment_uploads/`;
66+
const resp = await api({ url, method: METHOD.GET });
67+
return resp.data.results;
68+
};
69+
5570
export const loadProjectsList = () => async (dispatch, getState) => {
5671
const url = `${base_url}/api/projects/`;
5772
const resp = await api({ url, method: METHOD.GET });

0 commit comments

Comments
 (0)