@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
162 lines (157 loc) • 6.23 kB
JavaScript
import { gettext } from '@c8y/ngx-components';
import { BaseObjectMapping, MeasurementObjectMapping, EventObjectMapping, AlarmObjectMapping, ALARM_SEVERITY } from '@c8y/ngx-components/device-protocol-object-mappings';
class OpcuaCustomActionObjectMapping extends BaseObjectMapping {
constructor() {
super({
icon: 'bell',
label: gettext('Custom action'),
formlyFieldConfig: {
key: 'customAction',
fieldGroup: [
{
type: 'array',
key: 'headers',
props: {
label: gettext('headers'),
addText: gettext('Add Header'),
required: true
},
className: 'formly-group-array-cols d-block min-height-fit',
fieldArray: {
fieldGroup: [
{
key: 'key',
type: 'string',
focus: true,
props: {
placeholder: 'Authorization',
label: gettext('Key'),
required: true,
smallFormGroup: true
},
wrappers: ['c8y-form-field']
},
{
key: 'value',
type: 'string',
props: {
placeholder: 'Basic <credentials>',
label: gettext('Value'),
required: true,
smallFormGroup: true
}
}
]
}
},
{
className: 'row',
wrappers: ['c8y-legend-wrapper'],
props: {
label: gettext('Action')
},
fieldGroup: [
{
type: 'string',
key: 'endpoint',
props: {
label: gettext('Endpoint'),
smallFormGroup: true,
required: true
},
className: 'col-md-6 p-0'
},
{
type: 'textarea',
key: 'bodyTemplate',
props: {
label: gettext('Body template'),
smallFormGroup: true,
required: true,
description: gettext('The following placeholders are available: ${value}`KEEP_ORIGINAL`, ${serverId}`KEEP_ORIGINAL`, ${nodeId}`KEEP_ORIGINAL`, ${deviceId}`KEEP_ORIGINAL`.')
},
className: 'col-md-6'
}
]
}
]
}
});
}
}
class OpcuaMeasurementObjectMapping extends MeasurementObjectMapping {
constructor(smallFormGroup = true) {
super(null, 'measurementCreation', smallFormGroup);
this.smallFormGroup = smallFormGroup;
}
}
class OpcuaEventObjectMapping extends EventObjectMapping {
constructor(smallFormGroup = true) {
super(null, 'eventCreation', smallFormGroup, undefined, [
{
key: 'type',
type: 'string',
props: {
label: gettext('Type'),
required: true,
smallFormGroup
},
className: 'col-md-3 col-sm-6'
},
{
key: 'text',
type: 'string',
props: {
label: gettext('Text'),
required: true,
smallFormGroup
},
className: 'col-md-3 col-sm-6'
}
]);
this.smallFormGroup = smallFormGroup;
}
}
class OpcuaAlarmObjectMapping extends AlarmObjectMapping {
constructor(smallFormGroup = true) {
super(null, 'alarmCreation', smallFormGroup, undefined, [
{
key: 'severity',
type: 'select',
props: {
label: gettext('Severity'),
options: [...Object.values(ALARM_SEVERITY).map(value => ({ label: value, value }))],
required: true,
smallFormGroup
},
className: 'col-md-3 col-sm-6'
},
{
key: 'type',
type: 'string',
props: {
label: gettext('Type'),
smallFormGroup,
required: true
},
className: 'col-md-3 col-sm-6'
},
{
key: 'text',
type: 'string',
props: {
label: gettext('Text'),
smallFormGroup,
required: true
},
className: 'col-md-3 col-sm-6'
}
]);
this.smallFormGroup = smallFormGroup;
}
}
/**
* Generated bundle index. Do not edit.
*/
export { OpcuaAlarmObjectMapping, OpcuaCustomActionObjectMapping, OpcuaEventObjectMapping, OpcuaMeasurementObjectMapping };
//# sourceMappingURL=c8y-ngx-components-protocol-opcua-mappings.mjs.map