Skip to content

Commit 972d298

Browse files
committed
fix video_url of iframe & add task count, module avatars
1 parent a7bf3d8 commit 972d298

21 files changed

Lines changed: 259 additions & 101 deletions

projects/social_platform/src/app/office/courses/lesson/lesson.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
'progress__task--done': isDone(task),
1616
'progress__task--current': isCurrent(task.id)
1717
}"
18-
(click)="selectTask(task)"
1918
>
2019
<p class="text-body-12">{{ task.order }}</p>
2120
</div>

projects/social_platform/src/app/office/courses/lesson/lesson.component.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,6 @@ export class LessonComponent implements OnInit {
143143
return task.isCompleted || this.completedTaskIds().has(task.id);
144144
}
145145

146-
selectTask(task: Task) {
147-
if (!task.isAvailable) return;
148-
this.currentTaskId.set(task.id);
149-
this.success.set(false);
150-
this.hasError.set(false);
151-
this.answerBody.set("");
152-
}
153-
154146
onSubmitAnswer() {
155147
const task = this.currentTask();
156148
if (!task) return;

projects/social_platform/src/app/office/courses/lesson/shared/exclude-task/exclude-task.component.html

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
<!-- @format -->
22

3-
<div class="exclude" [class.exclude--hasContent]="!!data.videoUrl || !!data.imageUrl">
3+
<div class="exclude" [class.exclude--hasContent]="hasVideoUrl() || !!data.imageUrl">
44
<div class="exclude__body">
5-
@if (!data.videoUrl && !data.imageUrl) {
5+
@if (!hasVideoUrl() && !data.imageUrl) {
66
<h2 class="exclude__title text-body-12-bold">{{ data.title | truncate: 110 }}</h2>
77
}
88
<div
99
class="exclude__text text-body-12"
10-
[class.exclude__text--hasContent]="!!data.videoUrl || !!data.imageUrl"
10+
[class.exclude__text--hasContent]="hasVideoUrl() || !!data.imageUrl"
1111
>
12-
@if (data.videoUrl) {
13-
<iframe
14-
[src]="getSafeVideoUrl()"
15-
width="397px"
16-
height="223px"
17-
frameborder="0"
18-
allowfullscreen
19-
allowtransparency="true"
20-
></iframe>
12+
@if (getSafeVideoUrl(); as videoUrl) {
13+
<iframe [src]="videoUrl" frameborder="0" allowfullscreen allowtransparency="true"></iframe>
2114
} @else {
2215
<img alt="exclude-image" [src]="data.imageUrl" class="exclude__image" />
2316
<div [innerHTML]="data.bodyText | truncate: 700"></div>

projects/social_platform/src/app/office/courses/lesson/shared/exclude-task/exclude-task.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
justify-content: center;
2727

2828
iframe {
29+
display: block;
30+
width: 100%;
31+
max-width: 400px;
32+
aspect-ratio: 16 / 9;
33+
height: auto;
34+
border: 0;
2935
border-radius: var(--rounded-lg);
3036
}
3137
}

projects/social_platform/src/app/office/courses/lesson/shared/exclude-task/exclude-task.component.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
import { Component, EventEmitter, inject, Input, type OnInit, Output, signal } from "@angular/core";
44
import { CommonModule } from "@angular/common";
55
import { DomSanitizer, SafeResourceUrl } from "@angular/platform-browser";
6-
import { ParseBreaksPipe } from "@corelib";
76
import { CheckboxComponent } from "@ui/components";
8-
import { TruncateHtmlPipe } from "projects/core/src/lib/pipes/truncate-html.pipe";
97
import { TruncatePipe } from "projects/core/src/lib/pipes/truncate.pipe";
108
import { Task } from "@office/models/courses.model";
9+
import { resolveVideoUrlForIframe } from "@utils/video-url-embed";
1110

1211
/**
1312
* Компо��ент задачи на исключение лишнего
@@ -65,10 +64,16 @@ export class ExcludeTaskComponent implements OnInit {
6564
_error = signal<boolean>(false);
6665

6766
getSafeVideoUrl(): SafeResourceUrl | null {
68-
if (!this.data?.videoUrl) {
67+
const iframeUrl = resolveVideoUrlForIframe(this.data?.videoUrl);
68+
if (!iframeUrl) {
6969
return null;
7070
}
71-
return this.sanitizer.bypassSecurityTrustResourceUrl(this.data.videoUrl);
71+
72+
return this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrl);
73+
}
74+
75+
hasVideoUrl(): boolean {
76+
return !!resolveVideoUrlForIframe(this.data?.videoUrl);
7277
}
7378

7479
/**

projects/social_platform/src/app/office/courses/lesson/shared/file-task/file-task.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<!-- @format -->
22

3-
<div class="file-task" [class.file-task--hasVideo]="!!data.videoUrl">
3+
<div class="file-task" [class.file-task--hasVideo]="hasVideoUrl()">
44
<div class="file-task__header">
55
<p class="text-body-12 file-task__task">задание {{ data.order }}</p>
6-
@if (!data.videoUrl && !data.imageUrl) {
6+
@if (!hasVideoUrl() && !data.imageUrl) {
77
<p class="file-task__text text-body-12-bold">{{ data.title | truncate: 80 }}</p>
88
}
99
<div
1010
class="file-task__description text-body-12"
11-
[class.file-task__description--hasVideo]="!!data.videoUrl"
11+
[class.file-task__description--hasVideo]="hasVideoUrl()"
1212
>
13-
@if (data.videoUrl) {
13+
@if (getSafeVideoUrl(); as videoUrl) {
1414
<iframe
15-
[src]="getSafeVideoUrl()"
15+
[src]="videoUrl"
1616
width="397px"
1717
height="223px"
1818
frameborder="0"

projects/social_platform/src/app/office/courses/lesson/shared/file-task/file-task.component.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@
9696
align-self: center;
9797
justify-content: center;
9898
}
99+
100+
iframe {
101+
display: block;
102+
width: 100%;
103+
max-width: 400px;
104+
aspect-ratio: 16 / 9;
105+
height: auto;
106+
border: 0;
107+
border-radius: var(--rounded-lg);
108+
}
99109
}
100110

101111
&__label {

projects/social_platform/src/app/office/courses/lesson/shared/file-task/file-task.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { FileItemComponent } from "@ui/components/file-item/file-item.component"
1111
import { FileService } from "@core/services/file.service";
1212
import { Task } from "@office/models/courses.model";
1313
import { FileModel } from "@office/models/file.model";
14+
import { resolveVideoUrlForIframe } from "@utils/video-url-embed";
1415

1516
@Component({
1617
selector: "app-file-task",
@@ -57,10 +58,16 @@ export class FileTaskComponent {
5758
uploadedFiles = signal<FileModel[]>([]);
5859

5960
getSafeVideoUrl(): SafeResourceUrl | null {
60-
if (!this.data?.videoUrl) {
61+
const iframeUrl = resolveVideoUrlForIframe(this.data?.videoUrl);
62+
if (!iframeUrl) {
6163
return null;
6264
}
63-
return this.sanitizer.bypassSecurityTrustResourceUrl(this.data.videoUrl);
65+
66+
return this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrl);
67+
}
68+
69+
hasVideoUrl(): boolean {
70+
return !!resolveVideoUrlForIframe(this.data?.videoUrl);
6471
}
6572

6673
onFileUploaded(event: { url: string; name: string; size: number; mimeType: string }) {

projects/social_platform/src/app/office/courses/lesson/shared/radio-select-task/radio-select-task.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!-- @format -->
22

3-
<div class="radio" [class.radio--hasContent]="!!data.videoUrl || !!data.imageUrl">
4-
<div class="radio__body" [class.radio__body--hasContent]="!!data.imageUrl || !!data.videoUrl">
5-
@if (data.videoUrl) {
3+
<div class="radio" [class.radio--hasContent]="hasVideoUrl() || !!data.imageUrl">
4+
<div class="radio__body" [class.radio__body--hasContent]="!!data.imageUrl || hasVideoUrl()">
5+
@if (getSafeVideoUrl(); as videoUrl) {
66
<iframe
7-
[src]="getSafeVideoUrl()"
7+
[src]="videoUrl"
88
width="283px"
99
height="183px"
1010
frameborder="0"

projects/social_platform/src/app/office/courses/lesson/shared/radio-select-task/radio-select-task.component.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@
109109
justify-content: center;
110110
max-width: 333px;
111111
text-align: center;
112+
113+
iframe {
114+
display: block;
115+
width: 100%;
116+
max-width: 288px;
117+
aspect-ratio: 16 / 9;
118+
height: auto;
119+
border: 0;
120+
border-radius: var(--rounded-lg);
121+
}
112122
}
113123
}
114124

0 commit comments

Comments
 (0)