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 a0d6591b62..e5b5e264e7 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 @@ -36,6 +36,7 @@ import { Subscription } from 'rxjs'; import { HttpDownloadProgressEvent, HttpEventType } from '@angular/common/http'; import { LivePreviewService } from '../../services/live-preview.service'; import { RuntimeInfo } from './pipeline-element-runtime-info.model'; +import { PipelineElementSchemaService } from './pipeline-element-schema.service'; @Component({ selector: 'sp-pipeline-element-runtime-info', @@ -58,6 +59,7 @@ export class PipelineElementRuntimeInfoComponent implements OnInit, OnDestroy { constructor( private restService: RestService, private livePreviewService: LivePreviewService, + private pipelineELementSchemaService: PipelineElementSchemaService, ) {} ngOnInit(): void { @@ -71,46 +73,25 @@ export class PipelineElementRuntimeInfoComponent implements OnInit, OnDestroy { return { label: ep.label || 'n/a', description: ep.description || 'n/a', - runtimeType: this.getFriendlyRuntimeType(ep), + runtimeType: + this.pipelineELementSchemaService.getFriendlyRuntimeType( + ep, + ), runtimeName: ep.runtimeName, value: undefined, - isTimestamp: this.isTimestamp(ep), - isImage: this.isImage(ep), - hasNoDomainProperty: this.hasNoDomainProperty(ep), + isTimestamp: + this.pipelineELementSchemaService.isTimestamp(ep), + isImage: this.pipelineELementSchemaService.isImage(ep), + hasNoDomainProperty: + this.pipelineELementSchemaService.hasNoDomainProperty( + ep, + ), valueChanged: false, }; }) .sort((a, b) => a.runtimeName.localeCompare(b.runtimeName)); } - getFriendlyRuntimeType(ep: EventPropertyUnion) { - if (ep instanceof EventPropertyPrimitive) { - if (DataType.isNumberType(ep.runtimeType)) { - return 'Number'; - } else if (DataType.isBooleanType(ep.runtimeType)) { - return 'Boolean'; - } else { - return 'Text'; - } - } else if (ep instanceof EventPropertyList) { - return 'List'; - } else { - return 'Nested'; - } - } - - private isImage(ep: EventPropertyUnion) { - return SemanticType.isImage(ep); - } - - private isTimestamp(ep: EventPropertyUnion) { - return SemanticType.isTimestamp(ep); - } - - private hasNoDomainProperty(ep: EventPropertyUnion) { - return !(this.isTimestamp(ep) || this.isImage(ep)); - } - getLatestRuntimeInfo() { this.runtimeSub = this.restService .getRuntimeInfo(this.streamDescription) diff --git a/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-schema.service.ts b/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-schema.service.ts new file mode 100644 index 0000000000..710143fa00 --- /dev/null +++ b/ui/src/app/core-ui/pipeline-element-runtime-info/pipeline-element-schema.service.ts @@ -0,0 +1,61 @@ +/* + * 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. + * + */ + +import { Injectable } from '@angular/core'; +import { + DataType, + EventPropertyList, + EventPropertyPrimitive, + EventPropertyUnion, + SemanticType, +} from '@streampipes/platform-services'; + +@Injectable({ providedIn: 'root' }) +export class PipelineElementSchemaService { + getFriendlyRuntimeType(ep: EventPropertyUnion): string { + if (ep instanceof EventPropertyPrimitive) { + if (this.isTimestamp(ep)) { + return 'Timestamp'; + } else if (this.isImage(ep)) { + return 'Image'; + } else if (DataType.isNumberType(ep.runtimeType)) { + return 'Number'; + } else if (DataType.isBooleanType(ep.runtimeType)) { + return 'Boolean'; + } else { + return 'Text'; + } + } else if (ep instanceof EventPropertyList) { + return 'List'; + } else { + return 'Nested'; + } + } + + isImage(ep: EventPropertyUnion) { + return SemanticType.isImage(ep); + } + + isTimestamp(ep: EventPropertyUnion) { + return SemanticType.isTimestamp(ep); + } + + hasNoDomainProperty(ep: EventPropertyUnion) { + return !(this.isTimestamp(ep) || this.isImage(ep)); + } +} diff --git a/ui/src/app/editor/components/output-strategy/custom-output/custom-output-strategy.component.html b/ui/src/app/editor/components/output-strategy/custom-output/custom-output-strategy.component.html index c2321fe8e6..0e1fe9ca24 100644 --- a/ui/src/app/editor/components/output-strategy/custom-output/custom-output-strategy.component.html +++ b/ui/src/app/editor/components/output-strategy/custom-output/custom-output-strategy.component.html @@ -53,6 +53,7 @@