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 505fc4ecf4 refactor(#2585): Extract field names table into a component
505fc4ecf4 is described below
commit 505fc4ecf4cac83fe14f2100e66b519f99b0b073
Author: Philipp Zehnder <[email protected]>
AuthorDate: Wed Mar 20 07:16:26 2024 +0100
refactor(#2585): Extract field names table into a component
---
ui/src/app/NS/xs.service.ts | 8 +++
ui/src/app/core-ui/core-ui.module.ts | 2 +
.../help-field-names/field-names.component.html | 53 +++++++++++++++
.../field-names.component.scss} | 3 -
.../help-field-names/field-names.component.ts} | 37 +++++-----
ui/src/app/core-ui/help/help.component.html | 79 +++++-----------------
ui/src/app/core-ui/help/help.component.scss | 9 ---
ui/src/app/core-ui/help/help.component.ts | 24 -------
8 files changed, 100 insertions(+), 115 deletions(-)
diff --git a/ui/src/app/NS/xs.service.ts b/ui/src/app/NS/xs.service.ts
index a8eea881e3..03b2382194 100644
--- a/ui/src/app/NS/xs.service.ts
+++ b/ui/src/app/NS/xs.service.ts
@@ -22,6 +22,8 @@ import { Injectable } from '@angular/core';
export class XsService {
XS_STRING = 'xs:string';
XS_INTEGER = 'http://www.w3.org/2001/XMLSchema#integer';
+ XS_FLOAT = 'http://www.w3.org/2001/XMLSchema#float';
+ XS_LONG = 'http://www.w3.org/2001/XMLSchema#long';
XS_DOUBLE = 'http://www.w3.org/2001/XMLSchema#double';
XS_BOOLEAN = 'http://www.w3.org/2001/XMLSchema#boolean';
XS_NUMBER = 'http://www.w3.org/2001/XMLSchema#number';
@@ -32,7 +34,13 @@ export class XsService {
return (
datatype === this.XS_DOUBLE ||
datatype === this.XS_INTEGER ||
+ datatype === this.XS_LONG ||
+ datatype === this.XS_FLOAT ||
datatype === this.XS_NUMBER
);
}
+
+ isBoolean(datatype: string): boolean {
+ return datatype === this.XS_BOOLEAN;
+ }
}
diff --git a/ui/src/app/core-ui/core-ui.module.ts
b/ui/src/app/core-ui/core-ui.module.ts
index df1787ba2e..4652adb5b5 100644
--- a/ui/src/app/core-ui/core-ui.module.ts
+++ b/ui/src/app/core-ui/core-ui.module.ts
@@ -80,6 +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';
@NgModule({
imports: [
@@ -147,6 +148,7 @@ import { MarkdownModule } from 'ngx-markdown';
SpSimpleLogsComponent,
SpSimpleMetricsComponent,
StatusWidgetComponent,
+ FieldNamesComponent,
],
providers: [
MatDatepickerModule,
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
new file mode 100644
index 0000000000..547b9530d5
--- /dev/null
+++ b/ui/src/app/core-ui/help/help-field-names/field-names.component.html
@@ -0,0 +1,53 @@
+<!--
+ ~ 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.scss
b/ui/src/app/core-ui/help/help-field-names/field-names.component.scss
similarity index 95%
copy from ui/src/app/core-ui/help/help.component.scss
copy to ui/src/app/core-ui/help/help-field-names/field-names.component.scss
index c95de1b0e5..4253550047 100644
--- a/ui/src/app/core-ui/help/help.component.scss
+++ b/ui/src/app/core-ui/help/help-field-names/field-names.component.scss
@@ -15,9 +15,6 @@
* limitations under the License.
*
*/
-
-@import '../../../scss/sp/sp-dialog.scss';
-
.preview-row,
.preview-table {
background: var(--color-bg-dialog);
diff --git a/ui/src/app/NS/xs.service.ts
b/ui/src/app/core-ui/help/help-field-names/field-names.component.ts
similarity index 53%
copy from ui/src/app/NS/xs.service.ts
copy to ui/src/app/core-ui/help/help-field-names/field-names.component.ts
index a8eea881e3..5e7d6912e7 100644
--- a/ui/src/app/NS/xs.service.ts
+++ b/ui/src/app/core-ui/help/help-field-names/field-names.component.ts
@@ -16,23 +16,28 @@
*
*/
-import { Injectable } from '@angular/core';
+import { Component, Input } from '@angular/core';
+import { EventSchema } from '@streampipes/platform-services';
+import { XsService } from '../../../NS/xs.service';
-@Injectable()
-export class XsService {
- XS_STRING = 'xs:string';
- XS_INTEGER = 'http://www.w3.org/2001/XMLSchema#integer';
- XS_DOUBLE = 'http://www.w3.org/2001/XMLSchema#double';
- XS_BOOLEAN = 'http://www.w3.org/2001/XMLSchema#boolean';
- XS_NUMBER = 'http://www.w3.org/2001/XMLSchema#number';
- XS_STRING1 = 'http://www.w3.org/2001/XMLSchema#string';
- SO_URL = 'https://schema.org/URL';
+@Component({
+ selector: 'sp-field-names',
+ templateUrl: './field-names.component.html',
+ styleUrls: ['./field-names.component.scss'],
+})
+export class FieldNamesComponent {
+ @Input()
+ eventSchema: EventSchema;
- isNumber(datatype: string): boolean {
- return (
- datatype === this.XS_DOUBLE ||
- datatype === this.XS_INTEGER ||
- datatype === this.XS_NUMBER
- );
+ constructor(private xsService: XsService) {}
+
+ getFriendlyRuntimeType(runtimeType: string) {
+ if (this.xsService.isNumber(runtimeType)) {
+ return 'Number';
+ } else if (this.xsService.isBoolean(runtimeType)) {
+ return 'Boolean';
+ } else {
+ return 'Text';
+ }
}
}
diff --git a/ui/src/app/core-ui/help/help.component.html
b/ui/src/app/core-ui/help/help.component.html
index b17cd1f4bb..4608c78ad3 100644
--- a/ui/src/app/core-ui/help/help.component.html
+++ b/ui/src/app/core-ui/help/help.component.html
@@ -31,72 +31,25 @@
<mat-tab *ngFor="let tab of tabs" label="{{ tab.title }}">
</mat-tab>
</mat-tab-group>
- <div style="margin-top: 15px">
- <div *ngIf="selectedIndex === 0 && streamMode">
- <h5>Field Names</h5>
- <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 pipelineElement.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>
- <div *ngIf="selectedIndex === 1 && streamMode">
- <div>
- <sp-pipeline-element-runtime-info
- [streamDescription]="pipelineElement"
- [pollingActive]="pollingActive"
- ></sp-pipeline-element-runtime-info>
- </div>
- </div>
- <div *ngIf="selectedTab === 2 || !streamMode">
- <sp-pipeline-element-documentation
- [useStyling]="false"
- [appId]="pipelineElement.appId"
- ></sp-pipeline-element-documentation>
- </div>
- </div>
+ <sp-field-names
+ *ngIf="selectedIndex === 0 && streamMode"
+ [eventSchema]="pipelineElement.eventSchema"
+ ></sp-field-names>
+ <sp-pipeline-element-runtime-info
+ *ngIf="selectedIndex === 1 && streamMode"
+ [streamDescription]="pipelineElement"
+ [pollingActive]="pollingActive"
+ ></sp-pipeline-element-runtime-info>
+ <sp-pipeline-element-documentation
+ *ngIf="selectedTab === 2 || !streamMode"
+ [useStyling]="false"
+ [appId]="pipelineElement.appId"
+ ></sp-pipeline-element-documentation>
</div>
+
<mat-divider></mat-divider>
+
<div class="sp-dialog-actions actions-align-right">
<button
mat-button
diff --git a/ui/src/app/core-ui/help/help.component.scss
b/ui/src/app/core-ui/help/help.component.scss
index c95de1b0e5..ecf2724830 100644
--- a/ui/src/app/core-ui/help/help.component.scss
+++ b/ui/src/app/core-ui/help/help.component.scss
@@ -17,12 +17,3 @@
*/
@import '../../../scss/sp/sp-dialog.scss';
-
-.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.component.ts
b/ui/src/app/core-ui/help/help.component.ts
index d6d3cf0b08..3b596e5172 100644
--- a/ui/src/app/core-ui/help/help.component.ts
+++ b/ui/src/app/core-ui/help/help.component.ts
@@ -32,7 +32,6 @@ export class HelpComponent implements OnInit {
selectedIndex = 0;
- nsPrefix = 'http://www.w3.org/2001/XMLSchema#';
availableTabs = [
{
title: 'Fields',
@@ -71,29 +70,6 @@ export class HelpComponent implements OnInit {
}
}
- getFriendlyRuntimeType(runtimeType) {
- if (this.isNumber(runtimeType)) {
- return 'Number';
- } else if (this.isBoolean(runtimeType)) {
- return 'Boolean';
- } else {
- return 'Text';
- }
- }
-
- isNumber(runtimeType) {
- return (
- runtimeType === this.nsPrefix + 'float' ||
- runtimeType === this.nsPrefix + 'integer' ||
- runtimeType === this.nsPrefix + 'long' ||
- runtimeType === this.nsPrefix + 'double'
- );
- }
-
- isBoolean(runtimeType) {
- return runtimeType === this.nsPrefix + 'boolean';
- }
-
close() {
this.pollingActive = false;
setTimeout(() => {