improve UI around payloadHandling

This commit is contained in:
Steve-Mcl
2022-11-29 13:38:09 +00:00
parent 3ed5969e87
commit 3a5cdbc8ae
11 changed files with 54 additions and 16 deletions

View File

@@ -33,11 +33,12 @@
</div>
<div class="form-row node-input-paytoqs-row">
<label for="node-input-paytoqs"><span data-i18n="common.label.payload"></span></label>
<label for="node-input-paytoqs"><span data-i18n="httpin.label.paytoqs.label"></span></label>
<select id="node-input-paytoqs" style="width: 70%;">
<option value="ignore" data-i18n="httpin.label.paytoqs.ignore"></option>
<option value="query" data-i18n="httpin.label.paytoqs.query"></option>
<option value="body" data-i18n="httpin.label.paytoqs.body"></option>
<option value="setby" data-i18n="httpin.label.paytoqs.setby"></option>
</select>
</div>
@@ -290,7 +291,7 @@
RED.tray.resize();
});
$("#node-input-method").on("change", function() {
if ($(this).val() == "GET") {
if ($(this).val() == "GET" || $(this).val() == "use") {
$(".node-input-paytoqs-row").show();
} else {
$(".node-input-paytoqs-row").hide();

View File

@@ -16,7 +16,7 @@
module.exports = function(RED) {
"use strict";
const got = require("got");
const got = require("got").default;
const {CookieJar} = require("tough-cookie");
const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent');
const FormData = require('form-data');
@@ -191,15 +191,21 @@ in your Node-RED user directory (${RED.settings.userDir}).
}
}
/** @type {boolean|'query'|'body'} */
let payloadHandling = node.paytoqs
let method = nodeMethod.toUpperCase() || "GET";
if (msg.method && n.method && (n.method !== "use")) { // warn if override option not set
node.warn(RED._("common.errors.nooverride"));
}
if (msg.method && n.method && (n.method === "use")) {
method = msg.method.toUpperCase(); // use the msg parameter
payloadHandling = msg.payloadHandling
}
/** @type {boolean|'query'|'body'|'setby'} */
let payloadHandling = node.paytoqs
if (msg.payloadHandling && payloadHandling && (payloadHandling !== "setby")) { // warn if override option not set
node.warn(RED._("common.errors.nooverride"));
}
if (msg.payloadHandling && payloadHandling && (payloadHandling === "setby")) {
payloadHandling = msg.payloadHandling // use the msg parameter
}
if (payloadHandling === true) { payloadHandling = "query" }