patch..
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import { Prisma } from '@prisma/client';
|
||||
|
||||
export type CourseMapPayload = {
|
||||
key: string;
|
||||
platformKey: 'NAV2';
|
||||
name: string;
|
||||
description: string;
|
||||
worldFile: string;
|
||||
viewerModel: 'turtlebot3_world' | 'turtlebot3_house';
|
||||
custom?: boolean;
|
||||
layout?: Prisma.JsonValue;
|
||||
};
|
||||
|
||||
export const NAV2_SYSTEM_MAPS: CourseMapPayload[] = [
|
||||
{
|
||||
key: 'nav2-turtlebot3-world',
|
||||
platformKey: 'NAV2',
|
||||
name: '기본 월드',
|
||||
description: 'TurtleBot3 기본 장애물 환경',
|
||||
worldFile: 'turtlebot3_world.world',
|
||||
viewerModel: 'turtlebot3_world',
|
||||
},
|
||||
{
|
||||
key: 'nav2-turtlebot3-house',
|
||||
platformKey: 'NAV2',
|
||||
name: '실내 환경',
|
||||
description: '방과 복도로 구성된 TurtleBot3 House',
|
||||
worldFile: 'turtlebot3_house.world',
|
||||
viewerModel: 'turtlebot3_house',
|
||||
},
|
||||
];
|
||||
|
||||
export function serializeCourseMaps(
|
||||
selectedKeys: string[],
|
||||
customMaps: Array<{
|
||||
key: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
platformKey: string;
|
||||
worldFile: string;
|
||||
viewerModel: string;
|
||||
layout: Prisma.JsonValue;
|
||||
}>,
|
||||
): CourseMapPayload[] {
|
||||
const systemByKey = new Map(NAV2_SYSTEM_MAPS.map((map) => [map.key, map]));
|
||||
const customByKey = new Map(customMaps.map((map) => [map.key, map]));
|
||||
|
||||
return selectedKeys.flatMap((key) => {
|
||||
const systemMap = systemByKey.get(key);
|
||||
if (systemMap) return [systemMap];
|
||||
const customMap = customByKey.get(key);
|
||||
if (!customMap || customMap.platformKey.toUpperCase() !== 'NAV2') return [];
|
||||
return [{
|
||||
key: customMap.key,
|
||||
platformKey: 'NAV2' as const,
|
||||
name: customMap.name,
|
||||
description: customMap.description ?? '강사가 구성한 학습 맵',
|
||||
worldFile: customMap.worldFile,
|
||||
viewerModel: customMap.viewerModel === 'turtlebot3_house' ? 'turtlebot3_house' as const : 'turtlebot3_world' as const,
|
||||
custom: true,
|
||||
layout: customMap.layout,
|
||||
}];
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user