我试着创建配置节点像this但它只显示文本框没有配置,我想projectid是一个配置节点,我试着下面的许多节点与配置节点,但它不适合我,如何修复它?
graphql_query.js
module.exports = function(RED) {
function netpie_graphql_query(nodeConfig) {
RED.nodes.createNode(this,nodeConfig);
var node = this;
node.on('input', function(msg) {
var gqlquery = nodeConfig.gqlquery;
nodeConfig.projectid = RED.nodes.getNode(nodeConfig.projectid).projectid;
const axios = require('axios');
let data = JSON.stringify({
query: gqlquery,
variables: {}
});
let axiosConfig = {
method: 'post',
maxBodyLength: Infinity,
url: 'http://gqlv2.aaaaa.io/',
headers: {
'Authorization': 'bearer '+auth.token,
'Content-Type': 'application/json'
},
data : data
};
axios.request(axiosConfig)
.then((response) => {
data = (JSON.stringify(response.data));
msg.payload = data;
node.send(msg);
})
.catch((error) => {
//console.log(error);
this.error("Request failed with status code 400, please check your schema");
});
});
}
RED.nodes.registerType("netpie_graphql_query",netpie_graphql_query);
}
graphql_query.html
RED.nodes.registerType('netpie_graphql_query',{
category: 'graphql',
color:'#00adff',
defaults:{
projectid:{value:"", type:"projectid"},
name:{value:""},
gqlquery:{value:""}
},
inputs:1,
outputs:1,
icon:"template.svg",
label:function(){
return this.name||"netpie graphql";
},
oneditprepare: function() {
this.editor = RED.editor.createEditor({
id: 'gqlquery-message-editor',
mode: 'ace/mode/text',
value: $("#node-input-gqlquery").val()
});
},
oneditsave: function() {
$("#node-input-gqlquery").val(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="netpie_graphql_query">
<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">
<label for="node-input-projectid"><i class="fa fa-tag"></i>Project ID</label>
<input type = "text" id="node-input-projectid">
</div>
<div class="form-row">
<label for="node-input-gqlquery"><i class="fa fa-cog"></i> <span>Query</span></label>
<div style="height: 250px;" class="node-text-editor" id="gqlquery-message-editor"></div>
<input type="hidden" id="node-input-gqlquery">
</div>
</script>
<script type="text/html" data-help-name="netpie_graphql_query">
<p>netpie graphql query</p>
</script>
graphql_query_config.js
function projectid(nodeConfig) {
RED.nodes.createNode(this,nodeConfig);
this.name = nodeConfig.name;
this.projectid = nodeConfig.projectid;
}
RED.nodes.registerType("projectid",projectid);
}
graphql_query_config.html
RED.nodes.registerType('projectid',{
category: 'config',
defaults: {
name: {value:""},
projectid: {value:""}
},
label: function() {
return this.name || this.("projectid");
}
});
</script>
<script type="text/html" data-template-name="projectid">
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-bookmark"></i> Name</label>
<input type="text" id="node-config-input-name">
</div>
<div class="form-row">
<label for="node-config-input-projectid"><i class="fa fa-bookmark"></i> projectid</label>
<input type="text" id="node-config-input-projectid">
</div>
</script>
但projectid不是配置节点
1条答案
按热度按时间tcomlyy61#
我通过将配置节点添加到package.json来修复它。