@siglesiasg/node-red-hyperledger-fabric-gateway
Version:
Hyperledger Fabric 2.x nodes for node-red with latest fabric-gateway library
167 lines (146 loc) • 8.21 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('fabric-cc-submit', {
category: 'Hyperledger Gateway',
color: '#E6E0F8',
paletteLabel: 'cc submit',
defaults: {
name: { value: '' },
gatewaySelector: { value: '', required: true, type: 'fabric-gateway' },
identitySelector: { value: '', required: true, type: 'fabric-identity' },
channelSelector: { value: '', required: true, type: 'fabric-channel' },
contractSelector: { value: '', required: true, type: 'fabric-contract' },
transaction: { value: '', required: false },
args: { value: '', required: false, validate: function(args, opt) {
try {
if (!args) { $(".form-row-tip-argsError").hide(); return true; }
if (Array.isArray(JSON.parse(args))) { $(".form-row-tip-argsError").hide(); return true; }
} catch (error) {}
$(".form-row-tip-argsError").show();
return 'Args must be an array of strings';
}},
transientData: { value: '', required: false, validate: function(args, opt) {
try {
if (!args) { $(".form-row-tip-transientError").hide(); return true; }
if (Array.isArray(JSON.parse(args))) { $(".form-row-tip-transientError").hide(); return true; }
} catch (error) {}
$(".form-row-tip-transientError").show();
return 'Transient must be an array of strings';
}},
},
inputs: 1,
outputs: 1,
icon: 'icon.png',
align: 'lect',
label: function () {
return this.name || 'hlf chaincode submit';
},
oneditprepare : function () {
var that = this;
this.editor = RED.editor.createEditor({
id : 'node-input-args-editor',
mode: 'monaco/mode/json',
value : $('#node-input-args').val()
});
this.editor.focus();
this.editorTransient = RED.editor.createEditor({
id : 'node-input-transientData-editor',
mode: 'monaco/mode/json',
value : $('#node-input-transientData').val()
});
this.editorTransient.focus();
},
oneditsave : function () {
$('#node-input-args').val(this.editor.getValue());
this.editor.destroy();
delete this.editor;
$('#node-input-transientData').val(this.editorTransient.getValue());
this.editorTransient.destroy();
delete this.editorTransient;
},
oneditcancel : function () {
this.editor.destroy();
delete this.editor;
this.editorTransient.destroy();
delete this.editorTransient;
}
});
</script>
<script type="text/html" data-template-name="fabric-cc-submit">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-row">
<label for="node-input-gatewaySelector"><i class="fa"></i>Gateway</label>
<input type="select" id="node-input-gatewaySelector" />
</div>
<div class="form-row">
<label for="node-input-identitySelector"><i class="fa"></i>Identity</label>
<input type="select" id="node-input-identitySelector" />
</div>
<div class="form-row">
<label for="node-input-channelSelector"><i class="fa"></i>Channel</label>
<input type="select" id="node-input-channelSelector" placeholder="" />
</div>
<div class="form-row">
<label for="node-input-contractSelector"><i class="fa"></i>Contract</label>
<input type="select" id="node-input-contractSelector" placeholder="" />
</div>
<div class="form-row">
<label for="node-input-transaction"><i class="fa"></i>Transaction</label>
<input type="text" id="node-input-transaction" placeholder="queryAllCars" />
</div>
<div class="form-row">
<div id="node-input-args-outer">
<div class="form-row" style="margin-bottom: 0px;">
<label for="node-input-args"><i class="fa"></i>Args Array</label>
<input type="hidden" id="node-input-args" autofocus="autofocus">
</div>
<div class="form-row node-text-editor-row">
<div style="height: 100px; min-height:80px;" class="node-text-editor" id="node-input-args-editor"></div>
</div>
</div>
</div>
<div class="form-row form-row-tip-argsError hide">
<div class="form-tips"><span>Args must be an array: ["arg1","arg2"]'</span></div>
</div>
<div class="form-row">
<div id="node-input-transientData-outer">
<div class="form-row" style="margin-bottom: 0px;">
<label for="node-input-transientData"><i class="fa"></i>Transient Data Array</label>
<input type="hidden" id="node-input-transientData" autofocus="autofocus">
</div>
<div class="form-row node-text-editor-row">
<div style="height: 100px; min-height:80px;" class="node-text-editor" id="node-input-transientData-editor"></div>
</div>
</div>
</div>
<div class="form-row form-row-tip-transientError hide">
<div class="form-tips"><span>Transient must be an array: ["tra1","tra2"]'</span></div>
</div>
</script>
<script type="text/html" data-help-name="fabric-cc-submit">
<span class="red-ui-text-bidi-aware">
<h2>Hyperledger Fabric Submit Node</h2>
<p>Submit a transaction to the ledger and return its result only after it is committed to the ledger. The transaction function will be evaluated on endorsing peers and then submitted to the ordering service to be committed to the ledger.</p>
<h3 class="red-ui-help-info-header">Details</h3>
<p>Basic connection config nodes must be provided: <code>Gateway</code>, <code>Identity</code>, <code>Channel</code> and <code>Contract</code> </p>
<p>Transaction config can be statically set in the node: <code>Transaction (Name)</code>, <code>Args Array</code> and <code>Transient Data Array</code> or if a payload with the following format is supplied, the static transaction config fields will be overwritten making node dinamically configured</p>
<p><code>Args Array</code> and <code>Transient Data Array</code> must be an array of strings</p>
<h3 class="red-ui-help-info-header">Input payload</h3>
<dl class="message-properties">
<dt class="optional">payload<span class="property-type">string[]</span></dt>
<dd>if configured as an array it will be used to invoke the chaincode with these arguments.</dd>
<dt class="optional">payload.transaction<span class="property-type">string[]</span></dt>
<dd>if configured as an array it will be used to invoke the chaincode with these arguments.</dd>
<dt class="optional">payload.transactionName <span class="property-type">string</span></dt>
<dd>if configured, this transaction will be invoked from the chaincode.</dd>
<dt class="optional">payload.transaction.name <span class="property-type">string</span></dt>
<dd>if configured, this transaction will be invoked from the chaincode.</dd>
<dt class="optional">payload.transaction.args<span class="property-type">string[]</span></dt>
<dd>if configured as an array it will be used to invoke the chaincode with these arguments.</dd>
<dt class="optional">payload.transaction.transient<span class="property-type">string[]</span></dt>
<dd>if configured as an array it will be used to invoke the chaincode with this transient data.</dd>
</dl>
</span>
</script>