You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2020/06/27 21:48:50 UTC

[incubator-streampipes] 01/03: [STREAMPIPES-145] Migrate secret static property

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

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

commit 932113bed822209c77f34d320488cacbd038aa17
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Sat Jun 27 23:02:33 2020 +0200

    [STREAMPIPES-145] Migrate secret static property
---
 ui/src/app/connect/connect.module.ts               |  6 ----
 .../static-property.component.html                 |  2 +-
 .../static-secret-input.component.html             | 18 ++++++-----
 .../static-secret-input.component.ts               | 36 +++++++---------------
 4 files changed, 22 insertions(+), 40 deletions(-)

diff --git a/ui/src/app/connect/connect.module.ts b/ui/src/app/connect/connect.module.ts
index e4ea1d6..719c0af 100644
--- a/ui/src/app/connect/connect.module.ts
+++ b/ui/src/app/connect/connect.module.ts
@@ -46,10 +46,7 @@ import {DragulaModule} from 'ng2-dragula';
 import {AdapterStartedDialog} from './new-adapter/component/adapter-started-dialog.component';
 import {DataTypesService} from './schema-editor/data-type.service';
 import {StaticFreeInputComponent} from './static-properties/static-free-input/static-free-input.component';
-import {StaticNumberInputComponent} from './static-properties/static-number-input/static-number-input.component';
 import {StaticPropertyUtilService} from './static-properties/static-property-util.service';
-import {StaticTextInputComponent} from './static-properties/static-text-input/static-text-input.component';
-import {StaticUrlInputComponent} from './static-properties/static-url-input/static-url-input.component';
 import {TransformationRuleService} from './transformation-rule.service';
 import {StaticSecretInputComponent} from "./static-properties/static-secret-input/static-secret-input.component";
 
@@ -133,9 +130,6 @@ import {xsService} from "../NS/XS.service";
         AdapterStartedDialog,
         AdapterExportDialog,
         AdapterUploadDialog,
-        StaticNumberInputComponent,
-        StaticUrlInputComponent,
-        StaticTextInputComponent,
         StaticFreeInputComponent,
         StaticSecretInputComponent,
         StaticFileInputComponent,
diff --git a/ui/src/app/connect/static-properties/static-property.component.html b/ui/src/app/connect/static-properties/static-property.component.html
index 476c4f5..545c582 100644
--- a/ui/src/app/connect/static-properties/static-property.component.html
+++ b/ui/src/app/connect/static-properties/static-property.component.html
@@ -20,7 +20,7 @@
 <div fxFlex="100">{{staticProperty.label}}</div>
 
 <app-static-secret-input *ngIf="isSecretStaticProperty(staticProperty)"
-                       (updateEmitter)="emitUpdate($event)" (inputEmitter)="valueChange($event)" [staticProperty]="staticProperty">
+                       (updateEmitter)="emitUpdate($event)" [staticProperty]="staticProperty" [parentForm]="parentForm">
 </app-static-secret-input>
 
 <app-static-free-input *ngIf="isFreeTextStaticProperty(staticProperty)"
diff --git a/ui/src/app/connect/static-properties/static-secret-input/static-secret-input.component.html b/ui/src/app/connect/static-properties/static-secret-input/static-secret-input.component.html
index e9cd9cf..6568b61 100644
--- a/ui/src/app/connect/static-properties/static-secret-input/static-secret-input.component.html
+++ b/ui/src/app/connect/static-properties/static-secret-input/static-secret-input.component.html
@@ -16,19 +16,21 @@
   ~
   -->
 
-<div id="formWrapper" fxFlex="100" fxLayout="column">
+<div [formGroup]="parentForm" id="formWrapper" fxFlex="100" fxLayout="column">
     <div fxFlex="100" fxLayout="row">
-        <form [formGroup]="secretForm" fxFlex="100">
             <mat-form-field fxFlex >
