Skip to content

Commit 8412b3d

Browse files
committed
2 parents 406e277 + 4c5593a commit 8412b3d

File tree

27 files changed

+1364
-774
lines changed

27 files changed

+1364
-774
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"date-fns": "^4.1.0",
4444
"github-markdown-css": "^5.8.1",
4545
"highlight.js": "^11.11.1",
46-
"hls.js": "^1.6.10",
46+
"hls.js": "^1.6.13",
4747
"marked": "^16.2.1",
4848
"ng-apexcharts": "^1.11.0",
4949
"ngx-cookie-service": "^20.1.0",

src/app/app.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { modalNoticeReducer } from './shared/store/modal-notice-state/modal-noti
2121
import { MarkdownModule, provideMarkdown } from 'ngx-markdown';
2222
import { provideLottieOptions } from 'ngx-lottie';
2323
import { variableReducer } from './shared/store/variable-state/variable.reducer';
24+
import { CustomPreloadStrategy } from './core/strategies/custom-preload.strategy';
2425

2526
export const appConfig: ApplicationConfig = {
2627
providers: [
@@ -39,7 +40,7 @@ export const appConfig: ApplicationConfig = {
3940
}),
4041
provideAnimations(),
4142
provideMarkdown(),
42-
provideRouter(routes, withPreloading(PreloadAllModules)),
43+
provideRouter(routes, withPreloading(CustomPreloadStrategy)),
4344
importProvidersFrom(MarkdownModule.forRoot()),
4445
],
4546
};

src/app/app.routes.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { AppLayoutComponent } from './layouts/layout-pages/app-layout/app-layout
66
import { AdminLayoutComponent } from './layouts/layout-pages/admin-layout/admin-layout';
77
// import { RoleGuard } from './core/guards/router-protected/role.guard';
88
import { PostModule } from './features/post/post.module';
9+
import { LandingModule } from './features/landing/landing.module';
910

1011
export const routes: Routes = [
1112
//Để test
@@ -76,7 +77,7 @@ export const routes: Routes = [
7677
{
7778
path: 'auth',
7879
component: AuthLayoutComponent,
79-
data: { skipBreadcrumb: true },
80+
data: { skipBreadcrumb: true, preload: true },
8081
children: [
8182
{
8283
path: 'identity',
@@ -93,10 +94,10 @@ export const routes: Routes = [
9394
children: [
9495
{
9596
path: '',
96-
loadChildren: () =>
97-
import('./features/landing/landing.module').then(
98-
(m) => m.LandingModule
99-
),
97+
loadChildren: () => LandingModule,
98+
// import('./features/landing/landing.module').then(
99+
// (m) => m.LandingModule
100+
// ),
100101
title: 'CodeCampus',
101102
},
102103
{
@@ -115,7 +116,8 @@ export const routes: Routes = [
115116
},
116117
{
117118
path: 'post-features',
118-
loadChildren: () => PostModule, //Load đầu tiên k dùng lazyload
119+
loadChildren: () =>
120+
import('./features/post/post.module').then((m) => m.PostModule), //Load đầu tiên k dùng lazyload
119121
},
120122
{
121123
path: 'resource-learning',
@@ -153,6 +155,7 @@ export const routes: Routes = [
153155
),
154156
},
155157
],
158+
data: { preload: true },
156159
},
157160

158161
{
@@ -200,6 +203,7 @@ export const routes: Routes = [
200203
data: { breadcrumb: 'Quản lý tài nguyên' },
201204
},
202205
],
206+
data: { preload: false },
203207
},
204208

205209
{

src/app/core/router-manager/horizontal-menu.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function getNavHorizontalItems(roles: string[]): SidebarItem[] {
3636
path: '/codecampus-statistics/admin-exercise-statistics',
3737
label: 'Thống kê',
3838
icon: 'fas fa-chart-bar',
39+
needHidden: !(roles.length !== 0),
3940
},
4041
{
4142
id: 'management',

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ export class ExerciseService {
8585
);
8686
}
8787

88-
getMyAssignExercise(page: number, size: number) {
88+
getMyAssignExercise(page?: number, size?: number) {
8989
return this.api.get<
9090
ApiResponse<IPaginationResponse<MyAssignExerciseResponse[]>>
91-
>(API_CONFIG.ENDPOINTS.GET.GET_MY_ASSGIN(page, size));
91+
>(API_CONFIG.ENDPOINTS.GET.GET_MY_ASSIGN(page, size));
9292
}
9393

9494
getMyQuizHistory(page: number, size: number) {
@@ -103,7 +103,7 @@ export class ExerciseService {
103103
>(API_CONFIG.ENDPOINTS.GET.GET_HISTORY_CODE(page, size));
104104
}
105105

106-
getMySubmissionsHistory(page: number, size: number) {
106+
getMySubmissionsHistory(page?: number, size?: number) {
107107
return this.api.get<
108108
ApiResponse<IPaginationResponse<MySubmissionsHistoryResponse[]>>
109109
>(API_CONFIG.ENDPOINTS.GET.GET_MY_SUBMISSION_HISTORY(page, size));

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,38 @@ export const API_CONFIG = {
102102

103103
return query;
104104
},
105-
GET_MY_ASSGIN: (page: number, size: number) =>
106-
`/submission/assignments/self?page=${page}&size=${size}`,
105+
GET_MY_ASSIGN: (page?: number, size?: number) => {
106+
let url = `/submission/assignments/self`;
107+
const params: string[] = [];
108+
109+
if (page !== undefined) params.push(`page=${page}`);
110+
if (size !== undefined) params.push(`size=${size}`);
111+
112+
if (params.length > 0) {
113+
url += `?${params.join('&')}`;
114+
}
115+
116+
return url;
117+
},
107118

108119
GET_HISTORY_QUIZ: (page: number, size: number) =>
109120
`/submission/quiz/self/history?page=${page}&size=${size}`,
110121
GET_HISTORY_CODE: (page: number, size: number) =>
111122
`/submission/coding/self/history?page=${page}&size=${size}`,
112-
GET_MY_SUBMISSION_HISTORY: (page: number, size: number) =>
113-
`/submission/self/history?page=${page}&size=${size}`,
123+
GET_MY_SUBMISSION_HISTORY: (page?: number, size?: number) => {
124+
let url = `/submission/self/history`;
125+
const params: string[] = [];
126+
127+
if (page !== undefined) params.push(`page=${page}`);
128+
if (size !== undefined) params.push(`size=${size}`);
129+
130+
if (params.length > 0) {
131+
url += `?${params.join('&')}`;
132+
}
133+
134+
return url;
135+
},
136+
114137
GET_ALL_USER: (
115138
page: number,
116139
size: number,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { PreloadingStrategy, Route } from '@angular/router';
2+
import { Observable, of } from 'rxjs';
3+
4+
export class CustomPreloadStrategy implements PreloadingStrategy {
5+
preload(route: Route, load: () => Observable<any>): Observable<any> {
6+
if (route.data && route.data['preload']) {
7+
return load();
8+
}
9+
return of(null);
10+
}
11+
}

0 commit comments

Comments
 (0)