Skip to content

Commit 87f10c9

Browse files
committed
Angular NgRx Course
1 parent 9693cbc commit 87f10c9

File tree

4 files changed

+6
-22
lines changed

4 files changed

+6
-22
lines changed

server/search-lessons.route.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ export function searchLessons(req: Request, res: Response) {
1111

1212
console.log('Searching for lessons ...');
1313

14-
// const error = (Math.random() >= 0.5);
15-
16-
// if (error) {
17-
// console.log("ERROR loading lessons!");
18-
// res.status(500).json({message: 'random error occurred.'});
19-
// }
20-
// else {
21-
22-
2314
const queryParams = req.query;
2415

2516
const courseId = queryParams.courseId,
@@ -43,12 +34,8 @@ export function searchLessons(req: Request, res: Response) {
4334
const lessonsPage = lessons.slice(initialPos, initialPos + pageSize);
4435

4536
setTimeout(() => {
46-
res.status(200).json({payload: lessonsPage});
37+
res.status(200).json(lessonsPage);
4738
},1000);
4839

49-
// }
50-
51-
52-
5340

5441
}

src/app/courses/course/course.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h2>{{course?.description}}</h2>
1010

1111
</div>
1212

13-
<mat-table class="lessons-table mat-elevation-z8" [dataSource]="lessons">
13+
<mat-table class="lessons-table mat-elevation-z8" [dataSource]="lessons$ | async">
1414

1515
<ng-container matColumnDef="seqNo">
1616

src/app/courses/course/course.component.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ export class CourseComponent implements OnInit {
3535

3636
const courseUrl = this.route.snapshot.paramMap.get('id');
3737

38-
this.loading$ = this.coursesService.loading$;
39-
40-
const selectAllCourses = this.coursesService.selectors.selectEntities;
41-
4238
this.course$ = this.coursesService.entities$
4339
.pipe(
4440
map(courses => courses.find(course => course.url == courseUrl))
@@ -51,9 +47,10 @@ export class CourseComponent implements OnInit {
5147
"pageIndex": "0",
5248
"pageSize": "3"
5349
}))
54-
5550
);
5651

52+
this.loading$ = this.lessonsService.loading$;
53+
5754
}
5855

5956

src/styles.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ $theme: mat-light-theme($primary, $accent);
5353

5454
.spinner-container {
5555
position: fixed;
56-
height: 334px;
57-
width: 360px;
56+
height: 300px;
57+
width: 390px;
5858
display: flex;
5959
background: white;
6060
margin-top: 70px;

0 commit comments

Comments
 (0)