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/09/22 13:49:15 UTC

[incubator-streampipes] branch dev updated (e3b82fe -> 1973024)

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

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


    from e3b82fe  [hotfix] Fix bug that prevented historical notifications from loading
     new 6543820  Fix CSV export for missing columns in database
     new 1973024  Add grouping to maps dashboard widget

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:
 .../rest/impl/datalake/DataLakeManagementV3.java   |  8 ++-
 .../dashboard/components/widgets/map/map-config.ts | 48 ++++++++------
 .../widgets/map/map-widget.component.html          |  3 +-
 .../components/widgets/map/map-widget.component.ts | 75 +++++++++++++++++-----
 4 files changed, 93 insertions(+), 41 deletions(-)


[incubator-streampipes] 02/02: Add grouping to maps dashboard widget

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

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

commit 19730246387ba670337f2342d6981a1e915e9305
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Tue Sep 22 15:48:43 2020 +0200

    Add grouping to maps dashboard widget
---
 .../dashboard/components/widgets/map/map-config.ts | 48 ++++++++------
 .../widgets/map/map-widget.component.html          |  3 +-
 .../components/widgets/map/map-widget.component.ts | 75 +++++++++++++++++-----
 3 files changed, 87 insertions(+), 39 deletions(-)

diff --git a/ui/src/app/dashboard/components/widgets/map/map-config.ts b/ui/src/app/dashboard/components/widgets/map/map-config.ts
index 6c56f4d..1f15c41 100644
--- a/ui/src/app/dashboard/components/widgets/map/map-config.ts
+++ b/ui/src/app/dashboard/components/widgets/map/map-config.ts
@@ -15,35 +15,41 @@
  *   limitations under the License.
  */
 
-import {WidgetConfigBuilder} from "../../../registry/widget-config-builder";
-import {SchemaRequirementsBuilder} from "../../../sdk/schema-requirements-builder";
-import {EpRequirements} from "../../../sdk/ep-requirements";
-import {WidgetConfig} from "../base/base-config";
-import {DashboardWidgetSettings} from "../../../../core-model/gen/streampipes-model";
+import { WidgetConfigBuilder } from '../../../registry/widget-config-builder';
+import { SchemaRequirementsBuilder } from '../../../sdk/schema-requirements-builder';
+import { EpRequirements } from '../../../sdk/ep-requirements';
+import { WidgetConfig } from '../base/base-config';
+import { DashboardWidgetSettings } from '../../../../core-model/gen/streampipes-model';
 
 export class MapConfig extends WidgetConfig {
 
-    static readonly LATITUDE_MAPPING_KEY: string = "latitude-mapping";
-    static readonly LONGITUDE_MAPPING_KEY: string = "longitude-mapping";
-    static readonly ITEMS_MAPPING_KEY: string = "items-mapping";
-    static readonly MARKER_TYPE_KEY: string = "marker-type-mapping";
+    static readonly LATITUDE_MAPPING_KEY: string = 'latitude-mapping';
+    static readonly LONGITUDE_MAPPING_KEY: string = 'longitude-mapping';
+    static readonly ITEMS_MAPPING_KEY: string = 'items-mapping';
+    static readonly ID_MAPPING_KEY: string = 'ids-mapping';
+    static readonly MARKER_TYPE_KEY: string = 'marker-type-mapping';
+    static readonly CENTER_MAP_KEY: string = 'center-map-mapping';
 
     constructor() {
         super();
     }
 
     getConfig(): DashboardWidgetSettings {
-        return WidgetConfigBuilder.createWithSelectableColorsAndTitlePanel("map", "Map")
-            .withIcon("fas fa-map")
-            .withDescription("A map including a marker to show the live position of a thing")
-            .requiredSchema(SchemaRequirementsBuilder
-                .create()
-                .requiredPropertyWithUnaryMapping(MapConfig.LATITUDE_MAPPING_KEY, "Latitude field", "", EpRequirements.latitudeReq())
-                .requiredPropertyWithUnaryMapping(MapConfig.LONGITUDE_MAPPING_KEY, "Latitude field", "", EpRequirements.longitudeReq())
-                .requiredPropertyWithNaryMapping(MapConfig.ITEMS_MAPPING_KEY, "Fields to display", "", EpRequirements.anyProperty())
-                .build())
-            .requiredSingleValueSelection(MapConfig.MARKER_TYPE_KEY, "Marker type", "", [this.makeOption("Default"), this.makeOption("Car")])
-            .build();
+        return WidgetConfigBuilder.createWithSelectableColorsAndTitlePanel('map', 'Map')
+          .withIcon('fas fa-map')
+          .withDescription('A map including a marker to show the live position of a thing')
+          .requiredSchema(SchemaRequirementsBuilder
+            .create()
+            .requiredPropertyWithUnaryMapping(MapConfig.LATITUDE_MAPPING_KEY, 'Latitude field', '', EpRequirements.latitudeReq())
+            .requiredPropertyWithUnaryMapping(MapConfig.LONGITUDE_MAPPING_KEY, 'Latitude field', '', EpRequirements.longitudeReq())
+            .requiredPropertyWithNaryMapping(MapConfig.ID_MAPPING_KEY, 'Group Markers', 'Each id gets its own marker', EpRequirements.anyProperty())
+            .requiredPropertyWithNaryMapping(MapConfig.ITEMS_MAPPING_KEY, 'Fields to display', '', EpRequirements.anyProperty())
+            .build())
+          .requiredSingleValueSelection(
+            MapConfig.CENTER_MAP_KEY, 'Center map', 'Center the map around new markers', [this.makeOption('Center'), this.makeOption('No Center')])
+          .requiredSingleValueSelection(
+            MapConfig.MARKER_TYPE_KEY, 'Marker type', '', [this.makeOption('Default'), this.makeOption('Car')])
+          .build();
     }
 
-}
\ No newline at end of file
+}
diff --git a/ui/src/app/dashboard/components/widgets/map/map-widget.component.html b/ui/src/app/dashboard/components/widgets/map/map-widget.component.html
index d159168..4fd2c93 100644
--- a/ui/src/app/dashboard/components/widgets/map/map-widget.component.html
+++ b/ui/src/app/dashboard/components/widgets/map/map-widget.component.html
@@ -23,6 +23,7 @@
          leaflet
          [leafletOptions]="options"
          (leafletMapReady)="onMapReady($event)">
