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 2a810e9be6 refactor: Remove duplicate import from dashboard module
2a810e9be6 is described below

commit 2a810e9be656427c6991965a6336ba343a2831c1
Author: Philipp Zehnder <[email protected]>
AuthorDate: Tue Mar 19 16:10:17 2024 +0100

    refactor: Remove duplicate import from dashboard module
---
 ui/src/app/connect/services/rest.service.ts        | 14 +----
 .../semantic-type/semantic-type-utils.service.ts   |  4 ++
 ui/src/app/core-ui/core-ui.module.ts               |  6 ++
 .../live-preview-error.component.html              |  3 +
 .../live-preview-error.component.scss              |  0
 .../live-preview-error.component.ts                |  8 +++
 .../live-preview-loading.component.html            | 14 +++++
 .../live-preview-loading.component.scss            |  0
 .../live-preview-loading.component.ts              |  8 +++
 .../live-preview-table.component.html              | 36 +++++++++++
 .../live-preview-table.component.scss              |  0
 .../live-preview-table.component.ts                | 33 ++++++++++
 .../pipeline-element-runtime-info.component.html   | 72 ++++------------------
 .../pipeline-element-runtime-info.component.ts     | 55 +++--------------
 14 files changed, 132 insertions(+), 121 deletions(-)

diff --git a/ui/src/app/connect/services/rest.service.ts 
b/ui/src/app/connect/services/rest.service.ts
index 9f766a9fc6..73a8f42978 100644
--- a/ui/src/app/connect/services/rest.service.ts
+++ b/ui/src/app/connect/services/rest.service.ts
@@ -78,7 +78,7 @@ export class RestService {
             );
     }
 
