diff --git a/frontend/src/app/_services/shared-data.service.ts b/frontend/src/app/_services/shared-data.service.ts index b30b414..1b49f95 100644 --- a/frontend/src/app/_services/shared-data.service.ts +++ b/frontend/src/app/_services/shared-data.service.ts @@ -5,11 +5,38 @@ import { ForumData } from '../_interfaces/forumdata'; @Injectable() export class SharedDataService { private dataBS: BehaviorSubject = new BehaviorSubject({}); + private json = ` + { + "id": "1", + "name": "Kurs 1", + "discussion": [ + { + "title": "test123", + "id": "1", + "first_post": "0" + }, + { + "title": "dupa321", + "id": "2", + "first_post": "2" + }, + { + "title": "TEST", + "id": "3", + "first_post": "10" + } + ] + }`; constructor() {} public setData(value: any): void { - this.dataBS.next(value); + /* + * this.dataBS.next(value); + */ + /* For testing purposes only */ + const obj = JSON.parse(this.json); + this.dataBS.next(obj); } public getData() { diff --git a/frontend/src/app/_types/color.d.ts b/frontend/src/app/_types/color.d.ts new file mode 100644 index 0000000..1371c75 --- /dev/null +++ b/frontend/src/app/_types/color.d.ts @@ -0,0 +1,9 @@ +export type Colors = + | '' + | 'primary' + | 'info' + | 'success' + | 'warning' + | 'danger' + | 'basic' + | 'control'; diff --git a/frontend/src/app/front-page/front-page.component.ts b/frontend/src/app/front-page/front-page.component.ts index af34387..2cc8fab 100644 --- a/frontend/src/app/front-page/front-page.component.ts +++ b/frontend/src/app/front-page/front-page.component.ts @@ -37,9 +37,11 @@ export class FrontPageComponent { } sendFile(event: any): void { - this.sendDataService.postFile(this.file).subscribe((res: any) => { - this.sharedDataService.setData(res); - }); + // this.sendDataService.postFile(this.file).subscribe((res: any) => { + // this.sharedDataService.setData(res); + // }); + /* For testing */ + this.sharedDataService.setData('test'); this.router.navigate(['/view']); } } diff --git a/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.html b/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.html index 9942342..5d0b550 100644 --- a/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.html +++ b/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.html @@ -1 +1,10 @@ -

discussion-chooser works!

+
+

Wybierz dyskusję z {{ data.name }}:

+ +

{{ item.title }}

+
+
diff --git a/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.scss b/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.scss index e69de29..ddb4748 100644 --- a/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.scss +++ b/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.scss @@ -0,0 +1,8 @@ +.picker-container { + &__discussion { + cursor: pointer; + } + &__disc-title { + margin: 1rem; + } +} diff --git a/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.ts b/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.ts index c855251..0b09f16 100644 --- a/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.ts +++ b/frontend/src/app/main-view/discussion-chooser/discussion-chooser.component.ts @@ -1,15 +1,49 @@ -import { Component, OnInit } from '@angular/core'; +import { + Component, + OnInit, + OnDestroy, + ChangeDetectionStrategy, +} from '@angular/core'; +import { SharedDataService } from '../../_services/shared-data.service'; +import { Colors } from '../../_types/color'; +import { Subscription } from 'rxjs'; + +interface CustomForumData { + id: string; + name: string; + discussion: [ + { + title: string; + id: string; + first_post: string; + } + ]; +} @Component({ selector: 'app-discussion-chooser', + changeDetection: ChangeDetectionStrategy.OnPush, templateUrl: './discussion-chooser.component.html', - styleUrls: ['./discussion-chooser.component.scss'] + styleUrls: ['./discussion-chooser.component.scss'], }) -export class DiscussionChooserComponent implements OnInit { +export class DiscussionChooserComponent implements OnInit, OnDestroy { + public data: CustomForumData; + colors: Colors[] = ['primary', 'danger', 'info', 'success', 'warning']; + private dataSub: Subscription; - constructor() { } + constructor(private sharedDataService: SharedDataService) {} ngOnInit(): void { + this.dataSub = this.sharedDataService.getData().subscribe((res) => { + this.data = res as CustomForumData; + }); } + ngOnDestroy(): void { + this.dataSub.unsubscribe(); + } + + getRandomColor(): Colors { + return this.colors[Math.floor(Math.random() * this.colors.length)]; + } } diff --git a/frontend/src/app/main-view/main-view.component.html b/frontend/src/app/main-view/main-view.component.html index aa6f6c7..61698ea 100644 --- a/frontend/src/app/main-view/main-view.component.html +++ b/frontend/src/app/main-view/main-view.component.html @@ -7,9 +7,12 @@ (click)="toggleSidebar()" nbTooltip="Schowaj/Pokaż panel menu" > + nkadf - Wyloguj + Wyloguj diff --git a/frontend/src/app/main-view/main-view.component.ts b/frontend/src/app/main-view/main-view.component.ts index 29750fb..6b43555 100644 --- a/frontend/src/app/main-view/main-view.component.ts +++ b/frontend/src/app/main-view/main-view.component.ts @@ -1,8 +1,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core'; -import { SharedDataService } from '../_services/shared-data.service'; +import { Router } from '@angular/router'; import { NbSidebarService } from '@nebular/theme'; -import { Subscription } from 'rxjs'; @Component({ selector: 'app-main-view', @@ -10,25 +9,20 @@ import { Subscription } from 'rxjs'; styleUrls: ['./main-view.component.scss'], }) export class MainViewComponent implements OnInit, OnDestroy { - public data: any; - private dataSub: Subscription; - constructor( - private sharedDataService: SharedDataService, - private sidebarService: NbSidebarService + private sidebarService: NbSidebarService, + private router: Router ) {} - ngOnInit(): void { - this.dataSub = this.sharedDataService.getData().subscribe((res) => { - this.data = res; - }); - } + ngOnInit(): void {} - ngOnDestroy(): void { - this.dataSub.unsubscribe(); - } + ngOnDestroy(): void {} toggleSidebar() { this.sidebarService.toggle(true, 'main'); } + + logout() { + this.router.navigate(['/']); + } } diff --git a/frontend/src/app/main-view/main-view.module.ts b/frontend/src/app/main-view/main-view.module.ts index a057c64..7305a52 100644 --- a/frontend/src/app/main-view/main-view.module.ts +++ b/frontend/src/app/main-view/main-view.module.ts @@ -10,6 +10,7 @@ import { NbActionsModule, NbSidebarModule, NbTooltipModule, + NbCardModule, } from '@nebular/theme'; @NgModule({ @@ -21,6 +22,7 @@ import { NbActionsModule, NbSidebarModule, NbTooltipModule, + NbCardModule, ], }) export class MainViewModule {}