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 { Directive } from '@angular/core';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
import {
|
import {
|
||||||
|
BrokerConfig,
|
||||||
MappingType,
|
MappingType,
|
||||||
MQTTBasicConfig, MQTTBasicConfig_v3_5_2,
|
MQTTBasicConfig,
|
||||||
|
MQTTBasicConfig_v3_5_2,
|
||||||
RequestMappingData,
|
RequestMappingData,
|
||||||
RequestMappingValue,
|
RequestMappingValue,
|
||||||
RequestType
|
RequestType,
|
||||||
|
WorkersConfig
|
||||||
} from '@home/components/widget/lib/gateway/gateway-widget.models';
|
} from '@home/components/widget/lib/gateway/gateway-widget.models';
|
||||||
import { isObject } from '@core/utils';
|
import { isObject } from '@core/utils';
|
||||||
import {
|
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 {
|
writeValue(basicConfig: BasicConfig): void {
|
||||||
this.basicFormGroup.setValue(this.mapConfigToFormValue(basicConfig), { emitEvent: false });
|
this.basicFormGroup.setValue(this.mapConfigToFormValue(basicConfig), { emitEvent: false });
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
MqttBasicConfigDirective
|
MqttBasicConfigDirective
|
||||||
} from '@home/components/widget/lib/gateway/connectors-configuration/mqtt/basic-config/mqtt-basic-config.abstract';
|
} 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 { CommonModule } from '@angular/common';
|
||||||
import { SharedModule } from '@shared/shared.module';
|
import { SharedModule } from '@shared/shared.module';
|
||||||
import {
|
import {
|
||||||
@ -85,19 +84,14 @@ export class MqttBasicConfigComponent extends MqttBasicConfigDirective<MQTTBasic
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override getMappedValue(basicConfig: MQTTBasicConfig_v3_5_2): MQTTBasicConfig_v3_5_2 {
|
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)) {
|
return {
|
||||||
broker = {
|
broker: this.getBrokerMappedValue(broker, workers),
|
||||||
...broker,
|
mapping,
|
||||||
...workers,
|
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 {
|
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)) {
|
const updatedRequestMapping = (requestsMapping as RequestMappingData[])?.length
|
||||||
broker = {
|
? this.getRequestDataObject(requestsMapping as RequestMappingValue[])
|
||||||
...broker,
|
: {} as Record<RequestType, RequestMappingData[]>;
|
||||||
...workers,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((requestsMapping as RequestMappingData[])?.length) {
|
|
||||||
requestsMapping = this.getRequestDataObject(requestsMapping as RequestMappingValue[]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
broker,
|
broker: this.getBrokerMappedValue(broker, workers),
|
||||||
mapping: MqttVersionMappingUtil.mapMappingToDowngradedVersion(mapping),
|
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