Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple custom layouts for tracing views #3299

Merged
merged 33 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f8f5f53
added UI support, moving layout into store
MichaelBuessemeyer Sep 27, 2018
024c4e9
made reset layout items in action bar into an own component; added ac…
MichaelBuessemeyer Sep 29, 2018
3c8bdf8
moved layout into less file, moved persisting methods
MichaelBuessemeyer Oct 1, 2018
17fda10
changed layout, goldenlayout adapter no gets layout via a method, and…
MichaelBuessemeyer Oct 1, 2018
16ed9c8
added resetting, deleting, adding a new layout; added modal to enter …
MichaelBuessemeyer Oct 1, 2018
0370fe4
added modal
MichaelBuessemeyer Oct 1, 2018
6571528
fixed import errors and added saving in local storage aber deleting a…
MichaelBuessemeyer Oct 1, 2018
7101a39
corrected adding, deleting and resetting the layout
MichaelBuessemeyer Oct 1, 2018
db153c5
fixed linter error
MichaelBuessemeyer Oct 2, 2018
59d9dcf
fixed flow errors
MichaelBuessemeyer Oct 2, 2018
75baf8a
Merge branch 'master' of github.com:scalableminds/webknossos into mul…
MichaelBuessemeyer Oct 2, 2018
34fadc2
using lodash to create deepcopy of stored layouts
MichaelBuessemeyer Oct 2, 2018
6e19cc6
v1.10.1
MichaelBuessemeyer Oct 2, 2018
fe90c6a
Merge branch 'master' into mulitple-tracing-custom-layouts
MichaelBuessemeyer Oct 2, 2018
61b5365
modified yarn.lock -> added checksum?
MichaelBuessemeyer Oct 2, 2018
9ad7120
Merge branch 'mulitple-tracing-custom-layouts' of github.com:scalable…
MichaelBuessemeyer Oct 2, 2018
e4371ae
removed unused comment; removed useless emit
MichaelBuessemeyer Oct 2, 2018
c2cd24d
Update CHANGELOG.md
MichaelBuessemeyer Oct 2, 2018
55c7875
Update CHANGELOG.md
MichaelBuessemeyer Oct 2, 2018
0d88758
Merge branch 'master' of github.com:scalableminds/webknossos into mul…
MichaelBuessemeyer Oct 4, 2018
2837206
applied requested feedback
MichaelBuessemeyer Oct 4, 2018
796d697
removed lastActive from filtering layout names
MichaelBuessemeyer Oct 4, 2018
55a903c
fixed linting error
MichaelBuessemeyer Oct 4, 2018
1fcb25b
changed ui to indicate that layout are stored separately
MichaelBuessemeyer Oct 5, 2018
41b4875
fix default layout bug
MichaelBuessemeyer Oct 5, 2018
1a9e1cd
some visual tweaks
MichaelBuessemeyer Oct 5, 2018
8d0429f
made the code pretty
MichaelBuessemeyer Oct 5, 2018
45ab3f2
fixed typos and change toast to thrown error message
MichaelBuessemeyer Oct 6, 2018
215bffd
renamed labels for layout sub menu
MichaelBuessemeyer Oct 8, 2018
74fb288
fixed visual bug with the icons
MichaelBuessemeyer Oct 8, 2018
1c6289a
merged master into mulitple-tracing-custom-layouts
MichaelBuessemeyer Oct 8, 2018
db8d6fe
removed bullet points from layout list
MichaelBuessemeyer Oct 8, 2018
fe5bb10
Merge branch 'master' into mulitple-tracing-custom-layouts
MichaelBuessemeyer Oct 10, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
### Added

