You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2023/09/14 18:39:55 UTC
[streampipes] branch 1934-improve-adapter-started-dialog-in-streampipes-connect updated: Improve dialog in StreamPipes connect (#1934)
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch 1934-improve-adapter-started-dialog-in-streampipes-connect
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/1934-improve-adapter-started-dialog-in-streampipes-connect by this push:
new 8afc6a980 Improve dialog in StreamPipes connect (#1934)
8afc6a980 is described below
commit 8afc6a9808daaeac15ab40a495fb20fe5d7bfd7c
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Thu Sep 14 20:38:34 2023 +0200
Improve dialog in StreamPipes connect (#1934)
---
.../template/PipelineTemplateGenerator.java | 10 ++--
.../streampipes/rest/impl/PipelineTemplate.java | 25 ++++++---
.../adapter-settings.component.html | 34 ++++++------
.../adapter-started-dialog.component.html | 24 ++++++++-
.../adapter-started-dialog.component.scss | 9 +++-
.../adapter-started-dialog.component.ts | 63 +++++++++++++---------
.../static-tree-input.component.html | 2 -
7 files changed, 105 insertions(+), 62 deletions(-)
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/template/PipelineTemplateGenerator.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/template/PipelineTemplateGenerator.java
index dfbbd9081..235e1b7e1 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/template/PipelineTemplateGenerator.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/template/PipelineTemplateGenerator.java
@@ -122,14 +122,12 @@ public class PipelineTemplateGenerator {
}
protected DataSinkDescription getSink(String id) throws ElementNotFoundException {
- DataSinkDescription result = getStorage()
- .getDataSinkByAppId(id);
-
- if (result == null) {
+ try {
+ return getStorage()
+ .getDataSinkByAppId(id);
+ } catch (IllegalArgumentException e) {
throw new ElementNotFoundException("Data stream " + id + " is not installed!");
}
-
- return result;
}
protected IPipelineElementDescriptionStorage getStorage() {
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineTemplate.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineTemplate.java
index 74221b3a7..43eb9234c 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineTemplate.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineTemplate.java
@@ -20,6 +20,7 @@ package org.apache.streampipes.rest.impl;
import org.apache.streampipes.manager.operations.Operations;
import org.apache.streampipes.model.SpDataStream;
import org.apache.streampipes.model.SpDataStreamContainer;
+import org.apache.streampipes.model.message.Notifications;
import org.apache.streampipes.model.pipeline.PipelineOperationStatus;
import org.apache.streampipes.model.template.PipelineTemplateDescription;
import org.apache.streampipes.model.template.PipelineTemplateInvocation;
@@ -35,6 +36,7 @@ import jakarta.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
@Path("/v2/pipeline-templates")
public class PipelineTemplate extends AbstractAuthGuardedRestResource {
@@ -60,11 +62,19 @@ public class PipelineTemplate extends AbstractAuthGuardedRestResource {
@QueryParam("templateId") String pipelineTemplateId) {
if (pipelineTemplateId != null) {
SpDataStream dataStream = getDataStream(streamId);
- PipelineTemplateDescription pipelineTemplateDescription = getPipelineTemplateDescription(pipelineTemplateId);
- PipelineTemplateInvocation invocation =
- Operations.getPipelineInvocationTemplate(dataStream, pipelineTemplateDescription);
- PipelineTemplateInvocation clonedInvocation = new PipelineTemplateInvocation(invocation);
- return ok(new PipelineTemplateInvocation(clonedInvocation));
+ var pipelineTemplateDescriptionOpt = getPipelineTemplateDescription(pipelineTemplateId);
+ if (pipelineTemplateDescriptionOpt.isPresent()) {
+ PipelineTemplateInvocation invocation =
+ Operations.getPipelineInvocationTemplate(dataStream, pipelineTemplateDescriptionOpt.get());
+ PipelineTemplateInvocation clonedInvocation = new PipelineTemplateInvocation(invocation);
+ return ok(new PipelineTemplateInvocation(clonedInvocation));
+ } else {
+ return badRequest(Notifications.error(
+ String.format(
+ "Could not create pipeline template %s - did you install all pipeline elements?",
+ pipelineTemplateId.substring(pipelineTemplateId.lastIndexOf(".") + 1))
+ ));
+ }
} else {
return fail();
}
@@ -82,13 +92,12 @@ public class PipelineTemplate extends AbstractAuthGuardedRestResource {
}
- private PipelineTemplateDescription getPipelineTemplateDescription(String pipelineTemplateId) {
+ private Optional<PipelineTemplateDescription> getPipelineTemplateDescription(String pipelineTemplateId) {
return Operations
.getAllPipelineTemplates()
.stream()
.filter(pt -> pt.getAppId().equals(pipelineTemplateId))
- .findFirst()
- .get();
+ .findFirst();
}
private List<SpDataStream> getAllDataStreams() {
diff --git a/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html b/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html
index 5fc885948..1e28a38f7 100644
--- a/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html
+++ b/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html
@@ -35,25 +35,23 @@
fxLayoutAlign="end center"
*ngIf="availableTemplates && availableTemplates.length > 0"
>
- <mat-form-field
- class="form-field"
- floatLabel="never"
- color="accent"
- >
- <mat-label>Use template</mat-label>
- <mat-select
- (selectionChange)="loadTemplate($event)"
- [(value)]="selectedTemplate"
- >
- <mat-option>--</mat-option>
- <mat-option
- [value]="template"
- *ngFor="let template of availableTemplates"
+ <div class="form-field-small">
+ <mat-form-field color="accent" appearance="outline">
+ <mat-label>Use template</mat-label>
+ <mat-select
+ (selectionChange)="loadTemplate($event)"
+ [(value)]="selectedTemplate"
>
- {{ template.templateName }}
- </mat-option>
- </mat-select>
- </mat-form-field>
+ <mat-option>--</mat-option>
+ <mat-option
+ [value]="template"
+ *ngFor="let template of availableTemplates"
+ >
+ {{ template.templateName }}
+ </mat-option>
+ </mat-select>
+ </mat-form-field>
+ </div>
</div>
</div>
<sp-configuration-group
diff --git a/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.html b/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.html
index b3addfc7c..a76b9dddb 100644
--- a/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.html
+++ b/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.html
@@ -50,6 +50,26 @@
*ngIf="adapterInstalled && !editMode"
class="w-100"
>
+ <div
+ fxLayout="column"
+ fxLayoutAlign="center center"
+ fxFlex="100"
+ *ngIf="saveInDataLake && templateErrorMessage"
+ >
+ <div
+ class="info-message warning-message"
+ fxFlex="100"
+ fxLayoutAlign="center center"
+ fxLayout="row"
+ >
+ <i class="material-icons">warning</i>
+ <span
+ > {{
+ templateErrorMessage.notifications[0].title
+ }}</span
+ >
+ </div>
+ </div>
<div
fxLayout="column"
fxLayoutAlign="center center"
@@ -70,7 +90,7 @@
>
<div>
<div
- class="success-message"
+ class="info-message"
fxFlex="100"
fxLayoutAlign="center center"
fxLayout="row"
@@ -91,7 +111,7 @@
</div>
<div *ngIf="!adapterStatus.success">
<div
- class="success-message"
+ class="info-message warning-message"
fxFlex="100"
fxLayoutAlign="center center"
fxLayout="row"
diff --git a/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.scss b/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.scss
index 91de402c9..2d6f70134 100644
--- a/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.scss
+++ b/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.scss
@@ -18,9 +18,16 @@
@import 'src/scss/sp/sp-dialog';
-.success-message {
+.info-message {
text-align: center;
font-size: 14pt;
margin-top: 20px;
margin-bottom: 20px;
}
+
+.warning-message {
+ border: 1px solid var(--color-warn);
+ padding: 10px;
+ font-size: 12pt;
+ background: var(--color-bg-2);
+}
diff --git a/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts b/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts
index b543ec098..73056e646 100644
--- a/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts
+++ b/ui/src/app/connect/dialog/adapter-started/adapter-started-dialog.component.ts
@@ -21,6 +21,7 @@ import { ShepherdService } from '../../../services/tour/shepherd.service';
import { RestService } from '../../services/rest.service';
import {
AdapterDescription,
+ ErrorMessage,
Message,
PipelineOperationStatus,
PipelineTemplateService,
@@ -69,6 +70,8 @@ export class AdapterStartedDialog implements OnInit {
*/
@Input() startAdapterNow = true;
+ templateErrorMessage: ErrorMessage;
+
constructor(
public dialogRef: DialogRef<AdapterStartedDialog>,
private adapterService: AdapterService,
@@ -157,31 +160,41 @@ export class AdapterStartedDialog implements OnInit {
adapter.correspondingDataStreamElementId,
pipelineId,
)
- .subscribe(res => {
- const pipelineName = 'Persist ' + this.adapter.name;
-
- const indexName = this.adapter.name;
-
- const pipelineInvocation = PipelineInvocationBuilder.create(
- res,
- )
- .setName(pipelineName)
- .setTemplateId(pipelineId)
- .setFreeTextStaticProperty('db_measurement', indexName)
- .setMappingPropertyUnary(
- 'timestamp_mapping',
- 's0::' + this.dataLakeTimestampField,
- )
- .build();
-
- this.pipelineTemplateService
- .createPipelineTemplateInvocation(pipelineInvocation)
- .subscribe(pipelineOperationStatus => {
- this.pipelineOperationStatus =
- pipelineOperationStatus;
- this.startAdapter(message, adapterElementId);
- });
- });
+ .subscribe(
+ res => {
+ const pipelineName = 'Persist ' + this.adapter.name;
+
+ const indexName = this.adapter.name;
+
+ const pipelineInvocation =
+ PipelineInvocationBuilder.create(res)
+ .setName(pipelineName)
+ .setTemplateId(pipelineId)
+ .setFreeTextStaticProperty(
+ 'db_measurement',
+ indexName,
+ )
+ .setMappingPropertyUnary(
+ 'timestamp_mapping',
+ 's0::' + this.dataLakeTimestampField,
+ )
+ .build();
+
+ this.pipelineTemplateService
+ .createPipelineTemplateInvocation(
+ pipelineInvocation,
+ )
+ .subscribe(pipelineOperationStatus => {
+ this.pipelineOperationStatus =
+ pipelineOperationStatus;
+ this.startAdapter(message, adapterElementId);
+ });
+ },
+ res => {
+ this.templateErrorMessage = res.error;
+ this.startAdapter(message, adapterElementId);
+ },
+ );
});
}
}
diff --git a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html
index be883f96d..4ac42a35b 100644
--- a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html
+++ b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html
@@ -20,7 +20,6 @@
<div fxLayout="row" fxLayoutGap="10px" fxLayoutAlign="start center">
<div>
<button
- mat-button
mat-raised-button
color="accent"
class="small-button"
@@ -215,7 +214,6 @@
<span fxFlex>{{ selectedNode }}</span>
<div fxLayoutAlign="end center">
<button
- mat-button
mat-icon-button
color="accent"
(click)="removeSelectedNode(selectedNode)"