Skip to content

Commit 131963a

Browse files
author
Markus Guder
committed
Fixed server issue + finished view
1 parent 6dbcdcb commit 131963a

5 files changed

Lines changed: 58 additions & 3 deletions

File tree

client/app/components/home/courses/courses.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<p class="subtitle">
2424
{{course.KURS_BESCHREIBUNG}}
2525
</p>
26+
<p class="subtitle applicationDate" *ngIf="course.ANM_DATUM">
27+
Anmeldung | {{course.ANM_DATUM | date:'dd.MM.yyyy'}}
28+
</p>
2629
</div>
2730
</div>
2831
</section>

client/app/components/home/courses/courses.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
border-bottom-left-radius: 0.8rem;
4242
}
4343

44+
.applicationDate {
45+
float: right;
46+
font-size: 0.8rem;
47+
}
48+
4449
.primary{
4550
background-color: #00d1b2;
4651
}

client/app/components/home/courses/courses.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ActivatedRoute, Params } from '@angular/router';
44
import { CommunicationService } from '../shared/communication.service';
55
import { log } from 'util';
66
import { UserService } from '../../../services/user.service';
7+
import { CoursesService } from '../shared/courses.service';
78

89
@Component({
910
selector: 'courses',
@@ -23,6 +24,7 @@ export class CoursesComponent implements AfterViewInit {
2324
public userService: UserService,
2425
private activatedRoute: ActivatedRoute,
2526
public comService: CommunicationService,
27+
public coursesService: CoursesService,
2628
public renderer: Renderer2) {}
2729

2830
ngAfterViewInit() {
@@ -42,10 +44,16 @@ export class CoursesComponent implements AfterViewInit {
4244

4345
requestCoursesByUser():void{
4446
this.userService.getCoursesByUser().subscribe(response =>{
45-
this.courses = response;
47+
response.forEach(element => {
48+
this.courses = [];
49+
this.coursesService.getCoursesByCourseId(element.ANM_KURS_ID).subscribe(response => {
50+
console.log(response);
51+
response.ANM_DATUM = element.ANM_DATUM;
52+
this.courses.push(response);
53+
});
54+
});
4655
if(response.name != "HttpResponseError"){
4756
this.dataIsAvailable = true;
48-
this.courses = response;
4957
}
5058
});
5159
}

client/app/components/home/home.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { SharedModule } from '../../sharedModule/shared.module';
1414
import { AlertService } from '../../services/alert.service';
1515
import { CategoryService } from '../../services/category.service';
1616
import { CoursesComponent } from './courses/courses.component';
17+
import { CoursesService } from './shared/courses.service';
1718

1819
@NgModule({
1920
declarations: [
@@ -34,7 +35,8 @@ import { CoursesComponent } from './courses/courses.component';
3435
UserService,
3536
AlertService,
3637
CommunicationService,
37-
CategoryService
38+
CategoryService,
39+
CoursesService
3840
],
3941
exports: [MenuComponent],
4042
})
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Injectable } from '@angular/core';
2+
import { map, catchError } from 'rxjs/operators';
3+
import { Observable } from 'rxjs';
4+
import { environment } from '../../../../environments/environment.prod';
5+
import { HttpHeaders, HttpClient, HttpErrorResponse } from '@angular/common/http';
6+
import { AlertService } from '../../../services/alert.service';
7+
8+
@Injectable({
9+
providedIn: 'root'
10+
})
11+
12+
export class CoursesService {
13+
14+
private url: string = environment.apiUrl;
15+
16+
private httpOptions = {
17+
headers: new HttpHeaders({
18+
'Content-Type': 'application/json',
19+
'Authorization': localStorage.getItem('token')
20+
})
21+
};
22+
23+
constructor(public http: HttpClient, public alertService: AlertService) { }
24+
25+
getCoursesByCourseId(courseId: String): Observable<any>{
26+
return this.http.get(this.url + "/courses/" + courseId, this.httpOptions).pipe(
27+
map((res: Response) => {
28+
return res;
29+
}),
30+
catchError((err: HttpErrorResponse) => {
31+
this.alertService.push(err);
32+
return Observable.of(err);
33+
})
34+
);
35+
}
36+
37+
}

0 commit comments

Comments
 (0)