import { Component } from '@angular/core';
import { TenantOptionsService } from '@c8y/client';
import { AlertService, gettext, OptionsService } from '@c8y/ngx-components';
import * as i0 from "@angular/core";
import * as i1 from "@c8y/ngx-components";
import * as i2 from "@c8y/client";
import * as i3 from "@angular/common";
import * as i4 from "@angular/forms";
import * as i5 from "ngx-bootstrap/dropdown";
export class CrlCheckSettingsComponent {
    constructor(optionsService, tenantOptionsService, alertService) {
        this.optionsService = optionsService;
        this.tenantOptionsService = tenantOptionsService;
        this.alertService = alertService;
        this.crlCheck = { online: false, offline: false };
    }
    async ngOnInit() {
        this.crlCheck = {
            offline: (await this.optionsService.getTenantOption('configuration', 'crl.offline.check.enabled', false)),
            online: (await this.optionsService.getTenantOption('configuration', 'crl.online.check.enabled', false))
        };
    }
    async updateTenantOption(tenantOption) {
        try {
            await this.tenantOptionsService.update(tenantOption);
            this.alertService.success(gettext('CRL check configuration saved.'));
        }
        catch (er) {
            this.alertService.addServerFailure(er);
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CrlCheckSettingsComponent, deps: [{ token: i1.OptionsService }, { token: i2.TenantOptionsService }, { token: i1.AlertService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.9", type: CrlCheckSettingsComponent, selector: "c8y-crl-check-settings", ngImport: i0, template: "<c8y-action-bar-item [placement]=\"'right'\">\n  <div\n    class=\"dropdown\"\n    dropdown\n    [insideClick]=\"true\"\n  >\n    <button\n      class=\"dropdown-toggle c8y-dropdown d-flex a-i-center\"\n      title=\"{{ 'CRL check' | translate }}\"\n      aria-haspopup=\"true\"\n      type=\"button\"\n      dropdownToggle\n    >\n      <i\n        class=\"m-r-4\"\n        [c8yIcon]=\"'check-document'\"\n      ></i>\n      <span\n        class=\"text-truncate\"\n        translate\n      >\n        CRL check\n      </span>\n      <i\n        class=\"m-l-4 text-primary\"\n        [c8yIcon]=\"'caret-down'\"\n      ></i>\n    </button>\n    <ul\n      class=\"dropdown-menu dropdown-menu-right hidden-xs\"\n      data-cy=\"register-device--dropdown\"\n      *dropdownMenu\n    >\n      <ng-container *ngTemplateOutlet=\"dropdown\"></ng-container>\n    </ul>\n\n    <ul class=\"dropdown-menu dropdown-menu-right visible-xs\">\n      <ng-container *ngTemplateOutlet=\"dropdown\"></ng-container>\n    </ul>\n\n    <ng-template #dropdown>\n      <li>\n        <label\n          class=\"c8y-checkbox d-flex a-i-center\"\n          title=\"{{ 'Online`type of checking`' | translate }}\"\n        >\n          <input\n            type=\"checkbox\"\n            [(ngModel)]=\"crlCheck.online\"\n            (ngModelChange)=\"\n              updateTenantOption({\n                category: 'configuration',\n                key: 'crl.online.check.enabled',\n                value: $event\n              })\n            \"\n          />\n          <span class=\"m-r-4\"></span>\n          {{ 'Online`type of checking`' | translate }}\n        </label>\n      </li>\n      <li>\n        <label\n          class=\"c8y-checkbox d-flex a-i-center\"\n          title=\"{{ 'Offline`type of checking`' | translate }}\"\n        >\n          <input\n            type=\"checkbox\"\n            [(ngModel)]=\"crlCheck.offline\"\n            (ngModelChange)=\"\n              updateTenantOption({\n                category: 'configuration',\n                key: 'crl.offline.check.enabled',\n                value: $event\n              })\n            \"\n          />\n          <span class=\"m-r-4\"></span>\n          {{ 'Offline`type of checking`' | translate }}\n        </label>\n      </li>\n    </ng-template>\n  </div>\n</c8y-action-bar-item>\n", dependencies: [{ kind: "component", type: i1.ActionBarItemComponent, selector: "c8y-action-bar-item", inputs: ["placement", "priority", "itemClass", "injector", "groupId", "inGroupPriority"] }, { kind: "directive", type: i1.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: i1.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i4.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i5.BsDropdownMenuDirective, selector: "[bsDropdownMenu],[dropdownMenu]", exportAs: ["bs-dropdown-menu"] }, { kind: "directive", type: i5.BsDropdownToggleDirective, selector: "[bsDropdownToggle],[dropdownToggle]", exportAs: ["bs-dropdown-toggle"] }, { kind: "directive", type: i5.BsDropdownDirective, selector: "[bsDropdown], [dropdown]", inputs: ["placement", "triggers", "container", "dropup", "autoClose", "isAnimated", "insideClick", "isDisabled", "isOpen"], outputs: ["isOpenChange", "onShown", "onHidden"], exportAs: ["bs-dropdown"] }, { kind: "pipe", type: i1.C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CrlCheckSettingsComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-crl-check-settings', template: "<c8y-action-bar-item [placement]=\"'right'\">\n  <div\n    class=\"dropdown\"\n    dropdown\n    [insideClick]=\"true\"\n  >\n    <button\n      class=\"dropdown-toggle c8y-dropdown d-flex a-i-center\"\n      title=\"{{ 'CRL check' | translate }}\"\n      aria-haspopup=\"true\"\n      type=\"button\"\n      dropdownToggle\n    >\n      <i\n        class=\"m-r-4\"\n        [c8yIcon]=\"'check-document'\"\n      ></i>\n      <span\n        class=\"text-truncate\"\n        translate\n      >\n        CRL check\n      </span>\n      <i\n        class=\"m-l-4 text-primary\"\n        [c8yIcon]=\"'caret-down'\"\n      ></i>\n    </button>\n    <ul\n      class=\"dropdown-menu dropdown-menu-right hidden-xs\"\n      data-cy=\"register-device--dropdown\"\n      *dropdownMenu\n    >\n      <ng-container *ngTemplateOutlet=\"dropdown\"></ng-container>\n    </ul>\n\n    <ul class=\"dropdown-menu dropdown-menu-right visible-xs\">\n      <ng-container *ngTemplateOutlet=\"dropdown\"></ng-container>\n    </ul>\n\n    <ng-template #dropdown>\n      <li>\n        <label\n          class=\"c8y-checkbox d-flex a-i-center\"\n          title=\"{{ 'Online`type of checking`' | translate }}\"\n        >\n          <input\n            type=\"checkbox\"\n            [(ngModel)]=\"crlCheck.online\"\n            (ngModelChange)=\"\n              updateTenantOption({\n                category: 'configuration',\n                key: 'crl.online.check.enabled',\n                value: $event\n              })\n            \"\n          />\n          <span class=\"m-r-4\"></span>\n          {{ 'Online`type of checking`' | translate }}\n        </label>\n      </li>\n      <li>\n        <label\n          class=\"c8y-checkbox d-flex a-i-center\"\n          title=\"{{ 'Offline`type of checking`' | translate }}\"\n        >\n          <input\n            type=\"checkbox\"\n            [(ngModel)]=\"crlCheck.offline\"\n            (ngModelChange)=\"\n              updateTenantOption({\n                category: 'configuration',\n                key: 'crl.offline.check.enabled',\n                value: $event\n              })\n            \"\n          />\n          <span class=\"m-r-4\"></span>\n          {{ 'Offline`type of checking`' | translate }}\n        </label>\n      </li>\n    </ng-template>\n  </div>\n</c8y-action-bar-item>\n" }]
        }], ctorParameters: () => [{ type: i1.OptionsService }, { type: i2.TenantOptionsService }, { type: i1.AlertService }] });
//# sourceMappingURL=data:application/json;base64, 