You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@streampipes.apache.org by GitBox <gi...@apache.org> on 2023/01/07 21:05:36 UTC

[GitHub] [streampipes] aamirxshaikh commented on a diff in pull request #1057: [#877] Apply UI linting to connect module

aamirxshaikh commented on code in PR #1057:
URL: https://github.com/apache/streampipes/pull/1057#discussion_r1064047049


##########
ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.ts:
##########
@@ -33,159 +44,215 @@ import { EditValueTransformationComponent } from './components/edit-value-transf
 import { EditUnitTransformationComponent } from './components/edit-unit-transformation/edit-unit-transformation.component';
 
 @Component({
-  selector: 'sp-edit-event-property',
-  templateUrl: './edit-event-property.component.html',
-  styleUrls: ['./edit-event-property.component.scss']
+    selector: 'sp-edit-event-property',
+    templateUrl: './edit-event-property.component.html',
+    styleUrls: ['./edit-event-property.component.scss'],
 })
 export class EditEventPropertyComponent implements OnInit {
-
-  @Input() property: EventPropertyUnion;
-  @Input() isEditable: boolean;
-
-  @Output() propertyChange = new EventEmitter<EventPropertyUnion>();
-
-  schemaTransformationComponent: EditSchemaTransformationComponent;
-  valueTransformationComponent: EditValueTransformationComponent;
-  unitTransformationComponent: EditUnitTransformationComponent;
-
-  cachedProperty: any;
-
-  isTimestampProperty = false;
-  isEventPropertyPrimitive: boolean;
-  isEventPropertyNested: boolean;
-  isEventPropertyList: boolean;
-  isNumericProperty: boolean;
-  isSaveBtnEnabled: boolean;
-
-  private propertyForm: UntypedFormGroup;
-
-  private runtimeDataTypes;
-
-  constructor(public dialogRef: DialogRef<EditEventPropertyComponent>,
-              private formBuilder: UntypedFormBuilder,
-              private dataTypeService: DataTypesService,
-              private semanticTypeUtilsService: SemanticTypeUtilsService,
-              private semanticTypesService: SemanticTypesService) {
-  }
-
-  ngOnInit(): void {
-    this.cachedProperty = this.copyEp(this.property);
-    this.runtimeDataTypes = this.dataTypeService.getDataTypes();
-    this.isTimestampProperty = this.semanticTypeUtilsService.isTimestamp(this.cachedProperty);
-    this.isEventPropertyList = this.property instanceof EventPropertyList;
-    this.isEventPropertyPrimitive = this.property instanceof EventPropertyPrimitive;
-    this.isEventPropertyNested = this.property instanceof EventPropertyNested;
-    this.isNumericProperty = this.semanticTypeUtilsService.isNumeric(this.cachedProperty) ||
-      this.dataTypeService.isNumeric(this.cachedProperty.runtimeType);
-    this.createForm();
-
-  }
-
-  copyEp(ep: EventPropertyUnion) {
-    if (ep instanceof EventPropertyPrimitive) {
-      const result = EventPropertyPrimitive.fromData(ep as EventPropertyPrimitive, new EventPropertyPrimitive());
-
-      result.measurementUnit = (ep as EventPropertyPrimitive).measurementUnit;
-      (result as any).measurementUnitTmp = (ep as any).measurementUnitTmp;
-      (result as any).oldMeasurementUnit = (ep as any).oldMeasurementUnit;
-      (result as any).hadMeasarumentUnit = (ep as any).hadMeasarumentUnit;
-
-      (result as any).timestampTransformationMode = (ep as any).timestampTransformationMode;
-      (result as any).timestampTransformationFormatString = (ep as any).timestampTransformationFormatString;
-      (result as any).timestampTransformationMultiplier = (ep as any).timestampTransformationMultiplier;
-
-      (result as any).staticValue = (ep as any).staticValue;
-
-      (result as any).correctionValue = (ep as any).correctionValue;
-      (result as any).operator = (ep as any).operator;
-
-      return result;
-    } else if (ep instanceof EventPropertyNested) {
-      return EventPropertyNested.fromData(ep as EventPropertyNested, new EventPropertyNested());
-    } else {
-      return EventPropertyList.fromData(ep as EventPropertyList, new EventPropertyList());
-    }
-  }
-
-  private createForm() {
-    this.propertyForm = this.formBuilder.group({
-      label: [this.property.label, Validators.required],
-      runtimeName: [this.property.runtimeName, Validators.required],
-      description: [this.property.description, Validators.required],
-      domainProperty: ['', Validators.required],
-      dataType: ['', Validators.required]
-    });
-  }
-
-  staticValueAddedByUser() {
-    return (this.property.elementId.startsWith('http://eventProperty.de/staticValue/'));
-  }
-
-  save(): void {
-    this.property.label = this.cachedProperty.label;
-    this.property.description = this.cachedProperty.description;
-
-    // remove undefined from domain properies array
-    this.property.domainProperties = this.cachedProperty.domainProperties.filter(n => n);
-    this.property.runtimeName = this.cachedProperty.runtimeName;
-    this.property.propertyScope = this.cachedProperty.propertyScope;
-
-    if (this.property instanceof EventPropertyList) {
-      // @ts-ignore
-      this.property.eventProperty.runtimeType = (this.cachedProperty as EventPropertyList).eventProperty.runtimeType;
+    @Input() property: EventPropertyUnion;
+    @Input() isEditable: boolean;
+
+    @Output() propertyChange = new EventEmitter<EventPropertyUnion>();
+
+    schemaTransformationComponent: EditSchemaTransformationComponent;
+    valueTransformationComponent: EditValueTransformationComponent;
+    unitTransformationComponent: EditUnitTransformationComponent;
+
+    cachedProperty: any;
+
+    isTimestampProperty = false;
+    isEventPropertyPrimitive: boolean;
+    isEventPropertyNested: boolean;
+    isEventPropertyList: boolean;
+    isNumericProperty: boolean;
+    isSaveBtnEnabled: boolean;
+
+    private propertyForm: UntypedFormGroup;
+
+    private runtimeDataTypes;
+
+    constructor(
+        public dialogRef: DialogRef<EditEventPropertyComponent>,
+        private formBuilder: UntypedFormBuilder,
+        private dataTypeService: DataTypesService,
+        private semanticTypeUtilsService: SemanticTypeUtilsService,
+        private semanticTypesService: SemanticTypesService,
+    ) {}
+
+    ngOnInit(): void {
+        this.cachedProperty = this.copyEp(this.property);
+        this.runtimeDataTypes = this.dataTypeService.getDataTypes();
+        this.isTimestampProperty = this.semanticTypeUtilsService.isTimestamp(
+            this.cachedProperty,
+        );
+        this.isEventPropertyList = this.property instanceof EventPropertyList;
+        this.isEventPropertyPrimitive =
+            this.property instanceof EventPropertyPrimitive;
+        this.isEventPropertyNested =
+            this.property instanceof EventPropertyNested;
+        this.isNumericProperty =
+            this.semanticTypeUtilsService.isNumeric(this.cachedProperty) ||
+            this.dataTypeService.isNumeric(this.cachedProperty.runtimeType);
+        this.createForm();
     }
 
-    if (this.property instanceof EventPropertyPrimitive) {
-      this.property.runtimeType = (this.cachedProperty as EventPropertyPrimitive).runtimeType;
-
-      this.property.measurementUnit = (this.cachedProperty as any).oldMeasurementUnit;
+    copyEp(ep: EventPropertyUnion) {
+        if (ep instanceof EventPropertyPrimitive) {
+            const result = EventPropertyPrimitive.fromData(
+                ep as EventPropertyPrimitive,
+                new EventPropertyPrimitive(),
+            );
+
+            result.measurementUnit = (
+                ep as EventPropertyPrimitive
+            ).measurementUnit;
+            (result as any).measurementUnitTmp = (ep as any).measurementUnitTmp;
+            (result as any).oldMeasurementUnit = (ep as any).oldMeasurementUnit;
+            (result as any).hadMeasarumentUnit = (ep as any).hadMeasarumentUnit;
+
+            (result as any).timestampTransformationMode = (
+                ep as any
+            ).timestampTransformationMode;
+            (result as any).timestampTransformationFormatString = (
+                ep as any
+            ).timestampTransformationFormatString;
+            (result as any).timestampTransformationMultiplier = (
+                ep as any
+            ).timestampTransformationMultiplier;
+
+            (result as any).staticValue = (ep as any).staticValue;
+
+            (result as any).correctionValue = (ep as any).correctionValue;
+            (result as any).operator = (ep as any).operator;
+
+            return result;
+        } else if (ep instanceof EventPropertyNested) {
+            return EventPropertyNested.fromData(
+                ep as EventPropertyNested,
+                new EventPropertyNested(),
+            );
+        } else {
+            return EventPropertyList.fromData(
+                ep as EventPropertyList,
+                new EventPropertyList(),
+            );
+        }
+    }
 
-      (this.property as any).measurementUnitTmp = (this.cachedProperty as any).measurementUnitTmp;
-      (this.property as any).oldMeasurementUnit = (this.cachedProperty as any).oldMeasurementUnit;
-      (this.property as any).hadMeasarumentUnit = (this.cachedProperty as any).hadMeasarumentUnit;
+    private createForm() {
+        this.propertyForm = this.formBuilder.group({
+            label: [this.property.label, Validators.required],
+            runtimeName: [this.property.runtimeName, Validators.required],
+            description: [this.property.description, Validators.required],
+            domainProperty: ['', Validators.required],
+            dataType: ['', Validators.required],
+        });
+    }
 
-      (this.property as any).timestampTransformationMode = (this.cachedProperty as any).timestampTransformationMode;
-      (this.property as any).timestampTransformationFormatString = (this.cachedProperty as any).timestampTransformationFormatString;
-      (this.property as any).timestampTransformationMultiplier = (this.cachedProperty as any).timestampTransformationMultiplier;
+    staticValueAddedByUser() {
+        return this.property.elementId.startsWith(
+            'http://eventProperty.de/staticValue/',
+        );
+    }
 
-      (this.property as any).staticValue = (this.cachedProperty as any).staticValue;
+    save(): void {
+        this.property.label = this.cachedProperty.label;
+        this.property.description = this.cachedProperty.description;
+
+        // remove undefined from domain properies array
+        this.property.domainProperties =
+            this.cachedProperty.domainProperties.filter(n => n);
+        this.property.runtimeName = this.cachedProperty.runtimeName;
+        this.property.propertyScope = this.cachedProperty.propertyScope;
+
+        if (this.property instanceof EventPropertyList) {
+            // @ts-ignore
+            this.property.eventProperty.runtimeType = (
+                this.cachedProperty as EventPropertyList
+            ).eventProperty.runtimeType;

Review Comment:
   cypress-e2e-tests fails when building the UI
   
   file: `ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.ts",`
   
   ```
   Property 'runtimeType' does not exist on type 'EventPropertyUnion'.
     Property 'runtimeType' does not exist on type 'EventPropertyList'.
   ```
   
   ![image](https://user-images.githubusercontent.com/56036364/211169355-914cf3a3-ce6d-4f1f-a974-747c4851812d.png)
   
   It seems like, inlining the code fixes the issue. After Inlining, not getting any errors.
   
   ![image](https://user-images.githubusercontent.com/56036364/211169598-0f38694c-b72b-4749-a195-c973d4f99969.png)
   
   Any thoughts? @bossenti 
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org