UNPKG

@energyweb/node-red-contrib-green-proof-worker

Version:
68 lines (63 loc) 1.89 kB
<script type="text/javascript"> RED.nodes.registerType('json-schema-validator',{ category: 'Generic Green Proofs', color: '#B28CFF', icon: 'ewf-logo.svg', defaults: { name: { value: "" }, jsonSchema: { value:"", required: false }, }, inputs: 1, outputs: 1, labelStyle: 'ggp-label-style', paletteLabel: 'JSON Schema validator', label: function() { return this.name || 'JSON Schema validator'; }, oneditprepare: function() { this.editor = RED.editor.createEditor({ id: 'jsonSchema-editor', mode: 'ace/mode/json', value: this.jsonSchema }); }, oneditsave: function() { this.jsonSchema = this.editor.getValue(); this.editor.destroy(); delete this.editor; }, oneditcancel: function() { this.editor.destroy(); delete this.editor; }, }); </script> <script type="text/html" data-template-name="json-schema-validator"> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <div><i class="fa fa-bookmark"></i> JSON schema</div> <div style="height: 400px; min-height:400px;" class="node-text-editor" id="jsonSchema-editor"></div> </div> </script> <script type="text/html" data-help-name="json-schema-validator"> <p> Validates `msg.payload` against provided JSON Schema. If payload is invalid, then the node throws an error. </p> </script><style>.ggp-label-style { /** Text color */ /* fill: #fff; */ } .red-ui-flow-node-icon-group:has(~ .ggp-label-style) { image { width: 15px; height: 15px; x: 9px; y: 7.5px; } } .red-ui-flow-node:has(~ .ggp-label-style) { stroke-width: 0; }</style>