- Added support for duplicate dataset names for different organizations [#3137](https://github.com/scalableminds/webknossos/pull/3137)
- A User can now have multiple layouts for tracing views. [#3299](https://github.com/scalableminds/webknossos/pull/3299)

### Changed

Expand Down
15 changes: 14 additions & 1 deletion app/assets/javascripts/oxalis/model/actions/ui_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ type SetVersionRestoreVisibilityAction = {
active: boolean,
};

export type UiAction = SetDropzoneModalVisibilityAction | SetVersionRestoreVisibilityAction;
type SetStoredLayoutsAction = {
type: "SET_STORED_LAYOUTS",
storedLayouts: Object,
};

export type UiAction =
| SetDropzoneModalVisibilityAction
| SetVersionRestoreVisibilityAction
| SetStoredLayoutsAction;

export const setDropzoneModalVisibilityAction = (
visible: boolean,
Expand All @@ -26,3 +34,8 @@ export const setVersionRestoreVisibilityAction = (
type: "SET_VERSION_RESTORE_VISIBILITY",
active,
});

export const setStoredLayoutsAction = (storedLayouts: Object): SetStoredLayoutsAction => ({
type: "SET_STORED_LAYOUTS",
storedLayouts,
});
8 changes: 8 additions & 0 deletions app/assets/javascripts/oxalis/model/reducers/ui_reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ function UiReducer(state: OxalisState, action: Action): OxalisState {
});
}

case "SET_STORED_LAYOUTS": {
return update(state, {
uiInformation: {
storedLayouts: { $set: action.storedLayouts },
},
});
}

default:
return state;
}
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/oxalis/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import type {
APIDataset,
APIDataLayer,
} from "admin/api_flow_types";
import { defaultLayoutSchema } from "oxalis/view/layouting/default_layout_configs";

