@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
87 lines (82 loc) • 8.09 kB
JavaScript
import * as i0 from '@angular/core';
import { Input, Component, NgModule } from '@angular/core';
import * as i1 from '@angular/forms';
import { Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { gettext } from '@c8y/ngx-components/gettext';
import { FormGroupComponent, C8yTranslateDirective, RequiredInputPlaceholderDirective, C8yTranslatePipe } from '@c8y/ngx-components';
import { get } from 'lodash-es';
import { BulkOperationType } from '@c8y/ngx-components/operations/bulk-operations-service';
import { OperationSchedulerComponent } from '@c8y/ngx-components/operations/bulk-operation-scheduler';
class CreateBulkOperationDetailsComponent {
set bulkOperationType(bulkOperationType) {
this.titlePlaceholder = get(this.placeholders[bulkOperationType], 'title');
this.descriptionPlaceholder = get(this.placeholders[bulkOperationType], 'description', gettext('e.g. Reset factory settings of all devices of model XYZ'));
}
constructor(formBuilder) {
this.formBuilder = formBuilder;
this.titlePlaceholder = gettext('e.g. Reset factory settings');
this.descriptionPlaceholder = gettext('e.g. Reset factory settings of all devices of model XYZ');
this.placeholders = {
[BulkOperationType.SOFTWARE]: {
title: gettext('e.g. Cloud connectivity software'),
description: gettext('e.g. Cloud connectivity software applied to devices with type c8y_Linux')
},
[BulkOperationType.FIRMWARE]: {
title: gettext('e.g. Firmware for hardware revision B'),
description: gettext('e.g. Firmware for hardware revision B applied to devices with type c8y_Linux')
},
[BulkOperationType.CONFIGURATION]: {
title: gettext('e.g. Host configuration c8y_Linux'),
description: gettext('e.g. Host configuration applied to devices with type c8y_Linux')
},
[BulkOperationType.DEVICE_PROFILE]: {
title: gettext('e.g. Device profile for c8y_Linux devices'),
description: gettext('e.g. Device profile applied to devices with type c8y_Linux')
}
};
}
ngOnInit() {
const config = {
description: ['', Validators.required],
note: [''],
schedule: []
};
this.fgOperationDescription = this.formBuilder.group(config);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CreateBulkOperationDetailsComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: CreateBulkOperationDetailsComponent, isStandalone: true, selector: "c8y-create-bulk-operation-details", inputs: { bulkOperationType: "bulkOperationType" }, ngImport: i0, template: "<div [formGroup]=\"fgOperationDescription\">\n <c8y-form-group>\n <label translate>Title</label>\n <input\n class=\"form-control\"\n required\n formControlName=\"description\"\n [placeholder]=\"titlePlaceholder | translate\"\n />\n </c8y-form-group>\n <c8y-form-group>\n <label translate>Description</label>\n <textarea\n class=\"form-control\"\n rows=\"3\"\n formControlName=\"note\"\n [placeholder]=\"descriptionPlaceholder | translate\"\n ></textarea>\n </c8y-form-group>\n <c8y-operation-scheduler formControlName=\"schedule\"></c8y-operation-scheduler>\n</div>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "component", type: OperationSchedulerComponent, selector: "c8y-operation-scheduler", inputs: ["minutesAhead"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CreateBulkOperationDetailsComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-create-bulk-operation-details', imports: [
FormsModule,
ReactiveFormsModule,
FormGroupComponent,
C8yTranslateDirective,
RequiredInputPlaceholderDirective,
OperationSchedulerComponent,
C8yTranslatePipe
], template: "<div [formGroup]=\"fgOperationDescription\">\n <c8y-form-group>\n <label translate>Title</label>\n <input\n class=\"form-control\"\n required\n formControlName=\"description\"\n [placeholder]=\"titlePlaceholder | translate\"\n />\n </c8y-form-group>\n <c8y-form-group>\n <label translate>Description</label>\n <textarea\n class=\"form-control\"\n rows=\"3\"\n formControlName=\"note\"\n [placeholder]=\"descriptionPlaceholder | translate\"\n ></textarea>\n </c8y-form-group>\n <c8y-operation-scheduler formControlName=\"schedule\"></c8y-operation-scheduler>\n</div>\n" }]
}], ctorParameters: () => [{ type: i1.FormBuilder }], propDecorators: { bulkOperationType: [{
type: Input
}] } });
/**
* This module provides a component for entering operation details.
*/
class CreateBulkOperationDetailsModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CreateBulkOperationDetailsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: CreateBulkOperationDetailsModule, imports: [CreateBulkOperationDetailsComponent], exports: [CreateBulkOperationDetailsComponent] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CreateBulkOperationDetailsModule, imports: [CreateBulkOperationDetailsComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CreateBulkOperationDetailsModule, decorators: [{
type: NgModule,
args: [{
imports: [CreateBulkOperationDetailsComponent],
exports: [CreateBulkOperationDetailsComponent]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { CreateBulkOperationDetailsComponent, CreateBulkOperationDetailsModule };
//# sourceMappingURL=c8y-ngx-components-operations-create-bulk-operation-details.mjs.map