node-red-contrib-agilite
Version:
Node-RED nodes to integrate with Agilit-e cloud or Agilit-e on-prem
257 lines (250 loc) • 12.3 kB
HTML
<script type='text/javascript'>
var agiliteAdhocFunctions = {
updateActionType:function(){
var value = $('#node-input-actionType option:selected').val()
switch(value){
case '5': // Format Date/Time
document.querySelector('#rowDateTimeValue').style.display = 'block'
document.querySelector('#rowFormatKey').style.display = 'block'
document.querySelector('#rowFullName').style.display = 'none'
document.querySelector('#rowFullName').style.display = 'none'
document.querySelector('#rowApiKey').style.display = 'none'
break
case '10': // Generate Username
document.querySelector('#rowDateTimeValue').style.display = 'none'
document.querySelector('#rowFormatKey').style.display = 'none'
document.querySelector('#rowFullName').style.display = 'block'
document.querySelector('#rowRecordId').style.display = 'none'
document.querySelector('#rowApiKey').style.display = 'none'
break
case '11': // Generate OCR
document.querySelector('#rowDateTimeValue').style.display = 'none'
document.querySelector('#rowFormatKey').style.display = 'none'
document.querySelector('#rowFullName').style.display = 'none'
document.querySelector('#rowRecordId').style.display = 'block'
document.querySelector('#rowApiKey').style.display = 'none'
break
case '12': // Authenticate Token
document.querySelector('#rowDateTimeValue').style.display = 'none'
document.querySelector('#rowFormatKey').style.display = 'none'
document.querySelector('#rowFullName').style.display = 'none'
document.querySelector('#rowRecordId').style.display = 'none'
document.querySelector('#rowApiKey').style.display = 'block'
break
default:
document.querySelector('#rowDateTimeValue').style.display = 'none'
document.querySelector('#rowFormatKey').style.display = 'none'
document.querySelector('#rowFullName').style.display = 'none'
document.querySelector('#rowRecordId').style.display = 'none'
document.querySelector('#rowApiKey').style.display = 'none'
break
}
}
}
RED.nodes.registerType('adhoc',{
category: 'agilite',
inputs: 1,
outputs:1,
icon: 'adhoc.png',
color: '#ffa4a2',
label: function () {
return this.name||'Adhoc'
},
paletteLabel: 'adhoc',
defaults: {
server: {
value: '',
required: true,
type: 'agilite-login'
},
actionType: {
value: '',
required : true
},
dateTimeValue: {
value: ''
},
fullName: {
value: ''
},
recordId: {
value : ''
},
apiKey: {
value: ''
},
formatKey: {
value: ''
},
name: {
value: ''
},
field: {
value: 'payload',
},
fieldType: {
value: 'msg'
},
failFlow: {
value: true
}
},
oneditprepare: function(){
if(!this.fieldType) this.fieldType = 'msg'
$('#node-input-field').typedInput({
default: 'msg',
types: ['msg','flow','global'],
typeField: $('#node-input-fieldType')
})
$('#node-input-actionType').change(function(){agiliteAdhocFunctions.updateActionType()})
agiliteAdhocFunctions.updateActionType()
}
})
</script>
<script type="text/x-red" data-template-name="adhoc">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
<input type="text" id="node-input-server" placeholder="Server"></input>
</div>
<div class="form-row" id="rowActionType">
<label for="node-input-actionType"><i class="fa fa-arrow-circle-right"></i> Action Type</label>
<select id="node-input-actionType" style="width:auto;">
<option value="12">Authenticate Token</option>
<option value="1">Encode XML</option>
<option value="6">Decode XML</option>
<option value="7">Convert XML to JS</option>
<option value="8">Convert JS to XML</option>
<option value="2">Convert HTML to JSON</option>
<option value="3">Generate PDF (PDFMake)</option>
<option value="4">Generate UUID</option>
<option value="5">Format Date/Time (MomentJS)</option>
<option value="9">JSON Difference</option>
<option value="10">Generate Username</option>
<option value="11">Generate OCR</option>
</select>
</div>
<div class="form-row" id="rowDateTimeValue">
<label for="node-input-dateTimeValue"><i class="fa fa-calendar-times-o"></i> Date/Time Value {{}}</label>
<input type="text" id="node-input-dateTimeValue" />
</div>
<div class="form-row" id="rowFormatKey">
<label for="node-input-formatKey"><i class="fa fa-key"></i> Format Key {{}}</label>
<input type="text" id="node-input-formatKey" />
</div>
<div class="form-row" id="rowFullName">
<label for="node-input-fullName"><i class="fa fa-key"></i> Full Name</label>
<input type="text" id="node-input-fullName" />
</div>
<div class="form-row" id="rowRecordId">
<label for="node-input-recordId"><i class="fa fa-key"></i> Record ID {{}}</label>
<input type="text" id="node-input-recordId" />
</div>
<div class="form-row" id="rowApiKey">
<label for="node-input-apiKey"><i class="fa fa-key"></i> API Key {{}}</label>
<input type="text" id="node-input-apiKey" />
</div>
<div class="form-row">
<label for="node-input-field"><i class="fa fa-edit"></i> <span data-i18n="template.label.property">Output to</span></label>
<input type="text" id="node-input-field" placeholder="payload" style="width:250px;">
<input type="hidden" id="node-input-fieldType">
</div>
<div class="form-row">
<label for="node-input-failFlow"><i class="fa fa-exclamation-triangle"></i> <span data-i18n="template.label.property">Fail Flow on Error</span></label>
<input type="checkbox" id="node-input-failFlow" style="width:initial;" /> Yes
</div>
<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="Node Name" />
</div>
</script>
<script type="text/x-red" data-help-name="adhoc">
<p>A node to have Agilit-e process Utility transactions based on the Action Type selected</p>
<h3>Inputs</h3>
<h4>General</h4>
<dl class="message-properties">
<dt>Server (required)<span class="property-type">Configuration Node</span></dt>
<dd>The server configuration to connect to the relevant Agilit-e API Server. This is achieved by providing the API Server URL (required) and an API Key (optional). <b>NOTE:</b> If providing an API Key, be sure to click on the "Authenticate" button, to have Node-RED authenticate the API Key before the Server configuration is used by Nodes.</dd>
<dt>msg.payload<span class="property-type">object</span></dt>
<dd>Optional data to be passed to Agilit-e for Handlebars evaluations in the relevant module's Profile.</dd>
<br />
<p style="margin: 0 5px 0 5px"><b>NOTE:</b> Values can be provided manually in the Input Fields in this Node's UI Form, or programmatically using <a href="https://handlebarsjs.com/" target="_blank">Handlebars</a>, where the Input Field's Label includes <code>{{}}</code>. Labels with <code>{{}}</code> are <b>Handlebars-enabled</b> and evaluate prop values relative to the <code>msg</code> object (e.g. <code>{{profileKey}}</code> = <code>msg.profileKey</code>). A final note: The difference between using 2 curly braces vs 3, is that values evaluated using 2 curly braces are first encoded/escaped before evaluated, whereas values using 3 curly braces are not. It is usually safer to use 3 curly braces, but in most cases 2 will work fine.</p>
</dl>
<h3>Action Types</h3>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Authenticate Token</h4>
<dt>API Key<span class="property-type">string</span></dt>
<dd>The API Key that needs to be authenticated.</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Encode XML</h4>
<dt>msg.payload<span class="property-type">string</span></dt>
<dd>The XML that needs to be encoded</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Decode XML</h4>
<dt>msg.payload<span class="property-type">string</span></dt>
<dd>The XML that needs to be decoded</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Convert XML To JS</h4>
<dt>msg.payload<span class="property-type">string</span></dt>
<dd>The XML that needs to be converted to JS</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Convert JS To XML</h4>
<dt>msg.payload<span class="property-type">object</span></dt>
<dd>The JS that needs to be converted to XML</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Convert HTML To JSON</h4>
<dt>msg.payload<span class="property-type">string</span></dt>
<dd>The HTML that needs to be converted to JSON</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Generate PDF (PDFMake)</h4>
<dt>msg.payload<span class="property-type">object</span></dt>
<dd>The data used to generate the PDF</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Generate UUID</h4>
<dt>-none-<span class="property-type">none</span></dt>
<dd>This action type doesn't require any data</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Format Date/Time (MomentJS)</h4>
<dt>Date/Time Value<span class="property-type">string</span></dt>
<dd>The Date/Time that needs to be formatted</dd>
<dt>Format Key<span class="property-type">string</span></dt>
<dd>The format string used to format the Date/Time value</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">JSON Difference</h4>
<dt>msg.payload<span class="property-type">object</span></dt>
<dd>The JSON data that needs to be compared</dd>
<dd>Example: <code>{ data: [ { srcData: { prop: "value" }, desData: { prop: "other value" } } ]}</code></dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Generate Username</h4>
<dt>Full Name<span class="property-type">string</span></dt>
<dd>The Full Name used to generate a username from</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Generate OCR</h4>
<dt>Record ID<span class="property-type">string</span></dt>
<dd>The Id of the PDF Document that needs to be OCR'd</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<p style="margin: 0 5px 0 5px">By default, this Node will output the result to <code>msg.payload</code>. This can be changed in the Node UI Form's <b>Output To</b> Field</p>
</dl>
<h3>Additional Properties</h3>
<dl class="message-properties">
<p style="margin: 0 5px 0 5px">By default, if an error occurs, this Node will fail and stop the flow from continuing. This can be switched off in the Node UI Form's <b>Fail Flow on Error</b> Field. This allows one to manually manage the error by referencing the <code>msg.agilite.succcess</code> and <code>msg.agilite.errorMessage</code> prop values.</p>
<br />
<p style="margin: 0 5px 0 5px">The following properties can be set in the <code>msg.agilite</code> object:</p>
<dt>logProfileKey <span class="property-type">string</span></dt>
<dd>The unique <b>key</b> to the Batch Logging Profile used for custom logging.</dd>
<dt>apiKey <span class="property-type">string</span></dt>
<dd>The Agilit-e API Key used to authenticate the Agilit-e transaction. This is not required if you've set up a Configuration Node that already has an API Key which has been authenticated.</dd>
</dl>
</script>