-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create user-doorboard component files and rename user-service
I've taken the infrastructure from the previous iteration and pasted it into the userdoorboardcomponent.ts, but I haven't made it work with the new code base yet. Progresses issue #9
- Loading branch information
Showing
6 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Component, OnInit, OnDestroy} from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { User } from '../user'; | ||
import { UserService } from '../user.service'; | ||
import { Subscription } from 'rxjs'; | ||
import { Note } from '../note'; | ||
import { NotesService } from '../notes.service'; | ||
|
||
|
||
@Component({ | ||
selector: 'app-user-doorboard', | ||
templateUrl: './user-doorboard.component.html', | ||
styleUrls: ['./user-doorboard.component.scss'] | ||
}) | ||
// starting structure taken from https://github.com/UMM-CSci-3601-S20/it-1-knights-who-say-ni | ||
|
||
// This class has access to the user of the doorboard, and all the notes that said user has made | ||
export class UserDoorBoardComponent implements OnInit, OnDestroy { | ||
constructor(private route: ActivatedRoute, private notesService: NotesService, | ||
private userService: UserService) { } | ||
notes: Note[]; | ||
user: User; | ||
id: string; | ||
getNotesSub: Subscription; | ||
getUserSub: Subscription; | ||
ngOnInit(): void { | ||
// We subscribe to the parameter map here so we'll be notified whenever | ||
// that changes (i.e., when the URL changes) so this component will update | ||
// to display the newly requested user. | ||
this.route.paramMap.subscribe((pmap) => { | ||
this.id = pmap.get('id'); | ||
this.getUserSub = this.userService.getUserById(this.id).subscribe(user => this.user = user); | ||
this.getNotesSub = this.notesService.getUserNotes({ user_id: this.id }).subscribe(notes => this.notes = notes.reverse()); | ||
|
||
}); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
if (this.getNotesSub) { | ||
this.getNotesSub.unsubscribe(); | ||
} | ||
if (this.getUserSub) { | ||
this.getUserSub.unsubscribe(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters