1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-27 04:03:00 +02:00

Added search logic

This commit is contained in:
Andre Rosado 2024-06-11 16:50:59 +01:00
parent e2b49b74c4
commit b971474974
No known key found for this signature in database
GPG Key ID: 99F68267CCD45AA9

View File

@ -1,6 +1,7 @@
import { Component, OnInit } from "@angular/core";
import { BehaviorSubject } from "rxjs";
import { BehaviorSubject, Subject, from, switchMap, takeUntil } from "rxjs";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { SearchModule, TableDataSource } from "@bitwarden/components";
import { HeaderModule } from "../../../../../../../apps/web/src/app/layouts/header/header.module";
@ -16,6 +17,7 @@ import { MemberAccessReportView } from "./view/member-access-report.view";
standalone: true,
})
export class MemberAccessReportComponent implements OnInit {
protected destroy$ = new Subject<void>();
protected dataSource = new TableDataSource<MemberAccessReportView>();
private _searchText$ = new BehaviorSubject<string>("");
@ -25,10 +27,25 @@ export class MemberAccessReportComponent implements OnInit {
set searchText(value: string) {
this._searchText$.next(value);
this.dataSource.filter = value;
}
constructor(protected reportService: MemberAccessReportService) {}
constructor(
protected reportService: MemberAccessReportService,
private searchService: SearchService,
) {}
ngOnInit() {
this.dataSource.data = this.reportService.getMemberAccessMockData();
this._searchText$.pipe(
switchMap((searchText) => from(this.searchService.isSearchable(searchText))),
takeUntil(this.destroy$),
);
}
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
}