All files / src/app/sys-check sys-check.component.ts

2.77% Statements 1/36
0% Branches 0/8
0% Functions 0/9
2.85% Lines 1/35

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 65 66 67 68 69 70 71 72 73                          1x                                                                                                                      
import { ActivatedRoute, ParamMap } from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { CustomtextService, MainDataService } from '../shared/shared.module';
import { BackendService } from './backend.service';
import { SysCheckDataService } from './sys-check-data.service';
import { UnitAndPlayerContainer } from './sys-check.interfaces';
import { AppError } from '../app.interfaces';
 
@Component({
  templateUrl: './sys-check.component.html',
  styleUrls: ['./sys-check.component.css']
})
 
export class SysCheckComponent implements OnInit {
  checkLabel = '';
  constructor(
    private bs: BackendService,
    public ds: SysCheckDataService,
    private route: ActivatedRoute,
    private mds: MainDataService,
    private cts: CustomtextService
  ) {
  }
 
  ngOnInit(): void {
    this.ds.networkReports = [];
    setTimeout(() => this.mds.appSubTitle$.next('System-Check'));
    this.route.paramMap.subscribe((params: ParamMap) => {
      const sysCheckId = params.get('sys-check-name');
      const workspaceId = params.get('workspace-id');
      Iif (!sysCheckId || !workspaceId) {
        throw new AppError({
          description: '', label: 'Invalid Route Parameters', type: 'script'
        });
      }
      setTimeout(() => {
        this.bs.getCheckConfigData(parseInt(workspaceId, 10), sysCheckId).subscribe(checkConfig => {
          this.ds.checkConfig = checkConfig;
          if (checkConfig) {
            this.checkLabel = checkConfig.label;
            this.mds.appSubTitle$.next(`System-Check ${this.checkLabel}`);
            Iif (Object.values(checkConfig.customTexts).length > 0) {
              const myCustomTexts: { [key: string]: string } = {};
              Object.values(checkConfig.customTexts).forEach(ct => {
                myCustomTexts[ct.key] = ct.value;
              });
              this.cts.addCustomTexts(myCustomTexts);
            }
            if (checkConfig.hasUnit) {
              this.bs.getUnitAndPlayer(this.ds.checkConfig.workspaceId, this.ds.checkConfig.name)
                .subscribe(unitAndPlayer => {
                  this.ds.unitAndPlayerContainer = unitAndPlayer;
                  this.completeConfig();
                });
            } else {
              this.completeConfig();
            }
          } else {
            this.checkLabel = `Fehler beim Laden der Konfiguration ${workspaceId}/${sysCheckId}`;
            this.completeConfig();
          }
        });
      });
    });
  }
 
  private completeConfig() {
    this.ds.loadConfigComplete = true;
    this.ds.setSteps();
    this.ds.setNewCurrentStep('w');
  }
}