src/app/modules/daily-processing/processing-color-by-healthcheck/processing-color-by-healthcheck.component.ts
selector | app-processing-color-by-healthcheck |
styleUrls | ./processing-color-by-healthcheck.component.css |
templateUrl | ./processing-color-by-healthcheck.component.html |
Properties |
Methods |
|
Inputs |
constructor(colorService: HealthCheckColorService)
|
||||||
Parameters :
|
run
|
Type : |
runs
|
Type : |
ngOnInit |
ngOnInit()
|
Returns :
void
|
Private pickColor | ||||||
pickColor(color: string)
|
||||||
Parameters :
Returns :
void
|
Private setColorForRun |
setColorForRun()
|
Returns :
void
|
Private setColorForRuns |
setColorForRuns()
|
Returns :
void
|
blue |
blue:
|
Type : boolean
|
color |
color:
|
Type : string
|
colors |
colors:
|
Default value : colors
|
green |
green:
|
Type : boolean
|
red |
red:
|
Type : boolean
|
unknown |
unknown:
|
Type : boolean
|
yellow |
yellow:
|
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>
{{ color }}
</span>
./processing-color-by-healthcheck.component.css