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 1c328ff0bdc48bf06b411a2e9226a7dfad29df5f Author: Dominik Riemer <[email protected]> AuthorDate: Sat Jul 11 21:28:03 2020 +0200 [STREAMPIPES-145] Migrate CustomOutputStrategy --- .../output-strategy/base/BaseOutputStrategy.ts | 44 ++++++++++++ .../custom-output-strategy.component.html | 51 ++++++++++++++ .../custom-output-strategy.component.scss | 18 +++++ .../custom-output-strategy.component.ts | 72 +++++++++++++++++++ .../output-strategy/output-strategy.component.html | 43 ++++++++++++ .../output-strategy/output-strategy.component.scss | 18 +++++ .../output-strategy/output-strategy.component.ts | 46 +++++++++++++ .../property-selection.component.html | 40 +++++++++++ .../property-selection.component.scss | 21 ++++++ .../property-selection.component.ts | 80 ++++++++++++++++++++++ .../user-defined-output.component.html | 18 +++++ .../user-defined-output.component.scss | 18 +++++ .../user-defined-output.component.ts | 18 +++++ .../dialog/customize/customize.component.html | 42 +++++++----- .../dialog/customize/customize.component.ts | 9 ++- ui/src/app/editor-v2/editor.module.ts | 6 ++ ui/src/app/services/property-selector.service.ts | 23 ++++--- 17 files changed, 538 insertions(+), 29 deletions(-) diff --git a/ui/src/app/editor-v2/components/output-strategy/base/BaseOutputStrategy.ts b/ui/src/app/editor-v2/components/output-strategy/base/BaseOutputStrategy.ts new file mode 100644 index 0000000..6106983 --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/base/BaseOutputStrategy.ts @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import {Input} from "@angular/core"; +import {FormGroup} from "@angular/forms"; +import { + DataProcessorInvocation, + OutputStrategy +} from "../../../../core-model/gen/streampipes-model"; + +export abstract class BaseOutputStrategy<T extends OutputStrategy> { + + @Input() + parentForm: FormGroup; + + @Input() + outputStrategy: T; + + @Input() + selectedElement: DataProcessorInvocation; + + @Input() + restrictedEditMode: boolean; + + constructor() { + + } + +} \ No newline at end of file diff --git a/ui/src/app/editor-v2/components/output-strategy/custom-output/custom-output-strategy.component.html b/ui/src/app/editor-v2/components/output-strategy/custom-output/custom-output-strategy.component.html new file mode 100644 index 0000000..2efa74e --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/custom-output/custom-output-strategy.component.html @@ -0,0 +1,51 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache License, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + ~ + --> +<div fxFlex="100" fxLayout="column"> + <div fxFlex="100" fxLayout="row" fxLayoutAlign="start center"> + <h5 style="margin-right:10px;">{{selectedElement.inputStreams[0].name}}</h5> + <button mat-button mat-raised-button color="primary" class="small-button" + (click)="selectAll(collectedPropertiesFirstStream)" + style="margin-right:10px;margin-left:10px;" [disabled]="restrictedEditMode">Select all + </button> + <button mat-button mat-raised-button class="mat-basic small-button" + (click)="deselectAll(collectedPropertiesFirstStream)" [disabled]="restrictedEditMode">Select + none + </button> + </div> + <div *ngFor="let property of collectedPropertiesFirstStream; let i = index"> + <property-selection (validateForm)="checkFormValidity()" [outputStrategy]="outputStrategy" [eventProperty]="property" + [layer]="0" [restrictedEditMode]="restrictedEditMode"></property-selection> + </div> + <div *ngIf="collectedPropertiesSecondStream.length > 0"> + <div fxFlex="100" fxLayout="row" fxLayoutAlign="start center"> + <h5 style="margin-right:10px;">{{selectedElement.inputStreams[1].name}}</h5> + <button mat-button mat-raised-button color="primary" class="small-button" + (click)="selectAll(collectedPropertiesSecondStream)" + style="margin-right:10px;margin-left:10px;" [disabled]="restrictedEditMode">Select all + </button> + <button mat-button mat-raised-button class="mat-basic small-button" + (click)="deselectAll(collectedPropertiesSecondStream)" [disabled]="restrictedEditMode">Select + none + </button> + </div> + <div *ngFor="let property of collectedPropertiesSecondStream; let i = index"> + <property-selection [outputStrategy]="outputStrategy" [eventProperty]="property" + [layer]="0" [restrictedEditMode]="restrictedEditMode"></property-selection> + </div> + </div> +</div> \ No newline at end of file diff --git a/ui/src/app/editor-v2/components/output-strategy/custom-output/custom-output-strategy.component.scss b/ui/src/app/editor-v2/components/output-strategy/custom-output/custom-output-strategy.component.scss new file mode 100644 index 0000000..58ba04b --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/custom-output/custom-output-strategy.component.scss @@ -0,0 +1,18 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + diff --git a/ui/src/app/editor-v2/components/output-strategy/custom-output/custom-output-strategy.component.ts b/ui/src/app/editor-v2/components/output-strategy/custom-output/custom-output-strategy.component.ts new file mode 100644 index 0000000..cc19057 --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/custom-output/custom-output-strategy.component.ts @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import {Component, OnInit} from "@angular/core"; +import {CustomOutputStrategy} from "../../../../core-model/gen/streampipes-model"; +import {BaseOutputStrategy} from "../base/BaseOutputStrategy"; +import {PropertySelectorService} from "../../../../services/property-selector.service"; +import {FormControl, Validators} from "@angular/forms"; + +@Component({ + selector: 'custom-output-strategy', + templateUrl: './custom-output-strategy.component.html', + styleUrls: ['./custom-output-strategy.component.scss'] +}) +export class CustomOutputStrategyComponent extends BaseOutputStrategy<CustomOutputStrategy> implements OnInit { + + collectedPropertiesFirstStream: any; + collectedPropertiesSecondStream: any; + + constructor(private PropertySelectorService: PropertySelectorService) { + super(); + } + + ngOnInit() { + this.parentForm.addControl("output-strategy", new FormControl()); + this.collectedPropertiesFirstStream = this.PropertySelectorService + .makeProperties(this.getProperties(0), this.outputStrategy.availablePropertyKeys, this.PropertySelectorService.firstStreamPrefix); + this.collectedPropertiesSecondStream = this.PropertySelectorService + .makeProperties(this.getProperties(1), this.outputStrategy.availablePropertyKeys, this.PropertySelectorService.secondStreamPrefix); + this.checkFormValidity(); + } + + getProperties(streamIndex) { + return this.selectedElement.inputStreams[streamIndex] === undefined ? [] : this.selectedElement.inputStreams[streamIndex].eventSchema.eventProperties; + } + + selectAll(collectedProperties) { + collectedProperties.forEach(ep => this.outputStrategy.selectedPropertyKeys.push(ep.runtimeId)); + // This is needed to trigger update of scope + this.outputStrategy.selectedPropertyKeys = this.outputStrategy.selectedPropertyKeys.filter(el => {return true;}); + this.checkFormValidity() + } + + deselectAll(collectedProperties) { + collectedProperties.forEach(ep => this.outputStrategy.selectedPropertyKeys = + this.outputStrategy.selectedPropertyKeys.filter(item => item !== ep.runtimeId)); + this.checkFormValidity() + } + + checkFormValidity() { + if (!this.outputStrategy.selectedPropertyKeys || this.outputStrategy.selectedPropertyKeys.length == 0) { + this.parentForm.controls["output-strategy"].setErrors({}); + } else { + this.parentForm.controls["output-strategy"].setErrors(undefined); + } + } +} \ No newline at end of file diff --git a/ui/src/app/editor-v2/components/output-strategy/output-strategy.component.html b/ui/src/app/editor-v2/components/output-strategy/output-strategy.component.html new file mode 100644 index 0000000..449a6ba --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/output-strategy.component.html @@ -0,0 +1,43 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache License, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + ~ + --> + +<div fxFlex="100" fxLayout="column"> + <div fxFlex="100" fxLayout="row" class="static-property-panel"> + <div fxFlex="40" fxLayout="column"> + <b>Select output</b> + </div> + <div fxFlex="60"> + <div class="customize-item-content" + *ngIf="outputStrategy['@class'] === 'org.apache.streampipes.model.output.CustomOutputStrategy'"> + <custom-output-strategy [outputStrategy]="outputStrategy" + [selectedElement]="selectedElement" + [parentForm]="parentForm" + [restrictedEditMode]="restrictedEditMode"> + </custom-output-strategy> + </div> + <div class="customize-item-content" + *ngIf="outputStrategy['@class'] === 'org.apache.streampipes.model.output.UserDefinedOutputStrategy'"> + <user-defined-output output-strategy="outputStrategy" + selected-element="ctrl.selectedElement" + customize-form="ctrl.customizeForm" + restricted-edit-mode="ctrl.restrictedEditMode"> + </user-defined-output> + </div> + </div> + </div> +</div> \ No newline at end of file diff --git a/ui/src/app/editor-v2/components/output-strategy/output-strategy.component.scss b/ui/src/app/editor-v2/components/output-strategy/output-strategy.component.scss new file mode 100644 index 0000000..58ba04b --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/output-strategy.component.scss @@ -0,0 +1,18 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + diff --git a/ui/src/app/editor-v2/components/output-strategy/output-strategy.component.ts b/ui/src/app/editor-v2/components/output-strategy/output-strategy.component.ts new file mode 100644 index 0000000..2f6f298 --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/output-strategy.component.ts @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import {Component, Input, OnInit} from "@angular/core"; +import {DataProcessorInvocation, OutputStrategy} from "../../../core-model/gen/streampipes-model"; +import {FormGroup} from "@angular/forms"; + +@Component({ + selector: 'output-strategy', + templateUrl: './output-strategy.component.html', + styleUrls: ['./output-strategy.component.scss'] +}) +export class OutputStrategyComponent implements OnInit { + + @Input() + parentForm: FormGroup; + + @Input() + outputStrategy: OutputStrategy; + + @Input() + selectedElement: DataProcessorInvocation; + + @Input() + restrictedEditMode: boolean; + + label: string; + + ngOnInit(): void { + } +} \ No newline at end of file diff --git a/ui/src/app/editor-v2/components/output-strategy/property-selection/property-selection.component.html b/ui/src/app/editor-v2/components/output-strategy/property-selection/property-selection.component.html new file mode 100644 index 0000000..732a3d0 --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/property-selection/property-selection.component.html @@ -0,0 +1,40 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache License, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + ~ + --> + +<div class="property-selection" style="margin-left:{{layer*5}}%"> + <div fxLayout="row"> + <mat-checkbox [checked]="exists(eventProperty.runtimeId)" + (change)="toggle(eventProperty.runtimeId)" + style="margin-right: 10px;" [disabled]="restrictedEditMode"> + </mat-checkbox> + <div> + <div *ngIf="eventProperty.label"><b>{{eventProperty.label}}</b><br/> + <mat-hint class="description">{{eventProperty.description}}, + field name: {{eventProperty.runtimeName}}</mat-hint> + <br/></div> + <div *ngIf="!eventProperty.label"><b>{{eventProperty.runtimeName}}</b><br/> + </div> + </div> + </div> +</div> +<div *ngIf="isNestedProperty"> + <div *ngFor="let nestedProperty of eventProperty.eventProperties"> + <property-selection [outputStrategy]="outputStrategy" [eventProperty]="nestedProperty" + [layer]="(layer + 1)"></property-selection> + </div> +</div> diff --git a/ui/src/app/editor-v2/components/output-strategy/property-selection/property-selection.component.scss b/ui/src/app/editor-v2/components/output-strategy/property-selection/property-selection.component.scss new file mode 100644 index 0000000..ad64fae --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/property-selection/property-selection.component.scss @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +.description { + font-size: 10px; +} \ No newline at end of file diff --git a/ui/src/app/editor-v2/components/output-strategy/property-selection/property-selection.component.ts b/ui/src/app/editor-v2/components/output-strategy/property-selection/property-selection.component.ts new file mode 100644 index 0000000..8cfefc6 --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/property-selection/property-selection.component.ts @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import {Component, EventEmitter, Input, Output} from "@angular/core"; +import { + CustomOutputStrategy, + EventPropertyNested, + EventPropertyUnion +} from "../../../../core-model/gen/streampipes-model"; + +@Component({ + selector: 'property-selection', + templateUrl: './property-selection.component.html', + styleUrls: ['./property-selection.component.scss'] +}) +export class PropertySelectionComponent { + + @Input() + outputStrategy: CustomOutputStrategy; + + @Input() + eventProperty: EventPropertyUnion; + + @Input() + layer: number; + + @Input() + restrictedEditMode: boolean; + + @Output() + validateForm: EventEmitter<boolean> = new EventEmitter<boolean>(); + + isNestedProperty: boolean + + ngOnInit() { + this.isNestedProperty = this.eventProperty instanceof EventPropertyNested; + } + + toggle(runtimeId) { + if (this.exists(runtimeId)) { + this.remove(runtimeId); + } else { + this.add(runtimeId); + } + this.triggerFormValidation(); + } + + exists(runtimeId) { + return this.outputStrategy.selectedPropertyKeys.some(e => e === runtimeId); + } + + add(runtimeId) { + this.outputStrategy.selectedPropertyKeys.push(runtimeId); + // This is needed to trigger update of scope + this.outputStrategy.selectedPropertyKeys = this.outputStrategy.selectedPropertyKeys.filter(el => {return true;}); + } + + remove(runtimeId) { + this.outputStrategy.selectedPropertyKeys = this.outputStrategy.selectedPropertyKeys.filter(el => { return el != runtimeId; }); + } + + triggerFormValidation() { + this.validateForm.emit(true); + } +} \ No newline at end of file diff --git a/ui/src/app/editor-v2/components/output-strategy/user-defined-output/user-defined-output.component.html b/ui/src/app/editor-v2/components/output-strategy/user-defined-output/user-defined-output.component.html new file mode 100644 index 0000000..e40d375 --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/user-defined-output/user-defined-output.component.html @@ -0,0 +1,18 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache License, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + ~ + --> + diff --git a/ui/src/app/editor-v2/components/output-strategy/user-defined-output/user-defined-output.component.scss b/ui/src/app/editor-v2/components/output-strategy/user-defined-output/user-defined-output.component.scss new file mode 100644 index 0000000..58ba04b --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/user-defined-output/user-defined-output.component.scss @@ -0,0 +1,18 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + diff --git a/ui/src/app/editor-v2/components/output-strategy/user-defined-output/user-defined-output.component.ts b/ui/src/app/editor-v2/components/output-strategy/user-defined-output/user-defined-output.component.ts new file mode 100644 index 0000000..58ba04b --- /dev/null +++ b/ui/src/app/editor-v2/components/output-strategy/user-defined-output/user-defined-output.component.ts @@ -0,0 +1,18 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + diff --git a/ui/src/app/editor-v2/dialog/customize/customize.component.html b/ui/src/app/editor-v2/dialog/customize/customize.component.html index 4a9b5e4..1f36231 100644 --- a/ui/src/app/editor-v2/dialog/customize/customize.component.html +++ b/ui/src/app/editor-v2/dialog/customize/customize.component.html @@ -31,33 +31,43 @@ </div> </div> <div fxFlex="100" fxLayout="row" *ngIf="restrictedEditMode"> - <div fxFlex="100" fxLayout="column"> - <div fxLayout="column" class="customize-item-main-help" style="border: 2px solid #ffc400"> - <div class="customize-item-title-help" style="background: #ffc400;" fxFlex="100" - fxLayout="row"> - You can only modify things that don't affect your pipeline structure. To fully - modify this element, make sure that it doesn't connect to any successors (remove - outgoing connectors). - </div> + <div fxFlex="100" fxLayout="column"> + <div fxLayout="column" class="customize-item-main-help" style="border: 2px solid #ffc400"> + <div class="customize-item-title-help" style="background: #ffc400;" fxFlex="100" + fxLayout="row"> + You can only modify things that don't affect your pipeline structure. To fully + modify this element, make sure that it doesn't connect to any successors (remove + outgoing connectors). </div> </div> + </div> </div> <div fxFlex="100" fxLayout="column" class="customize-section p-15"> <form [formGroup]="parentForm" fxFlex="100"> - <app-static-property *ngFor="let config of cachedPipelineElement.staticProperties" [staticProperty]="config" - [staticProperties]="cachedPipelineElement.staticProperties" - [eventSchemas]="eventSchemas" - [parentForm]="parentForm" - [fieldName]="config.internalName" - (validateEmitter)="validConfiguration($event)"> - </app-static-property> + <app-static-property *ngFor="let config of cachedPipelineElement.staticProperties" + [staticProperty]="config" + [staticProperties]="cachedPipelineElement.staticProperties" + [eventSchemas]="eventSchemas" + [parentForm]="parentForm" + [fieldName]="config.internalName" + (validateEmitter)="validConfiguration($event)"> + </app-static-property> + <div *ngIf="isDataProcessor"> + <output-strategy *ngFor="let outputStrategy of cachedPipelineElement.outputStrategies" + [parentForm]="parentForm" + [outputStrategy]="outputStrategy" + [selectedElement]="cachedPipelineElement" + [restrictedEditMode]="restrictedEditMode"> + </output-strategy> + </div> </form> </div> </div> </div> <mat-divider></mat-divider> <div class="sp-dialog-actions"> - <button mat-button mat-raised-button color="primary" (click)="save()" style="margin-right:10px;" [disabled]="!(formValid)"> + <button mat-button mat-raised-button color="primary" (click)="save()" style="margin-right:10px;" + [disabled]="!(formValid)"> Save </button> <button mat-button mat-raised-button class="mat-basic" (click)="close()"> diff --git a/ui/src/app/editor-v2/dialog/customize/customize.component.ts b/ui/src/app/editor-v2/dialog/customize/customize.component.ts index 768d77f..5939c28 100644 --- a/ui/src/app/editor-v2/dialog/customize/customize.component.ts +++ b/ui/src/app/editor-v2/dialog/customize/customize.component.ts @@ -27,7 +27,7 @@ import { import {InvocablePipelineElementUnion, PipelineElementConfig} from "../../model/editor.model"; import {DialogRef} from "../../../core-ui/dialog/base-dialog/dialog-ref"; import {JsplumbService} from "../../services/jsplumb.service"; -import {EventSchema} from "../../../core-model/gen/streampipes-model"; +import {DataProcessorInvocation, EventSchema} from "../../../core-model/gen/streampipes-model"; import {FormBuilder, FormGroup} from "@angular/forms"; @Component({ @@ -40,12 +40,14 @@ export class CustomizeComponent implements OnInit, AfterViewInit { @Input() pipelineElement: PipelineElementConfig; + @Input() + restrictedEditMode: boolean; + cachedPipelineElement: InvocablePipelineElementUnion; eventSchemas: EventSchema[] = []; displayRecommended: boolean; showDocumentation: boolean = false; - restrictedEditMode: boolean; selectedElement: any; selection: any; @@ -64,6 +66,8 @@ export class CustomizeComponent implements OnInit, AfterViewInit { formValid: boolean; viewInitialized: boolean = false; + isDataProcessor: boolean = false; + //ShepherdService: ShepherdService; constructor(private dialogRef: DialogRef<CustomizeComponent>, @@ -75,6 +79,7 @@ export class CustomizeComponent implements OnInit, AfterViewInit { ngOnInit(): void { this.cachedPipelineElement = this.JsPlumbService.clone(this.pipelineElement.payload) as InvocablePipelineElementUnion; + this.isDataProcessor = this.cachedPipelineElement instanceof DataProcessorInvocation; this.cachedPipelineElement.inputStreams.forEach(is => { this.eventSchemas = this.eventSchemas.concat(is.eventSchema); }); diff --git a/ui/src/app/editor-v2/editor.module.ts b/ui/src/app/editor-v2/editor.module.ts index 3a172f5..941c999 100644 --- a/ui/src/app/editor-v2/editor.module.ts +++ b/ui/src/app/editor-v2/editor.module.ts @@ -56,6 +56,9 @@ import {SafeCss} from "./utils/style-sanitizer"; import {MatchingErrorComponent} from "./dialog/matching-error/matching-error.component"; import {WelcomeTourComponent} from "./dialog/welcome-tour/welcome-tour.component"; import {MissingElementsForTutorialComponent} from "./dialog/missing-elements-for-tutorial/missing-elements-for-tutorial.component"; +import {OutputStrategyComponent} from "./components/output-strategy/output-strategy.component"; +import {CustomOutputStrategyComponent} from "./components/output-strategy/custom-output/custom-output-strategy.component"; +import {PropertySelectionComponent} from "./components/output-strategy/property-selection/property-selection.component"; @NgModule({ imports: [ @@ -77,10 +80,12 @@ import {MissingElementsForTutorialComponent} from "./dialog/missing-elements-for declarations: [ CompatibleElementsComponent, CustomizeComponent, + CustomOutputStrategyComponent, EditorComponent, HelpComponent, MatchingErrorComponent, MissingElementsForTutorialComponent, + OutputStrategyComponent, PipelineAssemblyComponent, PipelineElementComponent, PipelineElementDocumentationComponent, @@ -88,6 +93,7 @@ import {MissingElementsForTutorialComponent} from "./dialog/missing-elements-for PipelineElementOptionsComponent, PipelineElementRecommendationComponent, PipelineComponent, + PropertySelectionComponent, SavePipelineComponent, SafeCss, WelcomeTourComponent diff --git a/ui/src/app/services/property-selector.service.ts b/ui/src/app/services/property-selector.service.ts index d8219c6..bc9327b 100644 --- a/ui/src/app/services/property-selector.service.ts +++ b/ui/src/app/services/property-selector.service.ts @@ -17,6 +17,7 @@ */ import {Injectable} from "@angular/core"; +import {EventPropertyNested, EventPropertyUnion} from "../core-model/gen/streampipes-model"; @Injectable() export class PropertySelectorService { @@ -29,15 +30,15 @@ export class PropertySelectorService { } - makeProperties(eventProperties, availablePropertyKeys, currentPointer) { + makeProperties(eventProperties: Array<any>, availablePropertyKeys: Array<string>, currentPointer) { let outputProperties = []; eventProperties.forEach(ep => { availablePropertyKeys.forEach(apk => { if (this.isInSelection(ep, apk, currentPointer)) { - ep.properties.runtimeId = this.makeSelector(currentPointer, ep.properties.runtimeName); + ep.runtimeId = this.makeSelector(currentPointer, ep.runtimeName); if (this.isNested(ep)) { - ep.properties.eventProperties = this.makeProperties(ep.properties.eventProperties, availablePropertyKeys, this.makeSelector(currentPointer, ep.properties.runtimeName)); + ep.eventProperties = this.makeProperties(ep.eventProperties, availablePropertyKeys, this.makeSelector(currentPointer, ep.properties.runtimeName)); } outputProperties.push(ep); } @@ -46,7 +47,7 @@ export class PropertySelectorService { return outputProperties; } - makeFlatProperties(eventProperties, availablePropertyKeys) { + makeFlatProperties(eventProperties: Array<EventPropertyUnion>, availablePropertyKeys: Array<string>) { let outputProperties = []; availablePropertyKeys.forEach(apk => { @@ -57,15 +58,15 @@ export class PropertySelectorService { return outputProperties; } - makeProperty(eventProperties, propertySelector, originalSelector) { + makeProperty(eventProperties: Array<any>, propertySelector, originalSelector) { let outputProperty; eventProperties.forEach(ep => { - if (ep.properties.runtimeName === propertySelector[0]) { + if (ep.runtimeName === propertySelector[0]) { if (this.isNested(ep)) { propertySelector.shift(); - outputProperty = this.makeProperty(ep.properties.eventProperties, propertySelector, originalSelector); + outputProperty = this.makeProperty(ep.eventProperties, propertySelector, originalSelector); } else { - ep.properties.runtimeId = originalSelector; + ep.runtimeId = originalSelector; outputProperty = ep; outputProperty.properties.niceLabel = this.makeNiceLabel(originalSelector); } @@ -79,13 +80,13 @@ export class PropertySelectorService { } isNested(ep) { - return ep.type === "org.apache.streampipes.model.schema.EventPropertyNested"; + return ep instanceof EventPropertyNested; } - isInSelection(inputProperty, propertySelector, currentPropertyPointer) { + isInSelection(inputProperty: EventPropertyUnion, propertySelector, currentPropertyPointer) { return (currentPropertyPointer + this.propertyDelimiter - + inputProperty.properties.runtimeName) === propertySelector; + + inputProperty.runtimeName) === propertySelector; }
