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 2022/10/25 12:07:26 UTC
[incubator-streampipes] 02/02: [STREAMPIPES-597] add dialog that indicates when an adapter can not be edited
This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch STREAMPIPES-597
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit 0d43a8fb545ea3cddb838ea0376df14281cf9915
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Tue Oct 25 14:07:16 2022 +0200
[STREAMPIPES-597] add dialog that indicates when an adapter can not be edited
---
.../streampipes/rest/impl/PipelineResource.java | 69 ++--
.../adapter/editAdapterWithPipeline.smoke.spec.ts | 6 +-
.../src/lib/apis/pipeline.service.spec.ts | 12 +-
.../existing-adapters.component.ts | 398 ++++++++++++---------
ui/src/app/connect/connect.module.ts | 3 +
.../can-not-edit-adapter-dialog.component.cy.ts | 30 ++
.../can-not-edit-adapter-dialog.component.html | 36 ++
.../can-not-edit-adapter-dialog.component.scss | 1 +
.../can-not-edit-adapter-dialog.component.ts | 19 +
9 files changed, 378 insertions(+), 196 deletions(-)
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
index 2f2e636aa..64f512ed1 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
@@ -46,9 +46,20 @@ import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+
import java.util.List;
@Component
@@ -60,13 +71,13 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@Path("/own")
@JacksonSerialized
@Operation(summary = "Get all pipelines assigned to the current user",
- tags = {"Pipeline"},
- responses = {
- @ApiResponse(content = {
- @Content(
- mediaType = "application/json",
- array = @ArraySchema(schema = @Schema(implementation = Pipeline.class)))
- })})
+ tags = {"Pipeline"},
+ responses = {
+ @ApiResponse(content = {
+ @Content(
+ mediaType = "application/json",
+ array = @ArraySchema(schema = @Schema(implementation = Pipeline.class)))
+ })})
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE)
@PostFilter("hasPermission(filterObject.pipelineId, 'READ')")
public List<Pipeline> getOwn() {
@@ -78,7 +89,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@Path("/system")
@JacksonSerialized
@Operation(summary = "Get all system pipelines assigned to the current user",
- tags = {"Pipeline"})
+ tags = {"Pipeline"})
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE)
public Response getSystemPipelines() {
return ok(getPipelineStorage().getSystemPipelines());
@@ -89,7 +100,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@Path("/{pipelineId}/status")
@JacksonSerialized
@Operation(summary = "Get the pipeline status of a given pipeline",
- tags = {"Pipeline"})
+ tags = {"Pipeline"})
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE)
public Response getPipelineStatus(@PathParam("pipelineId") String pipelineId) {
return ok(PipelineStatusManager.getPipelineStatus(pipelineId, 5));
@@ -100,7 +111,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@Produces(MediaType.APPLICATION_JSON)
@JacksonSerialized
@Operation(summary = "Delete a pipeline with a given id",
- tags = {"Pipeline"})
+ tags = {"Pipeline"})
@PreAuthorize(AuthConstants.HAS_DELETE_PIPELINE_PRIVILEGE)
public Response removeOwn(@PathParam("pipelineId") String pipelineId) {
PipelineManager.deletePipeline(pipelineId);
@@ -112,7 +123,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@Produces(MediaType.APPLICATION_JSON)
@JacksonSerialized
@Operation(summary = "Get a specific pipeline with the given id",
- tags = {"Pipeline"})
+ tags = {"Pipeline"})
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE)
public Response getElement(@PathParam("pipelineId") String pipelineId) {
return ok(PipelineManager.getPipeline(pipelineId));
@@ -123,7 +134,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@Produces(MediaType.APPLICATION_JSON)
@JacksonSerialized
@Operation(summary = "Start the pipeline with the given id",
- tags = {"Pipeline"})
+ tags = {"Pipeline"})
@PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE)
public Response start(@PathParam("pipelineId") String pipelineId) {
try {
@@ -141,7 +152,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@Produces(MediaType.APPLICATION_JSON)
@JacksonSerialized
@Operation(summary = "Stop the pipeline with the given id",
- tags = {"Pipeline"})
+ tags = {"Pipeline"})
@PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE)
public Response stop(@PathParam("pipelineId") String pipelineId,
@QueryParam("forceStop") @DefaultValue("false") boolean forceStop) {
@@ -151,7 +162,9 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
} catch
(Exception e) {
e.printStackTrace();
- return constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR.title(), NotificationType.UNKNOWN_ERROR.description(), e.getMessage()));
+ return constructErrorMessage(
+ new Notification(NotificationType.UNKNOWN_ERROR.title(), NotificationType.UNKNOWN_ERROR.description(),
+ e.getMessage()));
}
}
@@ -159,7 +172,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@Produces(MediaType.APPLICATION_JSON)
@JacksonSerialized
@Operation(summary = "Store a new pipeline",
- tags = {"Pipeline"})
+ tags = {"Pipeline"})
@PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE)
public Response addPipeline(Pipeline pipeline) {
@@ -182,13 +195,14 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
return Operations.findRecommendedElements(pipeline, baseRecElement);
} catch (JsonSyntaxException e) {
throw new WebApplicationException(badRequest(new Notification(NotificationType.UNKNOWN_ERROR,
- e.getMessage())));
+ e.getMessage())));
} catch (NoSuitableSepasAvailableException e) {
throw new WebApplicationException(badRequest(new Notification(NotificationType.NO_SEPA_FOUND,
- e.getMessage())));
+ e.getMessage())));
} catch (Exception e) {
e.printStackTrace();
- throw new WebApplicationException(serverError(constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR,
+ throw new WebApplicationException(
+ serverError(constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR,
e.getMessage()))));
}
}
@@ -216,25 +230,25 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
return ok(Operations.validatePipeline(pipeline));
} catch (JsonSyntaxException e) {
return badRequest(new Notification(NotificationType.UNKNOWN_ERROR,
- e.getMessage()));
+ e.getMessage()));
} catch (NoMatchingSchemaException e) {
return badRequest(new Notification(NotificationType.NO_VALID_CONNECTION,
- e.getMessage()));
+ e.getMessage()));
} catch (NoMatchingFormatException e) {
return badRequest(new Notification(NotificationType.NO_MATCHING_FORMAT_CONNECTION,
- e.getMessage()));
+ e.getMessage()));
} catch (NoMatchingProtocolException e) {
return badRequest(new Notification(NotificationType.NO_MATCHING_PROTOCOL_CONNECTION,
- e.getMessage()));
+ e.getMessage()));
} catch (RemoteServerNotAccessibleException | NoMatchingJsonSchemaException e) {
return serverError(new Notification(NotificationType.REMOTE_SERVER_NOT_ACCESSIBLE
- , e.getMessage()));
+ , e.getMessage()));
} catch (InvalidConnectionException e) {
return badRequest(e.getErrorLog());
} catch (Exception e) {
e.printStackTrace();
return serverError(new Notification(NotificationType.UNKNOWN_ERROR,
- e.getMessage()));
+ e.getMessage()));
}
}
@@ -243,7 +257,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@Produces(MediaType.APPLICATION_JSON)
@JacksonSerialized
@Operation(summary = "Update an existing pipeline",
- tags = {"Pipeline"})
+ tags = {"Pipeline"})
@PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE)
public Response overwritePipeline(@PathParam("pipelineId") String pipelineId,
Pipeline pipeline) {
@@ -276,9 +290,10 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
})})
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE)
public List<Pipeline> getPipelinesContainingElements(@PathParam("elementId") String pipelineId) {
+
+ return PipelineManager.getAllPipelines();
// TODO What happens when user does not have privileges
// return PipelineManager.getAllPipelines();
- return null;
}
}
diff --git a/ui/cypress/tests/adapter/editAdapterWithPipeline.smoke.spec.ts b/ui/cypress/tests/adapter/editAdapterWithPipeline.smoke.spec.ts
index 00f405e56..07cf66431 100644
--- a/ui/cypress/tests/adapter/editAdapterWithPipeline.smoke.spec.ts
+++ b/ui/cypress/tests/adapter/editAdapterWithPipeline.smoke.spec.ts
@@ -38,7 +38,11 @@ describe('Test Edit Adapter', () => {
ConnectBtns.startAdapter().should('be.visible');
// ensure edit mode is still disabled
- ConnectBtns.editAdapter().should('be.disabled');
+ ConnectBtns.editAdapter().should('not.be.disabled');
+ ConnectBtns.editAdapter().click();
+
+ cy.dataCy('can-not-edit-adapter-dialog-warning').should('be.visible');
+ cy.dataCy('can-not-edit-adapter-dialog-close').click();
// Delete pipeline
PipelineUtils.deletePipeline();
diff --git a/ui/projects/streampipes/platform-services/src/lib/apis/pipeline.service.spec.ts b/ui/projects/streampipes/platform-services/src/lib/apis/pipeline.service.spec.ts
index 05e8cdc07..fdf8ad96e 100644
--- a/ui/projects/streampipes/platform-services/src/lib/apis/pipeline.service.spec.ts
+++ b/ui/projects/streampipes/platform-services/src/lib/apis/pipeline.service.spec.ts
@@ -42,15 +42,17 @@ describe('PipelineService', () => {
it('Get pipelines containing element', () => {
const elementId = 'elementId';
- const pipeline = new Pipeline();
- pipeline.name = 'Test Pipeline';
- const pipelines = [pipeline];
+ const expectedPipeline = new Pipeline();
+ expectedPipeline.name = 'Test Pipeline';
+ const expectedPipelines = [expectedPipeline];
pipelineService
.getPipelinesContainingElementId(elementId)
.subscribe(pipelines => {
expect(pipelines.length).toBe(1);
- expect(pipelines).toEqual(pipelines);
+ expect(pipelines[0]).toEqual(
+ jasmine.objectContaining(expectedPipeline),
+ );
});
const req = httpMock.expectOne({
@@ -58,6 +60,6 @@ describe('PipelineService', () => {
url: `${mockPath}/pipelines/contains/${elementId}`,
});
- req.flush(pipelines);
+ req.flush(expectedPipelines);
});
});
diff --git a/ui/src/app/connect/components/existing-adapters/existing-adapters.component.ts b/ui/src/app/connect/components/existing-adapters/existing-adapters.component.ts
index 2be628c7c..fd7480c2d 100644
--- a/ui/src/app/connect/components/existing-adapters/existing-adapters.component.ts
+++ b/ui/src/app/connect/components/existing-adapters/existing-adapters.component.ts
@@ -18,19 +18,20 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import {
- AdapterDescriptionUnion,
- AdapterService,
- PipelineElementService,
- StreamPipesErrorMessage
+ AdapterDescriptionUnion,
+ AdapterService,
+ PipelineElementService,
+ PipelineService,
+ StreamPipesErrorMessage,
} from '@streampipes/platform-services';
import { MatTableDataSource } from '@angular/material/table';
import { ConnectService } from '../../services/connect.service';
import {
- DialogRef,
- DialogService,
- PanelType,
- SpBreadcrumbService,
- SpExceptionDetailsDialogComponent
+ DialogRef,
+ DialogService,
+ PanelType,
+ SpBreadcrumbService,
+ SpExceptionDetailsDialogComponent,
} from '@streampipes/shared-ui';
import { DeleteAdapterDialogComponent } from '../../dialog/delete-adapter-dialog/delete-adapter-dialog.component';
import { MatPaginator } from '@angular/material/paginator';
@@ -43,168 +44,239 @@ import { Router } from '@angular/router';
import { AdapterFilterSettingsModel } from '../../model/adapter-filter-settings.model';
import { AdapterFilterPipe } from '../../filter/adapter-filter.pipe';
import { SpConnectRoutes } from '../../connect.routes';
+import { CanNotEditAdapterDialog } from '../../dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component';
@Component({
- selector: 'sp-existing-adapters',
- templateUrl: './existing-adapters.component.html',
- styleUrls: ['./existing-adapters.component.scss']
+ selector: 'sp-existing-adapters',
+ templateUrl: './existing-adapters.component.html',
+ styleUrls: ['./existing-adapters.component.scss'],
})
export class ExistingAdaptersComponent implements OnInit {
+ existingAdapters: AdapterDescriptionUnion[] = [];
+ filteredAdapters: AdapterDescriptionUnion[] = [];
- existingAdapters: AdapterDescriptionUnion[] = [];
- filteredAdapters: AdapterDescriptionUnion[] = [];
-
- currentFilter: AdapterFilterSettingsModel;
-
- @ViewChild(MatPaginator) paginator: MatPaginator;
- pageSize = 1;
- @ViewChild(MatSort) sort: MatSort;
-
- displayedColumns: string[] = ['start', 'name', 'adapterBase', 'adapterType', 'lastModified', 'action'];
-
- dataSource: MatTableDataSource<AdapterDescriptionUnion>;
- isAdmin = false;
-
- constructor(public connectService: ConnectService,
- private adapterService: AdapterService,
- private dialogService: DialogService,
- private authService: AuthService,
- private pipelineElementService: PipelineElementService,
- private router: Router,
- private adapterFilter: AdapterFilterPipe,
- private breadcrumbService: SpBreadcrumbService) {
-
- }
-
- ngOnInit(): void {
- this.breadcrumbService.updateBreadcrumb(this.breadcrumbService.getRootLink(SpConnectRoutes.BASE));
- this.authService.user$.subscribe(user => {
- this.isAdmin = user.roles.indexOf(UserRole.ROLE_ADMIN) > -1;
- this.getAdaptersRunning();
- });
- }
-
- startAdapter(adapter: AdapterDescriptionUnion) {
- this.adapterService.startAdapter(adapter).subscribe(_ => {
- this.getAdaptersRunning();
- }, error => {
- this.openAdapterStatusErrorDialog(error.error, 'Could not start adapter');
- });
- }
-
- stopAdapter(adapter: AdapterDescriptionUnion) {
- this.adapterService.stopAdapter(adapter).subscribe(_ => {
- this.getAdaptersRunning();
- }, error => {
- this.openAdapterStatusErrorDialog(error.error, 'Could not stop adapter');
- });
- }
-
- openAdapterStatusErrorDialog(message: StreamPipesErrorMessage,
- title: string) {
- this.dialogService.open(SpExceptionDetailsDialogComponent, {
- panelType: PanelType.STANDARD_PANEL,
- title: 'Adapter Status',
- width: '70vw',
- data: {
- 'message': message,
- 'title': title
- }
- });
- }
-
- getIconUrl(adapter: AdapterDescriptionUnion) {
- if (adapter.includedAssets.length > 0) {
- return this.adapterService.getAssetUrl(adapter.appId) + '/icon';
- } else {
- return 'assets/img/connect/' + adapter.iconUrl;
+ currentFilter: AdapterFilterSettingsModel;
+
+ @ViewChild(MatPaginator)
+ paginator: MatPaginator;
+ pageSize = 1;
+ @ViewChild(MatSort)
+ sort: MatSort;
+
+ displayedColumns: string[] = [
+ 'start',
+ 'name',
+ 'adapterBase',
+ 'adapterType',
+ 'lastModified',
+ 'action',
+ ];
+
+ dataSource: MatTableDataSource<AdapterDescriptionUnion>;
+ isAdmin = false;
+
+ constructor(
+ public connectService: ConnectService,
+ private adapterService: AdapterService,
+ private dialogService: DialogService,
+ private authService: AuthService,
+ private pipelineElementService: PipelineElementService,
+ private pipelineService: PipelineService,
+ private router: Router,
+ private adapterFilter: AdapterFilterPipe,
+ private breadcrumbService: SpBreadcrumbService,
+ ) {}
+
+ ngOnInit(): void {
+ this.breadcrumbService.updateBreadcrumb(
+ this.breadcrumbService.getRootLink(SpConnectRoutes.BASE),
+ );
+ this.authService.user$.subscribe(user => {
+ this.isAdmin = user.roles.indexOf(UserRole.ROLE_ADMIN) > -1;
+ this.getAdaptersRunning();
+ });
+ }
+
+ startAdapter(adapter: AdapterDescriptionUnion) {
+ this.adapterService.startAdapter(adapter).subscribe(
+ _ => {
+ this.getAdaptersRunning();
+ },
+ error => {
+ this.openAdapterStatusErrorDialog(
+ error.error,
+ 'Could not start adapter',
+ );
+ },
+ );
+ }
+
+ stopAdapter(adapter: AdapterDescriptionUnion) {
+ this.adapterService.stopAdapter(adapter).subscribe(
+ _ => {
+ this.getAdaptersRunning();
+ },
+ error => {
+ this.openAdapterStatusErrorDialog(
+ error.error,
+ 'Could not stop adapter',
+ );
+ },
+ );
}
- }
-
- showPermissionsDialog(adapter: AdapterDescriptionUnion) {
-
- const dialogRef = this.dialogService.open(ObjectPermissionDialogComponent, {
- panelType: PanelType.SLIDE_IN_PANEL,
- title: 'Manage permissions',
- width: '50vw',
- data: {
- 'objectInstanceId': adapter.correspondingDataStreamElementId,
- 'headerTitle': 'Manage permissions for adapter ' + adapter.name
- }
- });
-
- dialogRef.afterClosed().subscribe(refresh => {
- if (refresh) {
- this.getAdaptersRunning();
- }
- });
- }
-
- editAdapter(adapter: AdapterDescriptionUnion) {
- // TODO validate that adapter is not used in a pipeline
- this.router.navigate(['connect', 'edit', adapter.elementId]);
- }
-
- deleteAdapter(adapter: AdapterDescriptionUnion): void {
- const dialogRef: DialogRef<DeleteAdapterDialogComponent> = this.dialogService.open(DeleteAdapterDialogComponent, {
- panelType: PanelType.STANDARD_PANEL,
- title: 'Delete Adapter',
- width: '70vw',
- data: {
- 'adapter': adapter
- }
- });
-
- dialogRef.afterClosed().subscribe(data => {
- if (data) {
- this.getAdaptersRunning();
- }
- });
- }
-
- openHelpDialog(adapter: AdapterDescriptionUnion) {
- const streamId = adapter.correspondingDataStreamElementId;
-
- this.pipelineElementService.getDataStreamByElementId(streamId).subscribe(stream => {
- if (stream) {
- this.dialogService.open(HelpComponent, {
- panelType: PanelType.STANDARD_PANEL,
- title: stream.name,
- width: '70vw',
- data: {
- 'pipelineElement': stream
- }
+
+ openAdapterStatusErrorDialog(
+ message: StreamPipesErrorMessage,
+ title: string,
+ ) {
+ this.dialogService.open(SpExceptionDetailsDialogComponent, {
+ panelType: PanelType.STANDARD_PANEL,
+ title: 'Adapter Status',
+ width: '70vw',
+ data: {
+ message: message,
+ title: title,
+ },
});
- }
- });
- }
-
- getAdaptersRunning(): void {
- this.adapterService.getAdapters().subscribe(adapters => {
- this.existingAdapters = adapters;
- this.existingAdapters.sort((a, b) => a.name.localeCompare(b.name));
- this.filteredAdapters = this.adapterFilter.transform(this.existingAdapters, this.currentFilter);
- this.dataSource = new MatTableDataSource(this.filteredAdapters);
- setTimeout(() => {
- this.dataSource.paginator = this.paginator;
- this.dataSource.sort = this.sort;
- });
- });
- }
-
- createNewAdapter(): void {
- this.router.navigate(['connect', 'create']);
- }
-
- applyFilter(filter: AdapterFilterSettingsModel) {
- this.currentFilter = filter;
- if (this.dataSource) {
- this.dataSource.data = this.adapterFilter.transform(this.filteredAdapters, this.currentFilter);
}
- }
- navigateToDetailsOverviewPage(adapter: AdapterDescriptionUnion): void {
- this.router.navigate(['connect', 'details', adapter.elementId, 'metrics']);
- }
+ getIconUrl(adapter: AdapterDescriptionUnion) {
+ if (adapter.includedAssets.length > 0) {
+ return this.adapterService.getAssetUrl(adapter.appId) + '/icon';
+ } else {
+ return 'assets/img/connect/' + adapter.iconUrl;
+ }
+ }
+ showPermissionsDialog(adapter: AdapterDescriptionUnion) {
+ const dialogRef = this.dialogService.open(
+ ObjectPermissionDialogComponent,
+ {
+ panelType: PanelType.SLIDE_IN_PANEL,
+ title: 'Manage permissions',
+ width: '50vw',
+ data: {
+ objectInstanceId: adapter.correspondingDataStreamElementId,
+ headerTitle:
+ 'Manage permissions for adapter ' + adapter.name,
+ },
+ },
+ );
+
+ dialogRef.afterClosed().subscribe(refresh => {
+ if (refresh) {
+ this.getAdaptersRunning();
+ }
+ });
+ }
+
+ /**
+ * Start edit mode when adapter is not used within a pipeline, otherwise shows warning dialog
+ * @param adapter
+ */
+ editAdapter(adapter: AdapterDescriptionUnion) {
+ this.pipelineService
+ .getPipelinesContainingElementId(
+ adapter.correspondingDataStreamElementId,
+ )
+ .subscribe(effectedPipelines => {
+ if (effectedPipelines.length > 0) {
+ this.dialogService.open(
+ CanNotEditAdapterDialog,
+ {
+ panelType: PanelType.STANDARD_PANEL,
+ title: 'Edit error',
+ width: '50vw',
+ data: {
+ pipelines: effectedPipelines
+ },
+ },
+ );
+
+ } else {
+ this.router.navigate([
+ 'connect',
+ 'edit',
+ adapter.elementId,
+ ]);
+ }
+ });
+ }
+
+ deleteAdapter(adapter: AdapterDescriptionUnion): void {
+ const dialogRef: DialogRef<
+ DeleteAdapterDialogComponent
+ > = this.dialogService.open(DeleteAdapterDialogComponent, {
+ panelType: PanelType.STANDARD_PANEL,
+ title: 'Delete Adapter',
+ width: '70vw',
+ data: {
+ adapter: adapter,
+ },
+ });
+
+ dialogRef.afterClosed().subscribe(data => {
+ if (data) {
+ this.getAdaptersRunning();
+ }
+ });
+ }
+
+ openHelpDialog(adapter: AdapterDescriptionUnion) {
+ const streamId = adapter.correspondingDataStreamElementId;
+
+ this.pipelineElementService
+ .getDataStreamByElementId(streamId)
+ .subscribe(stream => {
+ if (stream) {
+ this.dialogService.open(HelpComponent, {
+ panelType: PanelType.STANDARD_PANEL,
+ title: stream.name,
+ width: '70vw',
+ data: {
+ pipelineElement: stream,
+ },
+ });
+ }
+ });
+ }
+
+ getAdaptersRunning(): void {
+ this.adapterService.getAdapters().subscribe(adapters => {
+ this.existingAdapters = adapters;
+ this.existingAdapters.sort((a, b) => a.name.localeCompare(b.name));
+ this.filteredAdapters = this.adapterFilter.transform(
+ this.existingAdapters,
+ this.currentFilter,
+ );
+ this.dataSource = new MatTableDataSource(this.filteredAdapters);
+ setTimeout(() => {
+ this.dataSource.paginator = this.paginator;
+ this.dataSource.sort = this.sort;
+ });
+ });
+ }
+
+ createNewAdapter(): void {
+ this.router.navigate(['connect', 'create']);
+ }
+
+ applyFilter(filter: AdapterFilterSettingsModel) {
+ this.currentFilter = filter;
+ if (this.dataSource) {
+ this.dataSource.data = this.adapterFilter.transform(
+ this.filteredAdapters,
+ this.currentFilter,
+ );
+ }
+ }
+
+ navigateToDetailsOverviewPage(adapter: AdapterDescriptionUnion): void {
+ this.router.navigate([
+ 'connect',
+ 'details',
+ adapter.elementId,
+ 'metrics',
+ ]);
+ }
}
diff --git a/ui/src/app/connect/connect.module.ts b/ui/src/app/connect/connect.module.ts
index a2870443f..5fa2a0052 100644
--- a/ui/src/app/connect/connect.module.ts
+++ b/ui/src/app/connect/connect.module.ts
@@ -88,6 +88,8 @@ import { SpAdapterDetailsOverviewComponent } from './components/adapter-details/
import { SpAdapterDetailsLogsComponent } from './components/adapter-details/adapter-details-logs/adapter-details-logs.component';
import { SpAdapterDetailsMetricsComponent } from './components/adapter-details/adapter-details-metrics/adapter-details-metrics.component';
import { SpecificAdapterConfigurationComponent } from './components/adapter-configuration/specific-adapter-configuration/specific-adapter-configuration.component';
+import { CanNotEditAdapterDialog } from './dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component';
+
@NgModule({
imports: [
CoreUiModule,
@@ -188,6 +190,7 @@ import { SpecificAdapterConfigurationComponent } from './components/adapter-conf
NewAdapterComponent,
EditAdapterComponent,
EventSchemaErrorHintsComponent,
+ CanNotEditAdapterDialog,
],
providers: [
RestService,
diff --git a/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.cy.ts b/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.cy.ts
new file mode 100644
index 000000000..fd3f95d0f
--- /dev/null
+++ b/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.cy.ts
@@ -0,0 +1,30 @@
+import { CanNotEditAdapterDialog } from './can-not-edit-adapter-dialog.component';
+import { DialogRef } from '@streampipes/shared-ui';
+import { Pipeline } from '@streampipes/platform-services';
+
+describe('CanNotEditAdapterDialog', () => {
+
+ it('Show error message and containing pipelines', () => {
+ const expectedPipelineName = 'Demo pipeline';
+ const pipeline = new Pipeline();
+ pipeline.name = expectedPipelineName;
+
+ mount(`<sp-can-not-edit-adapter-dialog
+ [pipelines]="pipelines">
+ </sp-can-not-edit-adapter-dialog>`,
+ {'pipelines': [pipeline]});
+
+ cy.dataCy('can-not-edit-adapter-dialog-warning').should('be.visible');
+ cy.dataCy('adapter-in-pipeline').should('have.length', 1);
+ cy.dataCy('adapter-in-pipeline').contains(expectedPipelineName);
+ });
+
+
+ const mount = (template: string, cp?) => {
+ cy.mount(template, {
+ declarations: [CanNotEditAdapterDialog],
+ providers: [{ provide: DialogRef, useValue: {}}],
+ componentProperties: cp
+ });
+ };
+});
diff --git a/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.html b/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.html
new file mode 100644
index 000000000..f3f14f988
--- /dev/null
+++ b/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.html
@@ -0,0 +1,36 @@
+<div class="sp-dialog-container">
+ <div class="sp-dialog-content p-15">
+ <div fxLayout="column">
+ <div fxLayout="column">
+ <div fxFlex="100"
+ fxLayoutAlign="center center"
+ fxLayout="column"
+ data-cy="can-not-edit-adapter-dialog-warning">
+ <b><h4>This adapter can not be edited.</h4></b>
+ <h5>It is used in the following pipelines:</h5>
+ </div>
+ </div>
+
+
+ <div fxFlex="100" fxLayout="column" class="w-100">
+ <div fxFlex="100" fxLayout="column" class="mat-elevation-z1 mt-10"
+ *ngFor="let pipeline of pipelines"
+ data-cy="adapter-in-pipeline">
+ <div fxFlex="100" fxLayout="column" class="p-15">
+ {{pipeline.name}}
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <mat-divider></mat-divider>
+ <div class="sp-dialog-actions actions-align-right">
+ <button mat-button
+ mat-raised-button
+ class="mat-basic"
+ (click)="close()"
+ data-cy="can-not-edit-adapter-dialog-close">
+ Close
+ </button>
+ </div>
+</div>
diff --git a/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.scss b/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.scss
new file mode 100644
index 000000000..f7f33c988
--- /dev/null
+++ b/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.scss
@@ -0,0 +1 @@
+@import '../../../../scss/sp/sp-dialog.scss';
diff --git a/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.ts b/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.ts
new file mode 100644
index 000000000..85fac48e6
--- /dev/null
+++ b/ui/src/app/connect/dialog/can-not-edit-adapter-dialog/can-not-edit-adapter-dialog.component.ts
@@ -0,0 +1,19 @@
+import { Component, Input } from '@angular/core';
+import { DialogRef } from '@streampipes/shared-ui';
+import { Pipeline } from '@streampipes/platform-services';
+
+@Component({
+ selector: 'sp-can-not-edit-adapter-dialog',
+ templateUrl: './can-not-edit-adapter-dialog.component.html',
+ styleUrls: ['./can-not-edit-adapter-dialog.component.scss'],
+})
+export class CanNotEditAdapterDialog {
+ @Input()
+ pipelines: Pipeline[];
+
+ constructor(public dialogRef: DialogRef<CanNotEditAdapterDialog>) {}
+
+ close() {
+ this.dialogRef.close();
+ }
+}