This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch
2235-no-pipeline-connections-when-editing-a-pipeline
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to
refs/heads/2235-no-pipeline-connections-when-editing-a-pipeline by this push:
new e7ebb5920 fix(#2235): Use lodash for deep copy
e7ebb5920 is described below
commit e7ebb5920646dc9b957095c8edf98a5c84257b0f
Author: Philipp Zehnder <[email protected]>
AuthorDate: Wed Nov 29 09:11:38 2023 +0100
fix(#2235): Use lodash for deep copy
---
ui/package-lock.json | 1 +
ui/package.json | 1 +
.../pipeline-element-options.component.ts | 51 +++-------------------
.../app/editor/services/jsplumb-bridge.service.ts | 1 -
.../app/editor/services/object-provider.service.ts | 28 +++++++-----
5 files changed, 25 insertions(+), 57 deletions(-)
diff --git a/ui/package-lock.json b/ui/package-lock.json
index 1eddf947c..edf64ef93 100644
--- a/ui/package-lock.json
+++ b/ui/package-lock.json
@@ -51,6 +51,7 @@
"jshint": "^2.13.6",
"konva": "9.2.0",
"leaflet": "1.9.3",
+ "lodash": "4.17.21",
"material-icons": "^1.13.1",
"ngx-color-picker": "^14.0.0",
"ngx-echarts": "^15.0.3",
diff --git a/ui/package.json b/ui/package.json
index 89408d636..3bcc38516 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -73,6 +73,7 @@
"jshint": "^2.13.6",
"konva": "9.2.0",
"leaflet": "1.9.3",
+ "lodash": "4.17.21",
"material-icons": "^1.13.1",
"ngx-color-picker": "^14.0.0",
"ngx-echarts": "^15.0.3",
diff --git
a/ui/src/app/editor/components/pipeline-element-options/pipeline-element-options.component.ts
b/ui/src/app/editor/components/pipeline-element-options/pipeline-element-options.component.ts
index a86eaed62..d03d38e49 100644
---
a/ui/src/app/editor/components/pipeline-element-options/pipeline-element-options.component.ts
+++
b/ui/src/app/editor/components/pipeline-element-options/pipeline-element-options.component.ts
@@ -17,8 +17,6 @@
*/
import { JsplumbBridge } from '../../services/jsplumb-bridge.service';
-import { JsplumbService } from '../../services/jsplumb.service';
-import { PipelineValidationService } from
'../../services/pipeline-validation.service';
import { RestApi } from '../../../services/rest-api.service';
import {
Component,
@@ -41,6 +39,7 @@ import {
SpDataStream,
WildcardTopicDefinition,
} from '@streampipes/platform-services';
+import { cloneDeep } from 'lodash';
import { EditorService } from '../../services/editor.service';
import { DialogService, PanelType } from '@streampipes/shared-ui';
import { CompatibleElementsComponent } from
'../../dialog/compatible-elements/compatible-elements.component';
@@ -91,7 +90,7 @@ export class PipelineElementOptionsComponent implements
OnInit, OnDestroy {
pipelineElementConfiguredObservable: Subscription;
- JsplumbBridge: JsplumbBridge;
+ jsplumbBridge: JsplumbBridge;
constructor(
private objectProvider: ObjectProvider,
@@ -99,15 +98,13 @@ export class PipelineElementOptionsComponent implements
OnInit, OnDestroy {
private dialogService: DialogService,
private editorService: EditorService,
private jsplumbFactoryService: JsplumbFactoryService,
- private jsplumbService: JsplumbService,
- private pipelineValidationService: PipelineValidationService,
private restApi: RestApi,
) {
this.recommendationsAvailable = false;
this.possibleElements = [];
this.recommendedElements = [];
this.recommendationsShown = false;
- this.JsplumbBridge =
this.jsplumbFactoryService.getJsplumbBridge(false);
+ this.jsplumbBridge =
this.jsplumbFactoryService.getJsplumbBridge(false);
}
ngOnInit() {
@@ -158,8 +155,8 @@ export class PipelineElementOptionsComponent implements
OnInit, OnDestroy {
//
this.EditorDialogManager.showCustomizeStreamDialog(this.pipelineElement.payload);
}
- initRecs(pipelineElementDomId) {
- const clonedModel: PipelineElementConfig[] = this.deepCopy(
+ initRecs(pipelineElementDomId: string) {
+ const clonedModel: PipelineElementConfig[] = cloneDeep(
this.rawPipelineModel,
);
const currentPipeline = this.objectProvider.makePipeline(clonedModel);
@@ -167,13 +164,13 @@ export class PipelineElementOptionsComponent implements
OnInit, OnDestroy {
.recommendPipelineElement(currentPipeline, pipelineElementDomId)
.subscribe(result => {
if (result.success) {
- this.possibleElements = this.deepCopy(
+ this.possibleElements = cloneDeep(
this.pipelineElementRecommendationService.collectPossibleElements(
this.allElements,
result.possibleElements,
),
);
- this.recommendedElements = this.deepCopy(
+ this.recommendedElements = cloneDeep(
this.pipelineElementRecommendationService.populateRecommendedList(
this.allElements,
result.recommendedElements,
@@ -203,16 +200,6 @@ export class PipelineElementOptionsComponent implements
OnInit, OnDestroy {
e.stopPropagation();
}
- isRootElement() {
- return (
- this.JsplumbBridge.getConnections({
- source: document.getElementById(
- this.pipelineElement.payload.dom,
- ),
- }).length === 0
- );
- }
-
isWildcardTopic() {
return (
(this.pipelineElement.payload as SpDataStream).eventGrounding
@@ -224,28 +211,4 @@ export class PipelineElementOptionsComponent implements
OnInit, OnDestroy {
ngOnDestroy(): void {
this.pipelineElementConfiguredObservable.unsubscribe();
}
-
- deepCopy(obj) {
- let clone: any = {};
- if (
- obj === null ||
- typeof obj !== 'object' ||
- Array.isArray(obj) ||
- obj === undefined
- ) {
- return obj;
- }
-
- if (Array.isArray(obj)) {
- clone = obj.map(item => this.deepCopy(item));
- }
-
- for (const key in obj) {
- if (obj.hasOwnProperty(key)) {
- clone[key] = this.deepCopy(obj[key]);
- }
- }
-
- return clone;
- }
}
diff --git a/ui/src/app/editor/services/jsplumb-bridge.service.ts
b/ui/src/app/editor/services/jsplumb-bridge.service.ts
index 28facb635..7cb0697b1 100644
--- a/ui/src/app/editor/services/jsplumb-bridge.service.ts
+++ b/ui/src/app/editor/services/jsplumb-bridge.service.ts
@@ -41,7 +41,6 @@ export class JsplumbBridge {
setEndpointType(endpointId: string, endpointType: string) {
const endpoint = this.getEndpointById(endpointId);
- // @ts-ignore
endpoint.setType(endpointType);
}
diff --git a/ui/src/app/editor/services/object-provider.service.ts
b/ui/src/app/editor/services/object-provider.service.ts
index 0aad0827f..002b9d6ba 100644
--- a/ui/src/app/editor/services/object-provider.service.ts
+++ b/ui/src/app/editor/services/object-provider.service.ts
@@ -17,7 +17,6 @@
*/
import { Injectable } from '@angular/core';
-import { RestApi } from '../../services/rest-api.service';
import {
InvocablePipelineElementUnion,
PipelineElementConfig,
@@ -29,7 +28,6 @@ import { JsplumbFactoryService } from
'./jsplumb-factory.service';
@Injectable({ providedIn: 'root' })
export class ObjectProvider {
constructor(
- private restApi: RestApi,
private editorService: EditorService,
private jsplumbFactoryService: JsplumbFactoryService,
) {}
@@ -50,11 +48,11 @@ export class ObjectProvider {
return pipeline;
}
- makeFinalPipeline(currentPipelineElements) {
+ makeFinalPipeline(currentPipelineElements: PipelineElementConfig[]) {
return this.makePipeline(currentPipelineElements);
}
- makePipeline(currentPipelineElements): Pipeline {
+ makePipeline(currentPipelineElements: PipelineElementConfig[]): Pipeline {
let pipeline = this.preparePipeline();
pipeline = this.addElementNew(pipeline, currentPipelineElements);
return pipeline;
@@ -100,28 +98,34 @@ export class ObjectProvider {
pipeline,
currentPipelineElements: PipelineElementConfig[],
): Pipeline {
- const JsplumbBridge =
+ const jsplumbBridge =
this.jsplumbFactoryService.getJsplumbBridge(false);
- currentPipelineElements.forEach(pe => {
- if (pe.settings.disabled === undefined || !pe.settings.disabled) {
- if (pe.type === 'sepa' || pe.type === 'action') {
- let payload = pe.payload;
+ currentPipelineElements.forEach(pipelineElementConfig => {
+ if (
+ pipelineElementConfig.settings.disabled === undefined ||
+ !pipelineElementConfig.settings.disabled
+ ) {
+ if (
+ pipelineElementConfig.type === 'sepa' ||
+ pipelineElementConfig.type === 'action'
+ ) {
+ let payload = pipelineElementConfig.payload;
payload = this.prepareElement(
payload as InvocablePipelineElementUnion,
);
- const connections = JsplumbBridge.getConnections({
+ const connections = jsplumbBridge.getConnections({
target: document.getElementById(payload.dom),
});
for (let i = 0; i < connections.length; i++) {
payload.connectedTo.push(connections[i].sourceId);
}
if (payload.connectedTo && payload.connectedTo.length > 0)
{
- pe.type === 'action'
+ pipelineElementConfig.type === 'action'
? pipeline.actions.push(payload)
: pipeline.sepas.push(payload);
}
} else {
- pipeline.streams.push(pe.payload);
+ pipeline.streams.push(pipelineElementConfig.payload);
}
}
});