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 2024/03/20 17:14:50 UTC

(streampipes) branch 2585-remove-datatable-from-helpcomponent updated: refactor(#2585): Replace dataTable with mat table in help component.

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

zehnder pushed a commit to branch 2585-remove-datatable-from-helpcomponent
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/2585-remove-datatable-from-helpcomponent by this push:
     new 60bd012544 refactor(#2585): Replace dataTable with mat table in help component.
60bd012544 is described below

commit 60bd012544d95390ec4fc1e1d72f6f21ccbc084a
Author: Philipp Zehnder <te...@users.noreply.github.com>
AuthorDate: Wed Mar 20 18:14:21 2024 +0100

    refactor(#2585): Replace dataTable with mat table in help component.
---
 ui/src/app/core-ui/core-ui.module.ts               |  4 +-
 .../field-names-table.component.html               | 64 ++++++++++++++++++++++
 .../field-names-table.component.scss}              |  8 ---
 .../field-names-table.component.ts}                | 15 +++--
 .../help-field-names/field-names.component.html    | 53 ------------------
 ui/src/app/core-ui/help/help.component.html        | 17 +++---
 ui/src/app/core-ui/help/help.component.ts          | 29 ++--------
 7 files changed, 89 insertions(+), 101 deletions(-)

diff --git a/ui/src/app/core-ui/core-ui.module.ts b/ui/src/app/core-ui/core-ui.module.ts
index 4652adb5b5..4f8622e469 100644
--- a/ui/src/app/core-ui/core-ui.module.ts
+++ b/ui/src/app/core-ui/core-ui.module.ts
@@ -80,7 +80,7 @@ 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 { FieldNamesComponent } from './help/help-field-names/field-names.component';
+import { FieldNamesTableComponent } from './help/field-names-table/field-names-table.component';
 
 @NgModule({
     imports: [
@@ -148,7 +148,7 @@ import { FieldNamesComponent } from './help/help-field-names/field-names.compone
         SpSimpleLogsComponent,
         SpSimpleMetricsComponent,
         StatusWidgetComponent,
-        FieldNamesComponent,
+        FieldNamesTableComponent,
     ],
     providers: [
         MatDatepickerModule,
diff --git a/ui/src/app/core-ui/help/field-names-table/field-names-table.component.html b/ui/src/app/core-ui/help/field-names-table/field-names-table.component.html
new file mode 100644
index 0000000000..b41f0f8e2c
--- /dev/null
+++ b/ui/src/app/core-ui/help/field-names-table/field-names-table.component.html
@@ -0,0 +1,64 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~
+  -->
+
+<div>
+    <div>
+        <table
+            mat-table
+            [dataSource]="eventSchema.eventProperties"
+            class="mat-mdc-table mdc-data-table__table"
+        >
+            <ng-container matColumnDef="label">
+                <th mat-header-cell *matHeaderCellDef>
+                    <strong>Field Name</strong>
+                </th>
+                <td mat-cell *matCellDef="let property">
+                    {{ property.label ? property.label : '(n/a)' }}
+                </td>
+            </ng-container>
+
+            <ng-container matColumnDef="description">
+                <th mat-header-cell *matHeaderCellDef>
+                    <strong>Description</strong>
+                </th>
+                <td mat-cell *matCellDef="let property">
+                    {{ property.description ? property.description : '(n/a)' }}
+                </td>
+            </ng-container>
+
+            <ng-container matColumnDef="runtimeName">
+                <th mat-header-cell *matHeaderCellDef>
+                    <strong>Runtime Name</strong>
+                </th>
+                <td mat-cell *matCellDef="let property">
+                    {{ property.runtimeName }}
+                </td>
+            </ng-container>
+
+            <ng-container matColumnDef="runtimeType">
+                <th mat-header-cell *matHeaderCellDef><strong>Type</strong></th>
+                <td mat-cell *matCellDef="let property">
+                    {{ getFriendlyRuntimeType(property.runtimeType) }}
+                </td>
+            </ng-container>
+
+            <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+            <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
+        </table>
+    </div>
+</div>
diff --git a/ui/src/app/core-ui/help/help-field-names/field-names.component.scss b/ui/src/app/core-ui/help/field-names-table/field-names-table.component.scss
similarity index 85%
rename from ui/src/app/core-ui/help/help-field-names/field-names.component.scss
rename to ui/src/app/core-ui/help/field-names-table/field-names-table.component.scss
index 4253550047..13cbc4aacb 100644
--- a/ui/src/app/core-ui/help/help-field-names/field-names.component.scss
+++ b/ui/src/app/core-ui/help/field-names-table/field-names-table.component.scss
@@ -15,11 +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/help/help-field-names/field-names.component.ts b/ui/src/app/core-ui/help/field-names-table/field-names-table.component.ts
similarity index 81%
rename from ui/src/app/core-ui/help/help-field-names/field-names.component.ts
rename to ui/src/app/core-ui/help/field-names-table/field-names-table.component.ts
index 5e7d6912e7..afc7a66489 100644
--- a/ui/src/app/core-ui/help/help-field-names/field-names.component.ts
+++ b/ui/src/app/core-ui/help/field-names-table/field-names-table.component.ts
@@ -21,14 +21,21 @@ import { EventSchema } from '@streampipes/platform-services';
 import { XsService } from '../../../NS/xs.service';
 
 @Component({
-    selector: 'sp-field-names',
-    templateUrl: './field-names.component.html',
-    styleUrls: ['./field-names.component.scss'],
+    selector: 'sp-field-names-table',
+    templateUrl: './field-names-table.component.html',
+    styleUrls: ['./field-names-table.component.scss'],
 })
-export class FieldNamesComponent {
+export class FieldNamesTableComponent {
     @Input()
     eventSchema: EventSchema;
 
+    displayedColumns: string[] = [
+        'label',
+        'description',
+        'runtimeName',
+        'runtimeType',
+    ];
+
     constructor(private xsService: XsService) {}
 
     getFriendlyRuntimeType(runtimeType: string) {
diff --git a/ui/src/app/core-ui/help/help-field-names/field-names.component.html b/ui/src/app/core-ui/help/help-field-names/field-names.component.html
deleted file mode 100644
index 547b9530d5..0000000000
--- a/ui/src/app/core-ui/help/help-field-names/field-names.component.html
+++ /dev/null
@@ -1,53 +0,0 @@
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~    http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  ~
-  -->
-
-<div>
-    <div>
-        <table class="dataTable row-border hover preview-table">
-            <thead>
-                <tr class="preview-row">
-                    <th>Field Name</th>
-                    <th>Description</th>
-                    <th>Runtime Name</th>
-                    <th>Type</th>
-                </tr>
-            </thead>
-            <tbody id="preview-data-rows-id">
-                <tr
-                    *ngFor="let property of eventSchema.eventProperties"
-                    class="preview-row"
-                >
-                    <td>
-                        {{ property.label ? property.label : '(n/a)' }}
-                    </td>
-                    <td>
-                        {{
-                            property.description
-                                ? property.description
-                                : '(n/a)'
-                        }}
-                    </td>
-                    <td>{{ property.runtimeName }}</td>
-                    <td>
-                        {{ getFriendlyRuntimeType(property.runtimeType) }}
-                    </td>
-                </tr>
-            </tbody>
-        </table>
-    </div>
-</div>
diff --git a/ui/src/app/core-ui/help/help.component.html b/ui/src/app/core-ui/help/help.component.html
index 4608c78ad3..156f892059 100644
--- a/ui/src/app/core-ui/help/help.component.html
+++ b/ui/src/app/core-ui/help/help.component.html
@@ -25,24 +25,23 @@
 
         <mat-tab-group
             color="accent"
-            [selectedIndex]="selectedIndex"
-            (selectedIndexChange)="selectedIndex = $event"
+            [selectedIndex]="selectedTabIndex"
+            (selectedIndexChange)="selectedTabIndex = $event"
         >
-            <mat-tab *ngFor="let tab of tabs" label="{{ tab.title }}">
-            </mat-tab>
+            <mat-tab *ngFor="let tab of tabs" label="{{ tab }}"> </mat-tab>
         </mat-tab-group>
 
-        <sp-field-names
-            *ngIf="selectedIndex === 0 && streamMode"
+        <sp-field-names-table
+            *ngIf="selectedTabIndex === 0"
             [eventSchema]="pipelineElement.eventSchema"
-        ></sp-field-names>
+        ></sp-field-names-table>
         <sp-pipeline-element-runtime-info
-            *ngIf="selectedIndex === 1 && streamMode"
+            *ngIf="selectedTabIndex === 1"
             [streamDescription]="pipelineElement"
             [pollingActive]="pollingActive"
         ></sp-pipeline-element-runtime-info>
         <sp-pipeline-element-documentation
-            *ngIf="selectedTab === 2 || !streamMode"
+            *ngIf="selectedTabIndex === 2"
             [useStyling]="false"
             [appId]="pipelineElement.appId"
         ></sp-pipeline-element-documentation>
diff --git a/ui/src/app/core-ui/help/help.component.ts b/ui/src/app/core-ui/help/help.component.ts
index 3b596e5172..59389287f1 100644
--- a/ui/src/app/core-ui/help/help.component.ts
+++ b/ui/src/app/core-ui/help/help.component.ts
@@ -27,31 +27,11 @@ import { PipelineElementUnion } from '../../editor/model/editor.model';
     styleUrls: ['./help.component.scss'],
 })
 export class HelpComponent implements OnInit {
-    selectedTab = 0;
     pollingActive: boolean;
+    selectedTabIndex = 0;
 
-    selectedIndex = 0;
-
-    availableTabs = [
-        {
-            title: 'Fields',
-            type: 'fields',
-            targets: ['set', 'stream'],
-        },
-        {
-            title: 'Values',
-            type: 'values',
-            targets: ['set', 'stream'],
-        },
-        {
-            title: 'Documentation',
-            type: 'documentation',
-            targets: ['set', 'stream', 'sepa', 'action'],
-        },
-    ];
-
-    tabs: any[] = [];
-    streamMode: boolean;
+    availableTabs = ['Fields', 'Values', 'Documentation'];
+    tabs: string[] = [];
 
     @Input()
     pipelineElement: PipelineElementUnion;
@@ -63,10 +43,9 @@ export class HelpComponent implements OnInit {
     ngOnInit() {
         if (this.pipelineElement instanceof SpDataStream) {
             this.tabs = this.availableTabs;
-            this.streamMode = true;
         } else {
             this.tabs.push(this.availableTabs[2]);
-            this.streamMode = false;
+            this.selectedTabIndex = 2;
         }
     }