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); transportPayloadTypes = Object.keys(TransportPayloadType);
get protobufControls() {
return this.getProtobufControls();
}
transportPayloadTypeTranslations = transportPayloadTypeTranslationMap; transportPayloadTypeTranslations = transportPayloadTypeTranslationMap;
mqttDeviceProfileTransportConfigurationFormGroup: FormGroup; mqttDeviceProfileTransportConfigurationFormGroup: FormGroup;
@ -215,21 +211,4 @@ export class MqttDeviceProfileTransportConfigurationComponent implements Control
} }
return null; 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 tb-fullscreen
[fullscreen]="fullscreen" (fullscreenChanged)="onFullscreen()" fxLayout="column"> [fullscreen]="fullscreen" (fullscreenChanged)="onFullscreen()" fxLayout="column">
<div fxLayout="row" fxLayoutAlign="start center" style="height: 40px;" class="tb-protobuf-content-toolbar"> <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> <span fxFlex></span>
<button type="button" <button type="button"
mat-button *ngIf="!readonly && !disabled" class="tidy" (click)="beautifyProtobuf()"> mat-button *ngIf="!readonly && !disabled" class="tidy" (click)="beautifyProtobuf()">

View File

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