This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new d5295c8be Remove lodash dependency from UI (#2193)
d5295c8be is described below
commit d5295c8bebe89797fb4f866b3d628deda5e695dd
Author: Marcelfrueh <[email protected]>
AuthorDate: Mon Nov 27 14:26:09 2023 +0100
Remove lodash dependency from UI (#2193)
* remove lodash
* Remove lodash from dependencies
* Modified deepCopy function
---
ui/angular.json | 2 +-
ui/package-lock.json | 1 -
ui/package.json | 1 -
.../pipeline-element-options.component.ts | 31 +++++++++++++++++++---
4 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/ui/angular.json b/ui/angular.json
index e9ef1b77d..710ed5025 100644
--- a/ui/angular.json
+++ b/ui/angular.json
@@ -18,7 +18,7 @@
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
- "allowedCommonJsDependencies": ["lodash", "codemirror"],
+ "allowedCommonJsDependencies": ["codemirror"],
"assets": [
"src/assets",
{
diff --git a/ui/package-lock.json b/ui/package-lock.json
index edf64ef93..1eddf947c 100644
--- a/ui/package-lock.json
+++ b/ui/package-lock.json
@@ -51,7 +51,6 @@
"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 3bcc38516..89408d636 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -73,7 +73,6 @@
"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 b409d77d5..a86eaed62 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
@@ -44,7 +44,6 @@ import {
import { EditorService } from '../../services/editor.service';
import { DialogService, PanelType } from '@streampipes/shared-ui';
import { CompatibleElementsComponent } from
'../../dialog/compatible-elements/compatible-elements.component';
-import { cloneDeep } from 'lodash';
import { Subscription } from 'rxjs';
import { JsplumbFactoryService } from '../../services/jsplumb-factory.service';
@@ -160,7 +159,7 @@ export class PipelineElementOptionsComponent implements
OnInit, OnDestroy {
}
initRecs(pipelineElementDomId) {
- const clonedModel: PipelineElementConfig[] = cloneDeep(
+ const clonedModel: PipelineElementConfig[] = this.deepCopy(
this.rawPipelineModel,
);
const currentPipeline = this.objectProvider.makePipeline(clonedModel);
@@ -168,13 +167,13 @@ export class PipelineElementOptionsComponent implements
OnInit, OnDestroy {
.recommendPipelineElement(currentPipeline, pipelineElementDomId)
.subscribe(result => {
if (result.success) {
- this.possibleElements = cloneDeep(
+ this.possibleElements = this.deepCopy(
this.pipelineElementRecommendationService.collectPossibleElements(
this.allElements,
result.possibleElements,
),
);
- this.recommendedElements = cloneDeep(
+ this.recommendedElements = this.deepCopy(
this.pipelineElementRecommendationService.populateRecommendedList(
this.allElements,
result.recommendedElements,
@@ -225,4 +224,28 @@ 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;
+ }
}