-                <input type="password" fxFlex id="{{ 'input-' + staticProperty.label.toLowerCase() }}" matInput [placeholder]="staticProperty.label" [(ngModel)]="staticPropertyUtil.asSecretStaticProperty(staticProperty).value"
-                       formControlName="secretStaticProperty" (ngModelChange)="valueChange(staticPropertyUtil.asSecretStaticProperty(staticProperty).value)"
-                       required (blur)="emitUpdate()">
+                <input type="password"
+                       fxFlex
+                       formControlName="{{staticProperty.internalName}}"
+                       matInput
+                       [placeholder]="staticProperty.label"
+                       required
+                       (blur)="emitUpdate()">
                 <mat-hint>{{staticProperty.description}}</mat-hint>
 
-                <mat-error *ngIf="!hasInput">
-                    {{staticProperty.errorMessage}}
+                <mat-error *ngIf="!fieldValid">
+                    {{errorMessage}}
                 </mat-error>
             </mat-form-field>
-        </form>
     </div>
 </div>
\ No newline at end of file
diff --git a/ui/src/app/connect/static-properties/static-secret-input/static-secret-input.component.ts b/ui/src/app/connect/static-properties/static-secret-input/static-secret-input.component.ts
index 0aff985..058c70e 100644
--- a/ui/src/app/connect/static-properties/static-secret-input/static-secret-input.component.ts
+++ b/ui/src/app/connect/static-properties/static-secret-input/static-secret-input.component.ts
@@ -22,6 +22,7 @@ import {StaticPropertyUtilService} from '../static-property-util.service';
 import {ConfigurationInfo} from "../../model/message/ConfigurationInfo";
 import {SecretStaticProperty} from "../../../core-model/gen/streampipes-model";
 import {AbstractStaticPropertyRenderer} from "../base/abstract-static-property";
+import {AbstractValidatedStaticPropertyRenderer} from "../base/abstract-validated-static-property";
 
 @Component({
     selector: 'app-static-secret-input',
@@ -29,7 +30,7 @@ import {AbstractStaticPropertyRenderer} from "../base/abstract-static-property";
     styleUrls: ['./static-secret-input.component.css']
 })
 export class StaticSecretInputComponent
-    extends AbstractStaticPropertyRenderer<SecretStaticProperty> implements OnInit {
+    extends AbstractValidatedStaticPropertyRenderer<SecretStaticProperty> implements OnInit {
 
     constructor(public staticPropertyUtil: StaticPropertyUtilService){
         super();
@@ -37,37 +38,22 @@ export class StaticSecretInputComponent
 
     @Output() updateEmitter: EventEmitter<ConfigurationInfo> = new EventEmitter();
 
-    @Output() inputEmitter: EventEmitter<any> = new EventEmitter<any>();
-
-    inputValue: String;
-    hasInput: Boolean;
-    secretForm: FormGroup;
-    private errorMessage = "Please enter a valid Text";
-
     ngOnInit() {
-        this.secretForm = new FormGroup({
-            'secretStaticProperty': new FormControl(this.inputValue, [
-                Validators.required
-            ]),
-        })
+        this.addValidator(this.staticProperty.value, Validators.required);
+        this.enableValidators();
     }
 
-    valueChange(inputValue) {
-        this.inputValue = inputValue;
-        this.staticPropertyUtil.asSecretStaticProperty(this.staticProperty).encrypted = false;
 
-        if (inputValue == "" || !inputValue) {
-            this.hasInput = false;
-        } else {
-            this.hasInput = true;
-        }
-
-        this.inputEmitter.emit(this.hasInput);
+    emitUpdate() {
+        this.updateEmitter.emit(new ConfigurationInfo(this.staticProperty.internalName, this.staticPropertyUtil.asFreeTextStaticProperty(this.staticProperty).value && this.staticPropertyUtil.asFreeTextStaticProperty(this.staticProperty).value !== ""));
+    }
 
+    onStatusChange(status: any) {
     }
 
-    emitUpdate() {
-        this.updateEmitter.emit(new ConfigurationInfo(this.staticProperty.internalName, this.staticPropertyUtil.asFreeTextStaticProperty(this.staticProperty).value && this.staticPropertyUtil.asFreeTextStaticProperty(this.staticProperty).value !== ""));
+    onValueChange(value: any) {
+        this.staticProperty.value = value;
+        this.staticProperty.encrypted=false;
     }
 
 }
\ No newline at end of file