This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch 2583-pipelineelementruntimeinfocomponent
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to
refs/heads/2583-pipelineelementruntimeinfocomponent by this push:
new b4235262f4 refactor(#2583): Replace dataTable with mat-table in
LivePreviewTable component
b4235262f4 is described below
commit b4235262f4bf53bd3562bf98a847029990fcac51
Author: Philipp Zehnder <[email protected]>
AuthorDate: Tue Mar 19 17:38:00 2024 +0100
refactor(#2583): Replace dataTable with mat-table in LivePreviewTable
component
---
.../live-preview-table.component.html | 56 +++++++++++-----------
.../live-preview-table.component.ts | 25 ++++++----
.../pipeline-element-runtime-info.component.scss | 9 ----
.../pipeline-element-runtime-info.component.ts | 7 ++-
4 files changed, 48 insertions(+), 49 deletions(-)
diff --git
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.html
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.html
index a82a165364..86c9e7641d 100644
---
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.html
+++
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.html
@@ -1,36 +1,34 @@
<div data-cy="sp-connect-adapter-success-live-preview">
<p>Here is a preview of your data:</p>
- <table class="dataTable row-border hover">
- <thead>
- <tr>
- <th>Runtime Name</th>
- <th>Value</th>
- </tr>
- </thead>
- <tbody id="preview-data-rows-id">
- <tr
- *ngFor="let property of eventSchema.eventProperties"
- class="preview-row"
- >
- <td>{{ property.runtimeName }}</td>
- <td *ngIf="isImage(property)">
+ <table mat-table [dataSource]="runtimeData">
+ <ng-container matColumnDef="runtimeName">
+ <th mat-header-cell *matHeaderCellDef>
+ <strong>Runtime Name</strong>
+ </th>
+ <td mat-cell *matCellDef="let element">
+ {{ element.runtimeName }}
+ </td>
+ </ng-container>
+
+ <ng-container matColumnDef="value">
+ <th mat-header-cell *matHeaderCellDef><strong>Value</strong></th>
+ <td mat-cell *matCellDef="let element">
+ <ng-container *ngIf="isImage(element.runtimeName)">
<img
- src="data:image/png;base64,{{
- runtimeData[property.runtimeName]
- }}"
+ src="data:image/png;base64,{{ element.value }}"
style="max-width: 150px"
/>
- </td>
- <td *ngIf="isTimestamp(property)">
- {{
- runtimeData[property.runtimeName]
- | date: 'yyyy-MM-dd HH:mm:ss '
- }}
- </td>
- <td *ngIf="hasNoDomainProperty(property)">
- {{ runtimeData[property.runtimeName] }}
- </td>
- </tr>
- </tbody>
+ </ng-container>
+ <ng-container *ngIf="isTimestamp(element.runtimeName)">
+ {{ element.value | date: 'yyyy-MM-dd HH:mm:ss ' }}
+ </ng-container>
+ <ng-container *ngIf="hasNoDomainProperty(element.runtimeName)">
+ {{ element.value }}
+ </ng-container>
+ </td>
+ </ng-container>
+
+ <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+ <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
</table>
</div>
diff --git
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.ts
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.ts
index f8cd0c2bb0..028f675eba 100644
---
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.ts
+++
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.ts
@@ -1,8 +1,5 @@
import { Component, Input } from '@angular/core';
-import {
- EventPropertyUnion,
- EventSchema,
-} from '@streampipes/platform-services';
+import { EventSchema } from '@streampipes/platform-services';
import { SemanticTypeUtilsService } from
'../../../core-services/semantic-type/semantic-type-utils.service';
@Component({
@@ -15,19 +12,29 @@ export class LivePreviewTableComponent {
eventSchema: EventSchema;
@Input()
- runtimeData: Record<string, any>;
+ runtimeData: { runtimeName: string; value: any }[];
+
+ displayedColumns: string[] = ['runtimeName', 'value'];
constructor(private semanticTypeUtilsService: SemanticTypeUtilsService) {}
- isImage(property: EventPropertyUnion) {
+ isImage(runtimeName: string) {
+ const property = this.getProperty(runtimeName);
return this.semanticTypeUtilsService.isImage(property);
}
- isTimestamp(property: EventPropertyUnion) {
+ isTimestamp(runtimeName: string) {
+ const property = this.getProperty(runtimeName);
return this.semanticTypeUtilsService.isTimestamp(property);
}
- hasNoDomainProperty(property: EventPropertyUnion) {
- return !(this.isTimestamp(property) || this.isImage(property));
+ hasNoDomainProperty(runtimeName: string) {
+ return !(this.isTimestamp(runtimeName) || this.isImage(runtimeName));
+ }
+
+ getProperty(runtimeName: string) {
+ return this.eventSchema.eventProperties.find(
+ property => property.runtimeName === runtimeName,
+ );
}
}
diff --git
a/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.scss
b/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.scss
index 442ccb57a6..13cbc4aacb 100644
---
a/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.scss
+++
b/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.scss
@@ -15,12 +15,3 @@
* limitations under the License.
*
*/
-
-.preview-row,
-.preview-table {
- background: var(--color-bg-dialog);
-}
-
-.dataTable tbody tr:hover {
- background: var(--color-bg-1);
-}
diff --git
a/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.ts
b/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.ts
index 2300901bd7..f66a7f5694 100644
---
a/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.ts
+++
b/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.ts
@@ -31,7 +31,7 @@ export class PipelineElementRuntimeInfoComponent implements
OnInit, OnDestroy {
_pollingActive: boolean;
- runtimeData: Record<string, any>;
+ runtimeData: { runtimeName: string; value: any }[];
timer: any;
runtimeDataError = false;
@@ -52,7 +52,10 @@ export class PipelineElementRuntimeInfoComponent implements
OnInit, OnDestroy {
.getRuntimeInfo(this.streamDescription)
.subscribe(data => {
this.runtimeDataError = !data;
- this.runtimeData = data;
+
+ this.runtimeData = Object.entries(data).map(
+ ([runtimeName, value]) => ({ runtimeName, value }),
+ );
this.timer = setTimeout(
() => this.getLatestRuntimeInfo(),