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

Hammer/demo tasks #925

Merged
merged 32 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
11f27ab
Moved custom deliveries to separate file naively and import naively
aaronchongth Mar 26, 2024
6eae244
Moved patrol
aaronchongth Mar 27, 2024
9bda508
Moved custom-compose
aaronchongth Mar 27, 2024
e0d07f8
Added clean and delivery
aaronchongth Mar 27, 2024
9947d87
Added delivery, renamed to SimpleDelivery
aaronchongth Mar 27, 2024
c780d63
Clean task added
aaronchongth Mar 27, 2024
ec851b7
Moved delivery-custom tests, added return type for forms
aaronchongth Mar 27, 2024
25fe0f3
Configurable supported tasks and name remapping
aaronchongth Mar 28, 2024
b5a8b76
Changed directory to types, since it doesn't just handle descriptions
aaronchongth Mar 28, 2024
2c52928
Fix test imports
aaronchongth Mar 28, 2024
eb9aeda
Using temporary task definition
aaronchongth Apr 2, 2024
ebd5f19
Merge branch 'deploy/hammer' into hammer/demo-tasks
aaronchongth Jun 3, 2024
01139aa
Refactoring new rename changes
aaronchongth Jun 3, 2024
1069946
Clean up
aaronchongth Jun 4, 2024
1edb5e9
Removed problematic and unsused component and test
aaronchongth Jun 4, 2024
d51646e
Lint
aaronchongth Jun 6, 2024
963ec12
Merge branch 'deploy/hammer' into hammer/demo-tasks
aaronchongth Jun 6, 2024
1901697
Updating pnpm version in github workflow
aaronchongth Jun 6, 2024
a1d3140
Reverting update to pnpm version
aaronchongth Jun 6, 2024
114631e
Fix build now that we use key value strings for labels
aaronchongth Jun 6, 2024
c421aa3
Refactored last parts of hard coding categories and rendering forms
aaronchongth Jun 6, 2024
5b102cb
Merge branch 'deploy/hammer' into hammer/demo-tasks
aaronchongth Jun 12, 2024
bce846f
Refactor callback names and error handling for misconfigs
aaronchongth Jun 19, 2024
bde2649
Display error as well
aaronchongth Jun 19, 2024
d452aff
Fixed more checks and failures
aaronchongth Jun 19, 2024
7f7eb62
Split configuration and definition, only handle configurations in res…
aaronchongth Jun 19, 2024
3573c59
Lint
aaronchongth Jun 19, 2024
2f3a1a7
Not using object as a type
aaronchongth Jun 19, 2024
ba6be30
Address feedback
aaronchongth Jun 25, 2024
0e803cb
Render using validTasks instead
aaronchongth Jun 25, 2024
f2c0b08
Use useMemo
aaronchongth Jun 25, 2024
ce58404
Merge branch 'deploy/hammer' into hammer/demo-tasks
aaronchongth Jun 26, 2024
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
2 changes: 2 additions & 0 deletions packages/dashboard/src/components/appbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@ export const AppBar = React.memo(({ extraToolbarItems }: AppBarProps): React.Rea
{openCreateTaskForm && (
<CreateTaskForm
user={username ? username : 'unknown user'}
supportedTasks={resourceManager?.tasks.supportedTasks}
taskNameRemap={resourceManager?.tasks.taskNameRemap}
patrolWaypoints={waypointNames}
cleaningZones={cleaningZoneNames}
pickupZones={resourceManager?.pickupZones}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,11 @@ export const apiScheduleToSchedule = (scheduleTask: ApiSchedule[]): Schedule =>
};
};

export const getScheduledTaskTitle = (task: ScheduledTask): string => {
const shortDescription = getShortDescription(task.task_request);
export const getScheduledTaskTitle = (
task: ScheduledTask,
taskNameRemap?: Record<string, string>,
): string => {
const shortDescription = getShortDescription(task.task_request, taskNameRemap);
if (!task.task_request || !task.task_request.category || !shortDescription) {
return `[${task.id}] Unknown`;
}
Expand Down
7 changes: 4 additions & 3 deletions packages/dashboard/src/components/tasks/task-schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from 'react-components';
import { useCreateTaskFormData } from '../../hooks/useCreateTaskForm';
import useGetUsername from '../../hooks/useFetchUser';
import { AppControllerContext } from '../app-contexts';
import { AppControllerContext, ResourcesContext } from '../app-contexts';
import { UserProfileContext } from 'rmf-auth';
import { AppEvents } from '../app-events';
import { RmfAppContext } from '../rmf-app';
Expand Down Expand Up @@ -69,6 +69,7 @@ const disablingCellsWithoutEvents = (

export const TaskSchedule = () => {
const rmf = React.useContext(RmfAppContext);
const resourceManager = React.useContext(ResourcesContext);
const { showAlert } = React.useContext(AppControllerContext);
const profile = React.useContext(UserProfileContext);

Expand Down Expand Up @@ -136,7 +137,7 @@ export const TaskSchedule = () => {
return tasks.flatMap((t: ScheduledTask) =>
t.schedules.flatMap<ProcessedEvent>((s: ApiSchedule) => {
const events = scheduleToEvents(params.start, params.end, s, t, getEventId, () =>
getScheduledTaskTitle(t),
getScheduledTaskTitle(t, resourceManager?.tasks.taskNameRemap),
);
events.forEach((ev) => {
eventsMap.current[Number(ev.event_id)] = t;
Expand All @@ -146,7 +147,7 @@ export const TaskSchedule = () => {
}),
);
},
[rmf],
[rmf, resourceManager],
);

const CustomCalendarEditor = ({ scheduler, value, onChange }: CustomCalendarEditorProps) => {
Expand Down
16 changes: 16 additions & 0 deletions packages/dashboard/src/managers/resource-manager-tasks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export class TaskResourceManager {
supportedTasks: string[] = ['patrol', 'delivery', 'clean'];
taskNameRemap: Record<string, string> = {};

constructor(
supportedTasks: string[] | undefined,
taskNameRemap: Record<string, string> | undefined,
) {
if (supportedTasks) {
this.supportedTasks = supportedTasks;
}
if (taskNameRemap) {
this.taskNameRemap = taskNameRemap;
}
}
}
9 changes: 9 additions & 0 deletions packages/dashboard/src/managers/resource-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Debug from 'debug';
import { DispenserResourceManager, RawDispenserResource } from './resource-manager-dispensers';
import { LogoResource, LogoResourceManager } from './resource-manager-logos';
import { RobotResource, RobotResourceManager } from './resource-manager-robots';
import { TaskResourceManager } from './resource-manager-tasks';

const debug = Debug('ResourceManager');
const ResourceFile = 'resources/main.json';
Expand All @@ -19,6 +20,8 @@ export interface ResourceConfigurationsType {
cartIds?: string[];
loggedInDisplayLevel?: string;
emergencyLots?: string[];
supportedTasks?: string[];
taskNameRemap?: Record<string, string>; // Record<OriginalName, NewName>
}

export default class ResourceManager {
Expand All @@ -34,6 +37,8 @@ export default class ResourceManager {
cartIds?: string[];
loggedInDisplayLevel?: string;
emergencyLots?: string[];
supportedTasks?: string[];
tasks: TaskResourceManager;

/**
* Gets the default resource manager using the embedded resource file (aka "assets/resources/main.json").
Expand Down Expand Up @@ -74,6 +79,10 @@ export default class ResourceManager {
this.cartIds = resources.cartIds || [];
this.loggedInDisplayLevel = resources.loggedInDisplayLevel;
this.emergencyLots = resources.emergencyLots || [];
this.tasks = new TaskResourceManager(
resources.supportedTasks || ['patrol', 'delivery', 'clean'],
resources.taskNameRemap,
);
}
}

Expand Down
Loading
Loading