@dataclouder/ngx-lessons 0.0.29 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/dataclouder-ngx-lessons.mjs +1205 -514
- package/fesm2022/dataclouder-ngx-lessons.mjs.map +1 -1
- package/lib/components/dc-lessons/dc-lesson-card/dc-lesson-card.component.d.ts +6 -8
- package/lib/components/dc-lessons/dc-lesson-component-adder/dc-lesson-component-adder.component.d.ts +11 -0
- package/lib/components/dc-lessons/dc-lesson-editor/dc-lesson-editor.component.d.ts +39 -38
- package/lib/components/dc-lessons/dc-lesson-metadata-editor/dc-lesson-metadata-editor.component.d.ts +22 -0
- package/lib/components/dc-lessons/dc-lesson-renderer/dc-lesson-renderer.component.d.ts +32 -37
- package/lib/components/dc-lessons/lesson-list/dc-lesson-list.component.d.ts +7 -17
- package/lib/components/lesson-mini-components/components/ComponentBuilder.d.ts +7 -2
- package/lib/components/lesson-mini-components/components/lessons.clases.d.ts +17 -42
- package/lib/components/lesson-mini-components/components/speaker/speaker-builder/speaker-builder.component.d.ts +13 -0
- package/lib/components/lesson-mini-components/components/speaker/speaker.component.d.ts +12 -0
- package/lib/services/lesson-ai.service.d.ts +18 -0
- package/lib/services/lesson-notion.service.d.ts +35 -0
- package/lib/services/lesson-utils.service.d.ts +34 -0
- package/package.json +3 -2
- package/src/lib/components/dc-lessons/dc-lesson-card/dc-lesson-card.component.html +40 -35
- package/src/lib/components/dc-lessons/dc-lesson-card/dc-lesson-card.component.scss +15 -2
- package/src/lib/components/dc-lessons/dc-lesson-card/dc-lesson-card.component.ts +16 -18
- package/src/lib/components/dc-lessons/dc-lesson-component-adder/dc-lesson-component-adder.component.css +1 -0
- package/src/lib/components/dc-lessons/dc-lesson-component-adder/dc-lesson-component-adder.component.html +46 -0
- package/src/lib/components/dc-lessons/dc-lesson-component-adder/dc-lesson-component-adder.component.ts +52 -0
- package/src/lib/components/dc-lessons/dc-lesson-editor/dc-lesson-editor.component.html +54 -92
- package/src/lib/components/dc-lessons/dc-lesson-editor/dc-lesson-editor.component.ts +268 -230
- package/src/lib/components/dc-lessons/dc-lesson-metadata-editor/dc-lesson-metadata-editor.component.css +1 -0
- package/src/lib/components/dc-lessons/dc-lesson-metadata-editor/dc-lesson-metadata-editor.component.html +72 -0
- package/src/lib/components/dc-lessons/dc-lesson-metadata-editor/dc-lesson-metadata-editor.component.ts +60 -0
- package/src/lib/components/dc-lessons/dc-lesson-renderer/dc-lesson-renderer.component.html +23 -27
- package/src/lib/components/dc-lessons/dc-lesson-renderer/dc-lesson-renderer.component.ts +247 -186
- package/src/lib/components/dc-lessons/lesson-form/lesson-form.component.ts +2 -2
- package/src/lib/components/dc-lessons/lesson-list/dc-lesson-list.component.html +3 -3
- package/src/lib/components/dc-lessons/lesson-list/dc-lesson-list.component.ts +28 -46
- package/src/lib/components/lesson-mini-components/components/ComponentBuilder.ts +23 -15
- package/src/lib/components/lesson-mini-components/components/lessons.clases.ts +32 -66
- package/src/lib/components/lesson-mini-components/components/selector/selector-builder/selector-builder.component.html +62 -58
- package/src/lib/components/lesson-mini-components/components/selector/selector-builder/selector-builder.component.ts +2 -2
- package/src/lib/components/lesson-mini-components/components/selector/selector.component.html +1 -2
- package/src/lib/components/lesson-mini-components/components/selector/selector.component.ts +2 -2
- package/src/lib/components/lesson-mini-components/components/speaker/speaker-builder/speaker-builder.component.html +5 -27
- package/src/lib/components/lesson-mini-components/components/speaker/speaker-builder/speaker-builder.component.ts +38 -25
- package/src/lib/components/lesson-mini-components/components/speaker/speaker.component.html +9 -7
- package/src/lib/components/lesson-mini-components/components/speaker/speaker.component.ts +30 -26
- package/src/lib/components/lesson-mini-components/components/translationSwitcher/translationSwitcher.component.ts +2 -2
- package/src/lib/components/lesson-mini-components/components/translationSwitcher/translationSwitcherBuilder/translationSwitcherBuilder.component.ts +2 -2
- package/src/lib/services/lesson-ai.service.ts +103 -0
- package/src/lib/services/lesson-notion.service.ts +161 -0
- package/src/lib/services/lesson-utils.service.ts +181 -0
- package/src/lib/components/lesson-mini-components/components/selector/selector-builder/selector-builder.component.spec.ts +0 -25
- package/src/lib/components/lesson-mini-components/components/speaker/speaker-builder/speaker-builder.component.spec.ts +0 -25
- package/src/lib/components/lesson-mini-components/components/speaker/speaker.component.spec.ts +0 -25
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChangeDetectorRef, Component, EventEmitter, Inject, Input, OnInit, Output, Type, ViewChildren, QueryList, OnDestroy } from '@angular/core';
|
|
2
|
-
|
|
1
|
+
import { ChangeDetectorRef, Component, EventEmitter, Inject, Input, OnInit, Output, Type, ViewChildren, QueryList, OnDestroy, input } from '@angular/core';
|
|
2
|
+
|
|
3
3
|
import { PaginatorModule } from 'primeng/paginator';
|
|
4
4
|
import { NgComponentOutlet } from '@angular/common';
|
|
5
5
|
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
|
@@ -8,6 +8,7 @@ import { Subscription } from 'rxjs';
|
|
|
8
8
|
import {
|
|
9
9
|
DCFilterBarComponent,
|
|
10
10
|
ICustomFilter,
|
|
11
|
+
OnActionEvent,
|
|
11
12
|
PaginationBase,
|
|
12
13
|
PColumn,
|
|
13
14
|
QuickTableComponent,
|
|
@@ -39,21 +40,15 @@ const returnProperties: Record<string, 0 | 1> = { id: 1, title: 1, assets: 1 };
|
|
|
39
40
|
templateUrl: './dc-lesson-list.component.html',
|
|
40
41
|
styleUrls: ['./dc-lesson-list.component.scss'],
|
|
41
42
|
standalone: true,
|
|
42
|
-
imports: [
|
|
43
|
+
imports: [RouterModule, DCFilterBarComponent, PaginatorModule, NgComponentOutlet, QuickTableComponent],
|
|
43
44
|
})
|
|
44
45
|
export class DCLessonListComponent extends PaginationBase implements OnInit, OnDestroy {
|
|
45
|
-
@Input() public
|
|
46
|
+
@Input() public showOptions: boolean = true;
|
|
46
47
|
@Input() public customCardComponent?: Type<DcLessonCardComponent>;
|
|
47
48
|
@Input() public customFilters: ICustomFilter[] = [];
|
|
48
|
-
@Input() public viewType: 'table' | '
|
|
49
|
-
|
|
50
|
-
@Input() public override actions: MenuItem[] = TableViewActions;
|
|
49
|
+
@Input() public viewType: 'table' | 'cards' = 'cards';
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
@Output() public onEditLesson: EventEmitter<any> = new EventEmitter();
|
|
54
|
-
@Output() public onRemoveLesson: EventEmitter<any> = new EventEmitter();
|
|
55
|
-
@Output() public qr: EventEmitter<any> = new EventEmitter();
|
|
56
|
-
@Output() public onNewLesson: EventEmitter<any> = new EventEmitter();
|
|
51
|
+
// readonly actions = input<MenuItem[]>(TableViewActions);
|
|
57
52
|
|
|
58
53
|
public override columns: PColumn[] = tableViewColumns;
|
|
59
54
|
|
|
@@ -92,17 +87,8 @@ export class DCLessonListComponent extends PaginationBase implements OnInit, OnD
|
|
|
92
87
|
const instance: DcLessonCardComponent = outlet.componentInstance;
|
|
93
88
|
|
|
94
89
|
this.cardEventSubs.push(
|
|
95
|
-
instance.
|
|
96
|
-
this.
|
|
97
|
-
}),
|
|
98
|
-
instance.edit.subscribe((lesson: any) => {
|
|
99
|
-
this.editLesson(lesson);
|
|
100
|
-
}),
|
|
101
|
-
instance.remove.subscribe((lesson: any) => {
|
|
102
|
-
this.removeLesson(lesson);
|
|
103
|
-
}),
|
|
104
|
-
instance.qr.subscribe((lesson: any) => {
|
|
105
|
-
this.generateQR(lesson);
|
|
90
|
+
instance.onAction.subscribe((lesson: any) => {
|
|
91
|
+
this.doOrEmitAction(lesson);
|
|
106
92
|
}),
|
|
107
93
|
);
|
|
108
94
|
});
|
|
@@ -138,28 +124,11 @@ export class DCLessonListComponent extends PaginationBase implements OnInit, OnD
|
|
|
138
124
|
}
|
|
139
125
|
}
|
|
140
126
|
|
|
141
|
-
public goToLessonDetails(id: string) {
|
|
142
|
-
// this.router.navigate([`${RouteNames.App}/${RouteNames.LessonsV2}/details/${id}`]);
|
|
143
|
-
alert('TODO: goToLessonDetails');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
127
|
public search(searchText: string) {
|
|
147
128
|
this.filterConfig['text'] = searchText;
|
|
148
129
|
this.getPaginatedLessons(this.filterConfig);
|
|
149
130
|
}
|
|
150
131
|
|
|
151
|
-
private generateQR(lesson: any) {
|
|
152
|
-
this.qr.emit(lesson);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
private takeLesson(lesson: any) {
|
|
156
|
-
this.onTakeLesson.emit(lesson);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
private editLesson(lesson: any) {
|
|
160
|
-
this.onEditLesson.emit(lesson);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
132
|
private removeLesson(lesson: any) {
|
|
164
133
|
const response = confirm('¿Estás seguro de querer eliminar esta lección?');
|
|
165
134
|
if (response) {
|
|
@@ -171,18 +140,31 @@ export class DCLessonListComponent extends PaginationBase implements OnInit, OnD
|
|
|
171
140
|
}
|
|
172
141
|
|
|
173
142
|
public newLesson() {
|
|
174
|
-
this.
|
|
143
|
+
this.onAction.emit({ action: 'new' });
|
|
175
144
|
}
|
|
176
145
|
|
|
177
|
-
public
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
146
|
+
public applyFilterBarEvent(filterEvent: OnActionEvent) {
|
|
147
|
+
if (filterEvent.action == 'changeView') {
|
|
148
|
+
this.viewType = this.viewType === 'table' ? 'cards' : 'table';
|
|
149
|
+
return;
|
|
150
|
+
} else {
|
|
151
|
+
console.log('filterChanged in dc-lesson-list', filterEvent);
|
|
152
|
+
this.filterConfig = filterEvent.item;
|
|
153
|
+
this.filterConfig.returnProps = returnProperties;
|
|
181
154
|
|
|
182
|
-
|
|
155
|
+
this.getPaginatedLessons(this.filterConfig);
|
|
156
|
+
}
|
|
183
157
|
}
|
|
184
158
|
|
|
185
159
|
protected override loadData(): Promise<void> {
|
|
186
160
|
return this.getPaginatedLessons(this.filterConfig);
|
|
187
161
|
}
|
|
162
|
+
|
|
163
|
+
public doOrEmitAction(actionEvent: OnActionEvent) {
|
|
164
|
+
if (actionEvent.action === 'delete') {
|
|
165
|
+
this.removeLesson(actionEvent.item);
|
|
166
|
+
} else {
|
|
167
|
+
this.onAction.emit(actionEvent);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
188
170
|
}
|
|
@@ -3,22 +3,24 @@ import { FormBuilder, FormControl } from '@angular/forms';
|
|
|
3
3
|
import { DynamicDialogRef } from 'primeng/dynamicdialog';
|
|
4
4
|
|
|
5
5
|
import { LessonComponentBuilders, LessonComponentConfiguration, LessonComponentEnum, LessonCompSettings } from './lessons.clases';
|
|
6
|
+
import { nanoid } from 'nanoid';
|
|
6
7
|
|
|
7
8
|
// Create a type that maps the interface to FormControls
|
|
8
9
|
export type LessonCompSettingsForm = {
|
|
9
10
|
[K in keyof Required<LessonCompSettings>]: FormControl<LessonCompSettings[K]>;
|
|
10
11
|
};
|
|
11
12
|
|
|
13
|
+
export interface ComponentBuildData {
|
|
14
|
+
str: string;
|
|
15
|
+
obj: LessonComponentConfiguration;
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
@Component({
|
|
13
19
|
selector: 'app-component-builder',
|
|
14
20
|
template: '<div>no template</div>',
|
|
15
21
|
})
|
|
16
22
|
export class ComponentBuilder {
|
|
17
|
-
constructor(
|
|
18
|
-
protected formBuilder: FormBuilder,
|
|
19
|
-
// protected toastrService: ToastService, // protected ref: NbDialogRef<ComponentBuilder>,
|
|
20
|
-
protected ref: DynamicDialogRef,
|
|
21
|
-
) {}
|
|
23
|
+
constructor(protected formBuilder: FormBuilder, protected ref: DynamicDialogRef) {}
|
|
22
24
|
|
|
23
25
|
// Sobreescribir si es necesario
|
|
24
26
|
// public formGroup = this.formBuilder.group<LessonCompSettings>({});
|
|
@@ -46,7 +48,7 @@ export class ComponentBuilder {
|
|
|
46
48
|
return <LessonComponentEnum>name;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
protected getCode(): LessonComponentConfiguration {
|
|
50
52
|
const data = this.formGroup.value;
|
|
51
53
|
// Deleting null values
|
|
52
54
|
Object.keys(data).forEach((key) => {
|
|
@@ -54,21 +56,27 @@ export class ComponentBuilder {
|
|
|
54
56
|
delete data[key];
|
|
55
57
|
}
|
|
56
58
|
});
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
return `~${JSON.stringify(code)}~`;
|
|
59
|
+
const code: LessonComponentConfiguration = { component: this.questionType, settings: { ...data } as unknown as LessonCompSettings };
|
|
60
|
+
return code;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
public showCode() {
|
|
63
64
|
const code = this.getCode();
|
|
64
|
-
|
|
65
|
+
const stringCode = `~${JSON.stringify(code)}~`;
|
|
66
|
+
alert(stringCode);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
public
|
|
69
|
+
public getComponentData(): ComponentBuildData {
|
|
68
70
|
const code = this.getCode();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
const id = nanoid().replace(/-/g, '_');
|
|
72
|
+
code.id = id;
|
|
73
|
+
return { str: `~${JSON.stringify(code)}~`, obj: code };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// TODO: for now copyToClipboard is the that that closes modal and return data.
|
|
77
|
+
public async copyToClipboard() {
|
|
78
|
+
const data = this.getComponentData();
|
|
79
|
+
await navigator.clipboard.writeText(data.str);
|
|
80
|
+
this.ref.close(data);
|
|
73
81
|
}
|
|
74
82
|
}
|
|
@@ -9,7 +9,8 @@ import { TextWriterBuiderComponent } from './text-writer/text-writer-buider/text
|
|
|
9
9
|
import { TextWriterComponent } from './text-writer/text-writer.component';
|
|
10
10
|
import { TranslationSwitcherBuilderComponent } from './translationSwitcher/translationSwitcherBuilder/translationSwitcherBuilder.component';
|
|
11
11
|
import { TranslationSwitcherComponent } from './translationSwitcher/translationSwitcher.component';
|
|
12
|
-
|
|
12
|
+
import { SpeakerBuilderComponent } from './speaker/speaker-builder/speaker-builder.component';
|
|
13
|
+
import { SpeakerComponent } from './speaker/speaker.component';
|
|
13
14
|
|
|
14
15
|
export type LessonComponentsType = 'selector' | 'speaker' | 'text-writer' | 'verb-summary' | 'word-summary';
|
|
15
16
|
|
|
@@ -24,7 +25,7 @@ export enum LessonComponentEnum {
|
|
|
24
25
|
|
|
25
26
|
export const LessonComponentBuilders = {
|
|
26
27
|
[LessonComponentEnum.Selector]: SelectorBuilderComponent,
|
|
27
|
-
|
|
28
|
+
[LessonComponentEnum.Speaker]: SpeakerBuilderComponent,
|
|
28
29
|
[LessonComponentEnum.TextWriter]: TextWriterBuiderComponent,
|
|
29
30
|
// [LessonComponentEnum.VerbSummary]: VerbSummaryBuilderComponent,
|
|
30
31
|
// [LessonComponentEnum.WordSummary]: WordSummaryBuilderComponent,
|
|
@@ -33,7 +34,7 @@ export const LessonComponentBuilders = {
|
|
|
33
34
|
|
|
34
35
|
export const LessonComponents = {
|
|
35
36
|
[LessonComponentEnum.Selector]: SelectorComponent,
|
|
36
|
-
|
|
37
|
+
[LessonComponentEnum.Speaker]: SpeakerComponent,
|
|
37
38
|
[LessonComponentEnum.TextWriter]: TextWriterComponent,
|
|
38
39
|
// [LessonComponentEnum.VerbSummary]: VerbSummaryComponent,
|
|
39
40
|
// [LessonComponentEnum.WordSummary]: WordSummaryComponent,
|
|
@@ -52,10 +53,12 @@ export interface LessonCompSettings {
|
|
|
52
53
|
hint?: string;
|
|
53
54
|
explanation?: string;
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
// Make LessonComponentConfiguration generic for settings
|
|
57
|
+
export interface LessonComponentConfiguration<T extends LessonCompSettings = LessonCompSettings> {
|
|
58
|
+
id?: string;
|
|
57
59
|
component: LessonComponentEnum;
|
|
58
|
-
settings
|
|
60
|
+
settings?: T; // for component that need and standards
|
|
61
|
+
inputs?: Record<string, any>; // for whatever component.
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
export interface StorageFile {
|
|
@@ -68,13 +71,15 @@ export interface AudioStorage extends StorageFile {
|
|
|
68
71
|
text?: string;
|
|
69
72
|
voiceType?: string;
|
|
70
73
|
}
|
|
71
|
-
|
|
74
|
+
// Make SpeakerCompConfiguration extend the generic base interface
|
|
75
|
+
export interface SpeakerCompConfiguration extends LessonComponentConfiguration<LessonCompSettings & { voice: string }> {
|
|
72
76
|
audio: AudioStorage;
|
|
73
|
-
settings
|
|
77
|
+
// settings is now inherited correctly via the generic type argument
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
export interface LessonComponentInterface {
|
|
77
|
-
config
|
|
81
|
+
// Update config to use the generic form
|
|
82
|
+
config: LessonComponentConfiguration<any>;
|
|
78
83
|
|
|
79
84
|
control?: UntypedFormControl;
|
|
80
85
|
|
|
@@ -89,20 +94,8 @@ export interface LessonComponentInterface {
|
|
|
89
94
|
|
|
90
95
|
export const LESSONS_TOKEN = new InjectionToken<LessonsAbstractService>('Lessons Service');
|
|
91
96
|
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
// Speaker = 'speaker',
|
|
95
|
-
// TextWriter = 'textWriter',
|
|
96
|
-
// VerbSummary = 'verbSummary',
|
|
97
|
-
// WordSummary = 'wordSummary',
|
|
98
|
-
// TranslationSwitcher = 'translationSwitcher',
|
|
99
|
-
// }
|
|
100
|
-
|
|
101
|
-
export interface StorageFile {
|
|
102
|
-
bucket: string;
|
|
103
|
-
url: string;
|
|
104
|
-
path: string; // path where the file is in the storage
|
|
105
|
-
}
|
|
97
|
+
// Removed duplicate LessonComponentEnum definition
|
|
98
|
+
// Removed duplicate StorageFile definition
|
|
106
99
|
|
|
107
100
|
export interface ImgStorageData extends StorageFile {
|
|
108
101
|
fullPath: string; // path + name
|
|
@@ -112,19 +105,15 @@ export interface ImgStorageData extends StorageFile {
|
|
|
112
105
|
|
|
113
106
|
export type LessonImage = ImgStorageData & { type: string };
|
|
114
107
|
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
// responses: string; // en caso de que haya multiples respuestas
|
|
118
|
-
// options: string[]; // optiones para visualizar
|
|
119
|
-
// text: string;
|
|
120
|
-
// hint: string;
|
|
121
|
-
// explanation: string;
|
|
122
|
-
// }
|
|
108
|
+
// Removed duplicate LessonCompSettings definition
|
|
109
|
+
// Removed duplicate LessonComponentConfiguration definition
|
|
123
110
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
111
|
+
// New way of render components
|
|
112
|
+
export interface DynamicContentComponent {
|
|
113
|
+
id: string; // duplicated id
|
|
114
|
+
component: LessonComponentEnum; // name of the component
|
|
115
|
+
inputs: Record<string, any>;
|
|
116
|
+
config: LessonComponentConfiguration<any>;
|
|
128
117
|
}
|
|
129
118
|
|
|
130
119
|
type StorageType = StorageFile & { type: string };
|
|
@@ -151,7 +140,9 @@ export interface ILesson {
|
|
|
151
140
|
authorEmail: string;
|
|
152
141
|
tags: string[];
|
|
153
142
|
media: Media;
|
|
154
|
-
components
|
|
143
|
+
// Update components array to use generic form
|
|
144
|
+
components: Array<LessonComponentConfiguration<any>>;
|
|
145
|
+
dynamicComponents: Record<string, DynamicContentComponent>;
|
|
155
146
|
baseLang: string;
|
|
156
147
|
targetLang: string;
|
|
157
148
|
|
|
@@ -197,36 +188,11 @@ export function provideLessonsService(serviceImplementation: Type<LessonsAbstrac
|
|
|
197
188
|
// return null;
|
|
198
189
|
// }
|
|
199
190
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
export interface StorageFile {
|
|
207
|
-
bucket: string;
|
|
208
|
-
url: string;
|
|
209
|
-
path: string; // path where the file is in the storage
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export interface AudioStorage extends StorageFile {
|
|
213
|
-
text?: string;
|
|
214
|
-
voiceType?: string;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export interface SpeakerCompConfiguration extends LessonComponentConfiguration {
|
|
218
|
-
audio: AudioStorage;
|
|
219
|
-
settings: LessonCompSettings & { voice: string };
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export interface LessonComponentInterface {
|
|
223
|
-
config: LessonComponentConfiguration;
|
|
224
|
-
|
|
225
|
-
control?: UntypedFormControl;
|
|
226
|
-
|
|
227
|
-
validate?(): boolean | null;
|
|
228
|
-
evaluate?(): boolean | null;
|
|
229
|
-
}
|
|
191
|
+
// Removed duplicate LessonComponentConfiguration definition
|
|
192
|
+
// Removed duplicate StorageFile definition
|
|
193
|
+
// Removed duplicate AudioStorage definition
|
|
194
|
+
// Removed duplicate SpeakerCompConfiguration definition
|
|
195
|
+
// Removed duplicate LessonComponentInterface definition
|
|
230
196
|
|
|
231
197
|
// export const LessonComponents = {
|
|
232
198
|
// [LessonComponentEnum.Selector]: 1,
|
|
@@ -1,58 +1,62 @@
|
|
|
1
|
-
<div>
|
|
2
|
-
<div>
|
|
3
|
-
<p-message>Construcción del componente de Selección, sirve para hacer una pregunta y mostrar varias opciones, ejemplo:</p-message>
|
|
4
|
-
</div>
|
|
5
|
-
|
|
6
|
-
<div>
|
|
7
|
-
<span>En que año llegó cristobal colon a america?</span>
|
|
8
|
-
<app-selector [config]="sampleConfig"></app-selector>
|
|
9
|
-
</div>
|
|
10
|
-
|
|
11
|
-
<hr />
|
|
12
|
-
|
|
13
|
-
<div>
|
|
14
|
-
<form class="builder-form" [formGroup]="formGroup">
|
|
15
|
-
<input class="form-input" type="text" pInputText fullWidth formControlName="response" placeholder="Respuesta Correcta..." />
|
|
16
|
-
<br />
|
|
17
|
-
|
|
18
|
-
<input class="form-input" type="" pInputText fullWidth formControlName="hint" placeholder="Escribe una pista para esta pregunta" />
|
|
19
|
-
|
|
20
|
-
<br />
|
|
21
|
-
<input
|
|
22
|
-
class="form-input"
|
|
23
|
-
type="text"
|
|
24
|
-
pInputText
|
|
25
|
-
fullWidth
|
|
26
|
-
formControlName="explanation"
|
|
27
|
-
placeholder="Excribe una explicación para la respuesta" />
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
<div>
|
|
2
|
+
<div>
|
|
3
|
+
<p-message>Construcción del componente de Selección, sirve para hacer una pregunta y mostrar varias opciones, ejemplo:</p-message>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<div>
|
|
7
|
+
<span>En que año llegó cristobal colon a america?</span>
|
|
8
|
+
<app-selector [config]="sampleConfig"></app-selector>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<hr />
|
|
12
|
+
|
|
13
|
+
<div>
|
|
14
|
+
<form class="builder-form" [formGroup]="formGroup">
|
|
15
|
+
<input class="form-input" type="text" pInputText fullWidth formControlName="response" placeholder="Respuesta Correcta..." />
|
|
16
|
+
<br />
|
|
17
|
+
|
|
18
|
+
<input class="form-input" type="" pInputText fullWidth formControlName="hint" placeholder="Escribe una pista para esta pregunta" />
|
|
19
|
+
|
|
20
|
+
<br />
|
|
21
|
+
<input
|
|
22
|
+
class="form-input"
|
|
23
|
+
type="text"
|
|
24
|
+
pInputText
|
|
25
|
+
fullWidth
|
|
26
|
+
formControlName="explanation"
|
|
27
|
+
placeholder="Excribe una explicación para la respuesta" />
|
|
28
|
+
|
|
29
|
+
<hr />
|
|
30
|
+
<h6>Opciones</h6>
|
|
31
|
+
|
|
32
|
+
<div class="form-group" formArrayName="options">
|
|
33
|
+
@for (item of optionsForm.controls; track item; let i = $index) {
|
|
34
|
+
<div
|
|
35
|
+
style="display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-direction: column"
|
|
36
|
+
>
|
|
37
|
+
<div>
|
|
38
|
+
<input type="text" pInputText fullWidth [formControlName]="i" />
|
|
39
|
+
<p-button (click)="deleteFormArrayByIndex('options', i)" icon="pi pi-times" severity="danger"></p-button>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
}
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<p-button (click)="pushControlToFormArray('options')" label="Agregar Opción" [text]="true" severity="help"></p-button>
|
|
46
|
+
</form>
|
|
47
|
+
|
|
48
|
+
<!-- <button nbButton (click)="isRendered = !isRendered"> Renderizar </button> -->
|
|
49
|
+
|
|
50
|
+
@if (isRendered) {
|
|
51
|
+
<div>
|
|
52
|
+
<!-- TODO: probably i need to pass some params -->
|
|
53
|
+
<app-selector></app-selector>
|
|
54
|
+
</div>
|
|
55
|
+
}
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div>
|
|
59
|
+
<p-button (click)="copyToClipboard()" [disabled]="formGroup.invalid" label="Copia Código" [rounded]="true"></p-button>
|
|
60
|
+
<p-button (click)="showCode()" [disabled]="formGroup.invalid" label="Mostrar" [rounded]="true" severity="secondary"></p-button>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, OnInit } from '@angular/core';
|
|
2
2
|
import { UntypedFormArray, FormsModule, ReactiveFormsModule, FormBuilder } from '@angular/forms';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import { InputTextModule } from 'primeng/inputtext';
|
|
6
6
|
import { ButtonModule } from 'primeng/button';
|
|
@@ -16,7 +16,7 @@ import { LessonComponentConfiguration, LessonComponentEnum } from '../../lessons
|
|
|
16
16
|
templateUrl: './selector-builder.component.html',
|
|
17
17
|
styleUrls: ['./selector-builder.component.scss'],
|
|
18
18
|
standalone: true,
|
|
19
|
-
imports: [FormsModule, ReactiveFormsModule,
|
|
19
|
+
imports: [FormsModule, ReactiveFormsModule, SelectorComponent, InputTextModule, ButtonModule, MessageModule],
|
|
20
20
|
})
|
|
21
21
|
export class SelectorBuilderComponent extends ComponentBuilder implements OnInit {
|
|
22
22
|
constructor(
|
package/src/lib/components/lesson-mini-components/components/selector/selector.component.html
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
<p-
|
|
2
|
-
[showClear]="true"></p-dropdown>
|
|
1
|
+
<p-select [class]="status" placeholder="Selecciona" [options]="config.settings.options" [formControl]="control"></p-select>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component, Input } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
-
import {
|
|
4
|
+
import { SelectModule } from 'primeng/select';
|
|
5
5
|
|
|
6
6
|
import { ComponentWithForm } from '../ComponentWithForm';
|
|
7
7
|
import { LessonComponentConfiguration, LessonComponentInterface } from '../lessons.clases';
|
|
@@ -11,7 +11,7 @@ import { LessonComponentConfiguration, LessonComponentInterface } from '../lesso
|
|
|
11
11
|
templateUrl: './selector.component.html',
|
|
12
12
|
styleUrls: ['./selector.component.scss'],
|
|
13
13
|
standalone: true,
|
|
14
|
-
imports: [FormsModule, ReactiveFormsModule,
|
|
14
|
+
imports: [FormsModule, ReactiveFormsModule, SelectModule],
|
|
15
15
|
})
|
|
16
16
|
export class SelectorComponent extends ComponentWithForm implements LessonComponentInterface {
|
|
17
17
|
public isFilled = false;
|
|
@@ -3,33 +3,11 @@
|
|
|
3
3
|
<h5>Constructor de Speaker</h5>
|
|
4
4
|
</div>
|
|
5
5
|
|
|
6
|
-
<
|
|
7
|
-
<input type="text" pInputText fullWidth formControlName="text" placeholder="Texto..." />
|
|
6
|
+
<lib-ngx-tts (ttsGenerated)="handleTtsGenerated($event)"></lib-ngx-tts>
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
<p-dropdown [options]="voiceOptions" optionLabel="name" optionValue="id" [showClear]="true" placeholder="Voz"
|
|
11
|
-
formControlName="voice">
|
|
12
|
-
|
|
13
|
-
<ng-template let-voice pTemplate="item">
|
|
14
|
-
<div class="flex align-items-center gap-2">
|
|
15
|
-
<div>{{ voice.provider }}</div>
|
|
16
|
-
-
|
|
17
|
-
<div>{{ voice.name }}</div>
|
|
18
|
-
</div>
|
|
19
|
-
</ng-template>
|
|
20
|
-
</p-dropdown>
|
|
21
|
-
|
|
22
|
-
</form>
|
|
23
|
-
|
|
24
|
-
<br>
|
|
25
|
-
<br>
|
|
26
|
-
<br>
|
|
27
|
-
|
|
28
|
-
<br>
|
|
8
|
+
<br />
|
|
29
9
|
<div>
|
|
30
|
-
<p-button (click)="copyToClipboard()" [disabled]="formGroup.invalid" label="Copia Código"
|
|
31
|
-
|
|
32
|
-
<p-button (click)="showCode()" [disabled]="formGroup.invalid" label="Mostrar" [rounded]="true"
|
|
33
|
-
severity="secondary"></p-button>
|
|
10
|
+
<p-button (click)="copyToClipboard()" [disabled]="formGroup.invalid" label="Copia Código" [rounded]="true"></p-button>
|
|
11
|
+
<p-button (click)="showCode()" [disabled]="!tts()" label="Mostrar" [rounded]="true" severity="secondary"></p-button>
|
|
34
12
|
</div>
|
|
35
|
-
</div>
|
|
13
|
+
</div>
|
|
@@ -1,27 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Component, signal } from '@angular/core';
|
|
2
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
3
|
+
import { ComponentBuilder } from '../../ComponentBuilder';
|
|
4
|
+
import { ButtonModule } from 'primeng/button';
|
|
5
|
+
import { InputTextModule } from 'primeng/inputtext';
|
|
6
|
+
import { DropdownModule } from 'primeng/dropdown';
|
|
7
|
+
import { NgxTtsComponent, TTSGenerated } from '@dataclouder/ngx-tts';
|
|
8
|
+
import { LessonComponentConfiguration, LessonCompSettings } from '../../lessons.clases';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// public voiceOptions = VoiceOptions;
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'app-speaker-builder',
|
|
12
|
+
templateUrl: './speaker-builder.component.html',
|
|
13
|
+
styleUrls: ['./speaker-builder.component.scss'],
|
|
14
|
+
standalone: true,
|
|
15
|
+
imports: [FormsModule, ReactiveFormsModule, InputTextModule, ButtonModule, DropdownModule, NgxTtsComponent],
|
|
16
|
+
})
|
|
17
|
+
export class SpeakerBuilderComponent extends ComponentBuilder {
|
|
18
|
+
public tts = signal<TTSGenerated | undefined>(undefined);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
public handleTtsGenerated(event: TTSGenerated): void {
|
|
21
|
+
console.log('TTS generated:', event);
|
|
22
|
+
this.tts.set(event);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Update return type and add settings object
|
|
26
|
+
protected override getCode(): LessonComponentConfiguration<LessonCompSettings & { voice: string }> {
|
|
27
|
+
const ttsValue = this.tts();
|
|
28
|
+
if (!ttsValue) {
|
|
29
|
+
// Handle the case where tts is undefined, maybe throw an error or return a default config
|
|
30
|
+
console.error('TTS data is not generated yet.');
|
|
31
|
+
// Depending on requirements, you might return a default/empty config or throw
|
|
32
|
+
return { component: this.questionType, inputs: {} }; // Example: return empty inputs
|
|
33
|
+
}
|
|
34
|
+
const code: LessonComponentConfiguration<LessonCompSettings & { voice: string }> = {
|
|
35
|
+
component: this.questionType,
|
|
36
|
+
inputs: { tts: ttsValue },
|
|
37
|
+
};
|
|
38
|
+
return code;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<button
|
|
2
|
+
pButton
|
|
3
|
+
style="padding: 0px 2px"
|
|
4
|
+
severity="help"
|
|
5
|
+
size="small"
|
|
6
|
+
(click)="speach()"
|
|
7
|
+
[label]="config?.settings?.text"
|
|
8
|
+
[text]="true"
|
|
9
|
+
[rounded]="true"></button>
|