import { Component } from '@angular/core';
import { DeviceRegistrationSecurityMode, DeviceRegistrationStatus } from '@c8y/client';
import { BehaviorSubject, Subject } from 'rxjs';
import { filter, map, switchMap, takeUntil } from 'rxjs/operators';
import { DeviceBootstrapRealtimeService, TenantUiService, ModalService, Status, gettext, OptionsService } from '@c8y/ngx-components';
import { RegisterDeviceService } from './register-device.service';
import { sortBy } from 'lodash-es';
import { TranslateService } from '@ngx-translate/core';
import { ActivatedRoute } from '@angular/router';
import { GeneralDeviceRegistrationService } from './general/general-device-registration.service';
import * as i0 from "@angular/core";
import * as i1 from "./register-device.service";
import * as i2 from "@c8y/ngx-components";
import * as i3 from "@ngx-translate/core";
import * as i4 from "@angular/router";
import * as i5 from "./general/general-device-registration.service";
import * as i6 from "ngx-bootstrap/popover";
import * as i7 from "@angular/common";
import * as i8 from "@angular/forms";
import * as i9 from "./dropdown/register-device-dropdown.component";
export class DeviceRegistrationViewComponent {
    constructor(registerDeviceService, bootstrapRealtimeService, tenantUiService, modalService, translateService, optionsService, activatedRoute, generalRegistration) {
        this.registerDeviceService = registerDeviceService;
        this.bootstrapRealtimeService = bootstrapRealtimeService;
        this.tenantUiService = tenantUiService;
        this.modalService = modalService;
        this.translateService = translateService;
        this.optionsService = optionsService;
        this.activatedRoute = activatedRoute;
        this.generalRegistration = generalRegistration;
        this.requireSecurityToken = false;
        this.isManagementTenant = false;
        this.isLoading = false;
        this.gridOrList = 'interact-grid';
        this.status = DeviceRegistrationStatus;
        this.statusProps = {
            [DeviceRegistrationStatus.WAITING_FOR_CONNECTION]: {
                label: gettext('Waiting for connection'),
                icon: 'unlink',
                cls: 'text-danger'
            },
            [DeviceRegistrationStatus.PENDING_ACCEPTANCE]: {
                label: gettext('Pending acceptance'),
                icon: 'circle',
                cls: 'text-info'
            },
            [DeviceRegistrationStatus.ACCEPTED]: {
                label: gettext('Accepted'),
                icon: 'check-circle',
                cls: 'text-success'
            },
            [DeviceRegistrationStatus.BLOCKED]: {
                label: gettext('Blocked'),
                icon: 'ban',
                cls: 'text-danger'
            }
        };
        this.unsubscribe$ = new Subject();
        this._securityTokenPolicy = new BehaviorSubject(DeviceRegistrationSecurityMode.OPTIONAL);
    }
    ngOnInit() {
        this.loadAll();
        this.setIsManagementTenant();
        this.setRequireSecurityToken();
        this.deviceRequests$ = this.registerDeviceService.deviceRegistrationRequests$.pipe(map(req => ({
            data: sortBy(req.data, [
                ({ status }) => (status === DeviceRegistrationStatus.PENDING_ACCEPTANCE ? 0 : 1),
                '-creationTime'
            ]),
            paging: req.paging
        })));
        this.limit$ = this.registerDeviceService.limit$;
        this.limitReachedInfo$ = this.limit$.pipe(filter(deviceRegistrationLimit => deviceRegistrationLimit.isReached), switchMap(({ limit }) => this.translateService.stream(gettext('You reached the limit of {{ maxDevices }} devices. No more devices can be registered.'), { maxDevices: limit })));
        this.registerDeviceService.loading$
            .pipe(takeUntil(this.unsubscribe$))
            .subscribe(value => (this.isLoading = value));
        this.bootstrapRealtimeService
            .onUpdate$()
            .pipe(takeUntil(this.unsubscribe$))
            .subscribe((bootstrap) => {
            this.registerDeviceService.onDeviceBootstrap(bootstrap);
        });
        this.handleQueryParams();
    }
    ngOnDestroy() {
        this.unsubscribe$.next();
        this.unsubscribe$.complete();
    }
    updateList(data) {
        this.registerDeviceService.internalListUpdate(data);
    }
    async handleQueryParams() {
        const { externalId, 'one-time-password': oneTimePassword } = this.activatedRoute.snapshot.queryParams;
        if (!externalId) {
            return;
        }
        try {
            await this.generalRegistration.open({
                useEST$: new BehaviorSubject(!!oneTimePassword),
                model: {
                    devicesToCreate: [
                        {
                            id: externalId,
                            oneTimePassword
                        }
                    ]
                }
            });
            this.loadAll();
        }
        catch (e) {
            // modal closed
        }
    }
    async delete(id) {
        const confirmed = await this.modalService.confirm(gettext('Cancel device registration'), this.translateService.instant(gettext('You are about to cancel device registration for ID "{{id}}". Do you want to proceed?'), { id }), Status.DANGER, {
            ok: gettext('Cancel registration'),
            cancel: gettext('Close')
        });
        if (confirmed) {
            this.registerDeviceService.remove(id);
        }
    }
    accept(request) {
        this.registerDeviceService.accept(request);
    }
    acceptAll() {
        this.registerDeviceService.acceptAll();
    }
    canAcceptAll() {
        const pendingRequests = this.registerDeviceService.getRequestByStatus(DeviceRegistrationStatus.PENDING_ACCEPTANCE);
        return !(pendingRequests.length > 0 && !this.requireSecurityToken);
    }
    loadAll() {
        this.registerDeviceService.list();
    }
    displayMode(listClass) {
        this.gridOrList = listClass;
    }
    async setRequireSecurityToken() {
        const mode = (await this.optionsService.getTenantOption('device-registration', 'security-token.policy', DeviceRegistrationSecurityMode.OPTIONAL));
        this._securityTokenPolicy.next(mode);
        this.requireSecurityToken = mode === DeviceRegistrationSecurityMode.REQUIRED;
    }
    async setIsManagementTenant() {
        this.isManagementTenant = await this.tenantUiService.isManagementTenant();
    }
    shouldShowSecurityTokenInput(data) {
        return (data &&
            data.status === DeviceRegistrationStatus.PENDING_ACCEPTANCE &&
            this.showTokenInputBasedOnSecurityMode());
    }
    showTokenInputBasedOnSecurityMode() {
        return this._securityTokenPolicy.getValue() !== DeviceRegistrationSecurityMode.IGNORED;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DeviceRegistrationViewComponent, deps: [{ token: i1.RegisterDeviceService }, { token: i2.DeviceBootstrapRealtimeService }, { token: i2.TenantUiService }, { token: i2.ModalService }, { token: i3.TranslateService }, { token: i2.OptionsService }, { token: i4.ActivatedRoute }, { token: i5.GeneralDeviceRegistrationService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: DeviceRegistrationViewComponent, selector: "c8y-device-registration-view", ngImport: i0, template: "<ng-container *ngIf=\"deviceRequests$ | async as deviceRequestList\">\n  <c8y-title>\n    {{ 'Device registration' | translate }}\n    <small *ngIf=\"deviceRequestList.data.length === 1\">1 {{ 'new device' | translate }}</small>\n    <small *ngIf=\"deviceRequestList.data.length > 1\">\n      {{ deviceRequestList.data.length }} {{ 'new devices' | translate }}\n    </small>\n  </c8y-title>\n\n  <c8y-breadcrumb>\n    <c8y-breadcrumb-item\n      [icon]=\"'exchange'\"\n      [label]=\"'Devices' | translate\"\n    ></c8y-breadcrumb-item>\n    <c8y-breadcrumb-item\n      [icon]=\"'c8y-device-connect'\"\n      [label]=\"'Device registration' | translate\"\n    ></c8y-breadcrumb-item>\n  </c8y-breadcrumb>\n\n  <c8y-action-bar-item\n    [placement]=\"'left'\"\n    itemClass=\"navbar-form hidden-xs\"\n  >\n    <c8y-list-display-switch (onListClassChange)=\"displayMode($event)\"></c8y-list-display-switch>\n  </c8y-action-bar-item>\n\n  <ng-container *ngIf=\"limit$ | async as limitStatus\">\n    <c8y-action-bar-item\n      [placement]=\"'right'\"\n      [priority]=\"10\"\n    >\n      <button\n        class=\"btn btn-link\"\n        title=\"{{ 'Accept all' | translate }}\"\n        type=\"button\"\n        *c8yIfAllowed=\"['ROLE_DEVICE_CONTROL_ADMIN']\"\n        (click)=\"acceptAll()\"\n        [disabled]=\"canAcceptAll() || limitStatus?.isReached\"\n      >\n        <i [c8yIcon]=\"'check'\"></i>\n        {{ 'Accept all' | translate }}\n      </button>\n    </c8y-action-bar-item>\n\n    <c8y-action-bar-item\n      [placement]=\"'right'\"\n      [priority]=\"9\"\n    >\n      <button\n        class=\"btn btn-link\"\n        title=\"{{ 'Reload' | translate }}\"\n        type=\"button\"\n        (click)=\"loadAll()\"\n        [disabled]=\"isLoading\"\n      >\n        <i\n          [c8yIcon]=\"'refresh'\"\n          [ngClass]=\"{ 'icon-spin': isLoading }\"\n        ></i>\n        {{ 'Reload' | translate }}\n      </button>\n    </c8y-action-bar-item>\n\n    <c8y-action-bar-item\n      [placement]=\"'right'\"\n      *c8yIfAllowed=\"['ROLE_DEVICE_CONTROL_ADMIN']\"\n    >\n      <c8y-register-device-dropdown></c8y-register-device-dropdown>\n    </c8y-action-bar-item>\n\n    <c8y-help\n      src=\"/docs/device-management-application/registering-devices/#registering-devices\"\n    ></c8y-help>\n\n    <ng-container *ngIf=\"deviceRequestList.data.length > 0; else noData\">\n      <div\n        class=\"card-group\"\n        [ngClass]=\"gridOrList\"\n      >\n        <!-- START interact-list sticky header START -->\n        <div\n          class=\"page-sticky-header hidden-xs\"\n          *ngIf=\"gridOrList === 'interact-list'\"\n        >\n          <div class=\"d-flex\">\n            <div class=\"card-header p-l-40\">\n              <p translate>Device</p>\n            </div>\n            <div class=\"card-block card-column-30 p-l-0 m-l-8\">\n              <p translate>Status</p>\n            </div>\n            <div\n              class=\"card-block card-column-30 p-0\"\n              *ngIf=\"showTokenInputBasedOnSecurityMode()\"\n            >\n              <p translate>Security token</p>\n              <button\n                class=\"btn-help\"\n                [attr.aria-label]=\"'Help' | translate\"\n                popover=\"{{\n                  'Security token is required if the connected device uses it.' | translate\n                }}\"\n                placement=\"right\"\n                triggers=\"focus\"\n                container=\"body\"\n                type=\"button\"\n              ></button>\n            </div>\n            <div class=\"card-footer card-column-50\">\n              <div\n                class=\"d-contents\"\n                *ngIf=\"isManagementTenant; else noManagement\"\n              >\n                <div class=\"card-column-50\">\n                  {{ 'Created' | translate }}\n                </div>\n                <div class=\"card-column-30\">\n                  {{ 'By`user`' | translate }}\n                </div>\n                <div class=\"card-column-20\">\n                  {{ 'Tenant ID' | translate }}\n                </div>\n              </div>\n              <ng-template #noManagement>\n                <div class=\"d-contents\">\n                  <div class=\"card-column-50\">\n                    {{ 'Created' | translate }}\n                  </div>\n                  <div class=\"card-column-50\">\n                    {{ 'By`user`' | translate }}\n                  </div>\n                </div>\n              </ng-template>\n            </div>\n            <div\n              class=\"card-actions-group\"\n              style=\"min-width: 176px\"\n            >\n              <div class=\"btn btn-xs invisible\">\n                <!--EMPTY by design-->\n              </div>\n            </div>\n          </div>\n        </div>\n        <!-- END interact-list sticky header END -->\n\n        <div\n          class=\"col-xs-12 col-sm-6 col-md-4 col-lg-3\"\n          *ngIf=\"limitStatus?.isReached\"\n        >\n          <p\n            class=\"alert alert-warning center-block\"\n            role=\"alert\"\n          >\n            <strong>\n              {{ limitReachedInfo$ | async }}\n            </strong>\n            <br />\n            <span translate>Please contact your platform administrator.</span>\n          </p>\n        </div>\n\n        <ng-container *ngFor=\"let singleRequest of deviceRequestList.data\">\n          <div class=\"col-xs-12 col-sm-6 col-md-4 col-lg-3\">\n            <div class=\"card\">\n              <div class=\"card-header separator\">\n                <div class=\"card-icon\">\n                  <i\n                    [class]=\"statusProps[singleRequest.status].cls\"\n                    [c8yIcon]=\"statusProps[singleRequest.status].icon\"\n                  ></i>\n                </div>\n                <p\n                  class=\"card-title text-truncate\"\n                  title=\"{{ singleRequest.id }}\"\n                >\n                  {{ singleRequest.id }}\n                </p>\n              </div>\n\n              <div class=\"card-block text-center card-column-30\">\n                <span\n                  class=\"text-label-small\"\n                  translate\n                >\n                  Status\n                </span>\n                <p>\n                  <i\n                    class=\"icon-spin text-primary\"\n                    c8yIcon=\"refresh\"\n                    *ngIf=\"singleRequest.status === status.WAITING_FOR_CONNECTION\"\n                  ></i>\n                  {{ statusProps[singleRequest.status].label | translate }}\n                </p>\n              </div>\n\n              <ng-container *c8yIfAllowed=\"['ROLE_DEVICE_CONTROL_ADMIN']\">\n                <div\n                  class=\"card-block text-center card-column-30 p-t-0\"\n                  [ngClass]=\"{ 'p-b-0': !shouldShowSecurityTokenInput(singleRequest) }\"\n                  *ngIf=\"showTokenInputBasedOnSecurityMode()\"\n                >\n                  <ng-container *ngIf=\"shouldShowSecurityTokenInput(singleRequest)\">\n                    <span\n                      class=\"text-label-small\"\n                      *ngIf=\"gridOrList !== 'interact-list'\"\n                      translate\n                    >\n                      Security token\n                    </span>\n                    <input\n                      class=\"form-control\"\n                      type=\"text\"\n                      [(ngModel)]=\"singleRequest.securityToken\"\n                      [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'A1e3gh5ds' }\"\n                      [required]=\"requireSecurityToken\"\n                    />\n                  </ng-container>\n                </div>\n\n                <div\n                  class=\"card-actions-group d-flex a-i-center j-c-center\"\n                  style=\"min-width: 176px\"\n                >\n                  <button\n                    class=\"btn btn-sm\"\n                    title=\"{{\n                      singleRequest.status === status.PENDING_ACCEPTANCE\n                        ? ('Remove' | translate)\n                        : ('Cancel' | translate)\n                    }}\"\n                    type=\"button\"\n                    [ngClass]=\"{\n                      'btn-danger': singleRequest.status === status.PENDING_ACCEPTANCE,\n                      'btn-default': singleRequest.status !== status.PENDING_ACCEPTANCE\n                    }\"\n                    (click)=\"delete(singleRequest.id)\"\n                    [disabled]=\"isLoading\"\n                  >\n                    <span *ngIf=\"singleRequest.status === status.PENDING_ACCEPTANCE\">\n                      {{ 'Remove' | translate }}\n                    </span>\n                    <span *ngIf=\"singleRequest.status !== status.PENDING_ACCEPTANCE\">\n                      {{ 'Cancel' | translate }}\n                    </span>\n                  </button>\n                  <button\n                    class=\"btn btn-primary btn-sm\"\n                    title=\"{{ 'Accept' | translate }}\"\n                    type=\"button\"\n                    (click)=\"accept(singleRequest)\"\n                    *ngIf=\"singleRequest.status === status.PENDING_ACCEPTANCE\"\n                    [disabled]=\"\n                      isLoading ||\n                      limitStatus?.isReached ||\n                      (!singleRequest.securityToken && requireSecurityToken)\n                    \"\n                  >\n                    {{ 'Accept' | translate }}\n                  </button>\n                </div>\n              </ng-container>\n\n              <div class=\"card-footer separator text-center card-column-50\">\n                <small\n                  class=\"d-contents\"\n                  *ngIf=\"isManagementTenant; else noManagement\"\n                >\n                  <div\n                    class=\"d-contents\"\n                    *ngIf=\"singleRequest.creationTime && singleRequest.owner\"\n                  >\n                    <span class=\"card-column-50\">\n                      <span\n                        class=\"text-label-small m-l-4 m-r-4\"\n                        translate\n                      >\n                        Created on`date`\n                      </span>\n                      <span data-cy=\"device-registration--creation-date\">\n                        {{ singleRequest.creationTime | c8yDate }}\n                      </span>\n                    </span>\n                    <span class=\"card-column-30 text-truncate\">\n                      <span\n                        class=\"text-label-small m-l-4 m-r-4\"\n                        translate\n                      >\n                        by`user`\n                      </span>\n                      <span\n                        title=\"{{ singleRequest.owner }}\"\n                        data-cy=\"device-registration--created-by\"\n                      >\n                        {{ singleRequest.owner }}\n                      </span>\n                    </span>\n                    <span class=\"card-column-20\">\n                      <span\n                        class=\"text-label-small m-l-4 m-r-4\"\n                        translate\n                      >\n                        in`tenant`\n                      </span>\n                      <span>{{ singleRequest.tenantId }}</span>\n                    </span>\n                  </div>\n                  <div\n                    class=\"d-contents\"\n                    *ngIf=\"!singleRequest.creationTime || !singleRequest.owner\"\n                  >\n                    <div class=\"card-column-50\"></div>\n                    <div class=\"card-column-30\"></div>\n                    <span\n                      class=\"text-label-small\"\n                      translate\n                    >\n                      Created in`tenant`\n                    </span>\n                    <div class=\"card-column-20\">\n                      <span>\n                        {{ singleRequest.tenantId }}\n                      </span>\n                    </div>\n                  </div>\n                </small>\n                <ng-template #noManagement>\n                  <small class=\"d-contents\">\n                    <span class=\"card-column-50\">\n                      <span\n                        class=\"text-label-small m-l-4 m-r-4\"\n                        translate\n                      >\n                        Created on`date`\n                      </span>\n                      <span data-cy=\"device-registration--creation-date\">\n                        {{ singleRequest.creationTime | c8yDate }}\n                      </span>\n                    </span>\n                    <span class=\"card-column-50 text-truncate\">\n                      <span\n                        class=\"text-label-small m-l-4 m-r-4\"\n                        translate\n                      >\n                        by`user`\n                      </span>\n                      <span\n                        title=\"{{ singleRequest.owner }}\"\n                        data-cy=\"device-registration--created-by\"\n                      >\n                        {{ singleRequest.owner }}\n                      </span>\n                    </span>\n                  </small>\n                </ng-template>\n              </div>\n            </div>\n          </div>\n        </ng-container>\n      </div>\n      <c8y-load-more\n        [paging]=\"deviceRequestList.paging\"\n        [hidden]=\"true\"\n        (onLoad)=\"updateList($event)\"\n      ></c8y-load-more>\n    </ng-container>\n\n    <ng-template #noData>\n      <div class=\"c8y-empty-state m-t-40 text-center\">\n        <h1 class=\"c8y-icon c8y-icon-device-connect c8y-icon-duocolor\"></h1>\n        <ng-container *ngIf=\"limitStatus?.isReached; else limitNotReached\">\n          <h3>\n            {{ limitReachedInfo$ | async }}\n          </h3>\n          <p translate>Please contact your platform administrator.</p>\n        </ng-container>\n        <ng-template #limitNotReached>\n          <h3 translate>No pending registrations to display.</h3>\n          <p\n            *c8yIfAllowed=\"['ROLE_DEVICE_CONTROL_ADMIN']\"\n            translate\n          >\n            Use the \"Register device\" dropdown in the top right corner.\n          </p>\n        </ng-template>\n      </div>\n    </ng-template>\n  </ng-container>\n</ng-container>\n", dependencies: [{ kind: "directive", type: i6.PopoverDirective, selector: "[popover]", inputs: ["adaptivePosition", "boundariesElement", "popover", "popoverContext", "popoverTitle", "placement", "outsideClick", "triggers", "container", "containerClass", "isOpen", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }, { kind: "directive", type: i2.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: i2.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i7.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.IfAllowedDirective, selector: "[c8yIfAllowed]", inputs: ["c8yIfAllowed", "c8yIfAllowedAllowAny"] }, { kind: "component", type: i2.LoadMoreComponent, selector: "c8y-load-more", inputs: ["paging", "useIntersection", "hidden", "container", "class", "maxIterations", "noMoreDataHint", "loadingTemplate", "hideNoMoreDataHint", "loadNextLabel", "loadingLabel"], outputs: ["onLoad"] }, { kind: "component", type: i2.ActionBarItemComponent, selector: "c8y-action-bar-item", inputs: ["placement", "priority", "itemClass", "injector", "groupId", "inGroupPriority"] }, { kind: "component", type: i2.BreadcrumbComponent, selector: "c8y-breadcrumb" }, { kind: "component", type: i2.BreadcrumbItemComponent, selector: "c8y-breadcrumb-item", inputs: ["icon", "translate", "label", "path", "injector"] }, { kind: "component", type: i2.TitleComponent, selector: "c8y-title", inputs: ["pageTitleUpdate"] }, { kind: "directive", type: i8.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i8.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i8.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i8.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2.RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "component", type: i2.HelpComponent, selector: "c8y-help", inputs: ["src", "isCollapsed", "priority", "icon"] }, { kind: "component", type: i2.ListDisplaySwitchComponent, selector: "c8y-list-display-switch", inputs: ["listKey", "listLength", "filterPipe"], outputs: ["onListClassChange"] }, { kind: "component", type: i9.RegisterDeviceDropdownComponent, selector: "c8y-register-device-dropdown" }, { kind: "pipe", type: i2.C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: i7.AsyncPipe, name: "async" }, { kind: "pipe", type: i2.DatePipe, name: "c8yDate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DeviceRegistrationViewComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-device-registration-view', template: "<ng-container *ngIf=\"deviceRequests$ | async as deviceRequestList\">\n  <c8y-title>\n    {{ 'Device registration' | translate }}\n    <small *ngIf=\"deviceRequestList.data.length === 1\">1 {{ 'new device' | translate }}</small>\n    <small *ngIf=\"deviceRequestList.data.length > 1\">\n      {{ deviceRequestList.data.length }} {{ 'new devices' | translate }}\n    </small>\n  </c8y-title>\n\n  <c8y-breadcrumb>\n    <c8y-breadcrumb-item\n      [icon]=\"'exchange'\"\n      [label]=\"'Devices' | translate\"\n    ></c8y-breadcrumb-item>\n    <c8y-breadcrumb-item\n      [icon]=\"'c8y-device-connect'\"\n      [label]=\"'Device registration' | translate\"\n    ></c8y-breadcrumb-item>\n  </c8y-breadcrumb>\n\n  <c8y-action-bar-item\n    [placement]=\"'left'\"\n    itemClass=\"navbar-form hidden-xs\"\n  >\n    <c8y-list-display-switch (onListClassChange)=\"displayMode($event)\"></c8y-list-display-switch>\n  </c8y-action-bar-item>\n\n  <ng-container *ngIf=\"limit$ | async as limitStatus\">\n    <c8y-action-bar-item\n      [placement]=\"'right'\"\n      [priority]=\"10\"\n    >\n      <button\n        class=\"btn btn-link\"\n        title=\"{{ 'Accept all' | translate }}\"\n        type=\"button\"\n        *c8yIfAllowed=\"['ROLE_DEVICE_CONTROL_ADMIN']\"\n        (click)=\"acceptAll()\"\n        [disabled]=\"canAcceptAll() || limitStatus?.isReached\"\n      >\n        <i [c8yIcon]=\"'check'\"></i>\n        {{ 'Accept all' | translate }}\n      </button>\n    </c8y-action-bar-item>\n\n    <c8y-action-bar-item\n      [placement]=\"'right'\"\n      [priority]=\"9\"\n    >\n      <button\n        class=\"btn btn-link\"\n        title=\"{{ 'Reload' | translate }}\"\n        type=\"button\"\n        (click)=\"loadAll()\"\n        [disabled]=\"isLoading\"\n      >\n        <i\n          [c8yIcon]=\"'refresh'\"\n          [ngClass]=\"{ 'icon-spin': isLoading }\"\n        ></i>\n        {{ 'Reload' | translate }}\n      </button>\n    </c8y-action-bar-item>\n\n    <c8y-action-bar-item\n      [placement]=\"'right'\"\n      *c8yIfAllowed=\"['ROLE_DEVICE_CONTROL_ADMIN']\"\n    >\n      <c8y-register-device-dropdown></c8y-register-device-dropdown>\n    </c8y-action-bar-item>\n\n    <c8y-help\n      src=\"/docs/device-management-application/registering-devices/#registering-devices\"\n    ></c8y-help>\n\n    <ng-container *ngIf=\"deviceRequestList.data.length > 0; else noData\">\n      <div\n        class=\"card-group\"\n        [ngClass]=\"gridOrList\"\n      >\n        <!-- START interact-list sticky header START -->\n        <div\n          class=\"page-sticky-header hidden-xs\"\n          *ngIf=\"gridOrList === 'interact-list'\"\n        >\n          <div class=\"d-flex\">\n            <div class=\"card-header p-l-40\">\n              <p translate>Device</p>\n            </div>\n            <div class=\"card-block card-column-30 p-l-0 m-l-8\">\n              <p translate>Status</p>\n            </div>\n            <div\n              class=\"card-block card-column-30 p-0\"\n              *ngIf=\"showTokenInputBasedOnSecurityMode()\"\n            >\n              <p translate>Security token</p>\n              <button\n                class=\"btn-help\"\n                [attr.aria-label]=\"'Help' | translate\"\n                popover=\"{{\n                  'Security token is required if the connected device uses it.' | translate\n                }}\"\n                placement=\"right\"\n                triggers=\"focus\"\n                container=\"body\"\n                type=\"button\"\n              ></button>\n            </div>\n            <div class=\"card-footer card-column-50\">\n              <div\n                class=\"d-contents\"\n                *ngIf=\"isManagementTenant; else noManagement\"\n              >\n                <div class=\"card-column-50\">\n                  {{ 'Created' | translate }}\n                </div>\n                <div class=\"card-column-30\">\n                  {{ 'By`user`' | translate }}\n                </div>\n                <div class=\"card-column-20\">\n                  {{ 'Tenant ID' | translate }}\n                </div>\n              </div>\n              <ng-template #noManagement>\n                <div class=\"d-contents\">\n                  <div class=\"card-column-50\">\n                    {{ 'Created' | translate }}\n                  </div>\n                  <div class=\"card-column-50\">\n                    {{ 'By`user`' | translate }}\n                  </div>\n                </div>\n              </ng-template>\n            </div>\n            <div\n              class=\"card-actions-group\"\n              style=\"min-width: 176px\"\n            >\n              <div class=\"btn btn-xs invisible\">\n                <!--EMPTY by design-->\n              </div>\n            </div>\n          </div>\n        </div>\n        <!-- END interact-list sticky header END -->\n\n        <div\n          class=\"col-xs-12 col-sm-6 col-md-4 col-lg-3\"\n          *ngIf=\"limitStatus?.isReached\"\n        >\n          <p\n            class=\"alert alert-warning center-block\"\n            role=\"alert\"\n          >\n            <strong>\n              {{ limitReachedInfo$ | async }}\n            </strong>\n            <br />\n            <span translate>Please contact your platform administrator.</span>\n          </p>\n        </div>\n\n        <ng-container *ngFor=\"let singleRequest of deviceRequestList.data\">\n          <div class=\"col-xs-12 col-sm-6 col-md-4 col-lg-3\">\n            <div class=\"card\">\n              <div class=\"card-header separator\">\n                <div class=\"card-icon\">\n                  <i\n                    [class]=\"statusProps[singleRequest.status].cls\"\n                    [c8yIcon]=\"statusProps[singleRequest.status].icon\"\n                  ></i>\n                </div>\n                <p\n                  class=\"card-title text-truncate\"\n                  title=\"{{ singleRequest.id }}\"\n                >\n                  {{ singleRequest.id }}\n                </p>\n              </div>\n\n              <div class=\"card-block text-center card-column-30\">\n                <span\n                  class=\"text-label-small\"\n                  translate\n                >\n                  Status\n                </span>\n                <p>\n                  <i\n                    class=\"icon-spin text-primary\"\n                    c8yIcon=\"refresh\"\n                    *ngIf=\"singleRequest.status === status.WAITING_FOR_CONNECTION\"\n                  ></i>\n                  {{ statusProps[singleRequest.status].label | translate }}\n                </p>\n              </div>\n\n              <ng-container *c8yIfAllowed=\"['ROLE_DEVICE_CONTROL_ADMIN']\">\n                <div\n                  class=\"card-block text-center card-column-30 p-t-0\"\n                  [ngClass]=\"{ 'p-b-0': !shouldShowSecurityTokenInput(singleRequest) }\"\n                  *ngIf=\"showTokenInputBasedOnSecurityMode()\"\n                >\n                  <ng-container *ngIf=\"shouldShowSecurityTokenInput(singleRequest)\">\n                    <span\n                      class=\"text-label-small\"\n                      *ngIf=\"gridOrList !== 'interact-list'\"\n                      translate\n                    >\n                      Security token\n                    </span>\n                    <input\n                      class=\"form-control\"\n                      type=\"text\"\n                      [(ngModel)]=\"singleRequest.securityToken\"\n                      [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'A1e3gh5ds' }\"\n                      [required]=\"requireSecurityToken\"\n                    />\n                  </ng-container>\n                </div>\n\n                <div\n                  class=\"card-actions-group d-flex a-i-center j-c-center\"\n                  style=\"min-width: 176px\"\n                >\n                  <button\n                    class=\"btn btn-sm\"\n                    title=\"{{\n                      singleRequest.status === status.PENDING_ACCEPTANCE\n                        ? ('Remove' | translate)\n                        : ('Cancel' | translate)\n                    }}\"\n                    type=\"button\"\n                    [ngClass]=\"{\n                      'btn-danger': singleRequest.status === status.PENDING_ACCEPTANCE,\n                      'btn-default': singleRequest.status !== status.PENDING_ACCEPTANCE\n                    }\"\n                    (click)=\"delete(singleRequest.id)\"\n                    [disabled]=\"isLoading\"\n                  >\n                    <span *ngIf=\"singleRequest.status === status.PENDING_ACCEPTANCE\">\n                      {{ 'Remove' | translate }}\n                    </span>\n                    <span *ngIf=\"singleRequest.status !== status.PENDING_ACCEPTANCE\">\n                      {{ 'Cancel' | translate }}\n                    </span>\n                  </button>\n                  <button\n                    class=\"btn btn-primary btn-sm\"\n                    title=\"{{ 'Accept' | translate }}\"\n                    type=\"button\"\n                    (click)=\"accept(singleRequest)\"\n                    *ngIf=\"singleRequest.status === status.PENDING_ACCEPTANCE\"\n                    [disabled]=\"\n                      isLoading ||\n                      limitStatus?.isReached ||\n                      (!singleRequest.securityToken && requireSecurityToken)\n                    \"\n                  >\n                    {{ 'Accept' | translate }}\n                  </button>\n                </div>\n              </ng-container>\n\n              <div class=\"card-footer separator text-center card-column-50\">\n                <small\n                  class=\"d-contents\"\n                  *ngIf=\"isManagementTenant; else noManagement\"\n                >\n                  <div\n                    class=\"d-contents\"\n                    *ngIf=\"singleRequest.creationTime && singleRequest.owner\"\n                  >\n                    <span class=\"card-column-50\">\n                      <span\n                        class=\"text-label-small m-l-4 m-r-4\"\n                        translate\n                      >\n                        Created on`date`\n                      </span>\n                      <span data-cy=\"device-registration--creation-date\">\n                        {{ singleRequest.creationTime | c8yDate }}\n                      </span>\n                    </span>\n                    <span class=\"card-column-30 text-truncate\">\n                      <span\n                        class=\"text-label-small m-l-4 m-r-4\"\n                        translate\n                      >\n                        by`user`\n                      </span>\n                      <span\n                        title=\"{{ singleRequest.owner }}\"\n                        data-cy=\"device-registration--created-by\"\n                      >\n                        {{ singleRequest.owner }}\n                      </span>\n                    </span>\n                    <span class=\"card-column-20\">\n                      <span\n                        class=\"text-label-small m-l-4 m-r-4\"\n                        translate\n                      >\n                        in`tenant`\n                      </span>\n                      <span>{{ singleRequest.tenantId }}</span>\n                    </span>\n                  </div>\n                  <div\n                    class=\"d-contents\"\n                    *ngIf=\"!singleRequest.creationTime || !singleRequest.owner\"\n                  >\n                    <div class=\"card-column-50\"></div>\n                    <div class=\"card-column-30\"></div>\n                    <span\n                      class=\"text-label-small\"\n                      translate\n                    >\n                      Created in`tenant`\n                    </span>\n                    <div class=\"card-column-20\">\n                      <span>\n                        {{ singleRequest.tenantId }}\n                      </span>\n                    </div>\n                  </div>\n                </small>\n                <ng-template #noManagement>\n                  <small class=\"d-contents\">\n                    <span class=\"card-column-50\">\n                      <span\n                        class=\"text-label-small m-l-4 m-r-4\"\n                        translate\n                      >\n                        Created on`date`\n                      </span>\n                      <span data-cy=\"device-registration--creation-date\">\n                        {{ singleRequest.creationTime | c8yDate }}\n                      </span>\n                    </span>\n                    <span class=\"card-column-50 text-truncate\">\n                      <span\n                        class=\"text-label-small m-l-4 m-r-4\"\n                        translate\n                      >\n                        by`user`\n                      </span>\n                      <span\n                        title=\"{{ singleRequest.owner }}\"\n                        data-cy=\"device-registration--created-by\"\n                      >\n                        {{ singleRequest.owner }}\n                      </span>\n                    </span>\n                  </small>\n                </ng-template>\n              </div>\n            </div>\n          </div>\n        </ng-container>\n      </div>\n      <c8y-load-more\n        [paging]=\"deviceRequestList.paging\"\n        [hidden]=\"true\"\n        (onLoad)=\"updateList($event)\"\n      ></c8y-load-more>\n    </ng-container>\n\n    <ng-template #noData>\n      <div class=\"c8y-empty-state m-t-40 text-center\">\n        <h1 class=\"c8y-icon c8y-icon-device-connect c8y-icon-duocolor\"></h1>\n        <ng-container *ngIf=\"limitStatus?.isReached; else limitNotReached\">\n          <h3>\n            {{ limitReachedInfo$ | async }}\n          </h3>\n          <p translate>Please contact your platform administrator.</p>\n        </ng-container>\n        <ng-template #limitNotReached>\n          <h3 translate>No pending registrations to display.</h3>\n          <p\n            *c8yIfAllowed=\"['ROLE_DEVICE_CONTROL_ADMIN']\"\n            translate\n          >\n            Use the \"Register device\" dropdown in the top right corner.\n          </p>\n        </ng-template>\n      </div>\n    </ng-template>\n  </ng-container>\n</ng-container>\n" }]
        }], ctorParameters: () => [{ type: i1.RegisterDeviceService }, { type: i2.DeviceBootstrapRealtimeService }, { type: i2.TenantUiService }, { type: i2.ModalService }, { type: i3.TranslateService }, { type: i2.OptionsService }, { type: i4.ActivatedRoute }, { type: i5.GeneralDeviceRegistrationService }] });
//# sourceMappingURL=data:application/json;base64, 