Skip to content

Commit

Permalink
BC-7165-Include tldraw to quick links
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemida authored and Artemida committed Apr 29, 2024
1 parent 3bdee0f commit a32b612
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/server/src/modules/copy-helper/types/copy.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export enum CopyElementType {
LESSON_CONTENT_GROUP = 'LESSON_CONTENT_GROUP',
LESSON_CONTENT_LERNSTORE = 'LESSON_CONTENT_LERNSTORE',
LESSON_CONTENT_NEXBOARD = 'LESSON_CONTENT_NEXBOARD',
LESSON_CONTENT_TLDRAW = 'LESSON_CONTENT_TLDRAW',
LESSON_CONTENT_TASK = 'LESSON_CONTENT_TASK',
LESSON_CONTENT_TEXT = 'LESSON_CONTENT_TEXT',
LERNSTORE_MATERIAL = 'LERNSTORE_MATERIAL',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ export class CommonCartridgeMapper {
};
}) || []
);
case ComponentType.TLDRAW:
return(
type:CommonCartridgeResourceType.WEB_LINK,
identifier: createIdentifier(content._id),
title: content.title,
url:content.content.url,
);
default:
return [];
}
Expand Down
28 changes: 28 additions & 0 deletions apps/server/src/modules/lesson/service/lesson-copy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,22 @@ export class LessonCopyService {
}
copiedContentStatus.push(etherpadStatus);
}

if (element.component === ComponentType.TLDRAW && tldrawEnabled) {
const tldrawContent = await this.copyTldraw(element, params);
const tldrawStatus = {
title: element.title,
type: CopyElementType.LESSON_CONTENT_TLDRAW,
status: CopyStatusEnum.PARTIAL,
};
if (tldrawContent) {
copiedContent.push(tldrawContent);
} else {
tldrawStatus.status = CopyStatusEnum.FAIL;
}
copiedContentStatus.push(tldrawStatus);
}

if (element.component === ComponentType.INTERNAL) {
const linkContent = this.copyEmbeddedTaskLink(element);
const embeddedTaskStatus = {
Expand Down Expand Up @@ -336,6 +352,18 @@ export class LessonCopyService {
return false;
}

private async copyTldraw(
originalElement: ComponentProperties,
params: LessonCopyParams
): Promise<ComponentProperties | false> {
const copy = { ...originalElement } as ComponentProperties;
delete copy._id;
const content = { ...copy.content, url: '', board: '' } as ComponentTldrawProperties;

cosnt tldraw = await this.
}


private async copyLinkedTasks(destinationLesson: LessonEntity, lesson: LessonEntity, params: LessonCopyParams) {
const linkedTasks = lesson.getLessonLinkedTasks();
if (linkedTasks.length > 0) {
Expand Down
28 changes: 28 additions & 0 deletions apps/server/src/modules/lesson/service/tldraw.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { FeathersServiceProvider } from '@infra/feathers/feathers-service.provider';
import { LegacyLogger } from '@src/core/logger';
import { Injectable } from '@nestjs/common';
import { EntityId } from '@shared/domain/types';

export type TldrawResponse = { id: string; publicLink: string };

@Injectable()
export class TldrawService {
constructor(private readonly feathersServiceProvider: FeathersServiceProvider, private logger: LegacyLogger) {}

async createTldraw(

Check failure on line 12 in apps/server/src/modules/lesson/service/tldraw.service.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Replace `⏎↹↹userId:·EntityId,⏎↹↹title:·string,⏎↹` with `userId:·EntityId,·title:·string`
userId: EntityId,
title: string,
): Promise<{ board: string; url: string } | false> {
const data = {
title,
};
try {
const service = this.feathersServiceProvider.getService('/tldraw/roomName');
const tldraw = (await service.create(data, { account: { userId } })) as TldrawResponse;
return { board: tldraw.id, url: tldraw.publicLink };
} catch (error) {
this.logger.error('Could not create new Tldraw', error);
return false;
}
}
}

Check failure on line 28 in apps/server/src/modules/lesson/service/tldraw.service.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Insert `⏎`
7 changes: 7 additions & 0 deletions apps/server/src/shared/domain/entity/lesson.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum ComponentType {
LERNSTORE = 'resources',
TEXT = 'text',
NEXBOARD = 'neXboard',
TLDRAW = 'tldraw',
}

export interface ComponentTextProperties {
Expand Down Expand Up @@ -63,6 +64,11 @@ export interface ComponentInternalProperties {
url: string;
}

export interface ComponentTldrawProperties {
url: string:
title: string;
}

export type ComponentProperties = {
_id?: string;
title: string;
Expand All @@ -75,6 +81,7 @@ export type ComponentProperties = {
| { component: ComponentType.INTERNAL; content: ComponentInternalProperties }
| { component: ComponentType.LERNSTORE; content?: ComponentLernstoreProperties }
| { component: ComponentType.NEXBOARD; content: ComponentNexboardProperties }
| { component: ComponentType.TLDRAW; content: ComponentTldrawProperties }
);

export interface LessonParent {
Expand Down

0 comments on commit a32b612

Please sign in to comment.