@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
125 lines (118 loc) • 8.05 kB
JavaScript
import * as i0 from '@angular/core';
import { Component, Injectable, NgModule } from '@angular/core';
import * as i1 from '@angular/router';
import { ProductExperienceDirective, C8yTranslatePipe, ManagedObjectRealtimeService, BuiltInActionType, CoreModule, hookRoute, hookDataGridActionControls, gettext, ViewContext } from '@c8y/ngx-components';
import * as i2 from '@c8y/ngx-components/device-grid';
import { DeviceGridComponent, DeviceGridModule } from '@c8y/ngx-components/device-grid';
import { PopoverModule } from 'ngx-bootstrap/popover';
import * as i1$1 from '@c8y/client';
import { isEmpty } from 'lodash-es';
class ChildDevicesComponent {
constructor(route, deviceGridService) {
this.route = route;
this.deviceGridService = deviceGridService;
}
async ngOnInit() {
await this.getAllDevices();
this.columns = this.deviceGridService.getChildDeviceGridColumns();
}
async getAllDevices() {
this.id = this.route.snapshot.parent.data.contextData;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ChildDevicesComponent, deps: [{ token: i1.ActivatedRoute }, { token: i2.DeviceGridService }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: ChildDevicesComponent, isStandalone: true, selector: "c8y-child-devices", providers: [ManagedObjectRealtimeService], ngImport: i0, template: "<div class=\"content-fullpage border-top border-bottom\">\n <c8y-device-grid\n [title]=\"'Child devices' | translate\"\n [childDeviceGrid]=\"true\"\n [columns]=\"columns\"\n [parentDeviceId]=\"id\"\n c8yProductExperience\n [actionName]=\"'childDevices'\"\n ></c8y-device-grid>\n</div>\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: "19.2.14", ngImport: i0, type: ChildDevicesComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-child-devices', providers: [ManagedObjectRealtimeService], imports: [DeviceGridComponent, ProductExperienceDirective, C8yTranslatePipe], template: "<div class=\"content-fullpage border-top border-bottom\">\n <c8y-device-grid\n [title]=\"'Child devices' | translate\"\n [childDeviceGrid]=\"true\"\n [columns]=\"columns\"\n [parentDeviceId]=\"id\"\n c8yProductExperience\n [actionName]=\"'childDevices'\"\n ></c8y-device-grid>\n</div>\n" }]
}], ctorParameters: () => [{ type: i1.ActivatedRoute }, { type: i2.DeviceGridService }] });
class ChildDevicesActionControlsFactory {
constructor(deviceGridService) {
this.deviceGridService = deviceGridService;
}
get() {
return {
actionControls: [
{
type: BuiltInActionType.Delete,
priority: -Infinity,
callback: async (item, reload) => {
await this.deviceGridService.delete(item);
reload();
}
}
],
matchesGrid(route) {
return route.snapshot.routeConfig?.path === 'child-devices';
}
};
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ChildDevicesActionControlsFactory, deps: [{ token: i2.DeviceGridService }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ChildDevicesActionControlsFactory, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ChildDevicesActionControlsFactory, decorators: [{
type: Injectable,
args: [{ providedIn: 'root' }]
}], ctorParameters: () => [{ type: i2.DeviceGridService }] });
class ChildDevicesTabGuard {
constructor(inventory) {
this.inventory = inventory;
}
async canActivate(route) {
const contextData = route.data.contextData;
const filter = {
pageSize: 1
};
if (isEmpty(contextData)) {
return true;
}
const device = await this.inventory.childDevicesList(contextData.id, filter);
const hasChildren = device.data.length;
return !!hasChildren;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ChildDevicesTabGuard, deps: [{ token: i1$1.InventoryService }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ChildDevicesTabGuard, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ChildDevicesTabGuard, decorators: [{
type: Injectable,
args: [{ providedIn: 'root' }]
}], ctorParameters: () => [{ type: i1$1.InventoryService }] });
class ChildDevicesModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ChildDevicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: ChildDevicesModule, imports: [CoreModule, DeviceGridModule, PopoverModule, ChildDevicesComponent] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ChildDevicesModule, providers: [
hookRoute({
context: ViewContext.Device,
path: 'child-devices',
priority: 1000,
icon: 'code-fork',
label: gettext('Child devices'),
component: ChildDevicesComponent,
canActivate: [ChildDevicesTabGuard]
}),
hookDataGridActionControls(ChildDevicesActionControlsFactory)
], imports: [CoreModule, DeviceGridModule, PopoverModule, ChildDevicesComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ChildDevicesModule, decorators: [{
type: NgModule,
args: [{
imports: [CoreModule, DeviceGridModule, PopoverModule, ChildDevicesComponent],
providers: [
hookRoute({
context: ViewContext.Device,
path: 'child-devices',
priority: 1000,
icon: 'code-fork',
label: gettext('Child devices'),
component: ChildDevicesComponent,
canActivate: [ChildDevicesTabGuard]
}),
hookDataGridActionControls(ChildDevicesActionControlsFactory)
]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { ChildDevicesComponent, ChildDevicesModule };
//# sourceMappingURL=c8y-ngx-components-child-devices.mjs.map