diff options
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts')
-rw-r--r-- | src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts new file mode 100644 index 000000000..313ac4c0d --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/filter.pipe.ts @@ -0,0 +1,25 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'filter' +}) +export class FilterPipe implements PipeTransform { + transform(value: any, args?: any): any { + return value.filter((row: any) => { + let result = true; + + args.forEach((filter: any): boolean | void => { + if (!filter.value) { + return undefined; + } + + result = result && filter.applyFilter(row, filter.value); + if (!result) { + return result; + } + }); + + return result; + }); + } +} |