Skip to content

Commit ee59353

Browse files
author
Ian Redpath
committed
add library support
1 parent 51f316d commit ee59353

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

public/project/components/header/header.view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<a [routerLink]='["/Login"]'>Sign In</a>
2020
</li>
2121
<li *ngIf="isActiveUser()" [class.active]="isRouteActive('user')">
22-
<a [routerLink]='["/User", { user: userService.getActiveUser().id }]'>Profile Icon</a>
22+
<a [routerLink]='["/User", { user: userService.getActiveUser()._id }]'>Profile Icon</a>
2323
</li>
2424
<li *ngIf="isActiveUser()">
2525
<a>Notifications Icon</a>

public/project/components/users/user.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class User {
4545
if (this.newLibraryName) {
4646
let newLib: any = {}
4747
newLib.name = this.newLibraryName
48+
newLib.user = this.user
4849
this.libraryService.addLibrary(newLib)
4950
.subscribe(resp => {
5051
if (resp.json().library) {

public/project/components/users/user.view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h1>{{user.username}}</h1>
1616
<div>
1717
<h3>Libraries</h3>
1818
<div class="new-library" *ngIf='hasEditRights()'>
19-
<input type="text" [(ngClass)]="newLibraryName" placeholder="Library name">
19+
<input type="text" [(ngModel)]="newLibraryName" placeholder="Library name">
2020
<button class="btn btn-default" (click)='newLibrary()'>+</button>
2121
</div>
2222
<div class="library-carousel">

server/project/data/database.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default class Database {
3333
}
3434

3535
createUser(user) {
36-
user._id = (this.randomId++).toString()
36+
user._id = this.randomId++
3737
if(_.find(this.users, u => { return u.username === user.username })) {
3838
return { error: "duplicate username!" }
3939
}
@@ -78,10 +78,13 @@ export default class Database {
7878
}
7979

8080
createLibrary(library) {
81-
library.id = (this.randomId++).toString()
81+
library.id = this.randomId++
8282
this.libraries.push(library)
8383
const user = library.user
84-
_.find(this.users, u => { return u._id === user.id }).libraries.push(library)
84+
console.log(user)
85+
const dbUser = _.find(this.users, u => { return u._id === user._id })
86+
console.log(dbUser)
87+
dbUser.libraries.push(library)
8588
return library
8689
}
8790

0 commit comments

Comments
 (0)