Skip to content

Commit

Permalink
Improve dialog in StreamPipes connect (#1934)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikriemer committed Sep 14, 2023
1 parent 2eb93c5 commit 8afc6a9
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,12 @@ protected DataProcessorDescription getProcessor(String id) throws ElementNotFoun
}

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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand All @@ -35,6 +36,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

@Path("/v2/pipeline-templates")
public class PipelineTemplate extends AbstractAuthGuardedRestResource {
Expand All @@ -60,11 +62,19 @@ public Response getPipelineTemplateInvocation(@QueryParam("streamId") String str
@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();
}
Expand All @@ -82,13 +92,12 @@ public Response generatePipeline(PipelineTemplateInvocation pipelineTemplateInvo
}


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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@ <h3>Adapter successfully updated</h3>
*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
>&nbsp;{{
templateErrorMessage.notifications[0].title
}}</span
>
</div>
</div>
<div
fxLayout="column"
fxLayoutAlign="center center"
Expand All @@ -70,7 +90,7 @@ <h3>Adapter successfully updated</h3>
>
<div>
<div
class="success-message"
class="info-message"
fxFlex="100"
fxLayoutAlign="center center"
fxLayout="row"
Expand All @@ -91,7 +111,7 @@ <h3>Adapter successfully updated</h3>
</div>
<div *ngIf="!adapterStatus.success">
<div
class="success-message"
class="info-message warning-message"
fxFlex="100"
fxLayoutAlign="center center"
fxLayout="row"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ShepherdService } from '../../../services/tour/shepherd.service';
import { RestService } from '../../services/rest.service';
import {
AdapterDescription,
ErrorMessage,
Message,
PipelineOperationStatus,
PipelineTemplateService,
Expand Down Expand Up @@ -69,6 +70,8 @@ export class AdapterStartedDialog implements OnInit {
*/
@Input() startAdapterNow = true;

templateErrorMessage: ErrorMessage;

constructor(
public dialogRef: DialogRef<AdapterStartedDialog>,
private adapterService: AdapterService,
Expand Down Expand Up @@ -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);
},
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<div fxLayout="row" fxLayoutGap="10px" fxLayoutAlign="start center">
<div>
<button
mat-button
mat-raised-button
color="accent"
class="small-button"
Expand Down Expand Up @@ -215,7 +214,6 @@
<span fxFlex>{{ selectedNode }}</span>
<div fxLayoutAlign="end center">
<button
mat-button
mat-icon-button
color="accent"
(click)="removeSelectedNode(selectedNode)"
Expand Down

0 comments on commit 8afc6a9

Please sign in to comment.