Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit b6c21b9
Author: Boris Kovar <[email protected]>
Date:   Tue Aug 15 12:32:55 2023 +0200

    Squashed commit of the following:

    commit 6052870
    Author: Boris Kovar <[email protected]>
    Date:   Tue Aug 15 12:31:31 2023 +0200

        - implemented #1129

commit 86a1a7c
Author: Boris Kovar <[email protected]>
Date:   Tue Aug 15 09:49:39 2023 +0200

    Squashed commit of the following:

    commit 0550be2
    Author: Boris Kovar <[email protected]>
    Date:   Tue Aug 15 08:46:33 2023 +0200

        - fixed #1092

commit fcf418d
Author: Boris Kovar <[email protected]>
Date:   Fri Aug 11 09:19:38 2023 +0200

    Squashed commit of the following:

    commit 5adc61a
    Merge: a8c90f2 1aef079
    Author: RobertMatuska <[email protected]>
    Date:   Thu Aug 10 15:31:40 2023 +0200

        Merge branch '#1118' of https://github.com/m2ms/fragalysis-frontend into #1118

    commit a8c90f2
    Author: RobertMatuska <[email protected]>
    Date:   Thu Aug 10 15:31:35 2023 +0200

        #1118 fixed filter and sort bugs

    commit 1aef079
    Author: boriskovar-m2ms <[email protected]>
    Date:   Thu Aug 10 08:25:48 2023 +0200

        Update package.json

        triggering build action

    commit 594ac19
    Merge: 5564d2c de09cdc
    Author: RobertMatuska <[email protected]>
    Date:   Wed Aug 9 11:59:25 2023 +0200

        Merge branch '#1106' into #1118

    commit 5564d2c
    Author: RobertMatuska <[email protected]>
    Date:   Wed Aug 9 11:26:34 2023 +0200

        #1118 change priority and fix bugs

    commit de09cdc
    Merge: 4caeef7 8b73ee2
    Author: Boris Kovar <[email protected]>
    Date:   Tue Aug 8 11:38:09 2023 +0200

        Merge branch '#1106' of https://github.com/m2ms/fragalysis-frontend into #1106

    commit 4caeef7
    Author: Boris Kovar <[email protected]>
    Date:   Tue Aug 8 11:37:40 2023 +0200

        - updated table styling

    commit 8b73ee2
    Author: boriskovar-m2ms <[email protected]>
    Date:   Mon Aug 7 13:24:08 2023 +0200

        Update package.json

        just to trigger build action

    commit d161306
    Author: Boris Kovar <[email protected]>
    Date:   Mon Aug 7 12:55:44 2023 +0200

        - table is now autosized

    commit e867e77
    Author: RobertMatuska <[email protected]>
    Date:   Mon Aug 7 09:03:11 2023 +0200

        #1106 edited columns size

    # Conflicts:
    #	js/components/projects/index.js
    #	package.json
  • Loading branch information