-        <div *ngIf="showMarkers" [leafletLayer]="markerLayer"></div>
+<!--        <div *ngIf="showMarkers" [leafletLayer]="markerLayer"></div>-->
+        <div *ngFor="let markerLayer of markerLayers" [leafletLayer]="markerLayer"></div>
     </div>
 </div>
diff --git a/ui/src/app/dashboard/components/widgets/map/map-widget.component.ts b/ui/src/app/dashboard/components/widgets/map/map-widget.component.ts
index a579bc2..4cc420f 100644
--- a/ui/src/app/dashboard/components/widgets/map/map-widget.component.ts
+++ b/ui/src/app/dashboard/components/widgets/map/map-widget.component.ts
@@ -36,11 +36,14 @@ export class MapWidgetComponent extends BaseStreamPipesWidget implements OnInit,
     selectedLatitudeField: string;
     selectedLongitudeField: string;
     selectedMarkerIcon: string;
-    additionalItemsToDisplay: Array<string>;
+    idsToDisplay: string[];
+    additionalItemsToDisplay: string[];
+    centerMap: boolean;
 
     map: Map;
-    showMarkers: boolean = false;
-    markerLayer: Marker;
+    showMarkers = false;
+    markerLayers: Marker[];
+    markerIds: string[];
 
     mapWidth: number;
     mapHeight: number;
