Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 9x 9x 9x 9x 9x 59x 9x 21x 19x 19x 19x 19x 76x 19x 5x 14x 14x 7x 7x 9x 59x 236x 9x 19x 19x 9x | import { Injectable } from '@angular/core'; import * as _ from 'lodash'; import { CephSharedModule } from './ceph-shared.module'; import { PgCategory } from './pg-category.model'; @Injectable({ providedIn: CephSharedModule }) export class PgCategoryService { private categories: object; constructor() { this.categories = this.createCategories(); } getAllTypes() { return PgCategory.VALID_CATEGORIES; } getTypeByStates(pgStatesText: string): string { const pgStates = this.getPgStatesFromText(pgStatesText); Iif (pgStates.length === 0) { return PgCategory.CATEGORY_UNKNOWN; } const intersections = _.zipObject( PgCategory.VALID_CATEGORIES, PgCategory.VALID_CATEGORIES.map( (category) => _.intersection(this.categories[category].states, pgStates).length ) ); if (intersections[PgCategory.CATEGORY_WARNING] > 0) { return PgCategory.CATEGORY_WARNING; } const pgWorkingStates = intersections[PgCategory.CATEGORY_WORKING]; if (pgStates.length > intersections[PgCategory.CATEGORY_CLEAN] + pgWorkingStates) { return PgCategory.CATEGORY_UNKNOWN; } return pgWorkingStates ? PgCategory.CATEGORY_WORKING : PgCategory.CATEGORY_CLEAN; } private createCategories() { return _.zipObject( PgCategory.VALID_CATEGORIES, PgCategory.VALID_CATEGORIES.map((category) => new PgCategory(category)) ); } private getPgStatesFromText(pgStatesText) { const pgStates = pgStatesText .replace(/[^a-z]+/g, ' ') .trim() .split(' '); return _.uniq(pgStates); } } |