You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2020/03/16 15:58:10 UTC

[incubator-streampipes] branch STREAMPIPES-79 updated: Use event schema to show available properties

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

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


The following commit(s) were added to refs/heads/STREAMPIPES-79 by this push:
     new 211264a  Use event schema to show available properties
211264a is described below

commit 211264ab0a71773572fd6346322f895a5a107416
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Mon Mar 16 16:57:25 2020 +0100

    Use event schema to show available properties
---
 .../model/datalake/DataExplorerWidgetModel.java       | 11 +++++++++++
 .../apache/streampipes/vocabulary/StreamPipes.java    |  1 +
 .../core-model/datalake/DataExplorerWidgetModel.ts    |  5 ++++-
 .../widgets/base/base-data-explorer-widget.ts         | 19 +++++++++++--------
 .../line-chart/line-chart-widget.component.html       |  2 +-
 .../widgets/line-chart/line-chart-widget.component.ts |  5 +++--
 .../widgets/table/table-widget.component.ts           |  8 ++++----
 7 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/DataExplorerWidgetModel.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/DataExplorerWidgetModel.java
index 725f0a1..36a951b 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/DataExplorerWidgetModel.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/DataExplorerWidgetModel.java
@@ -39,6 +39,9 @@ public class DataExplorerWidgetModel extends DashboardEntity {
   @RdfProperty(StreamPipes.HAS_DASHBOARD_WIDGET_TYPE)
   private String widgetType;
 
+  @RdfProperty(StreamPipes.HAS_DASHBOARD_WIDGET_TYPE)
+  private String selectedKeys;
+
 //  @RdfProperty(StreamPipes.HAS_MEASUREMENT_NAME)
 //  private String measureName;
 
@@ -74,4 +77,12 @@ public class DataExplorerWidgetModel extends DashboardEntity {
   public void setWidgetType(String widgetType) {
     this.widgetType = widgetType;
   }
+
+  public String getSelectedKeys() {
+    return selectedKeys;
+  }
+
+  public void setSelectedKeys(String selectedKeys) {
+    this.selectedKeys = selectedKeys;
+  }
 }
diff --git a/streampipes-vocabulary/src/main/java/org/apache/streampipes/vocabulary/StreamPipes.java b/streampipes-vocabulary/src/main/java/org/apache/streampipes/vocabulary/StreamPipes.java
index b5484e3..58980d1 100644
--- a/streampipes-vocabulary/src/main/java/org/apache/streampipes/vocabulary/StreamPipes.java
+++ b/streampipes-vocabulary/src/main/java/org/apache/streampipes/vocabulary/StreamPipes.java
@@ -385,4 +385,5 @@ public class StreamPipes {
   public static final String HAS_EVENT_SCHEMA = NS + "hasEventSchema";
   public static final String HAS_WIDGET_ICON_NAME = NS + "hasWidgetIconName";
   public static final String HAS_WIDGET_DESCRIPTION = NS + "hasWidgetDescription";
+  public static final String HAS_SELECTED_KEYS = NS + "hasSelectedKeys";
 }
diff --git a/ui/src/app/core-model/datalake/DataExplorerWidgetModel.ts b/ui/src/app/core-model/datalake/DataExplorerWidgetModel.ts
index e776d16..38582a6 100644
--- a/ui/src/app/core-model/datalake/DataExplorerWidgetModel.ts
+++ b/ui/src/app/core-model/datalake/DataExplorerWidgetModel.ts
@@ -41,7 +41,10 @@ export class DataExplorerWidgetModel extends UnnamedStreamPipesEntity {
     widgetType: string;
 
     @RdfProperty('sp:hasDataLakeMeasure')
-    dataLakeMeasure: DataLakeMeasure
+    dataLakeMeasure: DataLakeMeasure;
+
+    @RdfProperty('sp:hasSelectedKeys')
+    selectedKeys: string[];
 
     constructor() {
         super();
diff --git a/ui/src/app/data-explorer-v2/components/widgets/base/base-data-explorer-widget.ts b/ui/src/app/data-explorer-v2/components/widgets/base/base-data-explorer-widget.ts
index a534f7e..ae045ab 100644
--- a/ui/src/app/data-explorer-v2/components/widgets/base/base-data-explorer-widget.ts
+++ b/ui/src/app/data-explorer-v2/components/widgets/base/base-data-explorer-widget.ts
@@ -18,17 +18,18 @@
 
 import { EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
 import { GridsterItem, GridsterItemComponent } from 'angular-gridster2';
+import { EventPropertyComponent } from '../../../../connect/schema-editor/event-property/event-property.component';
+import { EventProperty } from '../../../../connect/schema-editor/model/EventProperty';
+import { EventPropertyPrimitive } from '../../../../connect/schema-editor/model/EventPropertyPrimitive';
+import { EventSchema } from '../../../../connect/schema-editor/model/EventSchema';
 import { DataExplorerWidgetModel } from '../../../../core-model/datalake/DataExplorerWidgetModel';
 import { DateRange } from '../../../../core-model/datalake/DateRange';
 import { IDataViewDashboardItem } from '../../../models/dataview-dashboard.model';
-import { EventSchema } from '../../../../connect/schema-editor/model/EventSchema';
-import { EventPropertyPrimitive } from '../../../../connect/schema-editor/model/EventPropertyPrimitive';
-import { EventPropertyComponent } from '../../../../connect/schema-editor/event-property/event-property.component';
-import { EventProperty } from '../../../../connect/schema-editor/model/EventProperty';
+import { DatalakeRestService } from '../../../../core-services/datalake/datalake-rest.service';
 
 export abstract class BaseDataExplorerWidget implements OnChanges {
 
-  protected constructor() {
+  protected constructor(protected dataLakeRestService: DatalakeRestService) {
   }
 
   @Output()
@@ -45,6 +46,8 @@ export abstract class BaseDataExplorerWidget implements OnChanges {
   @Input() dataViewDashboardItem: IDataViewDashboardItem;
   @Input() dataExplorerWidget: DataExplorerWidgetModel;
 
+  public selectedProperties: string[];
+
   public showNoDataInDateRange: boolean;
   public showData: boolean;
   public showIsLoadingData: boolean;
@@ -112,9 +115,9 @@ export abstract class BaseDataExplorerWidget implements OnChanges {
       ? true : false;
 }
 
-  // TODO add get a specific property
-  getPropertyKeysOfStaticProperty(eventSchema) {
 
-  }
+  // updateDataExplorerWidget() {
+  //   this.
+  // }
 
 }
diff --git a/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.html b/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.html
index 7393197..bb60499 100644
--- a/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.html
+++ b/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.html
@@ -17,7 +17,7 @@
   -->
 
 <div fxLayout="column" fxLayoutAlign="stretch">
-    <div class="assemblyOptions sp-blue-bg m-0 row header h-40" style="margin-left: 0px;margin-right: 0px;">
+    <div class="assemblyOptions sp-blue-bg m-0 row header h-40" style="margin-left: 0px;margin-right: 0px;margin-top: 0px;">
         <div fxFlex="100" layout="row" fxLayoutAlign="end center" style="margin-left: 0px;margin-right: 0px;">
             <sp-select-keys (changeSelectedKeys)="setSelectedColumn($event)" [availableKeys]="availableColumns" [selectedKeys]="yKeys"></sp-select-keys>
             <button mat-button mat-icon-button color="white" (click)="removeWidget()">
diff --git a/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.ts b/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.ts
index 8d4f3b5..b424981 100644
--- a/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.ts
+++ b/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.ts
@@ -33,8 +33,8 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget implements
   yKeys: string[] = [];
   xKey: string;
 
-  constructor(private dataLakeRestService: DatalakeRestService) {
-    super();
+  constructor(protected dataLakeRestService: DatalakeRestService) {
+    super(dataLakeRestService);
   }
 
 
@@ -178,5 +178,6 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget implements
 
   setSelectedColumn(selectedColumns: string[]) {
     this.yKeys = selectedColumns;
+    this.updateData();
   }
 }
diff --git a/ui/src/app/data-explorer-v2/components/widgets/table/table-widget.component.ts b/ui/src/app/data-explorer-v2/components/widgets/table/table-widget.component.ts
index 59540a8..5fdfd1a 100644
--- a/ui/src/app/data-explorer-v2/components/widgets/table/table-widget.component.ts
+++ b/ui/src/app/data-explorer-v2/components/widgets/table/table-widget.component.ts
@@ -39,13 +39,14 @@ export class TableWidgetComponent extends BaseDataExplorerWidget implements OnIn
 
   dataSource = new MatTableDataSource();
 
-  constructor(private dataLakeRestService: DatalakeRestService) {
-    super();
+  constructor(protected dataLakeRestService: DatalakeRestService) {
+    super(dataLakeRestService);
   }
 
   ngOnInit(): void {
     this.dataSource.sort = this.sort;
-    this.availableColumns = this.getValuePropertyKeys(this.dataExplorerWidget.dataLakeMeasure.eventSchema);
+    this.availableColumns = [this.getTimestampPropertyKey(this.dataExplorerWidget.dataLakeMeasure.eventSchema)];
+    this.availableColumns = this.availableColumns.concat(this.getValuePropertyKeys(this.dataExplorerWidget.dataLakeMeasure.eventSchema));
 
     // Reduce selected columns when more then 6
     this.selectedColumns = this.availableColumns.length > 6 ? this.availableColumns.slice(0, 5) : this.availableColumns;
@@ -63,7 +64,6 @@ export class TableWidgetComponent extends BaseDataExplorerWidget implements OnIn
       this.dataExplorerWidget.dataLakeMeasure.measureName, this.viewDateRange.startDate.getTime(), this.viewDateRange.endDate.getTime())
       .subscribe(
       (res: DataResult) => {
-
         this.dataSource.data = this.transformData(res);
       }
     );