Skip to content

Commit

Permalink
update api-client
Browse files Browse the repository at this point in the history
Signed-off-by: Teo Koon Peng <[email protected]>
  • Loading branch information
koonpeng committed Mar 21, 2024
1 parent 0c773dc commit 0c5b65f
Show file tree
Hide file tree
Showing 28 changed files with 116 additions and 126 deletions.
4 changes: 2 additions & 2 deletions packages/api-client/lib/openapi/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1713,10 +1713,10 @@ export interface ScheduledTask {
id: number;
/**
*
* @type {object}
* @type {TaskRequest}
* @memberof ScheduledTask
*/
task_request: object;
task_request: TaskRequest;
/**
*
* @type {string}
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { version as rmfModelVer } from 'rmf-models';

export const version = {
rmfModels: rmfModelVer,
rmfServer: '757c200c2133f69e3321bc6bc2ba392fb522f3c9',
rmfServer: '0c773dc3f4b1a5df8bccb1b9da9d66fc3b075b28',
openapiGenerator: '',
};
2 changes: 1 addition & 1 deletion packages/api-client/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
3 changes: 2 additions & 1 deletion packages/api-server/api_server/models/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from pydantic import BaseModel, ConfigDict

from .rmf_api.task_request import TaskRequest
from .tortoise_support import TortoiseReverseRelation


Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/components/alert-store.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/components/app-events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert,
TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert,
Dispenser,
Door,
Ingestor,
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/components/appbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
Typography,
} from '@mui/material';
import {
ApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert,
TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert,
TaskFavoritePydantic as TaskFavorite,
TaskRequest,
} from 'api-client';
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/components/beacons-app.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
10 changes: 1 addition & 9 deletions packages/dashboard/src/components/map-app.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 3 additions & 6 deletions packages/dashboard/src/components/rmf-app/rmf-ingress.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
AdminApi,
AlertsApi,
ApiServerModelsTortoiseModelsAlertsAlertLeaf,
ApiServerModelsTortoiseModelsBeaconsBeaconStateLeaf as BeaconState,
TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert,
TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsBeaconsBeaconStateLeaf as BeaconState,
BeaconsApi,
BuildingApi,
BuildingMap,
Expand All @@ -15,7 +15,7 @@ import {
DoorsApi,
DoorState,
FleetsApi,
ApiServerModelsRmfApiFleetStateFleetState,
FleetState,
Ingestor,
IngestorsApi,
IngestorState,
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/dashboard/src/components/robots/robot-info-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export const RobotInfoApp = createMicroApp('Robot Info', () => {
{robotState ? (
<RobotInfo
robotName={robotState.name || 'unknown'}
assignedTask={robotState.task_id}
battery={robotState.battery && +robotState.battery.toFixed(2)}
estFinishTime={taskState?.unix_millis_finish_time}
assignedTask={robotState.task_id ?? undefined}
battery={robotState.battery != null ? +robotState.battery.toFixed(2) : undefined}
estFinishTime={taskState?.unix_millis_finish_time ?? undefined}
taskProgress={taskProgress}
taskStatus={taskState?.status}
/>
Expand Down
14 changes: 9 additions & 5 deletions packages/dashboard/src/components/robots/robot-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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:
Expand Down Expand Up @@ -82,7 +86,7 @@ interface RobotSummaryProps {
}

const showBatteryIcon = (robot: RobotState, robotBattery: number) => {
if (robot.status === Status2.Charging) {
if (robot.status === RobotStatus.Charging) {
return <BatteryChargingFull />;
}

Expand Down
9 changes: 5 additions & 4 deletions packages/dashboard/src/components/robots/robots-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ export const RobotsApp = createMicroApp('Robots', () => {
? Object.entries(fleet.robots).map<RobotTableData>(([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',
}))
Expand Down
18 changes: 8 additions & 10 deletions packages/dashboard/src/components/tasks/task-alert.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import {
ApiServerModelsTortoiseModelsAlertsAlertLeaf,
TortoiseContribPydanticCreatorApiServerModelsTortoiseModelsAlertsAlertLeaf as Alert,
LogEntry,
Status,
ApiServerModelsRmfApiTaskStateStatus as TaskStatus,
TaskEventLog,
TaskState,
Tier,
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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()} - `
: '';
Expand All @@ -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:
Expand Down
31 changes: 18 additions & 13 deletions packages/dashboard/src/components/tasks/task-logs.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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) : '';
};
5 changes: 1 addition & 4 deletions packages/dashboard/src/components/tasks/task-schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions packages/dashboard/src/components/tasks/task-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 0c5b65f

Please sign in to comment.