UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

85 lines (80 loc) 4.9 kB
import { gettext } from '@c8y/ngx-components/gettext'; import * as i1 from '@c8y/ngx-components'; import { CommonModule, I18nModule, DeviceStatusModule, BaseColumn, getBasicInputArrayFormFieldConfig } from '@c8y/ngx-components'; import * as i0 from '@angular/core'; import { Component } from '@angular/core'; import * as i2 from '@c8y/ngx-components/assets-navigator'; import * as i3 from '@angular/common'; class AssetTypeCellRendererComponent { constructor(context, assetNodeService) { this.context = context; this.assetNodeService = assetNodeService; } async ngOnInit() { this.isAnyGroup = this.assetNodeService.isAnyGroup(this.context.item); this.groupIcon = this.assetNodeService.icon(this.context.item); this.isDevice = this.assetNodeService.isDevice(this.context.item); this.isAsset = this.assetNodeService.isAsset(this.context.item); this.iconTitle = this.getIconTitle(await this.groupIcon); } getIconTitle(icon) { if (this.isAsset) { return this.context.item.type; } switch (icon) { case 'c8y-group': return gettext('Group'); case 'c8y-group-smart': return gettext('Smart group'); case 'c8y-group-remote-inactive': return 'Inactive remote group'; case 'c8y-group-remote': return gettext('Remote group'); case 'exchange': return gettext('Device'); default: return gettext('Asset'); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AssetTypeCellRendererComponent, deps: [{ token: i1.CellRendererContext }, { token: i2.AssetNodeService }], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: AssetTypeCellRendererComponent, isStandalone: true, selector: "c8y-asset-type-cell-renderer", ngImport: i0, template: "<device-status\n class=\"m-l-8\"\n [mo]=\"context.item\"\n *ngIf=\"isDevice\"\n></device-status>\n<i\n class=\"m-l-8 c8y-icon-duocolor\"\n [c8yIcon]=\"groupIcon | async\"\n title=\"{{ iconTitle | translate }}\"\n *ngIf=\"isAnyGroup || !isDevice\"\n></i>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: I18nModule }, { kind: "ngmodule", type: DeviceStatusModule }, { kind: "component", type: i1.DeviceStatusComponent, selector: "device-status, c8y-device-status", inputs: ["mo", "size"] }, { kind: "pipe", type: i1.C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AssetTypeCellRendererComponent, decorators: [{ type: Component, args: [{ standalone: true, imports: [CommonModule, I18nModule, DeviceStatusModule], selector: 'c8y-asset-type-cell-renderer', template: "<device-status\n class=\"m-l-8\"\n [mo]=\"context.item\"\n *ngIf=\"isDevice\"\n></device-status>\n<i\n class=\"m-l-8 c8y-icon-duocolor\"\n [c8yIcon]=\"groupIcon | async\"\n title=\"{{ iconTitle | translate }}\"\n *ngIf=\"isAnyGroup || !isDevice\"\n></i>\n" }] }], ctorParameters: () => [{ type: i1.CellRendererContext }, { type: i2.AssetNodeService }] }); class AssetTypeGridColumn extends BaseColumn { constructor(initialColumnConfig) { super(initialColumnConfig); this.name = 'type'; this.header = gettext('Type'); this.dataType = "icon" /* ColumnDataType.Icon */; this.cellRendererComponent = AssetTypeCellRendererComponent; this.sortable = true; this.sortingConfig = { pathSortingConfigs: [{ path: `c8y_IsDeviceGroup` }] }; this.filterable = true; this.filteringConfig = { fields: getBasicInputArrayFormFieldConfig({ key: 'types', label: gettext('Show items with type'), addText: gettext('Add next`type`'), tooltip: gettext('Use * as a wildcard character'), placeholder: gettext('building`e.g. house`') }), getFilter(model) { const filter = {}; if (model.types.length) { filter.type = { __in: model.types }; } return filter; } }; } } /** * Generated bundle index. Do not edit. */ export { AssetTypeCellRendererComponent, AssetTypeGridColumn }; //# sourceMappingURL=c8y-ngx-components-data-grid-columns.mjs.map