diff --git a/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-dashboard.component.html b/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-dashboard.component.html index 38b26c0..5757850 100644 --- a/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-dashboard.component.html +++ b/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-dashboard.component.html @@ -1,5 +1,6 @@
- + +
this.loadAll()); } + + onItemSelected(value?: IMicroservice): any { + if (value) { + this.microservices = this.microservices?.filter(i => i.id === value.id); + } else { + this.loadAll(); + } + } } diff --git a/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-search/microservice-search.component.html b/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-search/microservice-search.component.html index 0628a71..99a2088 100644 --- a/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-search/microservice-search.component.html +++ b/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-search/microservice-search.component.html @@ -1,5 +1,8 @@ diff --git a/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-search/microservice-search.component.ts b/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-search/microservice-search.component.ts index b9f78a7..0b72d0a 100644 --- a/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-search/microservice-search.component.ts +++ b/src/main/webapp/app/entities/microservice/microservice-dashboard/microservice-search/microservice-search.component.ts @@ -1,8 +1,7 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, EventEmitter, OnInit, Output } from '@angular/core'; import { Observable } from 'rxjs'; -import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators'; +import { debounceTime, distinctUntilChanged, map, switchMap } from 'rxjs/operators'; import { MicroserviceService } from 'app/entities/microservice/microservice.service'; -import { HttpResponse } from '@angular/common/http'; import { IMicroservice } from 'app/shared/model/microservice.model'; @Component({ @@ -11,18 +10,38 @@ import { IMicroservice } from 'app/shared/model/microservice.model'; styleUrls: ['./microservice-search.component.scss'], }) export class MicroserviceSearchComponent implements OnInit { + model: any; + + @Output() itemSelected = new EventEmitter(); + constructor(protected microserviceService: MicroserviceService) {} + ngOnInit(): void {} + search = (text$: Observable) => text$.pipe( - debounceTime(200), + debounceTime(500), distinctUntilChanged(), - switchMap(searchText => (searchText.length < 2 ? [] : this.microserviceService.query())) + switchMap(searchText => (searchText.length < 2 ? [] : this.loadData(searchText))) ); - microserviceFormatter = (result: HttpResponse) => result?.body?.name; - microserviceInputFormatter = (result: HttpResponse) => result?.body?.name; + loadData(searchText: string): Observable { + return this.microserviceService + .query() + .pipe(map(response => response.body!.filter(m => m.name!.toLowerCase().includes(searchText.toLowerCase())) || [{}])); + } - ngOnInit(): void {} + formatter = (result: IMicroservice) => result.name || ''; + + inputFormatter = (result: IMicroservice) => result.name || ''; + + onItemSelected(item: IMicroservice): any { + this.itemSelected.emit(item); + } + + clear(): any { + this.model = ''; + this.itemSelected.emit(); + } }