From 267b3d1fcb14ff11c4a23c2c2f16c5a036f00e04 Mon Sep 17 00:00:00 2001 From: Teo Koon Peng Date: Thu, 21 Mar 2024 16:42:05 +0800 Subject: [PATCH] update api-client Signed-off-by: Teo Koon Peng --- packages/api-client/lib/openapi/api.ts | 4 +-- packages/api-client/lib/version.ts | 2 +- packages/api-client/schema/index.ts | 2 +- .../api-server/api_server/models/tasks.py | 3 +- packages/dashboard/package.json | 2 +- .../dashboard/src/components/alert-store.tsx | 2 +- .../dashboard/src/components/app-events.ts | 2 +- packages/dashboard/src/components/appbar.tsx | 2 +- .../dashboard/src/components/beacons-app.tsx | 2 +- packages/dashboard/src/components/map-app.tsx | 10 +----- .../src/components/rmf-app/rmf-ingress.ts | 9 ++--- .../src/components/robots/robot-info-app.tsx | 6 ++-- .../src/components/robots/robot-summary.tsx | 14 +++++--- .../src/components/robots/robots-app.tsx | 9 ++--- .../src/components/tasks/task-alert.tsx | 18 +++++----- .../src/components/tasks/task-logs.tsx | 31 +++++++++-------- .../components/tasks/task-schedule-utils.ts | 9 ++--- .../src/components/tasks/task-schedule.tsx | 5 +-- .../src/components/tasks/task-summary.tsx | 10 +++--- packages/dashboard/src/components/utils.ts | 3 +- .../src/util/common-subscriptions.ts | 10 +----- .../lib/beacons/beacon-table-datagrid.tsx | 2 +- .../lib/robots/robot-info.tsx | 2 +- .../lib/robots/robot-table-datagrid.tsx | 8 ++--- packages/react-components/lib/robots/utils.ts | 18 +++++----- .../lib/tasks/task-table-datagrid.tsx | 12 +++---- .../react-components/lib/tasks/task-table.tsx | 12 +++---- .../lib/tasks/task-timeline.tsx | 33 +++++++++++-------- 28 files changed, 116 insertions(+), 126 deletions(-) diff --git a/packages/api-client/lib/openapi/api.ts b/packages/api-client/lib/openapi/api.ts index a4384060e..d9c6d258b 100644 --- a/packages/api-client/lib/openapi/api.ts +++ b/packages/api-client/lib/openapi/api.ts @@ -1713,10 +1713,10 @@ export interface ScheduledTask { id: number; /** * - * @type {object} + * @type {TaskRequest} * @memberof ScheduledTask */ - task_request: object; + task_request: TaskRequest; /** * * @type {string} diff --git a/packages/api-client/lib/version.ts b/packages/api-client/lib/version.ts index 078a9bc2f..d7c528695 100644 --- a/packages/api-client/lib/version.ts +++ b/packages/api-client/lib/version.ts @@ -3,6 +3,6 @@ import { version as rmfModelVer } from 'rmf-models'; export const version = { rmfModels: rmfModelVer, - rmfServer: '757c200c2133f69e3321bc6bc2ba392fb522f3c9', + rmfServer: '0c773dc3f4b1a5df8bccb1b9da9d66fc3b075b28', openapiGenerator: '', }; diff --git a/packages/api-client/schema/index.ts b/packages/api-client/schema/index.ts index b4f868031..36e796e52 100644 --- a/packages/api-client/schema/index.ts +++ b/packages/api-client/schema/index.ts @@ -3579,7 +3579,7 @@ export default { ScheduledTask: { properties: { id: { type: 'integer', title: 'Id' }, - task_request: { type: 'object', title: 'Task Request' }, + task_request: { $ref: '#/components/schemas/TaskRequest' }, created_by: { type: 'string', title: 'Created By' }, schedules: { items: { $ref: '#/components/schemas/ScheduledTaskSchedule' }, diff --git a/packages/api-server/api_server/models/tasks.py b/packages/api-server/api_server/models/tasks.py index b3dd7773f..69e0cc2b0 100644 --- a/packages/api-server/api_server/models/tasks.py +++ b/packages/api-server/api_server/models/tasks.py @@ -3,6 +3,7 @@ from pydantic import BaseModel, ConfigDict +from .rmf_api.task_request import TaskRequest from .tortoise_support import TortoiseReverseRelation @@ -32,7 +33,7 @@ class ScheduledTask(BaseModel): model_config = ConfigDict(from_attributes=True) id: int - task_request: dict + task_request: TaskRequest created_by: str schedules: TortoiseReverseRelation[ScheduledTaskSchedule] last_ran: datetime | None = None diff --git a/packages/dashboard/package.json b/packages/dashboard/package.json index 067149f16..edf033597 100644 --- a/packages/dashboard/package.json +++ b/packages/dashboard/package.json @@ -61,7 +61,7 @@ "@types/three": "^0.156.0", "ajv": "^8.10.0", "api-client": "workspace:*", - "axios": "^1.6.8", + "axios": "^0.21.1", "date-fns": "^2.21.3", "debug": "^4.2.0", "eventemitter3": "^4.0.7", diff --git a/packages/dashboard/src/components/alert-store.tsx b/packages/dashboard/src/components/alert-store.tsx index 95e0db09e..6bf05e742 100644 --- a/packages/dashboard/src/components/alert-store.tsx +++ b/packages/dashboard/src/components/alert-store.tsx @@ -1,4 +1,4 @@ -import { ApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert } from 'api-client'; +import { TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert } from 'api-client'; import { AppEvents } from './app-events'; import React from 'react'; import { RmfAppContext } from './rmf-app'; diff --git a/packages/dashboard/src/components/app-events.ts b/packages/dashboard/src/components/app-events.ts index 78779578c..ec3ace5cb 100644 --- a/packages/dashboard/src/components/app-events.ts +++ b/packages/dashboard/src/components/app-events.ts @@ -1,5 +1,5 @@ import { - ApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert, + TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert, Dispenser, Door, Ingestor, diff --git a/packages/dashboard/src/components/appbar.tsx b/packages/dashboard/src/components/appbar.tsx index 39a846ae9..499532996 100644 --- a/packages/dashboard/src/components/appbar.tsx +++ b/packages/dashboard/src/components/appbar.tsx @@ -25,7 +25,7 @@ import { Typography, } from '@mui/material'; import { - ApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert, + TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert, TaskFavoritePydantic as TaskFavorite, TaskRequest, } from 'api-client'; diff --git a/packages/dashboard/src/components/beacons-app.tsx b/packages/dashboard/src/components/beacons-app.tsx index 2f6399d79..44a7ec545 100644 --- a/packages/dashboard/src/components/beacons-app.tsx +++ b/packages/dashboard/src/components/beacons-app.tsx @@ -1,4 +1,4 @@ -import { ApiServerModelsTortoiseModelsBeaconsBeaconStateLeaf as BeaconState } from 'api-client'; +import { TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsBeaconsBeaconStateLeaf as BeaconState } from 'api-client'; import React from 'react'; import { BeaconDataGridTable } from 'react-components'; import { createMicroApp } from './micro-app'; diff --git a/packages/dashboard/src/components/map-app.tsx b/packages/dashboard/src/components/map-app.tsx index b9826aa06..609d56613 100644 --- a/packages/dashboard/src/components/map-app.tsx +++ b/packages/dashboard/src/components/map-app.tsx @@ -1,11 +1,5 @@ import { styled } from '@mui/material'; -import { - BuildingMap, - Dispenser, - ApiServerModelsRmfApiFleetStateFleetState, - Ingestor, - Level, -} from 'api-client'; +import { BuildingMap, Dispenser, FleetState, Ingestor, Level } from 'api-client'; import Debug from 'debug'; import React, { ChangeEvent, Suspense } from 'react'; import { @@ -35,8 +29,6 @@ import { Line } from '@react-three/drei'; import { CameraControl, LayersController } from './three-fiber'; import { Lifts, Door, RobotThree } from './three-fiber'; -type FleetState = ApiServerModelsRmfApiFleetStateFleetState; - const debug = Debug('MapApp'); const TrajectoryUpdateInterval = 2000; diff --git a/packages/dashboard/src/components/rmf-app/rmf-ingress.ts b/packages/dashboard/src/components/rmf-app/rmf-ingress.ts index ed68240e7..c5a43c5a7 100644 --- a/packages/dashboard/src/components/rmf-app/rmf-ingress.ts +++ b/packages/dashboard/src/components/rmf-app/rmf-ingress.ts @@ -1,8 +1,8 @@ import { AdminApi, AlertsApi, - ApiServerModelsTortoiseModelsAlertsAlertLeaf, - ApiServerModelsTortoiseModelsBeaconsBeaconStateLeaf as BeaconState, + TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert, + TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsBeaconsBeaconStateLeaf as BeaconState, BeaconsApi, BuildingApi, BuildingMap, @@ -15,7 +15,7 @@ import { DoorsApi, DoorState, FleetsApi, - ApiServerModelsRmfApiFleetStateFleetState, + FleetState, Ingestor, IngestorsApi, IngestorState, @@ -37,9 +37,6 @@ import { RobotTrajectoryManager, } from '../../managers/robot-trajectory-manager'; -type Alert = ApiServerModelsTortoiseModelsAlertsAlertLeaf; -type FleetState = ApiServerModelsRmfApiFleetStateFleetState; - export class RmfIngress { // This should be private because socketio does not support "replaying" subscription. If // subscription is made before the one made by the observables, the replays will not work diff --git a/packages/dashboard/src/components/robots/robot-info-app.tsx b/packages/dashboard/src/components/robots/robot-info-app.tsx index 2bfbc3a51..8457054f2 100644 --- a/packages/dashboard/src/components/robots/robot-info-app.tsx +++ b/packages/dashboard/src/components/robots/robot-info-app.tsx @@ -63,9 +63,9 @@ export const RobotInfoApp = createMicroApp('Robot Info', () => { {robotState ? ( diff --git a/packages/dashboard/src/components/robots/robot-summary.tsx b/packages/dashboard/src/components/robots/robot-summary.tsx index 019bab9fd..7384b5507 100644 --- a/packages/dashboard/src/components/robots/robot-summary.tsx +++ b/packages/dashboard/src/components/robots/robot-summary.tsx @@ -17,7 +17,11 @@ import { makeStyles, createStyles } from '@mui/styles'; import React from 'react'; import { RmfAppContext } from '../rmf-app'; import { RobotTableData, base } from 'react-components'; -import { RobotState, Status2, TaskState } from 'api-client'; +import { + RobotState, + ApiServerModelsRmfApiRobotStateStatus as RobotStatus, + TaskState, +} from 'api-client'; import { EMPTY, combineLatest, mergeMap, of } from 'rxjs'; import { TaskInspector } from '../tasks/task-inspector'; import { @@ -44,16 +48,16 @@ const useStyles = makeStyles((theme: Theme) => }), ); -const setTaskDialogColor = (robotStatus: Status2 | undefined) => { +const setTaskDialogColor = (robotStatus?: RobotStatus | null) => { if (!robotStatus) { return base.palette.background.default; } switch (robotStatus) { - case Status2.Error: + case RobotStatus.Error: return base.palette.error.dark; - case Status2.Working: + case RobotStatus.Working: return base.palette.success.dark; default: @@ -82,7 +86,7 @@ interface RobotSummaryProps { } const showBatteryIcon = (robot: RobotState, robotBattery: number) => { - if (robot.status === Status2.Charging) { + if (robot.status === RobotStatus.Charging) { return ; } diff --git a/packages/dashboard/src/components/robots/robots-app.tsx b/packages/dashboard/src/components/robots/robots-app.tsx index 54416ec94..c839175ff 100644 --- a/packages/dashboard/src/components/robots/robots-app.tsx +++ b/packages/dashboard/src/components/robots/robots-app.tsx @@ -71,12 +71,13 @@ export const RobotsApp = createMicroApp('Robots', () => { ? Object.entries(fleet.robots).map(([name, robot]) => ({ fleet: fleet.name || '', name, - battery: robot.battery && +robot.battery.toFixed(2), + battery: robot.battery != null ? +robot.battery.toFixed(2) : undefined, status: robot.status, estFinishTime: - robot.task_id && tasks[robot.task_id] - ? tasks[robot.task_id].unix_millis_finish_time - : undefined, + (robot.task_id && + tasks[robot.task_id] && + tasks[robot.task_id].unix_millis_finish_time) || + undefined, lastUpdateTime: robot.unix_millis_time ? robot.unix_millis_time : undefined, level: robot.location?.map || 'N/A', })) diff --git a/packages/dashboard/src/components/tasks/task-alert.tsx b/packages/dashboard/src/components/tasks/task-alert.tsx index a7dcdb9df..10acf50a1 100644 --- a/packages/dashboard/src/components/tasks/task-alert.tsx +++ b/packages/dashboard/src/components/tasks/task-alert.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { - ApiServerModelsTortoiseModelsAlertsAlertLeaf, + TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert, LogEntry, - Status, + ApiServerModelsRmfApiTaskStateStatus as TaskStatus, TaskEventLog, TaskState, Tier, @@ -13,8 +13,6 @@ import { AlertContent, AlertDialog } from 'react-components'; import { base } from 'react-components'; import { TaskInspector } from './task-inspector'; -type Alert = ApiServerModelsTortoiseModelsAlertsAlertLeaf; - interface TaskAlert extends TaskEventLog { title: string; progress?: number; @@ -51,7 +49,7 @@ export function TaskAlertDialog({ alert, removeAlert }: TaskAlertDialogProps): J }; const getAlertTitle = (state: TaskState, errorLogEntries: LogEntry[]) => { - if (state.status && state.status === Status.Completed) { + if (state.status && state.status === TaskStatus.Completed) { return 'Task completed'; } if (errorLogEntries.length !== 0) { @@ -61,7 +59,7 @@ export function TaskAlertDialog({ alert, removeAlert }: TaskAlertDialogProps): J }; const getTaskProgress = (state: TaskState) => { - if (state.status && state.status === Status.Completed) { + if (state.status && state.status === TaskStatus.Completed) { return 1; } @@ -104,7 +102,7 @@ export function TaskAlertDialog({ alert, removeAlert }: TaskAlertDialogProps): J // If the task happen to complete anyway, we mention that it has completed // in a separate log - if (state.status && state.status === Status.Completed) { + if (state.status && state.status === TaskStatus.Completed) { const completionTimeString = state.unix_millis_finish_time ? `${new Date(state.unix_millis_finish_time).toLocaleString()} - ` : ''; @@ -124,11 +122,11 @@ export function TaskAlertDialog({ alert, removeAlert }: TaskAlertDialogProps): J const getAlertColor = (state: TaskState, errorLogs: LogEntry[]) => { if (state.status) { switch (state.status) { - case Status.Completed: + case TaskStatus.Completed: return base.palette.success.dark; - case Status.Error: - case Status.Failed: + case TaskStatus.Error: + case TaskStatus.Failed: return base.palette.error.dark; default: diff --git a/packages/dashboard/src/components/tasks/task-logs.tsx b/packages/dashboard/src/components/tasks/task-logs.tsx index f8b4870af..e24ca9a3e 100644 --- a/packages/dashboard/src/components/tasks/task-logs.tsx +++ b/packages/dashboard/src/components/tasks/task-logs.tsx @@ -1,5 +1,10 @@ import { Box, Divider, Grid, Paper, Typography, useTheme } from '@mui/material'; -import { EventState, Status, TaskEventLog, TaskState } from 'api-client'; +import { + EventState, + ApiServerModelsRmfApiTaskStateStatus as TaskStatus, + TaskEventLog, + TaskState, +} from 'api-client'; import { format } from 'date-fns'; interface TaskLogProps { @@ -19,28 +24,28 @@ export function TaskLogs({ taskLog, taskState, title }: TaskLogProps) { if (event == null || event.status == null) return theme.palette.warning.light; switch (event.status) { - case Status.Uninitialized: - case Status.Blocked: - case Status.Error: - case Status.Failed: + case TaskStatus.Uninitialized: + case TaskStatus.Blocked: + case TaskStatus.Error: + case TaskStatus.Failed: return theme.palette.error.dark; - case Status.Queued: - case Status.Standby: + case TaskStatus.Queued: + case TaskStatus.Standby: return theme.palette.info.light; - case Status.Underway: + case TaskStatus.Underway: return theme.palette.success.light; - case Status.Delayed: + case TaskStatus.Delayed: return theme.palette.warning.main; - case Status.Skipped: - case Status.Canceled: - case Status.Killed: + case TaskStatus.Skipped: + case TaskStatus.Canceled: + case TaskStatus.Killed: return theme.palette.error.light; - case Status.Completed: + case TaskStatus.Completed: return theme.palette.info.light; default: diff --git a/packages/dashboard/src/components/tasks/task-schedule-utils.ts b/packages/dashboard/src/components/tasks/task-schedule-utils.ts index 209280ce4..6831b49e8 100644 --- a/packages/dashboard/src/components/tasks/task-schedule-utils.ts +++ b/packages/dashboard/src/components/tasks/task-schedule-utils.ts @@ -1,8 +1,5 @@ import { ProcessedEvent } from '@aldabil/react-scheduler/types'; -import { - ApiServerModelsTortoiseModelsScheduledTaskScheduledTask as ScheduledTask, - ApiServerModelsTortoiseModelsScheduledTaskScheduledTaskScheduleLeaf as ApiSchedule, -} from 'api-client'; +import { ScheduledTask, ScheduledTaskSchedule as ApiSchedule } from 'api-client'; import { addMinutes, endOfDay, @@ -103,7 +100,7 @@ export const scheduleToEvents = ( ) { const curToIso = cur.toISOString(); const curFormatted = `${curToIso.slice(0, 10)}`; - if (!task.except_dates.includes(curFormatted)) { + if (!task.except_dates?.includes(curFormatted)) { events.push({ start: cur, end: addMinutes(cur, 45), @@ -162,5 +159,5 @@ export const getScheduledTaskTitle = (task: ScheduledTask): string => { return `[${task.id}] Unknown`; } - return `${getShortDescription(task.task_request)}`; + return task.task_request ? getShortDescription(task.task_request) : ''; }; diff --git a/packages/dashboard/src/components/tasks/task-schedule.tsx b/packages/dashboard/src/components/tasks/task-schedule.tsx index 306593951..7ab8dd48b 100644 --- a/packages/dashboard/src/components/tasks/task-schedule.tsx +++ b/packages/dashboard/src/components/tasks/task-schedule.tsx @@ -6,10 +6,7 @@ import { SchedulerProps, } from '@aldabil/react-scheduler/types'; import { Button } from '@mui/material'; -import { - ApiServerModelsTortoiseModelsScheduledTaskScheduledTask as ScheduledTask, - ApiServerModelsTortoiseModelsScheduledTaskScheduledTaskScheduleLeaf as ApiSchedule, -} from 'api-client'; +import { ScheduledTask, ScheduledTaskSchedule as ApiSchedule } from 'api-client'; import React from 'react'; import { ConfirmationDialog, diff --git a/packages/dashboard/src/components/tasks/task-summary.tsx b/packages/dashboard/src/components/tasks/task-summary.tsx index 3371012a2..5c9648d17 100644 --- a/packages/dashboard/src/components/tasks/task-summary.tsx +++ b/packages/dashboard/src/components/tasks/task-summary.tsx @@ -14,7 +14,7 @@ import DialogActions from '@mui/material/DialogActions'; import DialogContent from '@mui/material/DialogContent'; import DialogTitle from '@mui/material/DialogTitle'; import { makeStyles, createStyles } from '@mui/styles'; -import { Status, TaskState } from 'api-client'; +import { ApiServerModelsRmfApiTaskStateStatus as TaskStatus, TaskState } from 'api-client'; import { base } from 'react-components'; import { TaskInspector } from './task-inspector'; import { RmfAppContext } from '../rmf-app'; @@ -45,19 +45,19 @@ const LinearProgressWithLabel = (props: LinearProgressProps & { value: number }) ); }; -const setTaskDialogColor = (taskStatus: Status | undefined) => { +const setTaskDialogColor = (taskStatus?: TaskStatus | null) => { if (!taskStatus) { return base.palette.background.default; } switch (taskStatus) { - case Status.Failed: + case TaskStatus.Failed: return base.palette.error.dark; - case Status.Underway: + case TaskStatus.Underway: return base.palette.success.dark; - case Status.Queued: + case TaskStatus.Queued: return base.palette.info.main; default: diff --git a/packages/dashboard/src/components/utils.ts b/packages/dashboard/src/components/utils.ts index cdb1d6cb4..1fa82cab8 100644 --- a/packages/dashboard/src/components/utils.ts +++ b/packages/dashboard/src/components/utils.ts @@ -3,7 +3,8 @@ import schema from 'api-client/schema'; import { AxiosError } from 'axios'; export function getApiErrorMessage(error: unknown): string { - return (error as AxiosError).response?.data.detail || ''; + const body = (error as AxiosError).response?.data as any; + return typeof body === 'object' && body.detail ? body.detail : ''; } export const ajv = new Ajv(); diff --git a/packages/dashboard/src/util/common-subscriptions.ts b/packages/dashboard/src/util/common-subscriptions.ts index 6269c35d4..c79a12eec 100644 --- a/packages/dashboard/src/util/common-subscriptions.ts +++ b/packages/dashboard/src/util/common-subscriptions.ts @@ -1,16 +1,8 @@ import React from 'react'; import * as RmfModels from 'rmf-models'; -import { - ApiServerModelsRmfApiFleetStateFleetState, - SioClient, - Ingestor, - Dispenser, - Subscription, -} from 'api-client'; +import { FleetState, SioClient, Ingestor, Dispenser, Subscription } from 'api-client'; import { RmfIngress } from '../components/rmf-app/rmf-ingress'; -type FleetState = ApiServerModelsRmfApiFleetStateFleetState; - export const useFleets = ( rmfIngress: RmfIngress | undefined, setFleets: React.Dispatch>, diff --git a/packages/react-components/lib/beacons/beacon-table-datagrid.tsx b/packages/react-components/lib/beacons/beacon-table-datagrid.tsx index 5e0a790fa..c73a6c8d7 100644 --- a/packages/react-components/lib/beacons/beacon-table-datagrid.tsx +++ b/packages/react-components/lib/beacons/beacon-table-datagrid.tsx @@ -1,4 +1,4 @@ -import { ApiServerModelsTortoiseModelsBeaconsBeaconStateLeaf as BeaconState } from 'api-client'; +import { TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsBeaconsBeaconStateLeaf as BeaconState } from 'api-client'; import { DataGrid, GridColDef, GridValueGetterParams, GridCellParams } from '@mui/x-data-grid'; import { Box, SxProps, Typography, useTheme } from '@mui/material'; import React from 'react'; diff --git a/packages/react-components/lib/robots/robot-info.tsx b/packages/react-components/lib/robots/robot-info.tsx index 5d4efe5b6..829720580 100644 --- a/packages/react-components/lib/robots/robot-info.tsx +++ b/packages/react-components/lib/robots/robot-info.tsx @@ -4,7 +4,7 @@ import React from 'react'; import { CircularProgressBar } from './circular-progress-bar'; import { LinearProgressBar } from './linear-progress-bar'; -function getTaskStatusDisplay(assignedTask?: string, taskStatus?: string) { +function getTaskStatusDisplay(assignedTask?: string, taskStatus?: string | null) { if (assignedTask && !taskStatus) { return 'Unknown'; } diff --git a/packages/react-components/lib/robots/robot-table-datagrid.tsx b/packages/react-components/lib/robots/robot-table-datagrid.tsx index bee6db18b..7a33c55ff 100644 --- a/packages/react-components/lib/robots/robot-table-datagrid.tsx +++ b/packages/react-components/lib/robots/robot-table-datagrid.tsx @@ -9,7 +9,7 @@ import { } from '@mui/x-data-grid'; import { Box, SxProps, Typography, useTheme } from '@mui/material'; import * as React from 'react'; -import { Status2 } from 'api-client'; +import { ApiServerModelsRmfApiRobotStateStatus as RobotStatus } from 'api-client'; import { RobotTableData } from './robot-table'; import { robotStatusToUpperCase } from './utils'; @@ -45,11 +45,11 @@ export function RobotDataGridTable({ onRobotClick, robots }: RobotDataGridTableP }; switch (params.row.status) { - case Status2.Error: + case RobotStatus.Error: return error; - case Status2.Charging: + case RobotStatus.Charging: return charging; - case Status2.Working: + case RobotStatus.Working: return working; default: return defaultColor; diff --git a/packages/react-components/lib/robots/utils.ts b/packages/react-components/lib/robots/utils.ts index b6ca8f3a3..35bb1d66a 100644 --- a/packages/react-components/lib/robots/utils.ts +++ b/packages/react-components/lib/robots/utils.ts @@ -1,4 +1,4 @@ -import { Status2 } from 'api-client'; +import { ApiServerModelsRmfApiRobotStateStatus as RobotStatus } from 'api-client'; import { RobotMode as RmfRobotMode } from 'rmf-models'; /** @@ -8,21 +8,21 @@ export function robotHash(name: string, fleet: string): string { return `${name}__${fleet}`; } -export function robotStatusToUpperCase(status: Status2): string { +export function robotStatusToUpperCase(status: RobotStatus): string { switch (status) { - case Status2.Charging: + case RobotStatus.Charging: return 'CHARGING'; - case Status2.Idle: + case RobotStatus.Idle: return 'IDLE'; - case Status2.Working: + case RobotStatus.Working: return 'WORKING'; - case Status2.Offline: + case RobotStatus.Offline: return 'OFFLINE'; - case Status2.Uninitialized: + case RobotStatus.Uninitialized: return 'UNINITIALIZED'; - case Status2.Shutdown: + case RobotStatus.Shutdown: return 'SHUTDOWN'; - case Status2.Error: + case RobotStatus.Error: return 'ERROR'; default: return `UNKNOWN (${status})`; diff --git a/packages/react-components/lib/tasks/task-table-datagrid.tsx b/packages/react-components/lib/tasks/task-table-datagrid.tsx index 2ed3dee9e..10d546a69 100644 --- a/packages/react-components/lib/tasks/task-table-datagrid.tsx +++ b/packages/react-components/lib/tasks/task-table-datagrid.tsx @@ -13,7 +13,7 @@ import { } from '@mui/x-data-grid'; import { styled, TextField, Stack, Typography, Tooltip } from '@mui/material'; import * as React from 'react'; -import { TaskState, Status } from 'api-client'; +import { TaskState, ApiServerModelsRmfApiTaskStateStatus as TaskStatus } from 'api-client'; import { InsertInvitation as ScheduleIcon, Person as UserIcon } from '@mui/icons-material/'; const classes = { @@ -308,15 +308,15 @@ export function TaskDataGridTable({ getCellClassName={(params: GridCellParams) => { if (params.field === 'status') { switch (params.value) { - case Status.Underway: + case TaskStatus.Underway: return classes.taskActiveCell; - case Status.Completed: + case TaskStatus.Completed: return classes.taskCompletedCell; - case Status.Canceled: + case TaskStatus.Canceled: return classes.taskCancelledCell; - case Status.Failed: + case TaskStatus.Failed: return classes.taskFailedCell; - case Status.Queued: + case TaskStatus.Queued: return classes.taskQueuedCell; default: return classes.taskUnknownCell; diff --git a/packages/react-components/lib/tasks/task-table.tsx b/packages/react-components/lib/tasks/task-table.tsx index 65f2f8373..03f150ef2 100644 --- a/packages/react-components/lib/tasks/task-table.tsx +++ b/packages/react-components/lib/tasks/task-table.tsx @@ -9,7 +9,7 @@ import { TableRow, } from '@mui/material'; import { ArrowCircleDown, ArrowCircleUp } from '@mui/icons-material'; -import { Status, TaskState } from 'api-client'; +import { ApiServerModelsRmfApiTaskStateStatus as TaskStatus, TaskState } from 'api-client'; import clsx from 'clsx'; import React from 'react'; @@ -84,15 +84,15 @@ function TaskRow({ task, onClick }: TaskRowProps) { const getTaskStateCellClass = (task: TaskState) => { switch (task.status) { - case Status.Underway: + case TaskStatus.Underway: return classes.taskActiveCell; - case Status.Completed: + case TaskStatus.Completed: return classes.taskCompletedCell; - case Status.Canceled: + case TaskStatus.Canceled: return classes.taskCancelledCell; - case Status.Failed: + case TaskStatus.Failed: return classes.taskFailedCell; - case Status.Queued: + case TaskStatus.Queued: return classes.taskQueuedCell; default: return classes.taskUnknownCell; diff --git a/packages/react-components/lib/tasks/task-timeline.tsx b/packages/react-components/lib/tasks/task-timeline.tsx index 0fe30eb82..0cc45f4ec 100644 --- a/packages/react-components/lib/tasks/task-timeline.tsx +++ b/packages/react-components/lib/tasks/task-timeline.tsx @@ -15,7 +15,12 @@ import { } from '@mui/lab'; import { styled } from '@mui/material'; import Typography from '@mui/material/Typography'; -import { EventState, Phase, Status, TaskState } from 'api-client'; +import { + EventState, + Phase, + ApiServerModelsRmfApiTaskStateStatus as TaskStatus, + TaskState, +} from 'api-client'; import React from 'react'; interface TimeLinePropsWithRef extends TimelineProps { @@ -84,28 +89,28 @@ function colorDot(phase: Phase | undefined): TimelineDotProps['color'] { if (root_event.status == null) return 'error'; switch (root_event.status) { - case Status.Uninitialized: - case Status.Blocked: - case Status.Error: - case Status.Failed: + case TaskStatus.Uninitialized: + case TaskStatus.Blocked: + case TaskStatus.Error: + case TaskStatus.Failed: return 'error'; - case Status.Queued: - case Status.Standby: + case TaskStatus.Queued: + case TaskStatus.Standby: return 'grey'; - case Status.Underway: + case TaskStatus.Underway: return 'success'; - case Status.Skipped: - case Status.Canceled: - case Status.Killed: + case TaskStatus.Skipped: + case TaskStatus.Canceled: + case TaskStatus.Killed: return 'secondary'; - case Status.Delayed: + case TaskStatus.Delayed: return 'warning'; - case Status.Completed: + case TaskStatus.Completed: return 'primary'; default: @@ -136,7 +141,7 @@ function RenderPhase(phase: Phase) { {phase.id}. {phase.category} } defaultExpandIcon={}> - {NestedEvents(phase.events, phase.final_event_id)} + {phase.events && NestedEvents(phase.events, phase.final_event_id)}