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 2021/09/13 08:55:45 UTC

[incubator-streampipes] branch dev updated: [STREAMPIPES-79] Always show timestamp in table visualisationreact-particles-js

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


The following commit(s) were added to refs/heads/dev by this push:
     new f72561d  [STREAMPIPES-79] Always show timestamp in table visualisationreact-particles-js
f72561d is described below

commit f72561d48b8849480f2928b39da09ecbf47323a0
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Mon Sep 13 10:55:22 2021 +0200

    [STREAMPIPES-79] Always show timestamp in table visualisationreact-particles-js
---
 .../widgets/table/table-widget.component.html      | 41 +++++++++++++---------
 .../widgets/table/table-widget.component.ts        | 12 +++----
 2 files changed, 30 insertions(+), 23 deletions(-)

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 8599143..aee17c7 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
@@ -16,37 +16,44 @@
   ~
   -->
 
-<div fxLayout="column" fxFlex="100" [ngStyle]="{background: dataExplorerWidget.baseAppearanceConfig.backgroundColor, color: dataExplorerWidget.baseAppearanceConfig.textColor}">
+<div fxLayout="column" fxFlex="100"
+     [ngStyle]="{background: dataExplorerWidget.baseAppearanceConfig.backgroundColor, color: dataExplorerWidget.baseAppearanceConfig.textColor}">
 
-        <sp-load-data-spinner *ngIf="showIsLoadingData" class="h-100"></sp-load-data-spinner>
+    <sp-load-data-spinner *ngIf="showIsLoadingData" class="h-100"></sp-load-data-spinner>
 
-        <sp-no-data-in-date-range *ngIf="showNoDataInDateRange" [viewDateRange]="timeSettings"></sp-no-data-in-date-range>
+    <sp-no-data-in-date-range *ngIf="showNoDataInDateRange" [viewDateRange]="timeSettings"></sp-no-data-in-date-range>
 
     <div class="table-container">
         <table
-            mat-table
-            mat-sort
-            *ngIf="showData"
-            [dataSource]="dataSource" matSort
-            (matSortChange)="sortData($event)" class="table-widget">
+                mat-table
+                mat-sort
+                *ngIf="showData"
+                [dataSource]="dataSource" matSort
+                (matSortChange)="sortData($event)" class="table-widget">
 
             <ng-container
-                    *ngFor="let element of dataExplorerWidget.visualizationConfig.selectedColumns"
-                    [cdkColumnDef]="element.fullDbName">
-                <div *ngIf="!isTimestamp(element)">
-                    <th mat-header-cell mat-sort-header *matHeaderCellDef [ngStyle]="{background: dataExplorerWidget.baseAppearanceConfig.backgroundColor, color: dataExplorerWidget.baseAppearanceConfig.textColor}">
-                        <label class="column-header">{{element.fullDbName}}</label>
+                    [cdkColumnDef]="'time'">
+                <div>
+                    <th mat-header-cell mat-sort-header *matHeaderCellDef
+                        [ngStyle]="{background: dataExplorerWidget.baseAppearanceConfig.backgroundColor, color: dataExplorerWidget.baseAppearanceConfig.textColor}">
+                        <label class="column-header">Timestamp</label>
                     </th>
                     <td mat-cell *matCellDef="let row" style="text-align: left;">
-                        {{row[element.fullDbName]}}
+                        {{row['time'] | date:'yyyy-MM-dd HH:mm:ss.SSS'}}
                     </td>
                 </div>
-                <div *ngIf="isTimestamp(element)">
-                    <th mat-header-cell mat-sort-header *matHeaderCellDef [ngStyle]="{background: dataExplorerWidget.baseAppearanceConfig.backgroundColor, color: dataExplorerWidget.baseAppearanceConfig.textColor}">
+            </ng-container>
+
+            <ng-container
+                    *ngFor="let element of dataExplorerWidget.visualizationConfig.selectedColumns"
+                    [cdkColumnDef]="element.fullDbName">
+                <div *ngIf="!isTimestamp(element)">
+                    <th mat-header-cell mat-sort-header *matHeaderCellDef
+                        [ngStyle]="{background: dataExplorerWidget.baseAppearanceConfig.backgroundColor, color: dataExplorerWidget.baseAppearanceConfig.textColor}">
                         <label class="column-header">{{element.fullDbName}}</label>
                     </th>
                     <td mat-cell *matCellDef="let row" style="text-align: left;">
-                        {{row[element.fullDbName]| date:'yyyy-MM-dd HH:mm:ss'}}
+                        {{row[element.fullDbName]}}
                     </td>
                 </div>
             </ng-container>
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 7e4f579..3319e25 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
@@ -35,7 +35,7 @@ import { DataExplorerFieldProviderService } from '../../../services/data-explore
 })
 export class TableWidgetComponent extends BaseDataExplorerWidget<TableWidgetModel> implements OnInit, OnDestroy {
 
-  @ViewChild(MatSort, {static: true}) sort: MatSort;
+  @ViewChild(MatSort, { static: true }) sort: MatSort;
 
   dataSource = new MatTableDataSource();
   columnNames: string[];
@@ -60,7 +60,7 @@ export class TableWidgetComponent extends BaseDataExplorerWidget<TableWidgetMode
       this.setShownComponents(true, false, false);
     } else {
       data.rows.forEach(row =>
-          result.push(this.createTableObject(data.headers, row))
+        result.push(this.createTableObject(data.headers, row))
       );
       this.setShownComponents(false, true, false);
     }
@@ -83,17 +83,17 @@ export class TableWidgetComponent extends BaseDataExplorerWidget<TableWidgetMode
   sortData(event) {
     if (event.direction === 'asc') {
       this.dataSource.data = this.dataSource.data.sort(
-          (a, b) => (a[event.active] > b[event.active]) ? 1 : ((b[event.active] > a[event.active]) ? -1 : 0));
+        (a, b) => (a[event.active] > b[event.active]) ? 1 : ((b[event.active] > a[event.active]) ? -1 : 0));
     }
 
     if (event.direction === 'desc') {
       this.dataSource.data = this.dataSource.data.sort(
-          (a, b) => (a[event.active] > b[event.active]) ? -1 : ((b[event.active] > a[event.active]) ? 1 : 0));
+        (a, b) => (a[event.active] > b[event.active]) ? -1 : ((b[event.active] > a[event.active]) ? 1 : 0));
     }
 
     if (event.direction === '') {
       this.dataSource.data = this.dataSource.data.sort(
-          (a, b) => (a['timestamp'] > b['timestamp']) ? 1 : ((b['timestamp'] > a['timestamp']) ? -1 : 0));
+        (a, b) => (a['timestamp'] > b['timestamp']) ? 1 : ((b['timestamp'] > a['timestamp']) ? -1 : 0));
     }
   }
 
@@ -109,7 +109,7 @@ export class TableWidgetComponent extends BaseDataExplorerWidget<TableWidgetMode
   }
 
   onDataReceived(dataResults: DataResult[]) {
-    this.columnNames = this.dataExplorerWidget.visualizationConfig.selectedColumns.map(c => c.fullDbName);
+    this.columnNames = ['time'].concat(this.dataExplorerWidget.visualizationConfig.selectedColumns.map(c => c.fullDbName));
     this.dataSource.data = [...this.transformData(dataResults[0])];
   }