File

src/app/modules/daily-processing/processing-color-by-healthcheck/processing-color-by-healthcheck.component.ts

Implements

OnInit

Metadata

selector app-processing-color-by-healthcheck
styleUrls ./processing-color-by-healthcheck.component.css
templateUrl ./processing-color-by-healthcheck.component.html

Index

Properties
Methods
Inputs

Constructor

constructor(colorService: HealthCheckColorService)
Parameters :
Name Type Optional
colorService HealthCheckColorService No

Inputs

run

Type : ProcessingRunInfo

runs

Type : ProcessingRunInfo[]

Methods

ngOnInit
ngOnInit()
Returns : void
Private pickColor
pickColor(color: string)
Parameters :
Name Type Optional
color string No
Returns : void
Private setColorForRun
setColorForRun()
Returns : void
Private setColorForRuns
setColorForRuns()
Returns : void

Properties

blue
blue: boolean
Type : boolean
color
color: string
Type : string
colors
colors:
Default value : colors
green
green: boolean
Type : boolean
red
red: boolean
Type : boolean
unknown
unknown: boolean
Type : boolean
yellow
yellow: boolean
Type : boolean
import { Component, Input, OnInit } from '@angular/core';
import { ProcessingRunInfo } from '../models/i-processing-info';
import { colors, HealthCheckColorService } from '../providers/healtch-check-color.service';

@Component({
  selector: 'app-processing-color-by-healthcheck',
  templateUrl: './processing-color-by-healthcheck.component.html',
  styleUrls: ['./processing-color-by-healthcheck.component.css']
})
export class ProcessingColorByHealthcheckComponent implements OnInit {
  @Input() run?: ProcessingRunInfo;
  @Input() runs?: ProcessingRunInfo[];
  colors = colors;
  green: boolean;
  blue: boolean;
  yellow: boolean;
  red: boolean;
  unknown: boolean;
  color: string;

  constructor(private colorService: HealthCheckColorService) {}

  ngOnInit() {
    if (this.run) {
      return this.setColorForRun();
    }

    if (this.runs) {
      return this.setColorForRuns();
    }
  }

  private setColorForRun() {
    const color = this.colorService.getColor(this.run);
    this.pickColor(color);
  }

  private setColorForRuns() {
    const color = this.colorService.getColorForRuns(this.runs);
    this.pickColor(color);
  }

  private pickColor(color: string) {
    switch (color) {
      case colors.BLUE:
        this.blue = true;
        this.color = colors.BLUE.toUpperCase();
        break;
      case colors.YELLOW:
        this.yellow = true;
        this.color = colors.YELLOW.toUpperCase();
        break;
      case colors.RED:
        this.red = true;
        this.color = colors.RED.toUpperCase();
        break;
      case colors.GREEN:
        this.green = true;
        this.color = colors.GREEN.toUpperCase();
        break;
      default:
        this.unknown = true;
        this.color = 'UNKNOWN';
        return;
    }
  }
}
<span fxLayout="row" fxLayoutAlign="space-around center">
  <mat-icon *ngIf="green" color="primary">check_circle</mat-icon>
  <mat-icon *ngIf="yellow" color="accent">warning</mat-icon>
  <mat-icon *ngIf="red" color="warn">error</mat-icon>
  <mat-icon *ngIf="blue" color="accent">access_time </mat-icon>
  <mat-icon *ngIf="unknown" color="accent">help </mat-icon>
  &nbsp; {{ color }}
</span>

./processing-color-by-healthcheck.component.css

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""