@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
115 lines (110 loc) • 7.47 kB
JavaScript
import * as i0 from '@angular/core';
import { EventEmitter, Output, Input, ViewChild, Component, NgModule } from '@angular/core';
import { FilteringActionType, ProductExperienceDirective, C8yTranslatePipe, UserPreferencesConfigurationStrategy, DATA_GRID_CONFIGURATION_STRATEGY, DATA_GRID_CONFIGURATION_CONTEXT } from '@c8y/ngx-components';
import { TypeDeviceGridColumn, StatusDeviceGridColumn, NameDeviceGridColumn, ModelDeviceGridColumn, GroupDeviceGridColumn, RegistrationDateDeviceGridColumn, AlarmsDeviceGridColumn, DeviceGridComponent } from '@c8y/ngx-components/device-grid';
import { Subject } from 'rxjs';
import { distinctUntilChanged, takeUntil } from 'rxjs/operators';
const GRID_CONFIG_KEY = 'device-grid-bulk';
class DeviceSelectorComponent {
constructor() {
this.typeColumn = new TypeDeviceGridColumn();
this.onDeviceQueryStringChange = new EventEmitter();
this.columns = [
new StatusDeviceGridColumn(),
new NameDeviceGridColumn(),
this.typeColumn,
new ModelDeviceGridColumn(),
new GroupDeviceGridColumn(),
new RegistrationDateDeviceGridColumn(),
new AlarmsDeviceGridColumn()
];
this.unsubscribe$ = new Subject();
}
static { this.GRID_CONFIG_CONTEXT = {
key: GRID_CONFIG_KEY,
configFilter: {
filter: false
}
}; }
ngOnInit() {
if (this.deviceTypes) {
this.deviceTypes
.pipe(distinctUntilChanged(), takeUntil(this.unsubscribe$))
.subscribe((types) => {
// there is a concurrency issue when updateFiltering is called before the columns have actually been passed into the grid
// so we are already updating the typeColumn here additionally so in case updateFiltering has no affect, the type column is still correctly filtered
// "Dynamic group created for bulk operation should be invisible" cypress tests of configurationUpdateBulkOperation.cy.ts started failing otherwise
this.typeColumn.externalFilterQuery = { types };
this.deviceGrid.updateFiltering([this.typeColumn.name], {
type: types && types.length
? FilteringActionType.ApplyFilter
: FilteringActionType.ResetFilter,
payload: types
? {
filteringModifier: {
externalFilterQuery: {
types
}
}
}
: undefined
});
});
}
}
ngOnDestroy() {
this.unsubscribe$.next(true);
this.unsubscribe$.complete();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: DeviceSelectorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: DeviceSelectorComponent, isStandalone: true, selector: "c8y-device-selector", inputs: { deviceTypes: "deviceTypes" }, outputs: { onDeviceQueryStringChange: "onDeviceQueryStringChange" }, providers: [
{
provide: DATA_GRID_CONFIGURATION_STRATEGY,
useClass: UserPreferencesConfigurationStrategy
},
{
provide: DATA_GRID_CONFIGURATION_CONTEXT,
useValue: DeviceSelectorComponent.GRID_CONFIG_CONTEXT
}
], viewQueries: [{ propertyName: "deviceGrid", first: true, predicate: DeviceGridComponent, descendants: true, static: true }], ngImport: i0, template: "<c8y-device-grid\n [title]=\"'Target devices' | translate\"\n [columns]=\"columns\"\n [infiniteScroll]=\"'auto'\"\n [showSearch]=\"false\"\n (onDeviceQueryStringChange)=\"onDeviceQueryStringChange.emit($event)\"\n c8yProductExperience\n [actionName]=\"'bulkOperations'\"\n></c8y-device-grid>\n", dependencies: [{ kind: "component", type: DeviceGridComponent, selector: "c8y-device-grid", inputs: ["dataCallback", "refresh", "title", "loadMoreItemsLabel", "loadingItemsLabel", "legacyConfigKey", "legacyFilterKey", "columns", "pagination", "infiniteScroll", "actionControls", "selectable", "singleSelection", "baseQuery", "bulkActionControls", "headerActionControls", "childDeviceGrid", "parentDeviceId", "withChildren", "showSearch", "activeClassName"], outputs: ["onColumnsChange", "onFilterChange", "onDeviceQueryStringChange", "itemsSelect"] }, { kind: "directive", type: ProductExperienceDirective, selector: "[c8yProductExperience]", inputs: ["actionName", "actionData", "inherit", "suppressDataOverriding"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: DeviceSelectorComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-device-selector', providers: [
{
provide: DATA_GRID_CONFIGURATION_STRATEGY,
useClass: UserPreferencesConfigurationStrategy
},
{
provide: DATA_GRID_CONFIGURATION_CONTEXT,
useValue: DeviceSelectorComponent.GRID_CONFIG_CONTEXT
}
], imports: [DeviceGridComponent, ProductExperienceDirective, C8yTranslatePipe], template: "<c8y-device-grid\n [title]=\"'Target devices' | translate\"\n [columns]=\"columns\"\n [infiniteScroll]=\"'auto'\"\n [showSearch]=\"false\"\n (onDeviceQueryStringChange)=\"onDeviceQueryStringChange.emit($event)\"\n c8yProductExperience\n [actionName]=\"'bulkOperations'\"\n></c8y-device-grid>\n" }]
}], propDecorators: { deviceGrid: [{
type: ViewChild,
args: [DeviceGridComponent, { static: true }]
}], deviceTypes: [{
type: Input
}], onDeviceQueryStringChange: [{
type: Output
}] } });
/**
* This module provides a component for selecting devices based on filters.
*/
class DeviceSelectorModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: DeviceSelectorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: DeviceSelectorModule, imports: [DeviceSelectorComponent], exports: [DeviceSelectorComponent] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: DeviceSelectorModule, imports: [DeviceSelectorComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: DeviceSelectorModule, decorators: [{
type: NgModule,
args: [{
imports: [DeviceSelectorComponent],
exports: [DeviceSelectorComponent]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { DeviceSelectorComponent, DeviceSelectorModule };
//# sourceMappingURL=c8y-ngx-components-operations-device-selector.mjs.map