Skip to content

Commit

Permalink
feat(summoner): add loading icon
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveVanOpstal committed Aug 14, 2017
1 parent 4d40957 commit 2722c13
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/client/summoner/summoner.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,35 @@ import {LolApiService} from '../services';
<input type="text" name="name" #summoner (keyup.enter)="getAccountId(summoner)">
<button (click)="getAccountId(summoner)">Go</button>
</p>
<p *ngIf="error">Error summoner does not exist</p>
<lb-error [error]="error" [message]="'Summoner does not exist'"></lb-error>
<lb-icon-load *ngIf="loading"></lb-icon-load>
</div>`
})

export class SummonerComponent {
error: boolean = false;
loading: boolean = false;

constructor(
private route: ActivatedRoute, private router: Router, private lolApi: LolApiService) {}

getAccountId(event: HTMLInputElement) {
this.loading = true;
this.lolApi.getAccountId(event.value)
.subscribe(
res => {
if (!isNaN(res)) {
this.router.navigate([event.value], {relativeTo: this.route}).catch(() => {
this.loading = false;
this.error = true;
});
} else {
this.loading = false;
this.error = true;
}
},
() => {
this.loading = false;
this.error = true;
});
}
Expand Down
11 changes: 9 additions & 2 deletions src/client/summoner/summoner.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';

import {AssetsModule} from '../assets/assets.module';
import {SharedModule} from '../shared/shared.module';

import {SummonerComponent} from './summoner.component';

@NgModule(
{declarations: [SummonerComponent], imports: [CommonModule], exports: [SummonerComponent]})

@NgModule({
declarations: [SummonerComponent],
imports: [CommonModule, AssetsModule, SharedModule],
exports: [SummonerComponent]
})
export class SummonerModule {
}

0 comments on commit 2722c13

Please sign in to comment.