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 2023/03/08 21:31:01 UTC

[streampipes] branch 1391-data-explorer-filter-doesnt-work-for-boolean-and-false-value updated (c830543a2 -> 6fc37bb67)

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

riemer pushed a change to branch 1391-data-explorer-filter-doesnt-work-for-boolean-and-false-value
in repository https://gitbox.apache.org/repos/asf/streampipes.git


    from c830543a2 Bump mypy from 1.0.0 to 1.1.1 in /streampipes-client-python (#1395)
     new e92247981 Properly handle booleans with value false in data explorer filter (#1391)
     new 6fc37bb67 [hotfix] Add pagination to data explorer table widget, improve performance of line chart

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../v4/params/WhereStatementParams.java            |   5 +-
 .../data-explorer-dashboard-widget.component.ts    |   4 +-
 .../base/base-data-explorer-widget.directive.ts    |   6 +-
 .../widgets/table/table-widget.component.html      |   8 +-
 .../widgets/table/table-widget.component.ts        |  45 ++---
 .../time-series-chart-widget.component.ts          | 199 +++++++--------------
 6 files changed, 104 insertions(+), 163 deletions(-)


[streampipes] 01/02: Properly handle booleans with value false in data explorer filter (#1391)

Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch 1391-data-explorer-filter-doesnt-work-for-boolean-and-false-value
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit e9224798118beeb3d3c9873b24352f15a4872ba3
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Wed Mar 8 22:26:19 2023 +0100

    Properly handle booleans with value false in data explorer filter (#1391)
---
 .../streampipes/dataexplorer/v4/params/WhereStatementParams.java     | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/WhereStatementParams.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/WhereStatementParams.java
index b5ddcf16d..0c7f1829c 100644
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/WhereStatementParams.java
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/WhereStatementParams.java
@@ -103,14 +103,17 @@ public class WhereStatementParams extends QueryParamsV4 {
   }
 
   private String returnCondition(String inputCondition) {
-    if (NumberUtils.isCreatable(inputCondition) || Boolean.parseBoolean(inputCondition)) {
+    if (NumberUtils.isCreatable(inputCondition) || isBoolean(inputCondition)) {
       return inputCondition;
     } else if (inputCondition.equals("\"\"")) {
       return inputCondition;
     } else {
       return "'" + inputCondition + "'";
     }
+  }
 
+  private boolean isBoolean(String input) {
+    return "true".equalsIgnoreCase(input) || "false".equalsIgnoreCase(input);
   }
 
   public List<WhereCondition> getWhereConditions() {


[streampipes] 02/02: [hotfix] Add pagination to data explorer table widget, improve performance of line chart

Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch 1391-data-explorer-filter-doesnt-work-for-boolean-and-false-value
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit 6fc37bb674616889baa63af7e183426b6d00c782
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Wed Mar 8 22:27:14 2023 +0100

    [hotfix] Add pagination to data explorer table widget, improve performance of line chart
---
 .../data-explorer-dashboard-widget.component.ts    |   4 +-
 .../base/base-data-explorer-widget.directive.ts    |   6 +-
 .../widgets/table/table-widget.component.html      |   8 +-
 .../widgets/table/table-widget.component.ts        |  45 ++---
 .../time-series-chart-widget.component.ts          | 199 +++++++--------------
 5 files changed, 100 insertions(+), 162 deletions(-)

diff --git a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts
index 0fb1098b9..cbb0d243c 100644
--- a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts
+++ b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts
@@ -236,10 +236,10 @@ export class DataExplorerDashboardWidgetComponent implements OnInit, OnDestroy {
 
     startLoadingTimer() {
         this.timerActive = true;
-        this.intervalSubscription = interval(10)
+        this.intervalSubscription = interval(100)
             .pipe(takeWhile(() => this.timerActive))
             .subscribe(value => {
-                this.loadingTime = (value * 10) / 1000;
+                this.loadingTime = (value * 100) / 1000;
             });
     }
 
diff --git a/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts b/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts
index dd112a954..4ca1f9a85 100644
--- a/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts
+++ b/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts
@@ -131,9 +131,11 @@ export abstract class BaseDataExplorerWidgetDirective<
                 results.forEach(
                     (result, index) => (result.sourceIndex = index),
                 );
-                this.validateReceivedData(results);
-                this.refreshView();
                 this.timerCallback.emit(false);
+                setTimeout(() => {
+                    this.validateReceivedData(results);
+                    this.refreshView();
+                });
             });
 
         this.widgetConfigurationSub =
diff --git a/ui/src/app/data-explorer/components/widgets/table/table-widget.component.html b/ui/src/app/data-explorer/components/widgets/table/table-widget.component.html
index 846c45296..67f54a7c9 100644
--- a/ui/src/app/data-explorer/components/widgets/table/table-widget.component.html
+++ b/ui/src/app/data-explorer/components/widgets/table/table-widget.component.html
@@ -43,7 +43,6 @@
     <div class="table-container">
         <table
             mat-table
-            mat-sort
             *ngIf="showData"
             [dataSource]="dataSource"
             matSort
@@ -84,7 +83,7 @@
                 "
                 [cdkColumnDef]="element.fullDbName"
             >
-                <div *ngIf="!isTimestamp(element)">
+                <div *ngIf="!(element.fullDbName === 'time')">
                     <th
                         mat-header-cell
                         mat-sort-header
@@ -120,5 +119,10 @@
             ></tr>
             <tr mat-row *matRowDef="let row; columns: columnNames"></tr>
         </table>
+        <mat-paginator [length]="100"
+                       [pageSize]="500"
+                       [pageSizeOptions]="[10, 20, 50, 100, 500, 1000]"
+                       aria-label="Select page">
+        </mat-paginator>
     </div>
 </div>
diff --git a/ui/src/app/data-explorer/components/widgets/table/table-widget.component.ts b/ui/src/app/data-explorer/components/widgets/table/table-widget.component.ts
index 2c649ad61..37c2375f2 100644
--- a/ui/src/app/data-explorer/components/widgets/table/table-widget.component.ts
+++ b/ui/src/app/data-explorer/components/widgets/table/table-widget.component.ts
@@ -25,6 +25,7 @@ import {
     DataExplorerField,
     SpQueryResult,
 } from '@streampipes/platform-services';
+import { MatPaginator } from '@angular/material/paginator';
 
 @Component({
     selector: 'sp-data-explorer-table-widget',
@@ -35,7 +36,8 @@ export class TableWidgetComponent
     extends BaseDataExplorerWidgetDirective<TableWidgetModel>
     implements OnInit, OnDestroy
 {
-    @ViewChild(MatSort, { static: true }) sort: MatSort;
+    @ViewChild(MatSort, {static: true}) sort: MatSort;
+    @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
 
     dataSource = new MatTableDataSource();
     columnNames: string[];
@@ -43,31 +45,24 @@ export class TableWidgetComponent
     ngOnInit(): void {
         super.ngOnInit();
         this.dataSource.sort = this.sort;
+        this.dataSource.paginator = this.paginator;
         this.columnNames = ['time'].concat(
-            this.dataExplorerWidget.visualizationConfig.selectedColumns.map(
-                c => c.fullDbName,
-            ),
+          this.dataExplorerWidget.visualizationConfig.selectedColumns.map(
+            c => c.fullDbName,
+          ),
         );
     }
 
     transformData(spQueryResult: SpQueryResult) {
-        const result = [];
-        spQueryResult.allDataSeries.forEach(series => {
-            series.rows.forEach(row =>
-                result.push(this.createTableObject(spQueryResult.headers, row)),
-            );
-        });
-
-        this.setShownComponents(false, true, false, false);
-        return result;
+        return spQueryResult.allDataSeries.flatMap(series =>
+          series.rows.map(row => this.createTableObject(spQueryResult.headers, row)));
     }
 
     createTableObject(keys, values) {
-        const object = {};
-        keys.forEach((key, index) => {
+        return keys.reduce((object, key, index) => {
             object[key] = values[index];
-        });
-        return object;
+            return object;
+        }, {});
     }
 
     ngOnDestroy(): void {
@@ -115,20 +110,18 @@ export class TableWidgetComponent
 
     beforeDataFetched() {
         this.setShownComponents(false, false, true, false);
+        this.dataSource.data = [];
     }
 
     onDataReceived(spQueryResults: SpQueryResult[]) {
         this.columnNames = ['time'].concat(
-            this.dataExplorerWidget.visualizationConfig.selectedColumns.map(
-                c => c.fullDbName,
-            ),
+          this.dataExplorerWidget.visualizationConfig.selectedColumns.map(
+            c => c.fullDbName,
+          ),
         );
-        this.dataSource.data = [];
-        spQueryResults.forEach(spQueryResult => {
-            this.dataSource.data = this.dataSource.data.concat(
-                this.transformData(spQueryResult),
-            );
-        });
+        const transformedData = spQueryResults.map(spQueryResult => this.transformData(spQueryResult)).flat();
+        this.dataSource.data = [...transformedData];
+        this.setShownComponents(false, true, false, false);
     }
 
     handleUpdatedFields(
diff --git a/ui/src/app/data-explorer/components/widgets/time-series-chart/time-series-chart-widget.component.ts b/ui/src/app/data-explorer/components/widgets/time-series-chart/time-series-chart-widget.component.ts
index 3c5c9ba59..c85d71704 100644
--- a/ui/src/app/data-explorer/components/widgets/time-series-chart/time-series-chart-widget.component.ts
+++ b/ui/src/app/data-explorer/components/widgets/time-series-chart/time-series-chart-widget.component.ts
@@ -52,15 +52,9 @@ export class TimeSeriesChartWidgetComponent
         '#D466A1',
     ];
 
-    groupKeeper: {} = {};
+    groupKeeper = {};
 
     data: any[] = undefined;
-    advancedSettingsActive = false;
-    showBackgroundColorProperty = true;
-
-    selectedStartX = undefined;
-    selectedEndX = undefined;
-    n_selected_points = undefined;
 
     // this can be set to scale the line chart according to the layout
     offsetRightLineChart = 10;
@@ -160,133 +154,86 @@ export class TimeSeriesChartWidgetComponent
 
         const tmpLineChartTraces: any[] = [];
 
-        data.allDataSeries.map((group, index) => {
-            group.rows.forEach(row => {
-                this.dataExplorerWidget.visualizationConfig.selectedTimeSeriesChartProperties.forEach(
-                    field => {
-                        if (field.sourceIndex === data.sourceIndex) {
-                            const columnIndex = this.getColumnIndex(
-                                field,
-                                data,
-                            );
-                            const value = row[columnIndex];
-                            this.maxValue =
-                                value > this.maxValue ? value : this.maxValue;
+        let maxValue = -Infinity;
 
-                            if (
-                                !this.orderedSelectedProperties.includes(
-                                    field.fullDbName +
-                                        field.sourceIndex.toString(),
-                                )
-                            ) {
-                                this.orderedSelectedProperties.push(
-                                    field.fullDbName +
-                                        field.sourceIndex.toString(),
-                                );
-                            }
-                        }
-                    },
-                );
+        const selectedFields = this.dataExplorerWidget.visualizationConfig.selectedTimeSeriesChartProperties;
+        data.allDataSeries.forEach(group => {
+            group.rows.forEach(row => {
+                selectedFields.forEach(field => {
+                    if (field.sourceIndex === data.sourceIndex) {
+                        const columnIndex = this.getColumnIndex(field, data);
+                        const value = row[columnIndex];
+                        maxValue = value > maxValue ? value : maxValue;
+                    }
+                });
             });
         });
 
-        data.allDataSeries.map((group, index) => {
-            group.rows.forEach(row => {
-                this.dataExplorerWidget.visualizationConfig.selectedTimeSeriesChartProperties.forEach(
-                    field => {
-                        if (field.sourceIndex === data.sourceIndex) {
-                            const name =
-                                field.fullDbName + sourceIndex.toString();
-
-                            if (group['tags'] != null) {
-                                Object.entries(group['tags']).forEach(
-                                    ([key, val]) => {
-                                        if (name in this.groupKeeper) {
-                                            if (
-                                                this.groupKeeper[name].indexOf(
-                                                    val,
-                                                ) === -1
-                                            ) {
-                                                this.groupKeeper[name].push(
-                                                    val,
-                                                );
-                                            }
-                                        } else {
-                                            this.groupKeeper[name] = [val];
-                                        }
-                                    },
-                                );
-                            }
-
-                            const columnIndex = this.getColumnIndex(
-                                field,
-                                data,
-                            );
+        data.allDataSeries.forEach((group, index) => {
+            for (const row of group.rows) {
+                for (const field of selectedFields) {
+                    if (field.sourceIndex === data.sourceIndex) {
+                        const columnIndex = this.getColumnIndex(field, data);
+                        const name = field.fullDbName + sourceIndex.toString();
+                        let value = row[columnIndex];
+                        const fullDbNameAndIndex = field.fullDbName + field.sourceIndex.toString();
+                        if (!this.orderedSelectedProperties.includes(fullDbNameAndIndex)) {
+                            this.orderedSelectedProperties.push(fullDbNameAndIndex);
+                        }
 
-                            let value = row[columnIndex];
-                            if (
-                                this.fieldProvider.booleanFields.find(
-                                    f =>
-                                        field.fullDbName === f.fullDbName &&
-                                        f.sourceIndex === data.sourceIndex,
-                                ) !== undefined
-                            ) {
-                                value = value === true ? this.maxValue + 2 : 0;
+                        const {tags} = group;
+                        if (tags != null) {
+                            const groupValues = this.groupKeeper[name] ?? new Set();
+                            for (const [key, val] of Object.entries(tags)) {
+                                groupValues.add(val);
                             }
+                            this.groupKeeper[name] = groupValues;
+                        }
 
-                            if (
-                                !(
-                                    field.fullDbName +
-                                        sourceIndex.toString() +
-                                        index.toString() in
-                                    tmpLineChartTraces
-                                )
-                            ) {
-                                const headerName =
-                                    data.headers[
-                                        this.getColumnIndex(field, data)
-                                    ];
-                                tmpLineChartTraces[
-                                    field.fullDbName +
-                                        sourceIndex.toString() +
-                                        index.toString()
-                                ] = {
-                                    type: 'scatter',
-                                    mode: 'Line',
-                                    name: headerName,
-                                    connectgaps: false,
-                                    x: [],
-                                    y: [],
-                                };
-                            }
+                        if (
+                          this.fieldProvider.booleanFields.find(
+                            f =>
+                              field.fullDbName === f.fullDbName &&
+                              f.sourceIndex === data.sourceIndex,
+                          ) !== undefined
+                        ) {
+                            value = value === true ? this.maxValue + 2 : 0;
+                        }
 
+                        const traceKey = name + index.toString();
+                        const traceExists = traceKey in tmpLineChartTraces;
+
+                        if (!traceExists) {
+                            const headerName =
+                              data.headers[
+                                columnIndex
+                                ];
                             tmpLineChartTraces[
-                                field.fullDbName +
-                                    sourceIndex.toString() +
-                                    index.toString()
-                            ].x.push(new Date(row[indexXkey]));
-                            tmpLineChartTraces[
-                                field.fullDbName +
-                                    sourceIndex.toString() +
-                                    index.toString()
-                            ].y.push(value);
+                              traceKey
+                              ] = {
+                                type: 'scatter',
+                                mode: 'Line',
+                                name: headerName,
+                                connectgaps: false,
+                                x: [],
+                                y: [],
+                            };
                         }
-                    },
-                );
-            });
+
+                        tmpLineChartTraces[
+                          traceKey
+                          ].x.push(new Date(row[indexXkey]));
+                        tmpLineChartTraces[
+                          traceKey
+                          ].y.push(value);
+                    }
+                }
+            }
         });
 
         return Object.values(tmpLineChartTraces);
     }
 
-    setStartX(startX: string) {
-        this.selectedStartX = startX;
-    }
-
-    setEndX(endX: string) {
-        this.selectedEndX = endX;
-    }
-
     updateAppearance() {
         this.graph.layout.paper_bgcolor =
             this.dataExplorerWidget.baseAppearanceConfig.backgroundColor;
@@ -565,21 +512,13 @@ export class TimeSeriesChartWidgetComponent
 
     onDataReceived(spQueryResults: SpQueryResult[]) {
         this.data = [];
-
-        // this.setShownComponents(true, false, false, false);
         this.groupKeeper = {};
 
         this.orderedSelectedProperties = [];
 
-        spQueryResults.map((spQueryResult, index) => {
-            const res = this.transformData(
-                spQueryResult,
-                spQueryResult.sourceIndex,
-            );
-            res.forEach(item => {
-                this.data = this.data.concat(item);
-            });
-        });
+        this.data = spQueryResults.flatMap((spQueryResult) =>
+          this.transformData(spQueryResult, spQueryResult.sourceIndex)
+        );
 
         this.setShownComponents(false, true, false, false);
     }