UNPKG

node-red-contrib-tagui

Version:
166 lines (163 loc) 7.11 kB
<script type="text/x-red" data-template-name="tagui tagui"> <div class="form-row" style="margin-bottom: 0px;"> <label for="node-input-script"><i class="fa fa-wrench"></i> Script</label> <input type="hidden" id="node-input-script" autofocus="autofocus"> <input type="hidden" id="node-input-noerr-script"> </div> <div class="form-row node-text-editor-row" style="position:relative"> <div style="position: absolute; right:0; bottom:calc(100% + 3px);"><button id="node-function-expand-js-script" class="editor-button editor-button-small"><i class="fa fa-expand"></i></button></div> <div style="height: 100px; min-height:100px;" class="node-text-editor" id="node-input-script-editor" ></div> </div> <table style="width: 100%"> <tr> <td> <div class="form-row"> <label><i class="fa fa-eye-slash"></i> Headless</label> <input type="checkbox" id="node-input-headless" style="width: auto;"> </div> </td> <td> <div class="form-row"> <label><i class="fa fa-chrome"></i> No browser </label> <input type="checkbox" id="node-input-nobrowser" style="width: auto;"> </div> </td> </tr> <tr> <td> <div class="form-row"> <label><i class="fa fa-shopping-bag"></i> Param </label> <input type="checkbox" id="node-input-param" style="width: auto;"> </div> </td> <td> <div class="form-row"> <label><i class="fa fa-commenting-o"></i> Quiet </label> <input type="checkbox" id="node-input-quiet" style="width: auto;"> </div> </td> </tr> <tr> <td> <div class="form-row"> <label><i class="fa fa-shopping-bag"></i> Check for Update </label> <input type="checkbox" id="node-input-updatecheck" style="width: auto;"> </div> </td> </tr> </table> <div class="form-row"> <label ><i class="fa fa-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Node name"> </div> </script> <script type="text/x-red" data-help-name="tagui tagui"> <p>Execute RPA in human language using TagUI engine</p> <p>Node has 3 output nodes.<br /> The top output node is used to continue the flow, once TagUI is done processing. msg.payload will contain all the output from the script<br /> The second output node will receive all output from TagUI live. Use full for debugging<br /> The last output node will trigger incase TagUI returns a non zero exit code, ie an error happend<br /> </p> <p> For simple workflow you can pass arguments using msg.payload and reference them from <a href="https://tagui.readthedocs.io/en/latest/reference.html?highlight=p1%20#input-s" target="_blank">TagUI as p1 to p8</a>.<br> For more advanced cases simply inject the data in the script using msg.script<br> </p> <p> You can override the script setting using msg.script<br /> You can override the headless setting using msg.headless<br /> You can override the nobrowser setting using msg.nobrowser<br /> You can override the param setting using msg.param<br /> You can override the quiet setting using msg.quiet<br /> </p> </script> <script type="text/javascript"> RED.nodes.registerType('tagui tagui', { category: 'tagui', color: "#eeeeee", defaults: { name: { value: "" }, headless: { value: false }, nobrowser: { value: false }, param: { value: true }, quiet: { value: true }, updatecheck: { value: false }, script: { value: `https://www.google.dk/imghp?hl=en&ogbl type q as cute kitten[enter] wait 2 sec if present('//div[@data-ri="0"]') snap //div[@data-ri="0"] to kitten.png else if present('//table//img') snap //table//img to kitten.png`, required: true }, }, inputs: 1, outputs: 3, outputLabels: ["completed", "status", "failed"], icon: "tagui_logo.png", label: function () { return this.name || "tagui"; }, labelStyle: function () { return this.name ? "node_label_italic" : ""; }, oneditprepare: function () { this.scripteditor = RED.editor.createEditor({ id: 'node-input-script-editor', mode: 'ace/mode/python', value: $("#node-input-script").val(), globals: { msg: false, context: false, RED: false, util: true, flow: false, global: false, console: false, Buffer: true, setTimeout: false, clearTimeout: false, setInterval: false, clearInterval: false } }); this.scripteditor.focus(); const that = this; $("#node-function-expand-js-script").click(function (e) { e.preventDefault(); const value = that.scripteditor.getValue(); RED.editor.editJavaScript({ value: value, width: "Infinity", cursor: that.scripteditor.getCursorPosition(), mode: "ace/mode/python", complete: function (v, cursor) { that.scripteditor.setValue(v, -1); that.scripteditor.gotoLine(cursor.row + 1, cursor.column, false); setTimeout(function () { that.scripteditor.focus(); }, 300); } }) }); }, oneditsave: function () { let annot = this.scripteditor.getSession().getAnnotations(); $("#node-input-noerr-script").val(0); for (let k = 0; k < annot.length; k++) { if (annot[k].type === "error") { $("#node-input-noerr-script").val(annot.length); this.noerr = annot.length; } } $("#node-input-script").val(this.scripteditor.getValue()); this.scripteditor.destroy(); delete this.scripteditor; }, oneditcancel: function () { this.scripteditor.destroy(); delete this.scripteditor; } }); </script>