Skip to content

Commit

Permalink
Create user-doorboard component files and rename user-service
Browse files Browse the repository at this point in the history
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
Burge337 committed Mar 27, 2020
1 parent 3b8003c commit 021d95e
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 4 deletions.
Empty file.
Empty file.
Empty file.
47 changes: 47 additions & 0 deletions client/src/app/user-doorboard/user-doorboard.component.ts
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();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/
import { TestBed } from '@angular/core/testing';
import { User } from './user';
import { NotesService } from './notes.service';
import { UserService } from './user-service';
import { UserService } from './user.service';

describe('Note service:', () => {
// pulled these from https://github.com/UMM-CSci-3601-S20/it-1-knights-who-say-ni
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { User } from './user';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

@Injectable({
providedIn: 'root'
})
@Injectable()

export class UserService {

Expand All @@ -19,6 +17,11 @@ export class UserService {
return this.httpClient.get<User[]>(this.userUrl);
}

// needed for getting the user doorboards (we grab the user id from the url, and we need to get the actual user from that as well)
getUserById() {
return null;
}

// adding stub
addUser(newUser: User): Observable<string> {
return null;
Expand Down

0 comments on commit 021d95e

Please sign in to comment.