@@ -59,7 +62,9 @@ export class MapWidgetComponent extends BaseStreamPipesWidget implements OnInit,
 
     ngOnInit(): void {
         super.ngOnInit();
-        this.markerLayer = this.makeMarker([0, 0]);
+        // this.markerLayer = this.makeMarker([0, 0]);
+        this.markerLayers = [];
+        this.markerIds = [];
         this.showMarkers = true;
         this.mapWidth = this.computeCurrentWidth(this.gridsterItemComponent);
         this.mapHeight = this.computeCurrentHeight(this.gridsterItemComponent);
@@ -74,10 +79,13 @@ export class MapWidgetComponent extends BaseStreamPipesWidget implements OnInit,
         this.selectedLongitudeField = extractor.mappingPropertyValue(MapConfig.LONGITUDE_MAPPING_KEY);
         this.selectedMarkerIcon = this.markerImage(extractor.selectedSingleValue(MapConfig.MARKER_TYPE_KEY));
         this.additionalItemsToDisplay = extractor.mappingPropertyValues(MapConfig.ITEMS_MAPPING_KEY);
+        this.idsToDisplay = extractor.mappingPropertyValues(MapConfig.ID_MAPPING_KEY);
+        const b = extractor.singleValueParameter(MapConfig.CENTER_MAP_KEY);
+        this.centerMap = extractor.selectedSingleValue(MapConfig.CENTER_MAP_KEY) === 'Center';
     }
 
     markerImage(selectedMarker: string): string {
-        return selectedMarker === "Default" ? 'assets/img/marker-icon.png' : 'assets/img/pe_icons/car.png';
+        return selectedMarker === 'Default' ? 'assets/img/marker-icon.png' : 'assets/img/pe_icons/car.png';
     }
 
     onMapReady(map: Map) {
@@ -86,24 +94,47 @@ export class MapWidgetComponent extends BaseStreamPipesWidget implements OnInit,
     }
 
     protected onEvent(event: any) {
-        this.updatePosition(event);
+
+        // TODO handle when user selected id field
+
+        const tmpMarker = this.getMarker(event);
+
+        // Set one marker when no ids are selected
+        if (this.idsToDisplay.length === 0) {
+            this.markerLayers = [tmpMarker];
+        } else {
+
+            const id = this.getId(event);
+            const index = this.markerIds.indexOf(id);
+            if (index > -1) {
+                this.markerLayers[index] = tmpMarker;
+            } else {
+                this.markerIds.push(id);
+                this.markerLayers.push(tmpMarker);
+            }
+        }
+
     }
 
-    updatePosition(event) {
-        var lat = event[this.selectedLatitudeField];
-        var long = event[this.selectedLongitudeField];
-        var text = "";
+    getMarker(event) {
+        const lat = event[this.selectedLatitudeField];
+        const long = event[this.selectedLongitudeField];
+        let text = '';
         this.additionalItemsToDisplay.forEach(item => {
-            text =  text.concat("<b>" +item +"</b>" +  ": " + event[item] + "<br>");
+            text =  text.concat('<b>' + item + '</b>' +  ': ' + event[item] + '<br>');
         });
 
-        let content : Content = text;
-        let point: LatLngExpression = new LatLng(lat, long);
-        this.markerLayer.setLatLng(point);
-        this.markerLayer.bindTooltip(content);
-        this.map.panTo(point);
+        const content: Content = text;
+        const point: LatLngExpression = new LatLng(lat, long);
+        const result = this.makeMarker(point);
+        result.setLatLng(point);
+        result.bindTooltip(content);
 
-    };
+        if (this.centerMap) {
+            this.map.panTo(point);
+        }
+        return result;
+    }
 
     makeMarker(point: LatLngExpression): Marker {
         return marker(point, { icon: icon({
@@ -114,6 +145,16 @@ export class MapWidgetComponent extends BaseStreamPipesWidget implements OnInit,
             })});
     }
 
+    getId(event) {
+        let result = '';
+
+        for (const id of this.idsToDisplay) {
+            result = result + event[id];
+        }
+
+        return result;
+    }
+
     protected onSizeChanged(width: number, height: number) {
         this.mapWidth = width;
         this.mapHeight = height;


[incubator-streampipes] 01/02: Fix CSV export for missing columns in database

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

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

commit 6543820235ce1d0e4e5af9ed661135d3c1b21a28
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Tue Sep 22 13:46:05 2020 +0200

    Fix CSV export for missing columns in database
---
 .../streampipes/rest/impl/datalake/DataLakeManagementV3.java      | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeManagementV3.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeManagementV3.java
index 8d64aa9..2d9ef8d 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeManagementV3.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeManagementV3.java
@@ -332,11 +332,15 @@ public class DataLakeManagementV3 {
                   if (!isFirstInRow) {
                     outputStream.write(toBytes(";"));
                   }
-                  isFirstInRow = false;
+                  isFirstInRow = false  ;
                   if (i1 == 0) {
                     element = ((Double) element).longValue();
                   }
-                  outputStream.write(toBytes(element.toString()));
+                  if (element == null) {
+                    outputStream.write(toBytes(""));
+                  } else {
+                    outputStream.write(toBytes(element.toString()));
+                  }
                 }
                 outputStream.write(toBytes("\n"));
               }