node-red-contrib-nem2
Version:
NEM blockchain nodes
164 lines (154 loc) • 7.58 kB
HTML
<!--
* Copyright 2018 NEM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<script type="text/javascript">
RED.nodes.registerType('transactions', {
category: 'NEM Account',
color: '#C5523C',
defaults: {
name: { value: "" },
publicKey: { value: "", validate: RED.validators.regex(/^([0-9A-Fa-f]{2}){32}$|^.{0}$/) },
server: { value: "", type: "serverConfig" },
allTransactions: { value: false },
pageSize: { value: 10, validate: RED.validators.number() },
transactionsType: { value: "transactions" },
splitTransactions: { value: false }
},
inputs: 1,
outputs: 1,
icon: "Transaction-White.png",
label: function () {
return this.name || this.transactionsType || "transactions";
},
oneditprepare: function () {
$("#node-input-allTransactions").on("change", function () {
if (this.checked) {
$("#node-input-pageSizeView").hide();
}
else { $("#node-input-pageSizeView").show(); }
});
},
button: {
enabled: function () {
return !this.changed
},
onclick: function () {
if (this.changed) {
return RED.notify(RED._("notification.warning", { message: RED._("notification.warnings.undeployedChanges") }), "warning");
}
var label = (this.name || "transactions");
var node = this;
$.ajax({
url: "inject/" + this.id,
type: "POST",
success: function (resp, textStatus, xhr) {
RED.notify(node._("succesfully started " + label), "success");
},
error: function (jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 404) {
RED.notify(node._("common.notification.error", { message: node._("common.notification.errors.not-deployed") }), "error");
} else if (jqXHR.status == 500) {
RED.notify(node._("common.notification.error", { message: node._("inject.errors.failed") }), "error");
} else if (jqXHR.status == 0) {
RED.notify(node._("common.notification.error", { message: node._("common.notification.errors.no-response") }), "error");
} else {
RED.notify(node._("common.notification.error", { message: node._("common.notification.errors.unexpected", { status: jqXHR.status, message: textStatus }) }), "error");
}
}
});
}
}
});
</script>
<script type="text/x-red" data-template-name="transactions">
<div class="form-row">
<label for="node-input-server"><i class="icon-globe"></i> Server</label>
<input type="text" id="node-input-server">
</div>
<div class="form-row">
<label for="node-input-transactionsType"><i></i>transactions type</label>
<select type="text" id="node-input-transactionsType">
<option value="transactions">transactions</option>
<option value="incomingTransactions">incoming transactions</option>
<option value="outgoingTransactions">outgoing transactions</option>
<option value="unconfirmedTransactions">unconfirmed transactions</option>
<option value="aggregateBondedTransactions">aggregate bonded transactions</option>
</select>
</div>
<div class="form-row">
<label for="node-input-publicKey"><i></i> public key</label>
<input type="text" id="node-input-publicKey" placeholder="publicKey">
</div>
<div class="form-row"id="node-input-allTransactionsView">
<label for="node-input-allTransactions"><i></i>all transactions</label>
<input type="checkbox" id="node-input-allTransactions">
</div>
<div class="form-row"id="node-input-pageSizeView">
<label for="node-input-pageSize"><i></i>last x transactions up to 100</label>
<input type="number" id="node-input-pageSize" placeholder="10">
</div>
<div class="form-row"id="node-input-splitTransactionsView">
<label for="node-input-splitTransactions"><i></i>split transactions</label>
<input type="checkbox" id="node-input-splitTransactions">
</div>
<div class="form-row" id="node-input-nameView">
<label for="node-input-name"><i class="icon-tag"></i>name</label>
<input type="text" id="node-input-name"placeholder="name (optional)">
</div>
</script>
<script type="text/x-red" data-help-name="transactions">
<p>Get and filter transactions for the provided address. You can directly provide the public key here or simply link an account node. There is also the option for you to limit the number of results. </p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>server <span class="property-type">object</span></dt>
<dd>The server configuration.</dd>
</dl>
<dl class="message-properties">
<dt>transactions type <span class="property-type">string</span></dt>
<dd>transactions, incoming transactions, outgoing transactions, unconfirmed transactions or aggregate bonded transactions.</dd>
</dl>
<dl class="message-properties">
<dt>public key <span class="property-type">string</span></dt>
<dd>The account public key.</dd>
</dl>
<dl class="message-properties">
<dt>all transactions <span class="property-type">boolean</span></dt>
<dd>Set it to false if you want to choose the number of transactions to get manually.</dd>
</dl>
<dl class="message-properties">
<dt>last x transactions <span class="property-type">string</span></dt>
<dd>Number of transactions to retrieve. Minimum 10. Maximum 100</dd>
</dl>
<dl class="message-properties">
<dt>split transactions<span class="property-type">string</span></dt>
<dd>It will split the array of transactions into single transaction. A message will be send for every transaction</dd>
</dl>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>publicKey <span class="property-type">string</span></dt>
<dd>The account public key.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>transactions<span class="property-type">object</span></dt>
<dd>Array of <a href="https://nemtech.github.io/nem2-sdk-typescript-javascript/modules/_model_transaction_transaction_.html">Transactions</a>.
</dd>
</dl>
<dl class="message-properties">
<dt>transactionsType<span class="property-type">string</span></dt>
<dd>transactions, incoming transactions, outgoing transactions, unconfirmed transactions or aggregate bonded transactions</a>.
</dd>
</dl>
</script>