Protobuf component: removed validation

This commit is contained in:
Artem Babak 2021-10-26 22:06:48 +03:00
parent 706ace25ad
commit bc488421a1
3 changed files with 3 additions and 42 deletions

View File

@ -56,10 +56,6 @@ export class MqttDeviceProfileTransportConfigurationComponent implements Control
transportPayloadTypes = Object.keys(TransportPayloadType);
get protobufControls() {
return this.getProtobufControls();
}
transportPayloadTypeTranslations = transportPayloadTypeTranslationMap;
mqttDeviceProfileTransportConfigurationFormGroup: FormGroup;
@ -215,21 +211,4 @@ export class MqttDeviceProfileTransportConfigurationComponent implements Control
}
return null;
}
getProtobufControls() {
return [
{
name: 'deviceAttributesProtoSchema',
label: 'device-profile.attributes-proto-schema',
errorControl: 'transportPayloadTypeConfiguration.deviceAttributesProtoSchema',
errorText: 'device-profile.attributes-proto-schema-required'
},
{
deviceTelemetryProtoSchema: 'deviceRpcRequestProtoSchema',
label: 'device-profile.rpc-request-proto-schema',
errorControl: 'transportPayloadTypeConfiguration.deviceRpcRequestProtoSchema',
errorText: 'device-profile.rpc-request-proto-required'
}
];
}
}

View File

@ -2,7 +2,7 @@
tb-fullscreen
[fullscreen]="fullscreen" (fullscreenChanged)="onFullscreen()" fxLayout="column">
<div fxLayout="row" fxLayoutAlign="start center" style="height: 40px;" class="tb-protobuf-content-toolbar">
<label class="tb-title no-padding" [ngClass]="{'tb-error': !contentValid}">{{ label }}</label>
<label class="tb-title no-padding">{{ label }}</label>
<span fxFlex></span>
<button type="button"
mat-button *ngIf="!readonly && !disabled" class="tidy" (click)="beautifyProtobuf()">

View File

@ -3,13 +3,11 @@ import {
ElementRef,
forwardRef,
Input,
OnChanges,
OnDestroy,
OnInit,
SimpleChanges,
ViewChild
} from '@angular/core';
import { ControlValueAccessor, FormControl, NG_VALIDATORS, NG_VALUE_ACCESSOR, Validator } from '@angular/forms';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { Ace } from 'ace-builds';
import { CancelAnimationFrame, RafService } from '@core/services/raf.service';
import { ResizeObserver } from '@juggle/resize-observer';
@ -29,15 +27,10 @@ import { beautifyJs } from '@shared/models/beautify.models';
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => ProtobufContentComponent),
multi: true
},
{
provide: NG_VALIDATORS,
useExisting: forwardRef(() => ProtobufContentComponent),
multi: true,
}
]
})
export class ProtobufContentComponent implements OnInit, ControlValueAccessor, Validator, OnDestroy {
export class ProtobufContentComponent implements OnInit, ControlValueAccessor, OnDestroy {
@ViewChild('protobufEditor', {static: true})
protobufEditorElmRef: ElementRef;
@ -72,8 +65,6 @@ export class ProtobufContentComponent implements OnInit, ControlValueAccessor, V
contentBody: string;
contentValid: boolean;
errorShowed = false;
private propagateChange = null;
@ -138,17 +129,8 @@ export class ProtobufContentComponent implements OnInit, ControlValueAccessor, V
}
}
validate(c: FormControl) {
return (this.contentValid) ? null : {
contentBody: {
valid: false,
},
};
}
writeValue(value: string): void {
this.contentBody = value;
this.contentValid = true;
if (this.protobufEditor) {
this.ignoreChange = true;
this.protobufEditor.setValue(this.contentBody ? this.contentBody : '', -1);