Skip to content

Commit 4dddda1

Browse files
authored
Merge pull request #115 from marc101101/feature/courses-of-each-category
Feature/courses of each category
2 parents 12f56ae + daee32c commit 4dddda1

13 files changed

Lines changed: 180 additions & 11 deletions

client/app/app-routing.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { LocationStrategy, HashLocationStrategy } from '@angular/common';
2828
{
2929
path: 'home',
3030
loadChildren: './components/home/home.module#HomeModule',
31-
canActivate: [AuthGuard],
31+
//canActivate: [AuthGuard],
3232
data: {prelaod: true}
3333
},
3434
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</div>
1414

1515
<section style="padding: 1rem;" *ngIf="dataIsAvailable">
16-
<div class="card" *ngFor="let category of categories; let i=index">
16+
<div class="card" *ngFor="let category of categories; let i=index" (click)="routeToCourse(category.RUB_ID, colorArray[i])">
1717
<div class="color-marker" [ngClass]="colorArray[i]">
1818
</div>
1919
<div class="card-content">

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
22
import { CategoryService } from '../../../services/category.service';
3+
import { Router } from '@angular/router';
4+
import { CommunicationService } from '../shared/communication.service';
35

46
@Component({
57
selector: 'categories',
@@ -11,7 +13,7 @@ export class CategoriesComponent implements OnInit {
1113
public categories: Array<any>;
1214
public colorArray: Array<any> = ["primary", "link", "danger", "success", "warning", "info"];
1315

14-
constructor(public categoryService: CategoryService) { }
16+
constructor(public categoryService: CategoryService, private router: Router, public comService: CommunicationService) { }
1517

1618
ngOnInit() {
1719
this.categoryService.getAllCategories().subscribe(response =>{
@@ -22,4 +24,9 @@ export class CategoriesComponent implements OnInit {
2224
});
2325
}
2426

27+
routeToCourse(categoryId: number, color: string) {
28+
this.router.navigateByUrl('home/kurs-uebersicht/' + categoryId);
29+
this.comService.setColor(color);
30+
}
31+
2532
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<div class="container fullScreenBackground">
2+
<div class="circleBackground" #backgroundElement></div>
3+
<div class="columns is-mobile">
4+
<div class="column is-12" style="z-index: 0; padding: 2rem; padding-left: 5rem;">
5+
<div style="font-size: 1.5rem; color:white;">
6+
Kurs Kategorien
7+
</div>
8+
</div>
9+
</div>
10+
11+
<div class="column" style="margin-top: -2rem;padding: 1.0rem;">
12+
<alert></alert>
13+
</div>
14+
15+
<section style="padding: 1rem;" *ngIf="dataIsAvailable">
16+
<div class="card" *ngFor="let course of courses; let i=index">
17+
<div class="color-marker">
18+
</div>
19+
<div class="card-content">
20+
<p class="title">
21+
{{course.KURS_NAME}}
22+
</p>
23+
<p class="subtitle">
24+
{{course.KURS_BESCHREIBUNG}}
25+
</p>
26+
</div>
27+
</div>
28+
</section>
29+
30+
</div>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
.circleBackground {
2+
height: 30rem;
3+
width: 30rem;
4+
z-index: 0;
5+
background-color: #209cee;
6+
border-radius: 15rem;
7+
position: absolute;
8+
margin-top: -13rem;
9+
margin-left: -7rem;
10+
}
11+
12+
.fullScreenBackground {
13+
position: absolute;
14+
height: 100%;
15+
width: 100%;
16+
overflow: hidden;
17+
box-shadow: 0px 0px 13px #6E6E6E;
18+
}
19+
20+
.card {
21+
margin-top: 1rem;
22+
border-radius: 0.5rem;
23+
}
24+
25+
.title {
26+
font-size: 1.25rem !important;
27+
padding-left: 1rem;
28+
}
29+
30+
.subtitle {
31+
font-size: 0.9rem;
32+
padding-left: 1rem;
33+
}
34+
35+
.color-marker {
36+
float: right;
37+
height: 100%;
38+
position: absolute;
39+
width: 10px;
40+
border-top-left-radius: 0.8rem;
41+
border-bottom-left-radius: 0.8rem;
42+
}
43+
44+
.primary{
45+
background-color: #00d1b2;
46+
}
47+
48+
.link{
49+
background-color: #3273dc;
50+
}
51+
52+
.info{
53+
background-color: #23d160;
54+
}
55+
56+
.success{
57+
background-color: #ffdd57;
58+
}
59+
60+
.warning{
61+
background-color: #ffbc6b;
62+
}
63+
64+
.danger{
65+
background-color: #ff3860;
66+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Component, OnInit, Renderer2, ViewChild, ElementRef } from '@angular/core';
2+
import { CategoryService } from '../../../services/category.service';
3+
import { ActivatedRoute, Params } from '@angular/router';
4+
import { CommunicationService } from '../shared/communication.service';
5+
import { log } from 'util';
6+
7+
@Component({
8+
selector: 'courses',
9+
templateUrl: './courses.component.html',
10+
styleUrls: ['./courses.component.scss']
11+
})
12+
export class CoursesComponent implements OnInit {
13+
14+
@ViewChild('backgroundElement') backgroundElement: ElementRef;
15+
16+
public dataIsAvailable: boolean = false;
17+
public courses: Array<any>;
18+
19+
constructor(public categoryService: CategoryService,
20+
private activatedRoute: ActivatedRoute,
21+
public comService: CommunicationService,
22+
public renderer: Renderer2) {
23+
let localThis = this;
24+
this.comService.getColor().subscribe(color => {
25+
console.log(color);
26+
this.renderer.addClass(this.backgroundElement.nativeElement, color);
27+
});
28+
}
29+
30+
ngOnInit() {
31+
this.activatedRoute.params.subscribe((params: Params) => {
32+
this.categoryService.getCoursesByCategoryId(params.courseId).subscribe(response =>{
33+
this.courses = response;
34+
if(response.name != "HttpResponseError"){
35+
this.dataIsAvailable = true;
36+
this.courses = response;
37+
}
38+
});
39+
});
40+
}
41+
42+
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { AuthGuard } from '../../guards/auth.guard';
44
import { HomeComponent } from './home.component';
55
import { CategoriesComponent } from './categories/categories.component';
66
import { ProfilComponent } from './profil/profil.component';
7+
import { CoursesComponent } from './courses/courses.component';
78

89
const routes: Routes = [
910
{
1011
path: '',
1112
component: HomeComponent,
12-
canActivate: [AuthGuard],
13+
//canActivate: [AuthGuard],
1314
children: [
1415
{
1516
path: 'kategorien',
@@ -24,8 +25,8 @@ const routes: Routes = [
2425
component: CategoriesComponent
2526
},
2627
{
27-
path: 'kurs-uebersicht',
28-
component: CategoriesComponent
28+
path: 'kurs-uebersicht/:courseId',
29+
component: CoursesComponent
2930
},
3031
{
3132
path: 'kontakt',

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ import { UserService } from '../../services/user.service';
1313
import { SharedModule } from '../../sharedModule/shared.module';
1414
import { AlertService } from '../../services/alert.service';
1515
import { CategoryService } from '../../services/category.service';
16+
import { CoursesComponent } from './courses/courses.component';
1617

1718
@NgModule({
1819
declarations: [
1920
CategoriesComponent,
2021
ProfilComponent,
22+
CoursesComponent,
2123
MenuComponent,
2224
HomeComponent
2325
],

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ProfilComponent implements OnInit {
3838

3939
resetButton() {
4040
this.renderer.removeClass(this.saveButton.nativeElement, 'is-primary-save');
41-
this.button_text = 'Speichern';
41+
this.button_text = 'Speichern';
4242
}
4343

4444
backClicked() {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Injectable } from '@angular/core';
22
import { Subject } from 'rxjs/Subject';
33
import { log } from 'util';
4+
import { Observable } from 'rxjs';
45

56
@Injectable()
67
export class CommunicationService{
78

89
public instruction_sub_comb = new Subject<any>();
10+
private color: string;
911

1012
constructor() {
1113
}
@@ -14,4 +16,12 @@ export class CommunicationService{
1416
this.instruction_sub_comb.next(message);
1517
}
1618

19+
setColor(color: string) {
20+
this.color = color;
21+
}
22+
23+
getColor(): Observable<string>{
24+
return Observable.of(this.color);
25+
}
26+
1727
}

0 commit comments

Comments
 (0)