You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by bo...@apache.org on 2024/05/21 13:11:42 UTC

(streampipes) branch dev updated: fix(#2862): Support children selection in tree view (#2885)

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

bossenti pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 3b24a47a6a fix(#2862): Support children selection in tree view (#2885)
3b24a47a6a is described below

commit 3b24a47a6a1f53048b438ec86c3265532084bdba
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Tue May 21 15:11:33 2024 +0200

    fix(#2862): Support children selection in tree view (#2885)
---
 .../sdk/extractor/AbstractParameterExtractor.java  | 12 ++++++------
 .../static-tree-input.component.html               | 21 +++++++++++++++++++--
 .../static-tree-input.component.scss               | 13 +++++++++++++
 .../static-tree-input.component.ts                 | 22 ++++++++++++++++++++++
 4 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java
index ad29407fe6..bfefe341ba 100644
--- a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java
+++ b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/extractor/AbstractParameterExtractor.java
@@ -248,22 +248,22 @@ public abstract class AbstractParameterExtractor<T extends InvocableStreamPipesE
     List<TreeInputNode> allNodes = new ArrayList<>();
     RuntimeResolvableTreeInputStaticProperty sp =
         getStaticPropertyByName(internalName, RuntimeResolvableTreeInputStaticProperty.class);
-    if (sp.getNodes().size() > 0) {
+    if (!sp.getNodes().isEmpty()) {
       sp.getNodes().forEach(node -> buildFlatTree(node, allNodes));
     }
 
-    if (allNodes.size() > 0) {
-      return allNodes
+    if (!allNodes.isEmpty()) {
+      return sp.getSelectedNodesInternalNames()
           .stream()
           .filter(node -> {
             if (!onlyDataNodes) {
               return true;
             } else {
-              return node.isDataNode();
+              var existingNode = allNodes.stream().filter(n -> n.getInternalNodeName().equals(node)).findFirst();
+              return existingNode.map(TreeInputNode::isDataNode).orElse(false);
             }
           })
-          .filter(TreeInputNode::isSelected)
-          .map(node -> typeParser.parse(node.getInternalNodeName(), targetClass))
+          .map(node -> typeParser.parse(node, targetClass))
           .collect(Collectors.toList());
     } else {
       return new ArrayList<>();
diff --git a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html
index beabe6de63..b3bc952595 100644
--- a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html
+++ b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html
@@ -54,14 +54,30 @@
     <div fxLayout="row" fxLayoutGap="15px">
         <div fxFlex="30" class="tree-input-section" fxLayout="column">
             <div class="tree-input-header" fxLayoutAlign="start center">
-                <b>Browse</b>
+                <div fxLayout="row" fxFlex="100">
+                    <div fxFlex fxLayoutAlign="start center"><b>Browse</b></div>
+                    <div fxLayoutAlign="end center">
+                        <button
+                            mat-icon-button
+                            color="accent"
+                            (click)="largeView = !largeView"
+                        >
+                            <mat-icon *ngIf="!largeView">open_in_full</mat-icon>
+                            <mat-icon *ngIf="largeView"
+                                >close_fullscreen</mat-icon
+                            >
+                        </button>
+                    </div>
+                </div>
             </div>
             <mat-tree
                 [dataSource]="dataSource"
                 [treeControl]="treeControl"
                 #tree
                 class="sp-tree"
-                style="max-height: 300px; overflow-y: auto"
+                [ngClass]="
+                    largeView ? 'tree-large-height' : 'tree-normal-height'
+                "
             >
                 <mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle>
                     <div
@@ -156,6 +172,7 @@
                                     hasDataChildren(node)
                                 "
                                 matTooltip="Add all direct children"
+                                (click)="addAllDirectChildren(node)"
                                 >add_circle</i
                             >
                             <i
diff --git a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.scss b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.scss
index d8aa86627e..4cb8975c33 100644
--- a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.scss
+++ b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.scss
@@ -16,6 +16,19 @@
  *
  */
 
+.sp-tree {
+    overflow-y: auto;
+}
+
+.tree-normal-height {
+    min-height: 300px;
+    max-height: 300px;
+}
+
+.tree-large-height {
+    min-height: 800px;
+}
+
 .sp-tree-invisible {
     display: none;
 }
diff --git a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.ts b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.ts
index f736e4a139..1f7dbf2010 100644
--- a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.ts
+++ b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.ts
@@ -27,6 +27,7 @@ import { RuntimeResolvableService } from '../static-runtime-resolvable-input/run
 import { NestedTreeControl } from '@angular/cdk/tree';
 import { MatTree, MatTreeNestedDataSource } from '@angular/material/tree';
 import { UntypedFormControl } from '@angular/forms';
+import Tree from 'echarts/types/src/data/Tree';
 
 @Component({
     selector: 'sp-runtime-resolvable-tree-input',
@@ -43,6 +44,8 @@ export class StaticRuntimeResolvableTreeInputComponent
     selectedNodeMetadata: Record<string, string>;
     selectedNodeId: string;
 
+    largeView = false;
+
     @ViewChild('tree') tree: MatTree<TreeInputNode>;
 
     constructor(runtimeResolvableService: RuntimeResolvableService) {
@@ -159,6 +162,25 @@ export class StaticRuntimeResolvableTreeInputComponent
         this.performValidation();
     }
 
+    addAllDirectChildren(node: TreeInputNode) {
+        node.children.forEach(child => {
+            if (child.dataNode && !this.existsSelectedNode(child)) {
+                this.staticProperty.selectedNodesInternalNames.push(
+                    child.internalNodeName,
+                );
+            }
+        });
+        this.performValidation();
+    }
+
+    existsSelectedNode(node: TreeInputNode) {
+        return (
+            this.staticProperty.selectedNodesInternalNames.find(
+                nodeName => nodeName === node.internalNodeName,
+            ) !== undefined
+        );
+    }
+
     removeNode(node: TreeInputNode) {
         node.selected = false;
         const index = this.getSelectedNodeIndex(node.internalNodeName);