import { Component, Input } from '@angular/core';
import { InventoryService } from '@c8y/client';
import { AlertService } from '@c8y/ngx-components';
import * as i0 from "@angular/core";
import * as i1 from "@c8y/client";
import * as i2 from "@c8y/ngx-components";
import * as i3 from "@angular/common";
export class TypeDashboardInfoComponent {
    constructor(inventory, alert) {
        this.inventory = inventory;
        this.alert = alert;
    }
    async ngOnInit() {
        await this.updateDeviceTypeCount();
    }
    async updateDeviceTypeCount() {
        try {
            const count = await this.inventory.count({
                type: this.deviceTypeValue || this.context.c8y_Dashboard.deviceTypeValue
            });
            this.deviceTypeInstancesCount = count.data;
            this.asyncRenderSuccess?.();
        }
        catch (error) {
            this.alert.addServerFailure(error);
            this.asyncRenderFail?.();
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: TypeDashboardInfoComponent, deps: [{ token: i1.InventoryService }, { token: i2.AlertService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.9", type: TypeDashboardInfoComponent, selector: "c8y-type-dashboard-info", inputs: { deviceTypeValue: "deviceTypeValue", displayDeviceTypeValue: "displayDeviceTypeValue", context: "context", asyncRenderSuccess: "asyncRenderSuccess", asyncRenderFail: "asyncRenderFail" }, ngImport: i0, template: "<ul class=\"list-unstyled small animated fadeIn\">\n  <li class=\"p-t-4 p-b-4 d-flex separator-top-bottom text-nowrap\">\n    <label class=\"small m-b-0 m-r-8\">{{ 'Target asset model' | translate }}</label>\n    <span class=\"m-l-auto\">\n      <span class=\"label label-info\">\n        {{ displayDeviceTypeValue || context.c8y_Dashboard.deviceTypeValue }}\n      </span>\n    </span>\n  </li>\n  <li class=\"p-t-4 p-b-4 d-flex separator-bottom text-nowrap\">\n    <label class=\"small m-b-0 m-r-8\">{{ 'Dashboard instances' | translate }}</label>\n    <span class=\"m-l-auto\">{{ deviceTypeInstancesCount }}</span>\n  </li>\n  <ng-container *ngIf=\"context?.c8y_Dashboard\">\n    <li class=\"p-t-4 p-b-4 d-flex separator-bottom text-nowrap\">\n      <label class=\"small m-b-0 m-r-8\">{{ 'Created' | translate }}</label>\n      <span class=\"m-l-auto\">\n        {{ context.creationTime | c8yDate }} {{ 'by`user`' | translate }} {{ context.owner }}\n      </span>\n    </li>\n    <li\n      class=\"p-t-4 p-b-4 d-flex separator-bottom text-nowrap\"\n      *ngIf=\"context?.c8y_DashboardHistory?.length\"\n    >\n      <label class=\"small m-b-0 m-r-8\">{{ 'Last modified' | translate }}</label>\n      <span class=\"m-l-auto\">\n        {{ context.c8y_DashboardHistory[0].created | c8yDate }} {{ 'by`user`' | translate }}\n        {{ context.c8y_DashboardHistory[0].author }}\n      </span>\n    </li>\n  </ng-container>\n</ul>\n", dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: i2.DatePipe, name: "c8yDate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: TypeDashboardInfoComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-type-dashboard-info', template: "<ul class=\"list-unstyled small animated fadeIn\">\n  <li class=\"p-t-4 p-b-4 d-flex separator-top-bottom text-nowrap\">\n    <label class=\"small m-b-0 m-r-8\">{{ 'Target asset model' | translate }}</label>\n    <span class=\"m-l-auto\">\n      <span class=\"label label-info\">\n        {{ displayDeviceTypeValue || context.c8y_Dashboard.deviceTypeValue }}\n      </span>\n    </span>\n  </li>\n  <li class=\"p-t-4 p-b-4 d-flex separator-bottom text-nowrap\">\n    <label class=\"small m-b-0 m-r-8\">{{ 'Dashboard instances' | translate }}</label>\n    <span class=\"m-l-auto\">{{ deviceTypeInstancesCount }}</span>\n  </li>\n  <ng-container *ngIf=\"context?.c8y_Dashboard\">\n    <li class=\"p-t-4 p-b-4 d-flex separator-bottom text-nowrap\">\n      <label class=\"small m-b-0 m-r-8\">{{ 'Created' | translate }}</label>\n      <span class=\"m-l-auto\">\n        {{ context.creationTime | c8yDate }} {{ 'by`user`' | translate }} {{ context.owner }}\n      </span>\n    </li>\n    <li\n      class=\"p-t-4 p-b-4 d-flex separator-bottom text-nowrap\"\n      *ngIf=\"context?.c8y_DashboardHistory?.length\"\n    >\n      <label class=\"small m-b-0 m-r-8\">{{ 'Last modified' | translate }}</label>\n      <span class=\"m-l-auto\">\n        {{ context.c8y_DashboardHistory[0].created | c8yDate }} {{ 'by`user`' | translate }}\n        {{ context.c8y_DashboardHistory[0].author }}\n      </span>\n    </li>\n  </ng-container>\n</ul>\n" }]
        }], ctorParameters: () => [{ type: i1.InventoryService }, { type: i2.AlertService }], propDecorators: { deviceTypeValue: [{
                type: Input
            }], displayDeviceTypeValue: [{
                type: Input
            }], context: [{
                type: Input
            }], asyncRenderSuccess: [{
                type: Input
            }], asyncRenderFail: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 