diff --git a/admin-portal/src/app/components/add-new-book/add-new-book.component.html b/admin-portal/src/app/components/add-new-book/add-new-book.component.html index 2ae5606..6d2de23 100644 --- a/admin-portal/src/app/components/add-new-book/add-new-book.component.html +++ b/admin-portal/src/app/components/add-new-book/add-new-book.component.html @@ -99,7 +99,7 @@ - + Image   diff --git a/bookstore-api/.idea/workspace.xml b/bookstore-api/.idea/workspace.xml index 877f7e8..071577f 100644 --- a/bookstore-api/.idea/workspace.xml +++ b/bookstore-api/.idea/workspace.xml @@ -60,26 +60,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -90,16 +70,39 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -179,7 +182,6 @@ @@ -209,7 +212,7 @@ - - - + @@ -1039,14 +1042,14 @@ - + - + @@ -1069,7 +1072,7 @@ - @@ -1197,14 +1200,6 @@ - - - - - - - - @@ -1403,14 +1398,6 @@ - - - - - - - - @@ -1549,8 +1536,27 @@ - - + + + + + + + + + + + + + + + + + + + + + diff --git a/bookstore-api/src/main/java/com/bookstore/resource/BookResource.java b/bookstore-api/src/main/java/com/bookstore/resource/BookResource.java index 37fe20d..cf9b839 100644 --- a/bookstore-api/src/main/java/com/bookstore/resource/BookResource.java +++ b/bookstore-api/src/main/java/com/bookstore/resource/BookResource.java @@ -132,4 +132,18 @@ public class BookResource { return new ResponseEntity("Remove Success!", HttpStatus.OK); } + @RequestMapping(value="/searchBook", method = RequestMethod.POST) + public List searchBook( + @RequestBody String keyword, + Principal principal + ) { + if (principal != null) { + String username = principal.getName(); + User user = userService.findByUsername(username); + } + + List bookList = bookService.blurrySearch(keyword); + + return bookList; + } } diff --git a/bookstore-api/target/classes/com/bookstore/resource/BookResource.class b/bookstore-api/target/classes/com/bookstore/resource/BookResource.class index f3efe6b..a040d77 100644 Binary files a/bookstore-api/target/classes/com/bookstore/resource/BookResource.class and b/bookstore-api/target/classes/com/bookstore/resource/BookResource.class differ diff --git a/store-front/src/app/components/book-list/book-list.component.html b/store-front/src/app/components/book-list/book-list.component.html index b4f5681..be5c2ff 100644 --- a/store-front/src/app/components/book-list/book-list.component.html +++ b/store-front/src/app/components/book-list/book-list.component.html @@ -18,7 +18,7 @@
- Filter by Title: + Filter by Description:
diff --git a/store-front/src/app/components/book-list/book-list.component.ts b/store-front/src/app/components/book-list/book-list.component.ts index 9a6e518..4857081 100644 --- a/store-front/src/app/components/book-list/book-list.component.ts +++ b/store-front/src/app/components/book-list/book-list.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import {Book} from "../../models/book"; import {BookService} from "../../services/book.service"; -import {Router} from "@angular/router"; +import {Params, ActivatedRoute,Router} from "@angular/router"; import {Http} from "@angular/http"; import {AppConst} from '../../constants/app-const'; @@ -19,16 +19,8 @@ export class BookListComponent implements OnInit { private bookList: Book[]; private serverPath = AppConst.serverPath; - constructor(private bookService:BookService, private router: Router, private http: Http) { - this.bookService.getBookList().subscribe( - res => { - console.log(res.json()); - this.bookList=res.json(); - }, - err => { - console.log(err); - } - ); + constructor(private bookService:BookService, private router: Router, private http: Http, private route:ActivatedRoute) { + } onSelect(book:Book) { @@ -38,6 +30,24 @@ export class BookListComponent implements OnInit { ngOnInit() { + + this.route.queryParams.subscribe(params => { + if (params['bookList']){ + console.log("filtered book list"); + this.bookList = JSON.parse(params['bookList']); + } else { + this.bookService.getBookList().subscribe( + res => { + console.log(res.json()); + this.bookList=res.json(); + }, + err => { + console.log(err); + } + ); + } + + }); } } diff --git a/store-front/src/app/components/book-list/data-filter.pipe.ts b/store-front/src/app/components/book-list/data-filter.pipe.ts index 151bb45..2bf7c25 100644 --- a/store-front/src/app/components/book-list/data-filter.pipe.ts +++ b/store-front/src/app/components/book-list/data-filter.pipe.ts @@ -8,7 +8,7 @@ export class DataFilterPipe implements PipeTransform { transform(array: any[], query: string): any { if (query) { - return _.filter(array, row=>row.title.indexOf(query) > -1); + return _.filter(array, row=>row.description.indexOf(query) > -1); } return array; } diff --git a/store-front/src/app/components/nav-bar/nav-bar.component.html b/store-front/src/app/components/nav-bar/nav-bar.component.html index 381fb74..3962992 100644 --- a/store-front/src/app/components/nav-bar/nav-bar.component.html +++ b/store-front/src/app/components/nav-bar/nav-bar.component.html @@ -9,9 +9,9 @@