Browse Source

Merge pull request #13621 from deaflynx/feature/exclude-mqtt-version

Exclude mqtt version select in azure rule node
pull/13626/head
Vladyslav Prykhodko 12 months ago
committed by GitHub
parent
commit
7638edaeff
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      ui-ngx/src/app/modules/home/components/rule-node/external/azure-iot-hub-config.component.html
  2. 2
      ui-ngx/src/app/modules/home/components/rule-node/external/azure-iot-hub-config.component.ts
  3. 23
      ui-ngx/src/app/shared/components/mqtt-version-select.component.ts

4
ui-ngx/src/app/modules/home/components/rule-node/external/azure-iot-hub-config.component.html

@ -38,7 +38,9 @@
{{ 'rule-node-config.device-id-required' | translate }}
</mat-error>
</mat-form-field>
<tb-mqtt-version-select formControlName="protocolVersion" subscriptSizing="fixed"></tb-mqtt-version-select>
<tb-mqtt-version-select formControlName="protocolVersion" subscriptSizing="fixed"
[excludeVersions]="[MqttVersion.MQTT_3_1, MqttVersion.MQTT_5]">
</tb-mqtt-version-select>
<mat-accordion>
<mat-expansion-panel class="tb-mqtt-credentials-panel-group">
<mat-expansion-panel-header>

2
ui-ngx/src/app/modules/home/components/rule-node/external/azure-iot-hub-config.component.ts

@ -22,6 +22,7 @@ import {
azureIotHubCredentialsTypes,
azureIotHubCredentialsTypeTranslations
} from '@home/components/rule-node/rule-node-config.models';
import { MqttVersion } from '@shared/models/mqtt.models';
@Component({
selector: 'tb-external-node-azure-iot-hub-config',
@ -34,6 +35,7 @@ export class AzureIotHubConfigComponent extends RuleNodeConfigurationComponent {
allAzureIotHubCredentialsTypes = azureIotHubCredentialsTypes;
azureIotHubCredentialsTypeTranslationsMap = azureIotHubCredentialsTypeTranslations;
MqttVersion = MqttVersion;
constructor(private fb: UntypedFormBuilder) {
super();

23
ui-ngx/src/app/shared/components/mqtt-version-select.component.ts

@ -14,7 +14,7 @@
/// limitations under the License.
///
import { Component, forwardRef, Input } from '@angular/core';
import { Component, forwardRef, Input, OnChanges, SimpleChanges } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { coerceBoolean } from '@shared/decorators/coercion';
import { SubscriptSizing, MatFormFieldAppearance } from '@angular/material/form-field';
@ -30,7 +30,7 @@ import { MqttVersionTranslation, MqttVersion } from '@shared/models/mqtt.models'
multi: true
}]
})
export class MqttVersionSelectComponent implements ControlValueAccessor {
export class MqttVersionSelectComponent implements ControlValueAccessor, OnChanges {
@Input()
disabled: boolean;
@ -41,7 +41,10 @@ export class MqttVersionSelectComponent implements ControlValueAccessor {
@Input()
appearance: MatFormFieldAppearance = 'fill';
mqttVersions = Object.values(MqttVersion);
@Input()
excludeVersions: MqttVersion[];
mqttVersions = Object.values(MqttVersion);
mqttVersionTranslation = MqttVersionTranslation;
modelValue: MqttVersion;
@ -54,6 +57,20 @@ export class MqttVersionSelectComponent implements ControlValueAccessor {
constructor() {
}
ngOnChanges(changes: SimpleChanges): void {
for (const propName of Object.keys(changes)) {
const change = changes[propName];
if (propName === 'excludeVersions' && change.currentValue !== change.previousValue) {
const excludeVersions = change.currentValue;
if (excludeVersions?.length) {
this.mqttVersions = Object.values(MqttVersion).filter(v => !excludeVersions.includes(v));
} else {
this.mqttVersions = Object.values(MqttVersion);
}
}
}
}
registerOnChange(fn: any): void {
this.propagateChange = fn;
}

Loading…
Cancel
Save