summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/health-color.pipe.ts
blob: d046fa15a79b82c85dbbdd107f827ec0745cc6a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { Pipe, PipeTransform } from '@angular/core';

import { CssHelper } from '~/app/shared/classes/css-helper';
import { HealthColor } from '~/app/shared/enum/health-color.enum';

@Pipe({
  name: 'healthColor'
})
export class HealthColorPipe implements PipeTransform {
  constructor(private cssHelper: CssHelper) {}

  transform(value: any): any {
    return Object.keys(HealthColor).includes(value as HealthColor)
      ? { color: this.cssHelper.propertyValue(HealthColor[value]) }
      : null;
  }
}