Skip to content

Commit

Permalink
clean code; error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
luisthieme committed Aug 21, 2024
1 parent 806165b commit dba6abf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
11 changes: 0 additions & 11 deletions nodes/ui-dynamic-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ module.exports = function (RED) {
// store the latest value in our Node-RED datastore
base.stores.data.save(base, node, msg);
},
onSocket: {
'my-custom-event': function (conn, id, msg) {
console.info('"my-custom-event" received:', conn.id, id, msg);
console.info('conn.id:', conn.id);
console.info('id:', id);
console.info('msg:', msg);
console.info('node.id:', node.id);
// emit a msg in Node-RED from this node
node.send(msg);
},
},
};

// inform the dashboard UI that we are adding this node
Expand Down
14 changes: 9 additions & 5 deletions ui/components/UIDynamicForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,19 @@ export default {
},
methods: {
injectDynamicStyles() {
const styleTag = document.createElement('style');
const colors = JSON.parse(localStorage.getItem('styles'));
styleTag.type = 'text/css';
styleTag.innerHTML = `
try {
const styleTag = document.createElement('style');
const colors = JSON.parse(localStorage.getItem('styles'));
styleTag.type = 'text/css';
styleTag.innerHTML = `
.dynamicstyle {
background-color: ${colors.primary};
}
`;
document.head.appendChild(styleTag);
document.head.appendChild(styleTag);
} catch (e) {
console.log('style injection failed: ' + e);
}
},
hasUserTask() {
return this.messages && this.messages[this.id] && this.messages[this.id].payload.userTask;
Expand Down

0 comments on commit dba6abf

Please sign in to comment.