fixed no workers with mqtt default config
This commit is contained in:
parent
1778692c3e
commit
3493c51cf7
@ -17,11 +17,14 @@
|
||||
import { Directive } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import {
|
||||
BrokerConfig,
|
||||
MappingType,
|
||||
MQTTBasicConfig, MQTTBasicConfig_v3_5_2,
|
||||
MQTTBasicConfig,
|
||||
MQTTBasicConfig_v3_5_2,
|
||||
RequestMappingData,
|
||||
RequestMappingValue,
|
||||
RequestType
|
||||
RequestType,
|
||||
WorkersConfig
|
||||
} from '@home/components/widget/lib/gateway/gateway-widget.models';
|
||||
import { isObject } from '@core/utils';
|
||||
import {
|
||||
@ -73,6 +76,14 @@ export abstract class MqttBasicConfigDirective<BasicConfig>
|
||||
});
|
||||
}
|
||||
|
||||
protected getBrokerMappedValue(broker: BrokerConfig, workers: WorkersConfig): BrokerConfig {
|
||||
return {
|
||||
...broker,
|
||||
maxNumberOfWorkers: workers.maxNumberOfWorkers ?? 100,
|
||||
maxMessageNumberPerWorker: workers.maxMessageNumberPerWorker ?? 10,
|
||||
};
|
||||
}
|
||||
|
||||
writeValue(basicConfig: BasicConfig): void {
|
||||
this.basicFormGroup.setValue(this.mapConfigToFormValue(basicConfig), { emitEvent: false });
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ import {
|
||||
import {
|
||||
MqttBasicConfigDirective
|
||||
} from '@home/components/widget/lib/gateway/connectors-configuration/mqtt/basic-config/mqtt-basic-config.abstract';
|
||||
import { isDefinedAndNotNull } from '@core/utils';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { SharedModule } from '@shared/shared.module';
|
||||
import {
|
||||
@ -85,19 +84,14 @@ export class MqttBasicConfigComponent extends MqttBasicConfigDirective<MQTTBasic
|
||||
}
|
||||
|
||||
protected override getMappedValue(basicConfig: MQTTBasicConfig_v3_5_2): MQTTBasicConfig_v3_5_2 {
|
||||
let { broker, workers, mapping, requestsMapping } = basicConfig || {};
|
||||
const { broker, workers, mapping, requestsMapping } = basicConfig || {};
|
||||
|
||||
if (isDefinedAndNotNull(workers.maxNumberOfWorkers) || isDefinedAndNotNull(workers.maxMessageNumberPerWorker)) {
|
||||
broker = {
|
||||
...broker,
|
||||
...workers,
|
||||
return {
|
||||
broker: this.getBrokerMappedValue(broker, workers),
|
||||
mapping,
|
||||
requestsMapping: (requestsMapping as RequestMappingData[])?.length
|
||||
? this.getRequestDataObject(requestsMapping as RequestMappingValue[])
|
||||
: {} as Record<RequestType, RequestMappingValue[]>
|
||||
};
|
||||
}
|
||||
|
||||
if ((requestsMapping as RequestMappingData[])?.length) {
|
||||
requestsMapping = this.getRequestDataObject(requestsMapping as RequestMappingValue[]);
|
||||
}
|
||||
|
||||
return { broker, mapping, requestsMapping };
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,23 +102,16 @@ export class MqttLegacyBasicConfigComponent extends MqttBasicConfigDirective<MQT
|
||||
}
|
||||
|
||||
protected override getMappedValue(basicConfig: MQTTBasicConfig_v3_5_2): MQTTLegacyBasicConfig {
|
||||
let { broker, workers, mapping, requestsMapping } = basicConfig || {};
|
||||
const { broker, workers, mapping, requestsMapping } = basicConfig || {};
|
||||
|
||||
if (isDefinedAndNotNull(workers.maxNumberOfWorkers) || isDefinedAndNotNull(workers.maxMessageNumberPerWorker)) {
|
||||
broker = {
|
||||
...broker,
|
||||
...workers,
|
||||
};
|
||||
}
|
||||
|
||||
if ((requestsMapping as RequestMappingData[])?.length) {
|
||||
requestsMapping = this.getRequestDataObject(requestsMapping as RequestMappingValue[]);
|
||||
}
|
||||
const updatedRequestMapping = (requestsMapping as RequestMappingData[])?.length
|
||||
? this.getRequestDataObject(requestsMapping as RequestMappingValue[])
|
||||
: {} as Record<RequestType, RequestMappingData[]>;
|
||||
|
||||
return {
|
||||
broker,
|
||||
broker: this.getBrokerMappedValue(broker, workers),
|
||||
mapping: MqttVersionMappingUtil.mapMappingToDowngradedVersion(mapping),
|
||||
...(MqttVersionMappingUtil.mapRequestsToDowngradedVersion(requestsMapping as Record<RequestType, RequestMappingData[]>))
|
||||
...(MqttVersionMappingUtil.mapRequestsToDowngradedVersion(updatedRequestMapping as Record<RequestType, RequestMappingData[]>))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user