Skip to content

Commit 1a4a767

Browse files
authored
Merge pull request #140 from marc101101/feature/feedback-course
Feature/feedback course
2 parents 7273dae + 2364155 commit 1a4a767

5 files changed

Lines changed: 62 additions & 11 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="columns is-mobile">
44
<div class="column is-12" style="z-index: 0; padding: 2rem; padding-left: 5rem; padding-bottom: 0rem;">
55
<div style="font-size: 1.5rem; color:white;">
6-
Kontakt
6+
{{headerText}}
77
</div>
88
</div>
99
<div class="columns is-mobile">
Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import { Component, OnInit, ViewChild, Renderer2, ElementRef } from '@angular/core';
2-
import { Router } from '@angular/router';
2+
import { Router, ActivatedRoute, Params } from '@angular/router';
33
import { ContactService } from '../shared/contact.service';
4+
import { log } from 'util';
5+
import { CoursesService } from '../shared/courses.service';
46

57
@Component({
68
selector: 'contact',
79
templateUrl: './contact.component.html',
810
styleUrls: ['./contact.component.scss']
911
})
10-
export class ContactComponent {
12+
export class ContactComponent implements OnInit{
1113
public dataIsAvailable: boolean = false;
12-
public button_text: string = "Feedback senden"
14+
public button_text: string = "Feedback senden";
15+
public headerText: string = "Kontakt";
16+
public course_feedback: boolean = false;
17+
public single_course;
1318
public contactMessage: any = {
1419
text: "",
1520
bewertung: null,
@@ -20,14 +25,39 @@ export class ContactComponent {
2025
constructor(
2126
private router: Router,
2227
private renderer: Renderer2,
23-
private contactService: ContactService) { }
28+
private contactService: ContactService,
29+
private activatedRoute: ActivatedRoute,
30+
private coursesService:CoursesService) { }
2431

25-
submit():void{
26-
this.contactService.postContactFeedback(this.contactMessage).subscribe(response => {
27-
if(response.name != "HttpResponseError"){
28-
this.renderer.addClass(this.sendButton.nativeElement, 'is-primary-save');
29-
this.button_text = 'Senden erfolgreich';
30-
}
32+
ngOnInit(){
33+
this.activatedRoute.params.subscribe((params: Params) => {
34+
if(params.id){
35+
this.coursesService.getCoursesByCourseId(params.id).subscribe(response =>{
36+
this.single_course = response;
37+
this.course_feedback = true;
38+
this.headerText = "Bewertung: " + this.single_course.KURS_NAME;
39+
});
40+
}
3141
});
3242
}
43+
44+
submit():void{
45+
if(this.course_feedback){
46+
this.coursesService.postFeedbackByCourse(this.contactMessage, this.single_course.KURS_ID).subscribe(response => {
47+
console.log(response);
48+
if(response.name != "HttpResponseError"){
49+
this.renderer.addClass(this.sendButton.nativeElement, 'is-primary-save');
50+
this.button_text = 'Senden erfolgreich';
51+
}
52+
});
53+
}
54+
else{
55+
this.contactService.postContactFeedback(this.contactMessage).subscribe(response => {
56+
if(response.name != "HttpResponseError"){
57+
this.renderer.addClass(this.sendButton.nativeElement, 'is-primary-save');
58+
this.button_text = 'Senden erfolgreich';
59+
}
60+
});
61+
}
62+
}
3363
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ const routes: Routes = [
3838
path: 'kontakt',
3939
component: ContactComponent
4040
},
41+
{
42+
path: 'kontakt/:id',
43+
component: ContactComponent
44+
},
4145
{
4246
path: 'profil',
4347
component: ProfilComponent

client/app/components/home/shared/courses.service.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,19 @@ export class CoursesService {
5858
})
5959
)
6060
}
61+
62+
postFeedbackByCourse(feedback: any, courseId:string): Observable<any>{
63+
return this.http.post(this.url + "/courses/" + courseId + "/feedback" ,feedback, this.httpOptions).pipe(
64+
map((res: Response) => {
65+
return res;
66+
}),
67+
catchError((err: HttpErrorResponse) => {
68+
this.alertService.push(err);
69+
return of(err);
70+
})
71+
)
72+
}
73+
74+
6175

6276
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
+ singleCourse.location.ORT_PLZ">
3535
<i class="fa fa-location-arrow" aria-hidden="true"></i>
3636
</a>
37+
<a class="button is-fullwidth is-warning nav-button" [routerLink]="['/home/kontakt/' + singleCourse.KURS_ID]" >
38+
<i class="fa fa-star" aria-hidden="true"></i>
39+
</a>
3740
</section>
3841

3942
<div class="column is-12" *ngIf="showButton" style="padding: 1rem; padding-top: 1.5rem; padding-bottom: 1.5rem;">

0 commit comments

Comments
 (0)