Skip to content

Commit

Permalink
Merge pull request #27 from alberto-abarzua/22-saveload-actions
Browse files Browse the repository at this point in the history
22 saveload actions
  • Loading branch information
alberto-abarzua authored Nov 8, 2023
2 parents 1ba4585 + 5c3cdc0 commit 76a81d3
Show file tree
Hide file tree
Showing 16 changed files with 291 additions and 31 deletions.
2 changes: 2 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv
.pdm-python
6 changes: 0 additions & 6 deletions backend/package-lock.json

This file was deleted.

2 changes: 1 addition & 1 deletion backend/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ type_check = "mypy src"
format = {composite = ["isort", "black"]}
lint = {composite = ["pure_lint", "type_check"]}

[tool.pdm.overrides]
use_venv = false
2 changes: 2 additions & 0 deletions controller/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv
.pdm-python
29 changes: 29 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.7",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-context-menu": "^2.1.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-slot": "^1.0.2",
Expand Down
25 changes: 22 additions & 3 deletions frontend/src/components/actions/ActionSet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const ActionSet = ({ action, ...props }) => {

const id = action.id;
const [isOver, setIsOver] = useState(false);
const name = action.name ? action.name : '';

const actionList = action.value;

Expand Down Expand Up @@ -51,9 +52,26 @@ const ActionSet = ({ action, ...props }) => {
</div>
) : (
<div className="w-full px-2">
<Accordion type="single" collapsible defaultValue="item-1">
<Accordion type="single" collapsible defaultValue="item-1" className="w-full">
<AccordionItem value="item-1">
<AccordionTrigger>Sub Actions</AccordionTrigger>
<AccordionTrigger>
<input
type="search"
autoComplete="off"
className="focus:border-blue-3 w-2/3 rounded-md border-none bg-slate-300 px-2 py-1 text-lg italic text-gray-900 hover:border-blue-300 "
placeholder="Change Action Set Name"
value={name}
name="actionsetlabel"
onChange={e =>
dispatch(
actionListActions.setActionName({
actionId: action.id,
name: e.target.value,
})
)
}
/>
</AccordionTrigger>
<AccordionContent>
<ActionContainer actionList={actionList}></ActionContainer>
</AccordionContent>
Expand All @@ -69,7 +87,7 @@ const ActionSet = ({ action, ...props }) => {
{...props}
>
<div className=" flex flex-1 items-center justify-end">
<div className="flex w-full items-center justify-end text-black">
<div className="flex w-full flex-col items-start justify-center text-black">
<div className="my-3 flex w-full flex-1 items-center justify-center rounded-md bg-action-data shadow">
{body}
</div>
Expand All @@ -84,6 +102,7 @@ ActionSet.propTypes = {
type: PropTypes.string.isRequired,
id: PropTypes.number.isRequired,
value: PropTypes.arrayOf(PropTypes.any).isRequired,
name: PropTypes.string,
}).isRequired,
};

Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/actions/ActionsPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ const ActionPanel = () => {
let play_or_stop = {
icon: null,
color: null,
hoverColor: null,
hovercolor: null,
text: null,
};

if (valid) {
if (running) {
play_or_stop.icon = <StopIcon className="text-3xl text-white" />;
play_or_stop.color = 'bg-red-400';
play_or_stop.hoverColor = 'hover:bg-red-500';
play_or_stop.hovercolor = 'hover:bg-red-500';
play_or_stop.text = 'Stop';
} else {
play_or_stop.icon = <PlayArrowIcon className="text-3xl text-white" />;
play_or_stop.color = 'bg-green-400';
play_or_stop.hoverColor = 'hover:bg-green-500';
play_or_stop.hovercolor = 'hover:bg-green-500';
play_or_stop.text = 'Run';
}
} else {
play_or_stop.icon = <ErrorIcon className="text-3xl text-white" />;
play_or_stop.color = 'bg-orange-400';
play_or_stop.hoverColor = 'hover:bg-orange-500';
play_or_stop.hovercolor = 'hover:bg-orange-500';
play_or_stop.text = 'Errors';
}

Expand All @@ -85,7 +85,7 @@ const ActionPanel = () => {
<div className="absolute bottom-10 right-8 z-20">
<Button
color={play_or_stop.color}
hoverColor={play_or_stop.hoverColor}
hovercolor={play_or_stop.hoverColor}
onClick={handleClickPlayStop}
disabled={!valid}
>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/actions/ToolBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ToolBar = () => {
bgColor: 'bg-action-move',
type: ActionTypes.MOVE,
value: moveValue,
hoverColor: 'hover:bg-action-move-hover',
hovercolor: 'hover:bg-action-move-hover',
helpText: 'Move Addction: Move to a pose',
},
{
Expand All @@ -51,7 +51,7 @@ const ToolBar = () => {
bgColor: 'bg-action-sleep',
type: ActionTypes.SLEEP,
value: { duration: 2 },
hoverColor: 'hover:bg-action-sleep-hover',
hovercolor: 'hover:bg-action-sleep-hover',
helpText: 'Sleep Action: Pause movement',
},
{
Expand All @@ -60,7 +60,7 @@ const ToolBar = () => {
bgColor: 'bg-action-tool',
type: ActionTypes.TOOL,
value: { toolValue: 0 },
hoverColor: 'hover:bg-action-tool-hover',
hovercolor: 'hover:bg-action-tool-hover',
helpText: 'Tool Action: Change tool value',
},
{
Expand All @@ -69,7 +69,7 @@ const ToolBar = () => {
bgColor: 'bg-action-set',
type: ActionTypes.ACTIONSET,
value: [],
hoverColor: 'hover:bg-action-set-hover',
hovercolor: 'hover:bg-action-set-hover',
helpText: 'Action Set: Set of actions',
},
];
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/actions/ToolBarElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ToolBarElement = ({ element }) => {
<Tooltip delayDuration={300}>
<TooltipTrigger>
<div
className={`flex h-14 w-20 shrink grow basis-0 items-center justify-center gap-2.5 ${element.bgColor} ${element.hoverColor}`}
className={`flex h-14 w-20 shrink grow basis-0 items-center justify-center gap-2.5 ${element.bgColor} ${element.hovercolor}`}
ref={dragRef}
onClick={addToActionList}
>
Expand All @@ -60,7 +60,7 @@ ToolBarElement.propTypes = {
icon: PropTypes.object.isRequired,
bgColor: PropTypes.string.isRequired,
value: PropTypes.any.isRequired,
hoverColor: PropTypes.string.isRequired,
hovercolor: PropTypes.string.isRequired,
helpText: PropTypes.string.isRequired,
}).isRequired,
};
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/components/armsimulation/ArmSimulation.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const ArmSimulation = () => {
// const simulation_url = process.env.NEXT_PUBLIC_ARM_SIMULATION_URL;
// const websocket_port = process.env.NEXT_PUBLIC_ARM_SIMULATION_WEBSOCKET_PORT;
// const websocket_host = process.env.NEXT_PUBLIC_ARM_SIMULATION_WEBSOCKET_HOST;
const simulation_url = import.meta.env.VITE_ARM_SIMULATION_URL;
const websocket_port = import.meta.env.VITE_ARM_SIMULATION_WEBSOCKET_PORT;
const websocket_host = import.meta.env.VITE_ARM_SIMULATION_WEBSOCKET_HOST;
Expand Down
163 changes: 163 additions & 0 deletions frontend/src/components/ui/context-menu.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import * as React from 'react';
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu';
import { Check, ChevronRight, Circle } from 'lucide-react';

import { cn } from '@/lib/utils';

const ContextMenu = ContextMenuPrimitive.Root;

const ContextMenuTrigger = ContextMenuPrimitive.Trigger;

const ContextMenuGroup = ContextMenuPrimitive.Group;

const ContextMenuPortal = ContextMenuPrimitive.Portal;

const ContextMenuSub = ContextMenuPrimitive.Sub;

const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;

const ContextMenuSubTrigger = React.forwardRef(({ className, inset, children, ...props }, ref) => (
<ContextMenuPrimitive.SubTrigger
ref={ref}
className={cn(
'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',
inset && 'pl-8',
className
)}
{...props}
>
{children}
<ChevronRight className="ml-auto h-4 w-4" />
</ContextMenuPrimitive.SubTrigger>
));
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;

const ContextMenuSubContent = React.forwardRef(({ className, ...props }, ref) => (
<ContextMenuPrimitive.SubContent
ref={ref}
className={cn(
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
className
)}
{...props}
/>
));
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;

const ContextMenuContent = React.forwardRef(({ className, ...props }, ref) => (
<ContextMenuPrimitive.Portal>
<ContextMenuPrimitive.Content
ref={ref}
className={cn(
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
className
)}
{...props}
/>
</ContextMenuPrimitive.Portal>
));
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;

const ContextMenuItem = React.forwardRef(({ className, inset, ...props }, ref) => (
<ContextMenuPrimitive.Item
ref={ref}
className={cn(
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
inset && 'pl-8',
className
)}
{...props}
/>
));
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;

const ContextMenuCheckboxItem = React.forwardRef(
({ className, children, checked, ...props }, ref) => (
<ContextMenuPrimitive.CheckboxItem
ref={ref}
className={cn(
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
className
)}
checked={checked}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<ContextMenuPrimitive.ItemIndicator>
<Check className="h-4 w-4" />
</ContextMenuPrimitive.ItemIndicator>
</span>
{children}
</ContextMenuPrimitive.CheckboxItem>
)
);
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;

const ContextMenuRadioItem = React.forwardRef(({ className, children, ...props }, ref) => (
<ContextMenuPrimitive.RadioItem
ref={ref}
className={cn(
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
className
)}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<ContextMenuPrimitive.ItemIndicator>
<Circle className="h-2 w-2 fill-current" />
</ContextMenuPrimitive.ItemIndicator>
</span>
{children}
</ContextMenuPrimitive.RadioItem>
));
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;

const ContextMenuLabel = React.forwardRef(({ className, inset, ...props }, ref) => (
<ContextMenuPrimitive.Label
ref={ref}
className={cn(
'px-2 py-1.5 text-sm font-semibold text-foreground',
inset && 'pl-8',
className
)}
{...props}
/>
));
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;

const ContextMenuSeparator = React.forwardRef(({ className, ...props }, ref) => (
<ContextMenuPrimitive.Separator
ref={ref}
className={cn('-mx-1 my-1 h-px bg-border', className)}
{...props}
/>
));
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;

const ContextMenuShortcut = ({ className, ...props }) => {
return (
<span
className={cn('ml-auto text-xs tracking-widest text-muted-foreground', className)}
{...props}
/>
);
};
ContextMenuShortcut.displayName = 'ContextMenuShortcut';

export {
ContextMenu,
ContextMenuTrigger,
ContextMenuContent,
ContextMenuItem,
ContextMenuCheckboxItem,
ContextMenuRadioItem,
ContextMenuLabel,
ContextMenuSeparator,
ContextMenuShortcut,
ContextMenuGroup,
ContextMenuPortal,
ContextMenuSub,
ContextMenuSubContent,
ContextMenuSubTrigger,
ContextMenuRadioGroup,
};
Loading

0 comments on commit 76a81d3

Please sign in to comment.