UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

158 lines (150 loc) 7.95 kB
import * as i0 from '@angular/core'; import { Injectable, Input, Directive, ChangeDetectionStrategy, Component, NgModule } from '@angular/core'; import * as i1 from '@c8y/ngx-components'; import { gettext, Status, hookRoute } from '@c8y/ngx-components'; import * as i1$1 from '@angular/router'; import { UpgradeComponent } from '@angular/upgrade/static'; class DeviceTypeDetailEditedService { constructor() { this.isDetailEdited = false; } getIsDetailEdited() { return this.isDetailEdited; } setIsDetailEdited(value) { this.isDetailEdited = value; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceTypeDetailEditedService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceTypeDetailEditedService }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceTypeDetailEditedService, decorators: [{ type: Injectable }] }); class DeviceProtocolsGuard { constructor(modal, alert, deviceTypeDetailEditedService) { this.modal = modal; this.alert = alert; this.deviceTypeDetailEditedService = deviceTypeDetailEditedService; } async canDeactivate() { if (this.deviceTypeDetailEditedService.getIsDetailEdited()) { try { await this.modal.confirm(gettext('Discard changes'), gettext('You are about to leave this page and discard the changes made. Do you want to proceed?'), Status.WARNING, { ok: gettext('Discard') }); this.deviceTypeDetailEditedService.setIsDetailEdited(false); return true; } catch (e) { if (e) { this.alert.danger(e); } return false; } } return true; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceProtocolsGuard, deps: [{ token: i1.ModalService }, { token: i1.AlertService }, { token: DeviceTypeDetailEditedService }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceProtocolsGuard, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceProtocolsGuard, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [{ type: i1.ModalService }, { type: i1.AlertService }, { type: DeviceTypeDetailEditedService }] }); class DeviceTypeDetail extends UpgradeComponent { constructor(elementRef, injector) { super('c8yDeviceTypeDetail', elementRef, injector); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceTypeDetail, deps: [{ token: i0.ElementRef }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.14", type: DeviceTypeDetail, isStandalone: true, selector: "c8y-device-type-detail-directive", inputs: { id: "id" }, usesInheritance: true, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceTypeDetail, decorators: [{ type: Directive, args: [{ selector: 'c8y-device-type-detail-directive' }] }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Injector }], propDecorators: { id: [{ type: Input }] } }); /* https://stackoverflow.com/a/65290658 */ function rootScopeTypeDetailFactory($injector) { return $injector.get('$rootScope').$new(); } class DeviceTypeDetailComponent { constructor(route) { this.route = route; } ngOnInit() { this.deviceTypeId = this.route.snapshot.paramMap.get('id'); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceTypeDetailComponent, deps: [{ token: i1$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: DeviceTypeDetailComponent, isStandalone: true, selector: "c8y-device-type-detail", providers: [ { deps: ['$injector'], provide: '$scope', useFactory: rootScopeTypeDetailFactory } ], ngImport: i0, template: `<c8y-device-type-detail-directive [id]="deviceTypeId" ></c8y-device-type-detail-directive>`, isInline: true, dependencies: [{ kind: "directive", type: DeviceTypeDetail, selector: "c8y-device-type-detail-directive", inputs: ["id"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceTypeDetailComponent, decorators: [{ type: Component, args: [{ selector: 'c8y-device-type-detail', template: `<c8y-device-type-detail-directive [id]="deviceTypeId" ></c8y-device-type-detail-directive>`, providers: [ { deps: ['$injector'], provide: '$scope', useFactory: rootScopeTypeDetailFactory } ], changeDetection: ChangeDetectionStrategy.OnPush, imports: [DeviceTypeDetail] }] }], ctorParameters: () => [{ type: i1$1.ActivatedRoute }] }); const fieldbusTypes = [ 'actility', 'canbus', 'canopen', 'lora', 'lpwan', 'modbus', 'opcua', 'profibus', 'sigfox' ]; const protocolRoutes = fieldbusTypes.map(protocol => ({ path: `deviceprotocols/${protocol}/:id`, component: DeviceTypeDetailComponent, canDeactivate: [DeviceProtocolsGuard] })); class DeviceProtocolsModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceProtocolsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: DeviceProtocolsModule, imports: [DeviceTypeDetail, DeviceTypeDetailComponent], exports: [DeviceTypeDetailComponent] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceProtocolsModule, providers: [ DeviceTypeDetailEditedService, DeviceProtocolsGuard, ...protocolRoutes.map(route => hookRoute(route)) ] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DeviceProtocolsModule, decorators: [{ type: NgModule, args: [{ imports: [DeviceTypeDetail, DeviceTypeDetailComponent], exports: [DeviceTypeDetailComponent], providers: [ DeviceTypeDetailEditedService, DeviceProtocolsGuard, ...protocolRoutes.map(route => hookRoute(route)) ] }] }] }); /** * Generated bundle index. Do not edit. */ export { DeviceProtocolsGuard, DeviceProtocolsModule, DeviceTypeDetail, DeviceTypeDetailComponent, DeviceTypeDetailEditedService, rootScopeTypeDetailFactory }; //# sourceMappingURL=c8y-ngx-components-device-protocols.mjs.map