-    getRuntimeInfo(sourceDescription): Observable<any> {
+    getRuntimeInfo(sourceDescription): Observable<Record<string, any>> {
         return this.http.post(
             
`${this.platformServicesCommons.apiBasePath}/pipeline-element/runtime`,
             sourceDescription,
@@ -88,18 +88,6 @@ export class RestService {
         );
     }
 
-    // getFormats(): Observable<FormatDescription[]> {
-    //     return this.http
-    //         .get(`${this.connectPath}/master/description/formats`)
-    //         .pipe(
-    //             map(response => {
-    //                 return (response as any[]).map(f =>
-    //                     FormatDescription.fromData(f),
-    //                 );
-    //             }),
-    //         );
-    // }
-
     getFittingUnits(
         unitDescription: UnitDescription,
     ): Observable<UnitDescription[]> {
diff --git 
a/ui/src/app/core-services/semantic-type/semantic-type-utils.service.ts 
b/ui/src/app/core-services/semantic-type/semantic-type-utils.service.ts
index a56a3f48c7..f93d2eeddf 100644
--- a/ui/src/app/core-services/semantic-type/semantic-type-utils.service.ts
+++ b/ui/src/app/core-services/semantic-type/semantic-type-utils.service.ts
@@ -39,6 +39,10 @@ export class SemanticTypeUtilsService {
         return property.domainProperties.includes(this.TIMESTAMP);
     }
 
+    public isImage(property: EventProperty): boolean {
+        return property.domainProperties.includes(this.IMAGE);
+    }
+
     public is(property: EventProperty, uri: string): boolean {
         return property.domainProperties.includes(uri);
     }
diff --git a/ui/src/app/core-ui/core-ui.module.ts 
b/ui/src/app/core-ui/core-ui.module.ts
index df1787ba2e..2fb9be2263 100644
--- a/ui/src/app/core-ui/core-ui.module.ts
+++ b/ui/src/app/core-ui/core-ui.module.ts
@@ -80,6 +80,9 @@ import { HelpComponent } from './help/help.component';
 import { PipelineElementRuntimeInfoComponent } from 
'./pipeline-element-runtime-info/pipeline-element-runtime-info.component';
 import { PipelineElementDocumentationComponent } from 
'./pipeline-element-documentation/pipeline-element-documentation.component';
 import { MarkdownModule } from 'ngx-markdown';
+import { LivePreviewLoadingComponent } from 
'./pipeline-element-runtime-info/live-preview-loading/live-preview-loading.component';
+import { LivePreviewTableComponent } from 
'./pipeline-element-runtime-info/live-preview-table/live-preview-table.component';
+import { LivePreviewErrorComponent } from 
'./pipeline-element-runtime-info/live-preview-error/live-preview-error.component';
 
 @NgModule({
     imports: [
@@ -147,6 +150,9 @@ import { MarkdownModule } from 'ngx-markdown';
         SpSimpleLogsComponent,
         SpSimpleMetricsComponent,
         StatusWidgetComponent,
+        LivePreviewLoadingComponent,
+        LivePreviewTableComponent,
+        LivePreviewErrorComponent,
     ],
     providers: [
         MatDatepickerModule,
diff --git 
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-error/live-preview-error.component.html
 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-error/live-preview-error.component.html
new file mode 100644
index 0000000000..11343365a2
--- /dev/null
+++ 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-error/live-preview-error.component.html
@@ -0,0 +1,3 @@
+<div>
+    <p>Preview is currently unavailable.</p>
+</div>
diff --git 
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-error/live-preview-error.component.scss
 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-error/live-preview-error.component.scss
new file mode 100644
index 0000000000..e69de29bb2
diff --git 
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-error/live-preview-error.component.ts
 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-error/live-preview-error.component.ts
new file mode 100644
index 0000000000..f6d47037d1
--- /dev/null
+++ 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-error/live-preview-error.component.ts
@@ -0,0 +1,8 @@
+import { Component } from '@angular/core';
+
+@Component({
+    selector: 'sp-live-preview-error',
+    templateUrl: './live-preview-error.component.html',
+    styleUrls: ['./live-preview-error.component.scss'],
+})
+export class LivePreviewErrorComponent {}
diff --git 
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-loading/live-preview-loading.component.html
 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-loading/live-preview-loading.component.html
new file mode 100644
index 0000000000..5e52dc3a3a
--- /dev/null
+++ 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-loading/live-preview-loading.component.html
@@ -0,0 +1,14 @@
+<div fxLayout="column" data-cy="sp-connect-adapter-gathering-live-preview">
+    <div fxLayoutAlign="center">
+        <mat-spinner
+            [diameter]="40"
+            fxLayoutAlign="center"
+            style="margin: 10px 0 5px 0"
+            color="accent"
+            >Loading
+        </mat-spinner>
+    </div>
+    <div fxLayoutAlign="center">
+        <h3>Gathering data for live preview...</h3>
+    </div>
+</div>
diff --git 
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-loading/live-preview-loading.component.scss
 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-loading/live-preview-loading.component.scss
new file mode 100644
index 0000000000..e69de29bb2
diff --git 
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-loading/live-preview-loading.component.ts
 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-loading/live-preview-loading.component.ts
new file mode 100644
index 0000000000..cae3cd038a
--- /dev/null
+++ 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-loading/live-preview-loading.component.ts
@@ -0,0 +1,8 @@
+import { Component } from '@angular/core';
+
+@Component({
+    selector: 'sp-live-preview-loading',
+    templateUrl: './live-preview-loading.component.html',
+    styleUrls: ['./live-preview-loading.component.scss'],
+})
+export class LivePreviewLoadingComponent {}
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
new file mode 100644
index 0000000000..a82a165364
--- /dev/null
+++ 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.html
@@ -0,0 +1,36 @@
+<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)">
+                    <img
+                        src="data:image/png;base64,{{
+                            runtimeData[property.runtimeName]
+                        }}"
+                        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>
+    </table>
+</div>
diff --git 
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.scss
 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.scss
new file mode 100644
index 0000000000..e69de29bb2
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
new file mode 100644
index 0000000000..f8cd0c2bb0
--- /dev/null
+++ 
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.ts
@@ -0,0 +1,33 @@
+import { Component, Input } from '@angular/core';
+import {
+    EventPropertyUnion,
+    EventSchema,
+} from '@streampipes/platform-services';
+import { SemanticTypeUtilsService } from 
'../../../core-services/semantic-type/semantic-type-utils.service';
+
+@Component({
+    selector: 'sp-live-preview-table',
+    templateUrl: './live-preview-table.component.html',
+    styleUrls: ['./live-preview-table.component.scss'],
+})
+export class LivePreviewTableComponent {
+    @Input()
+    eventSchema: EventSchema;
+
+    @Input()
+    runtimeData: Record<string, any>;
+
+    constructor(private semanticTypeUtilsService: SemanticTypeUtilsService) {}
+
+    isImage(property: EventPropertyUnion) {
+        return this.semanticTypeUtilsService.isImage(property);
+    }
+
+    isTimestamp(property: EventPropertyUnion) {
+        return this.semanticTypeUtilsService.isTimestamp(property);
+    }
+
+    hasNoDomainProperty(property: EventPropertyUnion) {
+        return !(this.isTimestamp(property) || this.isImage(property));
+    }
+}
diff --git 
a/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.html
 
b/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.html
index df6e739e0f..f480c1a760 100644
--- 
a/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.html
+++ 
b/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-runtime-info.component.html
@@ -16,64 +16,14 @@
   ~
   -->
 
-<div *ngIf="!runtimeData && !runtimeDataError">
-    <div fxLayout="column">
-        <div fxLayoutAlign="center">
-            <mat-spinner
-                [diameter]="40"
-                fxLayoutAlign="center"
-                style="margin: 10px 0 5px 0"
-                color="accent"
-                >Loading</mat-spinner
-            >
-        </div>
-        <div
-            fxLayoutAlign="center"
-            data-cy="sp-connect-adapter-gathering-live-preview"
-        >
-            <h3>Gathering data for live preview...</h3>
-        </div>
-    </div>
-</div>
-<div *ngIf="runtimeData" 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 streamDescription.eventSchema
-                        .eventProperties
-                "
-                class="preview-row"
-            >
-                <td>{{ property.runtimeName }}</td>
-                <td *ngIf="isImage(property)">
-                    <img
-                        src="data:image/png;base64,{{
-                            runtimeData[property.runtimeName]
-                        }}"
-                        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>
-    </table>
-</div>
-<div *ngIf="runtimeDataError">
-    <p>Preview is currently unavailable.</p>
-</div>
+<sp-live-preview-loading *ngIf="!runtimeData && !runtimeDataError">
+</sp-live-preview-loading>
+
+<sp-live-preview-table
+    *ngIf="runtimeData"
+    [eventSchema]="streamDescription.eventSchema"
+    [runtimeData]="runtimeData"
+>
+</sp-live-preview-table>
+
+<sp-live-preview-error *ngIf="runtimeDataError"> </sp-live-preview-error>
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 db068fd067..2300901bd7 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
@@ -17,10 +17,7 @@
  */
 
 import { Component, Input, OnDestroy, OnInit } from '@angular/core';
-import {
-    EventPropertyUnion,
-    SpDataStream,
-} from '@streampipes/platform-services';
+import { SpDataStream } from '@streampipes/platform-services';
 import { RestService } from '../../connect/services/rest.service';
 
 @Component({
@@ -34,7 +31,7 @@ export class PipelineElementRuntimeInfoComponent implements 
OnInit, OnDestroy {
 
     _pollingActive: boolean;
 
-    runtimeData: any;
+    runtimeData: Record<string, any>;
     timer: any;
     runtimeDataError = false;
 
@@ -54,52 +51,16 @@ export class PipelineElementRuntimeInfoComponent implements 
OnInit, OnDestroy {
         this.restService
             .getRuntimeInfo(this.streamDescription)
             .subscribe(data => {
-                if (data) {
-                    this.runtimeDataError = false;
-                    if (
-                        !(
-                            Object.keys(data).length === 0 &&
-                            data.constructor === Object
-                        )
-                    ) {
-                        this.runtimeData = data;
-                    }
+                this.runtimeDataError = !data;
+                this.runtimeData = data;
 
-                    if (this._pollingActive) {
-                        this.timer = setTimeout(() => {
-                            this.getLatestRuntimeInfo();
-                        }, 1000);
-                    }
-                } else {
-                    this.runtimeDataError = true;
-                }
+                this.timer = setTimeout(
+                    () => this.getLatestRuntimeInfo(),
+                    1000,
+                );
             });
     }
 
-    isPropertyType(property: EventPropertyUnion, type) {
-        return (
-            property.domainProperties !== undefined &&
-            property.domainProperties.length === 1 &&
-            property.domainProperties[0] === type
-        );
-    }
-
-    isImage(property) {
-        return this.isPropertyType(property, 'https://image.com');
-    }
-
-    isTimestamp(property) {
-        return this.isPropertyType(property, 'http://schema.org/DateTime');
-    }
-
-    hasNoDomainProperty(property) {
-        if (this.isTimestamp(property) || this.isImage(property)) {
-            return false;
-        } else {
-            return true;
-        }
-    }
-
     @Input()
     set pollingActive(pollingActive: boolean) {
         this._pollingActive = pollingActive;

Reply via email to