Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
feat: search loading
Browse files Browse the repository at this point in the history
Change-Id: I4e7af36551dcb485a8e3d3a453c7a92a86468a2b
  • Loading branch information
myml committed Nov 28, 2018
1 parent 5564970 commit 435a910
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
<app-app-title #$title
[hidden]="$title.count === 0"
i18n>Searching results for {{ title$ | async }}</app-app-title>
<app-app-list #$list
[appList]="apps$|async"
[sortBy]="$title.sortBy"
[hidden]="$title.count === 0"
(appListLength)="$title.count = $event"></app-app-list>
<ng-container *ngIf="loaded;else loading">
<app-app-title #$title
[hidden]="$title.count === 0"
i18n>Searching results for {{ title$ | async }}</app-app-title>
<app-app-list #$list
[appList]="apps$|async"
[sortBy]="$title.sortBy"
[hidden]="$title.count === 0"
(appListLength)="$title.count = $event"></app-app-list>

<ng-container *ngIf="$title.count === 0">
<div class="searchEmpty">
<img class="tips_bg" /> <span i18n>Sorry</span>
<div class="gray-text"
i18n>No search results found</div>
<ng-container *ngIf="$title.count === 0">
<div class="searchEmpty">
<img class="tips_bg" /> <span i18n>Sorry</span>
<div class="gray-text"
i18n>No search results found</div>

<div class="gray-text"
i18n>Welcome to <a class="recommend"
(click)="recommend()">recommend</a> this application</div>
</div>
</ng-container>
<div class="gray-text"
i18n>Welcome to <a class="recommend"
(click)="recommend()">recommend</a> this application</div>
</div>
</ng-container>
</ng-container>

<div class="loadingContainer"
#loading>
<app-wait></app-wait>
</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { map, flatMap, switchMap } from 'rxjs/operators';
import { map, flatMap, switchMap, tap } from 'rxjs/operators';
import { truncate } from 'lodash';

import { App, AppService } from 'app/services/app.service';
Expand All @@ -22,6 +22,7 @@ export class SearchComponent implements OnInit {
keyword$: Observable<string>;
title$: Observable<string>;
apps$: Observable<App[]>;
loaded = false;

ngOnInit() {
this.title$ = this.route.queryParamMap.pipe(
Expand All @@ -30,9 +31,13 @@ export class SearchComponent implements OnInit {

this.apps$ = this.route.queryParamMap.pipe(
switchMap(param => {
this.loaded = false;
const appNameList = param.getAll('apps');
return this.appService.getApps(appNameList);
}),
tap(() => {
this.loaded = true;
}),
);
}

Expand Down

0 comments on commit 435a910

Please sign in to comment.