From e31b1a24c3e3d36fc3ebbf2ef31111f56ca3eed3 Mon Sep 17 00:00:00 2001
From: Sunil Shetye
Date: Fri, 25 Sep 2020 19:10:14 +0530
Subject: setting displayProperties via api
---
.../SchematicEditor/Helper/ComponentDrag.js | 4 +-
.../components/SchematicEditor/Helper/SvgParser.js | 16 +--
.../redux/actions/componentPropertiesActions.js | 24 ++--
.../redux/reducers/componentPropertiesReducer.js | 6 +-
.../src/static/gallery/AFFICH_Xcos_on_Cloud.png | Bin 0 -> 9642 bytes
blocks/eda-frontend/src/utils/GallerySchSample.js | 136 ++++++++++++++-------
6 files changed, 125 insertions(+), 61 deletions(-)
create mode 100644 blocks/eda-frontend/src/static/gallery/AFFICH_Xcos_on_Cloud.png
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js
index b66de100..b744d797 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js
@@ -58,10 +58,10 @@ export default function LoadGrid (container, sidebar, outline) {
mxCell.prototype.Pin = false
// Parent component of a pin, default is null
mxCell.prototype.ParentComponent = null
- mxCell.prototype.symbol = null
mxCell.prototype.node = null
mxCell.prototype.CompObject = null
mxCell.prototype.parameter_values = {}
+ mxCell.prototype.displayProperties = {}
mxCell.prototype.sourceVertex = false
mxCell.prototype.targetVertex = false
mxCell.prototype.tarx = 0
@@ -254,10 +254,12 @@ export default function LoadGrid (container, sidebar, outline) {
store.subscribe(() => {
var id = store.getState().componentPropertiesReducer.id
var parameter_values = store.getState().componentPropertiesReducer.parameter_values
+ var displayProperties = store.getState().componentPropertiesReducer.displayProperties
var cellList = graph.getModel().cells
var c = cellList[id]
if (c !== undefined) {
c.parameter_values = parameter_values
+ c.displayProperties = displayProperties
}
})
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/Helper/SvgParser.js b/blocks/eda-frontend/src/components/SchematicEditor/Helper/SvgParser.js
index 2d5e3890..996daf33 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/Helper/SvgParser.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/Helper/SvgParser.js
@@ -34,13 +34,15 @@ export function getSvgMetadata (graph, parent, evt, target, x, y, component) {
v1.Component = true
v1.CellType = 'Component'
v1.block_id = component.id
- v1.explicit_input_ports = component.initial_explicit_input_ports
- v1.implicit_input_ports = component.initial_implicit_input_ports
- v1.control_ports = component.initial_control_ports
- v1.explicit_output_ports = component.initial_explicit_output_ports
- v1.implicit_output_ports = component.initial_implicit_output_ports
- v1.command_ports = component.initial_command_ports
- v1.display_parameter = component.initial_display_parameter
+ v1.displayProperties = {
+ explicit_input_ports: component.initial_explicit_input_ports,
+ implicit_input_ports: component.initial_implicit_input_ports,
+ control_ports: component.initial_control_ports,
+ explicit_output_ports: component.initial_explicit_output_ports,
+ implicit_output_ports: component.initial_implicit_output_ports,
+ command_ports: component.initial_command_ports,
+ display_parameter: component.initial_display_parameter,
+ }
let parameter_values = {};
for (let i = 0; i < 40; i++) {
let p = getParameter(i) + '_value';
diff --git a/blocks/eda-frontend/src/redux/actions/componentPropertiesActions.js b/blocks/eda-frontend/src/redux/actions/componentPropertiesActions.js
index 39e8f3ce..1de3d9aa 100644
--- a/blocks/eda-frontend/src/redux/actions/componentPropertiesActions.js
+++ b/blocks/eda-frontend/src/redux/actions/componentPropertiesActions.js
@@ -22,13 +22,23 @@ export const getCompProperties = (block) => (dispatch) => {
// Actions for updating entered component properites on clicking set parameters
export const setCompProperties = (id, parameter_values) => (dispatch) => {
- dispatch({
- type: actions.SET_COMP_PROPERTIES,
- payload: {
- id: id,
- parameter_values: parameter_values
- }
- })
+ const url = 'setblockparameter'
+ const filtered_parameter_values = Object.fromEntries(Object.entries(parameter_values).filter(([k, v]) => v != null))
+ const data = { block_id: id, ...filtered_parameter_values }
+ api.post(url, data)
+ .then(
+ (res) => {
+ dispatch({
+ type: actions.SET_COMP_PROPERTIES,
+ payload: {
+ id: id,
+ parameter_values: parameter_values,
+ displayProperties: res.data
+ }
+ })
+ }
+ )
+ .catch((err) => { console.error(err) })
}
// Handling hiding of compProperties sidebar
diff --git a/blocks/eda-frontend/src/redux/reducers/componentPropertiesReducer.js b/blocks/eda-frontend/src/redux/reducers/componentPropertiesReducer.js
index 701b54e8..a2c44304 100644
--- a/blocks/eda-frontend/src/redux/reducers/componentPropertiesReducer.js
+++ b/blocks/eda-frontend/src/redux/reducers/componentPropertiesReducer.js
@@ -5,7 +5,8 @@ const InitialState = {
id: 0,
parameter_values: {},
isPropertiesWindowOpen: false,
- compProperties: {}
+ compProperties: {},
+ displayProperties: {}
}
export default function (state = InitialState, action) {
@@ -25,7 +26,8 @@ export default function (state = InitialState, action) {
...state,
id: action.payload.id,
parameter_values: action.payload.parameter_values,
- isPropertiesWindowOpen: false
+ isPropertiesWindowOpen: false,
+ displayProperties: action.payload.displayProperties
}
}
diff --git a/blocks/eda-frontend/src/static/gallery/AFFICH_Xcos_on_Cloud.png b/blocks/eda-frontend/src/static/gallery/AFFICH_Xcos_on_Cloud.png
new file mode 100644
index 00000000..e9cb4394
Binary files /dev/null and b/blocks/eda-frontend/src/static/gallery/AFFICH_Xcos_on_Cloud.png differ
diff --git a/blocks/eda-frontend/src/utils/GallerySchSample.js b/blocks/eda-frontend/src/utils/GallerySchSample.js
index 768ddf47..8083ec3b 100644
--- a/blocks/eda-frontend/src/utils/GallerySchSample.js
+++ b/blocks/eda-frontend/src/utils/GallerySchSample.js
@@ -3,52 +3,100 @@
const GallerySchSample = [
{
save_id: 'gallery0',
- data_dump: '',
- name: 'Voltage Divider',
- description: 'A voltage divider is a simple circuit which turns a large voltage into a smaller one. Using just two series resistors and an input voltage.',
- media: 'gallery0.png',
+ data_dump: `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `,
+ name: 'AFFICH',
+ description: 'A simple AFFICH diagram',
+ media: 'AFFICH_Xcos_on_Cloud.png',
shared: true
},
- {
- save_id: 'gallery1',
- data_dump: '',
- name: 'RC Circuit',
- description: 'An RC circuit is a circuit with both a resistor (R) and a capacitor (C). RC circuits are freqent element in electronic devices.',
- media: 'gallery1.png',
- shared: true
- },
- {
- save_id: 'gallery2',
- data_dump: '',
- name: 'Dual RC Ladder',
- description: 'This is an dual RC ladder circuit with Passive components. The input is a voltage waveform (a pulse) versus time, and the output is a waveform as well. ',
- media: 'gallery2.png',
- shared: true
- },
- {
- save_id: 'gallery3',
- data_dump: '',
- name: 'Bipolar Amplifier',
- description: 'A basic BJT amplifier has a very high gain that may vary widely from one transistor to the next. A NPN bipolar transistor is the used as amplifying device.',
- media: 'gallery3.png',
- shared: true
- },
- {
- save_id: 'gallery4',
- data_dump: '',
- name: 'Shunt Clipper',
- description: 'A Clipper circuit in which the diode is connected in shunt to the input signal and that attenuates the positive portions of the waveform, is termed as Positive Shunt Clipper.',
- media: 'gallery4.png',
- shared: true
- },
- {
- save_id: 'gallery5',
- data_dump: '',
- name: 'RC Circuit ( Parallel )',
- description: 'An RC circuit is a circuit with both a resistor (R) and a capacitor (C). RC circuits are freqent element in electronic devices.',
- media: 'gallery5.png',
- shared: true
- }
]
export default GallerySchSample
--
cgit