Skip to content

Commit 121ecea

Browse files
committed
Fixes #4 and fixes #5
Enter key now performs the search across all screens; Fixed “No results” text on Character and Series screens
1 parent 73998eb commit 121ecea

File tree

9 files changed

+69
-37
lines changed

9 files changed

+69
-37
lines changed

Angular2/ClientApp/app/components/books/books.component.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ <h1>Book Search</h1>
22

33
<div class="row">
44
<div class="col-xs-12">
5-
<input [value]="searchString" (input)="searchString = $event.target.value"/>
5+
<input [value]="searchString" (input)="searchString = $event.target.value" (keyup.enter)="getDwBook()"/>
66
<button (click)="getDwBook()">Search</button>
77
</div>
88
</div>
@@ -11,7 +11,7 @@ <h1>Book Search</h1>
1111
<p>Searching, please wait</p>
1212
</div>
1313

14-
<div class="table-responsive" *ngIf="!loading && books">
14+
<div class="table-responsive" *ngIf="!loading && success && books">
1515
<table class='table'>
1616
<thead>
1717
<tr>
@@ -32,4 +32,10 @@ <h1>Book Search</h1>
3232
</tr>
3333
</tbody>
3434
</table>
35+
</div>
36+
37+
<div class="row" *ngIf="!loading && !success">
38+
<div class="col-xs-12">
39+
No results found
40+
</div>
3541
</div>

Angular2/ClientApp/app/components/books/books.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class BooksComponent {
1212
this.http = http;
1313

1414
this.loading = false;
15+
this.success = true;
1516
this.baseApiUrl = 'http://dwcheckapi.azurewebsites.net/Books/Search?searchString=';
1617
this.books = null;
1718
this.registerFunctions();
@@ -43,6 +44,7 @@ export class BooksComponent {
4344
element.bookCoverImageUrl));
4445
});
4546
}
47+
this.success = resultJson.success;
4648
this.loading = false;
4749
});
4850
}

Angular2/ClientApp/app/components/characters/characters.component.html

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ <h1>Character Search</h1>
22

33
<div class="row">
44
<div class="col-xs-12">
5-
<input [value]="searchString" (input)="searchString = $event.target.value"/>
5+
<input [value]="searchString" (input)="searchString = $event.target.value" (keyup.enter)="getDwCharacter()"/>
66
<button (click)="getDwCharacter()">Search</button>
77
</div>
88
</div>
99

10-
<div class="loader" *ngIf="!success">
11-
<p>Could not find any results</p>
10+
<div class="loader" *ngIf="loading">
11+
<p>Searching, please wait</p>
1212
</div>
1313

14-
<div class="table-responsive" *ngIf="success">
14+
<div class="table-responsive" *ngIf="!loading && success && characters">
1515
<table class='table' *ngIf="characters">
1616
<thead>
1717
<tr>
@@ -26,4 +26,10 @@ <h1>Character Search</h1>
2626
</tr>
2727
</tbody>
2828
</table>
29+
</div>
30+
31+
<div class="row" *ngIf="!loading && !success">
32+
<div class="col-xs-12">
33+
No results found
34+
</div>
2935
</div>

Angular2/ClientApp/app/components/characters/characters.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export class CharacterComponent {
2020
private http: Http;
2121

2222
// public bound vars
23-
success: boolean;
2423
loading: boolean;
24+
success: boolean;
2525
baseApiUrl: string;
2626
searchString = '';
2727
characters: ICharacter[];
@@ -31,17 +31,18 @@ export class CharacterComponent {
3131

3232
private registerFunctions() {
3333
this.getDwCharacter = () => {
34-
this.success = false;
3534
var route = `${this.baseApiUrl}${this.searchString}`;
35+
this.loading = true;
3636
this.http.get(route).subscribe((result) => {
3737
var resultJson = result.json() as IResultJson;
3838
if(resultJson.success) {
39-
this.success = true;
4039
this.characters = new Array<ICharacter>();
4140
result.json().result.forEach(element => {
4241
this.characters.push(new Character(element.characterName, element.books));
4342
});
4443
}
44+
this.success = resultJson.success;
45+
this.loading = false;
4546
});
4647
}
4748
}

Angular2/ClientApp/app/components/series/series.component.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<h1>Series Search</h1>
22
<div class="row">
33
<div class="col-xs-12">
4-
<input [value]="searchString" (input)="searchString = $event.target.value" />
4+
<input [value]="searchString" (input)="searchString = $event.target.value" (keyup.enter)="getDwSeries()"/>
55
<button (click)="getDwSeries()">Search</button>
66
</div>
77
</div>
8-
<div class="loader" *ngIf="!success">
9-
<p>Could not find any results</p>
8+
9+
<div class="loader" *ngIf="loading">
10+
<p>Searching, please wait</p>
1011
</div>
11-
<div class="table-responsive" *ngIf="success">
12+
13+
<div class="table-responsive" *ngIf="!loading && success && series">
1214
<table class='table' *ngIf="series">
1315
<thead>
1416
<tr>
@@ -23,4 +25,10 @@
2325
</tr>
2426
</tbody>
2527
</table>
28+
</div>
29+
30+
<div class="row" *ngIf="!loading && !success">
31+
<div class="col-xs-12">
32+
No results found
33+
</div>
2634
</div>

Angular2/ClientApp/app/components/series/series.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class SeriesComponent {
1313

1414
this.success = true;
1515
this.loading = false;
16-
this.baseApiUrl = 'http://dwcheckapi.azurewebsites.net/series/search?searchString';
16+
this.baseApiUrl = 'http://dwcheckapi.azurewebsites.net/series/search?searchString=';
1717
this.registerFunctions();
1818
}
1919
// private vars
@@ -31,17 +31,18 @@ export class SeriesComponent {
3131

3232
private registerFunctions() {
3333
this.getDwSeries = () => {
34-
this.success = false;
3534
var route = `${this.baseApiUrl}${this.searchString}`;
35+
this.loading = true;
3636
this.http.get(route).subscribe((result) => {
3737
var resultJson = result.json() as IResultJson;
3838
if(resultJson.success) {
39-
this.success = true;
4039
this.series = new Array<ISeries>();
4140
result.json().result.forEach(element => {
4241
this.series.push(new Series(element.seriesName, element.bookNames));
4342
});
4443
}
44+
this.success = resultJson.success;
45+
this.loading = false;
4546
});
4647
}
4748
}

Angular2/ClientApp/dist/main-server.js

Lines changed: 14 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Angular2/wwwroot/dist/main-client.js

Lines changed: 14 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Angular2/wwwroot/dist/main-client.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)