boriskovar-m2ms committed Aug 15, 2023
1 parent de6df99 commit 5fd5b90
Show file tree
Hide file tree
Showing 11 changed files with 776 additions and 686 deletions.
2 changes: 1 addition & 1 deletion js/components/nglView/renderingObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ const showArrow = ({ stage, input_dict, object_name, representations, orientatio
let radius = input_dict.radius === undefined ? 0.3 : input_dict.radius;
// Handle undefined start and finish
if (input_dict.start === undefined || input_dict.end === undefined) {
const msgs = 'START OR END UNDEFINED FOR ARROW ' + input_dict.toString();
const msgs = 'START OR END UNDEFINED FOR ARROW ' + JSON.stringify(input_dict);
return Promise.reject(msgs);
}
let shape = new Shape(object_name, { disableImpostor: true });
Expand Down
6 changes: 3 additions & 3 deletions js/components/projects/helperConstants.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const moleculeProperty = {
createdAt: 'createdAt',
export const projectProperty = {
createdAt: 'init_date',
name: 'name',
target: 'target',
targetAccessString: 'targetAccessString',
description: 'description',
authority: 'authority',
tags: 'tags',
tags: 'tags'
};
370 changes: 59 additions & 311 deletions js/components/projects/index.js

Large diffs are not rendered by default.

104 changes: 77 additions & 27 deletions js/components/projects/projectListSortFilterDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ import ProjectListSortFilterItem from './projectListSortFilterItem';
import WarningIcon from '@material-ui/icons/Warning';
import { makeStyles } from '@material-ui/styles';
import { useDispatch, useSelector } from 'react-redux';
import { MOL_ATTRIBUTES } from './redux/constants';
import { PROJECTS_ATTR } from './redux/constants';
import { setFilter } from '../../reducers/selection/actions';
import { Panel } from '../common/Surfaces/Panel';
import { setSortDialogOpen, setListOfFilteredProjects, setListOfProjects, setDefaultFilter, setListOfFilteredProjectsByDate } from './redux/actions';
import {
setSortDialogOpen,
setListOfFilteredProjects,
setListOfProjects,
setDefaultFilter,
setListOfFilteredProjectsByDate
} from './redux/actions';
import { debounce } from 'lodash';
import { compareCreatedAtDateDesc } from './sortProjects/sortProjects';

const useStyles = makeStyles(theme => ({
title: {
Expand Down Expand Up @@ -44,45 +51,72 @@ const useStyles = makeStyles(theme => ({
},
paper: {
width: 490,
overflow: 'none',
overflow: 'none'
}
}));

const widthPrio = 50;
const widthOrder = 60;
const widthProperty = 170;
const filterData = 160

const filterData = 160;

export const getAttrDefinition = attr => {
return MOL_ATTRIBUTES.find(molAttr => molAttr.key === attr);
return PROJECTS_ATTR.find(molAttr => molAttr.key === attr);
};

const getNestedAttributeValue = (object, attribute, path) => {
if (!path) {
return object[attribute];
}

const pathAttributes = path.split('.');
let attributeValue = object;
for (const pathAttribute of pathAttributes) {
attributeValue = attributeValue[pathAttribute];
if (attributeValue === undefined) return undefined;
}
return attributeValue;
};

export const sortProjects = (projects, filter) => {
let sortedAttributes = filter.sortOptions.map(attr => attr);
return projects.sort((a, b) => {
for (const [attrName, path] of sortedAttributes) {
const order = filter.filter[attrName].order;
const val1 = getNestedAttributeValue(a, attrName, path);
const val2 = getNestedAttributeValue(b, attrName, path);

if (val1 === val2) continue;
if (order === -1) {
return val1 > val2 ? -1 : 1;
} else {
return val1 < val2 ? -1 : 1;
}
}
return 0;
});
};

export const ProjectListSortFilterDialog = memo(
({
filter,
anchorEl,
open,
parentID = 'default',
placement = 'right-start',
}) => {
({ filter, anchorEl, open, parentID = 'default', placement = 'right-start' }) => {
let classes = useStyles();
const dispatch = useDispatch();
const initialize = useCallback(() => {
let initObject = {
active: false,
predefined: 'none',
filter: {},
priorityOrder: MOL_ATTRIBUTES.map(molecule => molecule.key)
priorityOrder: PROJECTS_ATTR.map(project => project.key),
sortOptions: PROJECTS_ATTR.map(project => [project.key, project.path])
};

for (let attr of MOL_ATTRIBUTES) {
for (let attr of PROJECTS_ATTR) {
const lowAttr = attr.key.toLowerCase();

initObject.filter[attr.key] = {
priority: 0,
order: 1,
isFloat: attr.isFloat,
isFloat: attr.isFloat
};
}
return initObject;
Expand All @@ -91,17 +125,18 @@ export const ProjectListSortFilterDialog = memo(
useEffect(() => {
const init = initialize();
setInitState(init);
}, [])
}, []);

const [initState, setInitState] = useState(initialize());
const defaultListOfProjects = useSelector(state => state.projectReducers.listOfProjects);
let defaultListOfProjectsWithoutSort = useSelector(state => state.projectReducers.listOfProjects);
let defaultListOfProjects = [...defaultListOfProjectsWithoutSort].sort(compareCreatedAtDateDesc);

filter = filter || initState;

const handleFilterChange = useCallback(
filter => {
const filterSet = Object.assign({}, filter);
for (let attr of MOL_ATTRIBUTES) {
for (let attr of PROJECTS_ATTR) {
if (filterSet.filter[attr.key].priority === undefined || filterSet.filter[attr.key].priority === '') {
filterSet.filter[attr.key].priority = 0;
}
Expand All @@ -111,7 +146,6 @@ export const ProjectListSortFilterDialog = memo(
[dispatch]
);


const handleItemChange = key => setting => {
console.log(`handleItemChange attr: ${key} values: ${JSON.stringify(setting)}`);
let newFilter = Object.assign({}, filter);
Expand All @@ -121,11 +155,18 @@ export const ProjectListSortFilterDialog = memo(
handleFilterChange(newFilter);
};

const findIndexByKey = key => {
const sortIndex = filter.sortOptions.findIndex(item => item[0] === key);
return sortIndex;
};

const handlePrioChange = key => inc => () => {
const maxPrio = 5;
const minPrio = 0;
let priorityOrder = filter.priorityOrder;
let sortOptions = filter.sortOptions;
const index = filter.priorityOrder.indexOf(key);
const sortIndex = findIndexByKey(key);
if (index > -1 && index + inc >= minPrio && index <= maxPrio) {
priorityOrder.splice(index, 1);
priorityOrder.splice(index + inc, 0, key);
Expand All @@ -135,21 +176,31 @@ export const ProjectListSortFilterDialog = memo(
dispatch(setFilter(newFilter));
handleFilterChange(newFilter);
}
if (sortIndex > -1 && sortIndex + inc >= minPrio && sortIndex <= maxPrio) {
const path = sortOptions[sortIndex][1];
sortOptions.splice(sortIndex, 1);
sortOptions.splice(sortIndex + inc, 0, [key, path]);
let newFilter = Object.assign({}, filter);
newFilter.sortOptions = sortOptions;
newFilter.active = true;
dispatch(setFilter(newFilter));
handleFilterChange(newFilter);
}
};

const handleClearFilter = debounce(() => {
dispatch(setDefaultFilter(true));
dispatch(setSortDialogOpen(false));
dispatch(setListOfFilteredProjects(defaultListOfProjects));
dispatch(setListOfFilteredProjectsByDate(defaultListOfProjects));
dispatch(setListOfProjects(defaultListOfProjects));
dispatch(setListOfFilteredProjects(defaultListOfProjects.sort(compareCreatedAtDateDesc)));
dispatch(setListOfFilteredProjectsByDate(defaultListOfProjects.sort(compareCreatedAtDateDesc)));
dispatch(setListOfProjects(defaultListOfProjects.sort(compareCreatedAtDateDesc)));
dispatch(setSortDialogOpen(true));
});
dispatch(setFilter(filter));

// Check for multiple attributes with same sorting priority
let prioWarning = false;
let prioWarningTest = {};
for (const attr of MOL_ATTRIBUTES) {
for (const attr of PROJECTS_ATTR) {
const prioKey = filter.filter[attr.key].priority;
if (prioKey > 0) {
prioWarningTest[prioKey] = prioWarningTest[prioKey] ? prioWarningTest[prioKey] + 1 : 1;
Expand Down Expand Up @@ -207,10 +258,9 @@ export const ProjectListSortFilterDialog = memo(
property
</Grid>
<Grid item className={classes.centered} style={{ width: filterData }}>
Filter data
Filter data
</Grid>
</Grid>

{filter.priorityOrder.map(attr => {
let attrDef = getAttrDefinition(attr);
return (
Expand Down
Loading

0 comments on commit 5fd5b90

Please sign in to comment.