import {ChangeDetectorRef, Component, OnInit} from "@angular/core";
import {CadesHelper} from "@webbpm/base-package";
import {AccessChecker} from "../../security/AccessChecker";
import {AppConfigService} from "@webbpm/base-package";

@Component({
             moduleId: module.id,
             selector: "home-landing",
             templateUrl: "../../../../../src/resources/template/app/component/home_landing.html",
           })
export class HomeLandingComponent implements OnInit {
  private cspTimeout: number;

  constructor(private cd: ChangeDetectorRef,
              private appConfigService: AppConfigService) {
    this.cspTimeout = this.appConfigService.getParamValue("csp_load_timeout");
  }

  ngOnInit(): void {
    AccessChecker.checkCsp(this.cspTimeout)
        .then((cspCheckPassed) => {
          if (AccessChecker.checkBrowser() && cspCheckPassed) {
            document.getElementById("browser-check-info").hidden = true;
          }
          else {
            document.getElementById("login-button").classList.add('disabled');
          }
        });
    this.cd.markForCheck();
  }
}
