|
|
|
@ -14,7 +14,7 @@ |
|
|
|
/// limitations under the License.
|
|
|
|
///
|
|
|
|
|
|
|
|
import { Component, EventEmitter, forwardRef, Input, OnInit, Output } from '@angular/core'; |
|
|
|
import { Component, EventEmitter, forwardRef, Input, OnDestroy, OnInit, Output } from '@angular/core'; |
|
|
|
import { |
|
|
|
ControlValueAccessor, |
|
|
|
FormArray, |
|
|
|
@ -53,6 +53,8 @@ import { |
|
|
|
} from '@shared/components/dialog/json-object-edit-dialog.component'; |
|
|
|
import { jsonRequired } from '@shared/components/json-object-edit.component'; |
|
|
|
import { deepClone } from '@core/utils'; |
|
|
|
import { takeUntil, tap } from "rxjs/operators"; |
|
|
|
import { Subject } from "rxjs"; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'tb-gateway-service-rpc-connector', |
|
|
|
@ -66,7 +68,7 @@ import { deepClone } from '@core/utils'; |
|
|
|
} |
|
|
|
] |
|
|
|
}) |
|
|
|
export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValueAccessor { |
|
|
|
export class GatewayServiceRPCConnectorComponent implements OnInit, OnDestroy, ControlValueAccessor { |
|
|
|
|
|
|
|
@Input() |
|
|
|
connectorType: ConnectorType; |
|
|
|
@ -105,6 +107,7 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValue |
|
|
|
|
|
|
|
private propagateChange = (v: any) => { |
|
|
|
} |
|
|
|
private destroy$ = new Subject<void>(); |
|
|
|
|
|
|
|
constructor(private fb: FormBuilder, |
|
|
|
private dialog: MatDialog,) { |
|
|
|
@ -138,6 +141,12 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValue |
|
|
|
} |
|
|
|
}); |
|
|
|
this.isMQTTWithResponse = this.fb.control(false); |
|
|
|
this.observeMQTTWithResponse(); |
|
|
|
} |
|
|
|
|
|
|
|
ngOnDestroy(): void { |
|
|
|
this.destroy$.next(); |
|
|
|
this.destroy$.complete(); |
|
|
|
} |
|
|
|
|
|
|
|
connectorParamsFormGroupByType(type: ConnectorType): FormGroup { |
|
|
|
@ -148,7 +157,7 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValue |
|
|
|
formGroup = this.fb.group({ |
|
|
|
methodFilter: [null, [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], |
|
|
|
requestTopicExpression: [null, [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], |
|
|
|
responseTopicExpression: [null, [Validators.pattern(noLeadTrailSpacesRegex)]], |
|
|
|
responseTopicExpression: [{ value: null, disabled: true }, [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], |
|
|
|
responseTimeout: [null, [Validators.min(10), Validators.pattern(this.numbersOnlyPattern)]], |
|
|
|
valueExpression: [null, [Validators.required, Validators.pattern(noLeadTrailSpacesRegex)]], |
|
|
|
}) |
|
|
|
@ -424,4 +433,14 @@ export class GatewayServiceRPCConnectorComponent implements OnInit, ControlValue |
|
|
|
this.commandForm.patchValue(value, {onlySelf: false}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private observeMQTTWithResponse(): void { |
|
|
|
this.isMQTTWithResponse.valueChanges.pipe( |
|
|
|
tap((isActive: boolean) => { |
|
|
|
const responseControl = this.commandForm.get('responseTopicExpression'); |
|
|
|
isActive ? responseControl.enable() : responseControl.disable(); |
|
|
|
}), |
|
|
|
takeUntil(this.destroy$), |
|
|
|
).subscribe(); |
|
|
|
} |
|
|
|
} |
|
|
|
|