Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
unocelli committed Jul 1, 2023
2 parents 898f2f1 + bb5fedb commit 924fe4b
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 22 deletions.
2 changes: 1 addition & 1 deletion client/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
</div>
</div>
</app-root>
<script src="runtime.8ef63094e52a66ba.js" type="module"></script><script src="polyfills.2696a6f9dc75535e.js" type="module"></script><script src="scripts.1c3385254ff4c93c.js" defer></script><script src="main.ea8974d98bc4b8fb.js" type="module"></script>
<script src="runtime.8ef63094e52a66ba.js" type="module"></script><script src="polyfills.2696a6f9dc75535e.js" type="module"></script><script src="scripts.1c3385254ff4c93c.js" defer></script><script src="main.a9b8410c074ef73e.js" type="module"></script>

</body></html>
1 change: 1 addition & 0 deletions client/dist/main.a9b8410c074ef73e.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion client/dist/main.ea8974d98bc4b8fb.js

This file was deleted.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fuxa",
"version": "1.1.14-1235",
"version": "1.1.14-1241",
"keywords": [],
"author": "frangoteam <[email protected]>",
"description": "Web-based Process Visualization (SCADA/HMI/Dashboard) software",
Expand Down
14 changes: 14 additions & 0 deletions client/src/app/_helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ export class Utils {
return null;
}

static getInTreeIdAndType(element: Element): any[] {
let type = element.getAttribute('type');
let id = element.getAttribute('id');
let result = [];
if (id && type) {
result = [{ id: id, type: type }];
}
for (var i = 0; i < element.children.length; i++) {
const idsAndTypes = Utils.getInTreeIdAndType(element.children[i]);
result = [...result, ...idsAndTypes];
}
return result;
}

static isNullOrUndefined(ele) {
return (ele === null || ele === undefined) ? true : false;
}
Expand Down
53 changes: 35 additions & 18 deletions client/src/app/editor/editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,24 +235,7 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
}
},
(copiedPasted) => {
if (copiedPasted && copiedPasted.copy && copiedPasted.past) {
copiedPasted.copy = copiedPasted.copy.filter(function(e) { return e; });
if (copiedPasted.copy.length == copiedPasted.past.length) {
for (let i = 0; i < copiedPasted.copy.length; i++) {
let srcType = copiedPasted.copy[i].getAttribute('type');
let srcId = copiedPasted.copy[i].getAttribute('id');
if (srcId) {
let gaSrc: GaugeSettings = this.searchGaugeSettings({ id: srcId, type: srcType });
if (gaSrc) {
let gaDest: GaugeSettings = this.gaugesManager.createSettings(copiedPasted.past[i].id, gaSrc.type);
gaDest.property = JSON.parse(JSON.stringify(gaSrc.property));
this.setGaugeSettings(gaDest);
this.checkGaugeAdded(gaDest);
}
}
}
}
}
this.onCopyAndPaste(copiedPasted);
}
);

Expand Down Expand Up @@ -664,6 +647,35 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
this.checkMySelectedToSetColor(null, this.colorStroke, this.winRef.nativeWindow.svgEditor.getSelectedElements());
}

private onCopyAndPaste(copiedPasted: CopiedAndPasted) {
if (copiedPasted?.copy?.length && copiedPasted?.past?.length) {
const copied = copiedPasted.copy.filter(element => element !== null);
const pasted = copiedPasted.past.filter(element => element !== null);
if (copied.length == copiedPasted.past.length) {
for (let i = 0; i < copied.length; i++) {
const copiedIdsAndTypes = Utils.getInTreeIdAndType(copied[i]);
const pastedIdsAndTypes = Utils.getInTreeIdAndType(pasted[i]);
if (copiedIdsAndTypes.length === pastedIdsAndTypes.length) {
for (let j = 0; j < copiedIdsAndTypes.length; j++) {
if (copiedIdsAndTypes[j].id && pastedIdsAndTypes[j].id && copiedIdsAndTypes[j].type === pastedIdsAndTypes[j].type) {
let gaSrc: GaugeSettings = this.searchGaugeSettings(copiedIdsAndTypes[j]);
if (gaSrc) {
let gaDest: GaugeSettings = this.gaugesManager.createSettings(pastedIdsAndTypes[j].id, pastedIdsAndTypes[j].type);
gaDest.property = JSON.parse(JSON.stringify(gaSrc.property));
this.setGaugeSettings(gaDest);
this.checkGaugeAdded(gaDest);
}
} else {
console.error(`Inconsistent elements!`, `${copiedIdsAndTypes[j]}`, `${pastedIdsAndTypes[j]}`);
}
}
} else {
console.error('Between copied and pasted there are inconsistent elements!');
}
}
}
}
}

/**
* event from svg-editor: svg element removed
Expand Down Expand Up @@ -1423,6 +1435,11 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
}
}

interface CopiedAndPasted {
copy: HTMLElement[];
past: HTMLElement[];
}

@Component({
selector: 'dialog-new-doc',
templateUrl: 'newdoc.dialog.html',
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fuxa-server",
"version": "1.1.14-1240",
"version": "1.1.14-1241",
"description": "Web-based Process Visualization (SCADA/HMI/Dashboard) software",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 924fe4b

Please sign in to comment.