Skip to content

Commit 6024c6c

Browse files
committed
fix logic upload resource
1 parent 91fd9e7 commit 6024c6c

File tree

7 files changed

+23
-16
lines changed

7 files changed

+23
-16
lines changed

package-lock.json

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/core/models/resource.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ export interface ResourceCreateRequest {
6060
category: FileCategory;
6161
description: string;
6262
tags: string[];
63+
isLectureVideo: boolean;
64+
isTextbook: boolean;
65+
orgId: string | null | undefined;
6366
}
6467

6568
//--------------Input episode local---------------------

src/app/core/services/api-service/resource.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@ export class ResourceService {
5959
}
6060

6161
addResource(postData: ResourceCreateRequest) {
62-
const { file, category, description, tags } = postData;
62+
const { file, category, isLectureVideo, isTextbook, description, tags } =
63+
postData;
6364

6465
// data: phần dữ liệu thông thường (không phải file)
6566
const data: Record<string, any> = {
6667
category,
6768
description,
69+
isLectureVideo,
70+
isTextbook,
6871
tags: JSON.stringify(tags), // stringify array để backend parse
6972
};
7073

src/app/core/services/config-service/api.enpoints.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const version = 'v1';
1212

1313
export const API_CONFIG = {
1414
BASE_URLS: {
15-
MAIN_API: environment.IP_SERVER, //chạy ở local thì đổi ip thành IP_SERVER_LOCAL và thêm "+ version" vào chuỗi MAIN_API (sau IP). push lên github nhớ stash commit hoặc không làm thay đổi dòng này.
15+
MAIN_API: environment.IP_SERVER_LOCAL + version, //chạy ở local thì đổi ip thành IP_SERVER_LOCAL và thêm "+ version" vào chuỗi MAIN_API (sau IP). push lên github nhớ stash commit hoặc không làm thay đổi dòng này.
1616
SECONDARY_API: '',
1717
},
1818
ENDPOINTS: {

src/app/features/resource-learning/pages/resource-create/resource-create.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ export class ResourceCreatePageComponent {
109109

110110
const file = this.selectedFile;
111111
let category: FileCategory = 3;
112+
let isLectureVideo = false;
113+
let isTextbook = false;
112114

113115
if (file) {
114116
const fileType = file.type;
@@ -120,20 +122,26 @@ export class ResourceCreatePageComponent {
120122
fileType.includes('text')
121123
) {
122124
category = 2;
125+
isTextbook = true;
123126
}
124127
if (fileType.startsWith('video/')) {
125128
category = 1;
129+
isLectureVideo = true;
126130
}
127131
if (fileType.startsWith('image/')) {
128132
category = 0;
133+
isTextbook = true;
129134
}
130135
}
131136

132137
const postData = {
133138
file,
134139
category,
140+
isLectureVideo,
141+
isTextbook,
135142
description: this.htmlToMd.convert(this.editorContent),
136143
tags: this.tags,
144+
orgId: null,
137145
};
138146
this.store.dispatch(
139147
setLoading({

src/app/features/resource-learning/pages/resource-list/resource-list.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
[icon]="'fa fa-search'"
1414
></app-input>
1515
</div>
16+
@if(hasPermissionAction){
1617
<div class="resource-list-button">
1718
<app-button
1819
(onClick)="handleAdd()"
@@ -23,6 +24,7 @@
2324
<span style="font-size: 24px">+</span>
2425
</app-button>
2526
</div>
27+
}
2628
</div>
2729

2830
<div class="list-resource-card-container">

src/app/features/resource-learning/pages/resource-list/resource-list.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ResourceEditPopupComponent } from '../../modal/popup-update/resource-ed
1717
import { ScrollEndDirective } from '../../../../shared/directives/scroll-end.directive';
1818
import { forkJoin } from 'rxjs';
1919
import { map } from 'rxjs/operators';
20+
import { activeForAdminAndTeacher } from '../../../../shared/utils/authenRoleActions';
2021

2122
@Component({
2223
selector: 'app-resource-list',
@@ -44,6 +45,8 @@ export class ResourceListComponent {
4445
{ name: 'JavaScript', views: 20000 },
4546
];
4647

48+
hasPermissionAction = false;
49+
4750
isLoading = false;
4851
isLoadingMore = false;
4952
hasMore = true;
@@ -77,6 +80,8 @@ export class ResourceListComponent {
7780
}
7881

7982
ngOnInit(): void {
83+
this.hasPermissionAction = activeForAdminAndTeacher();
84+
8085
this.pageIndex = 1;
8186
this.fetchDataResource();
8287
}

0 commit comments

Comments
 (0)