This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch STREAMPIPES-145
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/STREAMPIPES-145 by this push:
     new c68ad2f  [STREAMPIPES-145] unit transformation just for numerical 
values
c68ad2f is described below

commit c68ad2fd07b4e91621d97327960c0f999810ba70
Author: Philipp Zehnder <[email protected]>
AuthorDate: Thu Jul 2 14:23:18 2020 +0200

    [STREAMPIPES-145] unit transformation just for numerical values
---
 .../edit-data-type/edit-data-type.component.html       |  2 +-
 .../edit-data-type/edit-data-type.component.ts         |  7 ++++++-
 .../edit-event-property-primitive.component.html       |  5 +++--
 .../edit-event-property-primitive.component.ts         | 18 +++++++++++-------
 ui/src/app/connect/schema-editor/data-type.service.ts  |  5 +++++
 5 files changed, 26 insertions(+), 11 deletions(-)

diff --git 
a/ui/src/app/connect/dialog/edit-event-property/components/edit-data-type/edit-data-type.component.html
 
b/ui/src/app/connect/dialog/edit-event-property/components/edit-data-type/edit-data-type.component.html
index fd44003..92aef57 100644
--- 
a/ui/src/app/connect/dialog/edit-event-property/components/edit-data-type/edit-data-type.component.html
+++ 
b/ui/src/app/connect/dialog/edit-event-property/components/edit-data-type/edit-data-type.component.html
@@ -17,7 +17,7 @@
   -->
 
 <mat-form-field class="doubleWidth" >
-    <mat-select placeholder="Runtime Type" 
[(ngModel)]="cachedProperty.runtimeType">
+    <mat-select placeholder="Runtime Type" 
[(ngModel)]="cachedProperty.runtimeType" (selectionChange)="valueChanged()">
         <mat-option *ngFor="let dataType of runtimeDataTypes" 
[value]="dataType.url">
             {{ dataType.label }}
         </mat-option>
diff --git 
a/ui/src/app/connect/dialog/edit-event-property/components/edit-data-type/edit-data-type.component.ts
 
b/ui/src/app/connect/dialog/edit-event-property/components/edit-data-type/edit-data-type.component.ts
index 48002a6..e53e56f 100644
--- 
a/ui/src/app/connect/dialog/edit-event-property/components/edit-data-type/edit-data-type.component.ts
+++ 
b/ui/src/app/connect/dialog/edit-event-property/components/edit-data-type/edit-data-type.component.ts
@@ -16,7 +16,7 @@
  *
  */
 
-import { Component, Input, OnInit } from '@angular/core';
+import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
 import { DataTypesService } from '../../../../schema-editor/data-type.service';
 
 @Component({
@@ -27,6 +27,7 @@ import { DataTypesService } from 
'../../../../schema-editor/data-type.service';
 export class EditDataTypeComponent implements OnInit {
 
   @Input() cachedProperty: any;
+  @Output() dataTypeChanged = new EventEmitter<boolean>();
 
   runtimeDataTypes;
   constructor(private dataTypeService: DataTypesService) { }
@@ -35,4 +36,8 @@ export class EditDataTypeComponent implements OnInit {
     this.runtimeDataTypes = this.dataTypeService.getDataTypes();
   }
 
+  valueChanged() {
+    this.dataTypeChanged.emit(true);
+  }
+
 }
diff --git 
a/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.html
 
b/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.html
index da4c291..e84b175 100644
--- 
a/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.html
+++ 
b/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.html
@@ -25,12 +25,13 @@
 
     <sp-edit-data-type
             *ngIf="!isTimestampProperty"
-            [cachedProperty]= "cachedProperty">
+            [cachedProperty]= "cachedProperty"
+            (dataTypeChanged)="setShowUnitTransformation()">
     </sp-edit-data-type>
 
     <sp-edit-unit-transformation
             [cachedProperty]= "cachedProperty"
-            [showUnitTransformation]="!isTimestampProperty">
+            [showUnitTransformation]="!hideUnitTransformation">
     </sp-edit-unit-transformation>
 
     <mat-form-field *ngIf="staticValueAddedByUser()" class="doubleWidth">
diff --git 
a/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.ts
 
b/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.ts
index d91ce0a..8b098f4 100644
--- 
a/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.ts
+++ 
b/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.ts
@@ -17,7 +17,6 @@
  */
 
 import { Component, Input, OnInit } from '@angular/core';
-import { FormBuilder } from '@angular/forms';
 import { DataTypesService } from '../../../../schema-editor/data-type.service';
 
 @Component({
@@ -25,20 +24,25 @@ import { DataTypesService } from 
'../../../../schema-editor/data-type.service';
   templateUrl: './edit-event-property-primitive.component.html',
   styleUrls: ['./edit-event-property-primitive.component.css']
 })
-export class EditEventPropertyPrimitiveComponent {
+export class EditEventPropertyPrimitiveComponent implements OnInit {
 
   @Input() cachedProperty: any;
   @Input() index: number;
   @Input() isTimestampProperty: boolean;
 
-  // runtimeDataTypes;
+  hideUnitTransformation: boolean;
 
-  constructor() {
+  constructor(private dataTypesService: DataTypesService) {
   }
 
-  // ngOnInit() {
-  //   this.runtimeDataTypes = this.dataTypeService.getDataTypes();
-  // }
+  ngOnInit(): void {
+    this.setShowUnitTransformation();
+  }
+
+  setShowUnitTransformation() {
+    this.hideUnitTransformation = this.isTimestampProperty ||
+      !this.dataTypesService.isNumeric(this.cachedProperty.runtimeType);
+  }
 
   staticValueAddedByUser() {
     if 
(this.cachedProperty.elementId.startsWith('http://eventProperty.de/staticValue/'))
 {
diff --git a/ui/src/app/connect/schema-editor/data-type.service.ts 
b/ui/src/app/connect/schema-editor/data-type.service.ts
index 137a302..7dd2f2c 100644
--- a/ui/src/app/connect/schema-editor/data-type.service.ts
+++ b/ui/src/app/connect/schema-editor/data-type.service.ts
@@ -67,4 +67,9 @@ export class DataTypesService {
     return String(this.dataTypes[1].url);
   }
 
+  isNumeric(uri: string) {
+    const numericDataTypes = ['http://www.w3.org/2001/XMLSchema#float', 
'http://www.w3.org/2001/XMLSchema#integer'];
+    return numericDataTypes.includes(uri);
+  }
+
 }

Reply via email to