export type CommentType = {|
+content: string,
Expand Down Expand Up @@ -345,6 +346,7 @@ export type ViewModeData = {
type UiInformation = {
+showDropzoneModal: boolean,
+showVersionRestore: boolean,
+storedLayouts: Object,
};

export type OxalisState = {|
Expand Down Expand Up @@ -527,6 +529,7 @@ export const defaultState: OxalisState = {
uiInformation: {
showDropzoneModal: false,
showVersionRestore: false,
storedLayouts: defaultLayoutSchema,
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// @flow

import * as React from "react";
import { Input, Modal } from "antd";

type Props = {
addLayout: string => void,
visible: boolean,
onCancel: () => void,
};

type State = {
value: string,
};

class AddNewLayoutModal extends React.PureComponent<Props, State> {
state = {
value: "",
};

render() {
return (
<Modal
title="Add a new layout"
visible={this.props.visible}
onOk={() => {
const value = this.state.value;
this.setState({ value: "" });
this.props.addLayout(value);
}}
onCancel={this.props.onCancel}
>
<Input
placeholder="Layout Name"
value={this.state.value}
onChange={evt => {
this.setState({ value: evt.target.value });
}}
/>
</Modal>
);
}
}

export default AddNewLayoutModal;
126 changes: 109 additions & 17 deletions app/assets/javascripts/oxalis/view/action-bar/tracing_actions_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { PureComponent } from "react";
import Model from "oxalis/model";
import Store from "oxalis/store";
import { connect } from "react-redux";
import { Upload, Button, Dropdown, Menu, Icon, Modal } from "antd";
import { Upload, Button, Dropdown, Menu, Icon, Modal, Tooltip } from "antd";
import Constants from "oxalis/constants";
import MergeModalView from "oxalis/view/action-bar/merge_modal_view";
import ShareModalView from "oxalis/view/action-bar/share_modal_view";
Expand All @@ -18,11 +18,10 @@ import { copyAnnotationToUserAccount, finishAnnotation } from "admin/admin_rest_
import { location } from "libs/window";
import type { OxalisState, RestrictionsAndSettings, Task } from "oxalis/store";
import type { APIUser, APITracingType } from "admin/api_flow_types";
import { layoutEmitter } from "oxalis/view/layouting/layout_persistence";
import { updateUserSettingAction } from "oxalis/model/actions/settings_actions";
import SceneController from "oxalis/controller/scene_controller";
import { readFileAsArrayBuffer } from "libs/read_file";
import { AsyncButton } from "components/async_clickables";
import { mapLayoutKeysToLanguage } from "oxalis/view/layouting/default_layout_configs";

type StateProps = {
tracingType: APITracingType,
Expand All @@ -32,27 +31,109 @@ type StateProps = {
activeUser: ?APIUser,
};

type Props = StateProps & {
storedLayoutNamesForView: Array<string>,
layoutKey: string,
activeLayout: string,
onResetLayout: () => void,
onSelectLayout: string => void,
onDeleteLayout: string => void,
addNewLayout: () => void,
};

type State = {
isShareModalOpen: boolean,
isMergeModalOpen: boolean,
isUserScriptsModalOpen: boolean,
};

export const resetLayoutItem = (
<Menu.Item key="reset-layout">
<div
onClick={() => {
Store.dispatch(updateUserSettingAction("layoutScaleValue", 1));
layoutEmitter.emit("resetLayout");
}}
type ResetLayoutItemProps = {
storedLayoutNamesForView: Array<string>,
layoutKey: string,
activeLayout: string,
onResetLayout: () => void,
onSelectLayout: string => void,
onDeleteLayout: string => void,
addNewLayout: () => void,
};

export const ResetLayoutItem = (props: ResetLayoutItemProps) => {
const {
storedLayoutNamesForView,
layoutKey,
activeLayout,
onResetLayout,
onSelectLayout,
onDeleteLayout,
addNewLayout,
...others
} = props;
const layoutMissingHelpTitle = (
<React.Fragment>
<h5 style={{ color: "#fff" }}>Where is my layout?</h5>
<p>
{`The tracing views are seperated into four classes. Each of them has their own layouts. If you
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separated

can't find your layout please open the tracing in the correct view mode or just add it here manually.`}
</p>
</React.Fragment>
);
const customLayoutsItems = storedLayoutNamesForView.map(layout => {
const isSelectedLayout = layout === activeLayout;
return (
<Menu.Item key={layout} className={isSelectedLayout ? "selected-layout-item" : null}>
<span
onClick={() => onSelectLayout(layout)}
style={{ minWidth: "100%", minHeight: "auto", display: "inline-block" }}
>
<div className="inline-with-margin" style={{ marginRight: 16 }}>
{layout}
{isSelectedLayout ? (
<Icon type="check" className="sub-menu-item-icon" theme="outlined" />
) : (
<Tooltip placement="top" title="Remove this layout">
<Icon
type="delete"
className="clickable-icon sub-menu-item-icon"
onClick={() => onDeleteLayout(layout)}
/>
</Tooltip>
)}
</div>
</span>
</Menu.Item>
);
});
return (
<Menu.SubMenu
{...others}
title={
<React.Fragment>
<Icon type="laptop" /> Layout
<Tooltip placement="top" title={layoutMissingHelpTitle}>
<Icon
type="info-circle-o"
style={{ color: "gray", marginRight: 36 }}
className="sub-menu-item-icon"
/>
</Tooltip>
</React.Fragment>
}
>
<Icon type="laptop" />
Reset Layout
</div>
</Menu.Item>
);
<Menu.Item>
<div onClick={onResetLayout}>Reset Layout</div>
</Menu.Item>
<Menu.Item>
<div onClick={addNewLayout}>Add a new Layout</div>
</Menu.Item>
<Menu.Divider />
<Menu.ItemGroup title={`Layouts for ${mapLayoutKeysToLanguage[layoutKey]}`}>
{customLayoutsItems}
</Menu.ItemGroup>
</Menu.SubMenu>
);
};

class TracingActionsView extends PureComponent<StateProps, State> {
class TracingActionsView extends PureComponent<Props, State> {
state = {
isShareModalOpen: false,
isMergeModalOpen: false,
Expand Down Expand Up @@ -266,7 +347,18 @@ class TracingActionsView extends PureComponent<StateProps, State> {
);
}

elements.push(resetLayoutItem);
elements.push(
<ResetLayoutItem
storedLayoutNamesForView={this.props.storedLayoutNamesForView}
layoutKey={this.props.layoutKey}
activeLayout={this.props.activeLayout}
onResetLayout={this.props.onResetLayout}
onSelectLayout={this.props.onSelectLayout}
onDeleteLayout={this.props.onDeleteLayout}
addNewLayout={this.props.addNewLayout}
key="layout"
/>,
);

const onStlUpload = async info => {
const buffer = await readFileAsArrayBuffer(info.file);
Expand Down
Loading