diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/app.component.html b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/app.component.html index 2b886ba981..1387065adf 100644 --- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/app.component.html +++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/app.component.html @@ -57,9 +57,7 @@

Title: {{selectedBook.title}}

Author: {{selectedBook.author}}

A quick summary of the book

- Rating:
-
-
+ diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/app.component.ts b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/app.component.ts index 5256ad2244..94718f34fc 100644 --- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/app.component.ts +++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/app.component.ts @@ -23,6 +23,7 @@ export class AppComponent { private username: String = ''; private password: String = ''; + principal: Principal = new Principal(true, []); loginFailed: boolean = false; diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.css b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.css index e69de29bb2..9c5c93b041 100644 --- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.css +++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.css @@ -0,0 +1,3 @@ +div.progress { + margin-top: 5px; +} diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.html b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.html index cf92591c80..35ff7afb6d 100644 --- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.html +++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.html @@ -1,3 +1,16 @@ -

- rating works! -

+Ratings: +
+
+
+
+
+ +
+
+ +
+ +
+ diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.ts b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.ts index 44b517edf7..a3ef33573a 100644 --- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.ts +++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/angular/ui/src/app/rating/rating.component.ts @@ -1,15 +1,44 @@ -import {Component, OnInit} from "@angular/core"; +import {Component, OnInit, Input, OnChanges} from "@angular/core"; +import {Rating} from "../rating"; @Component({ selector: 'app-rating', templateUrl: './rating.component.html', styleUrls: ['./rating.component.css'] }) -export class RatingComponent implements OnInit { +export class RatingComponent implements OnInit, OnChanges { + + @Input() bookId: number; + + ratings: Rating[] = []; + stars: number[] = [1,2,3,4,5]; + newRating: Rating = null; constructor() { } - ngOnInit() { + ngOnInit() {} + + ngOnChanges() { + this.newRating = new Rating(null, this.bookId, 1); + this.ratings = []; + this.loadRatings(); + } + + findWidth(rating: Rating): String { + let percent: number = (rating.stars/5)*100; + return percent.toString() + '%'; + } + + private loadRatings() { + let rating: Rating = new Rating(1, this.bookId, this.bookId); + let rating1: Rating = new Rating(1, this.bookId, this.bookId); + this.ratings.push(rating, rating1); + } + + onSubmit() { + console.log(this.newRating); + let ratingCopy: Rating = Object.assign({}, this.newRating, {id: 101}); + this.ratings.push(ratingCopy); } }