node-red-contrib-agilite
Version:
Node-RED nodes to integrate with Agilit-e cloud or Agilit-e on-prem
299 lines (292 loc) • 14.7 kB
HTML
<script type='text/javascript'>
var agiliteBatchLoggingFunctions = {
updateActionType:function(){
var value = $('#node-input-actionType option:selected').val()
switch(value){
case '1': // Get By Profile Key
document.querySelector('#rowProfileKey').style.display = 'block'
document.querySelector('#rowLogProfileKey').style.display = 'none'
document.querySelector('#rowQry').style.display = 'none'
document.querySelector('#rowFieldsToReturn').style.display = 'none'
document.querySelector('#rowQryOptions').style.display = 'none'
document.querySelector('#rowPage').style.display = 'none'
document.querySelector('#rowPageLimit').style.display = 'none'
document.querySelector('#rowCategory').style.display = 'none'
document.querySelector('#rowSubCategory').style.display = 'none'
document.querySelector('#rowCode').style.display = 'none'
document.querySelector('#rowMessage').style.display = 'none'
break
case '2': // Create Log Entry
document.querySelector('#rowProfileKey').style.display = 'block'
document.querySelector('#rowLogProfileKey').style.display = 'none'
document.querySelector('#rowQry').style.display = 'none'
document.querySelector('#rowFieldsToReturn').style.display = 'none'
document.querySelector('#rowQryOptions').style.display = 'none'
document.querySelector('#rowPage').style.display = 'none'
document.querySelector('#rowPageLimit').style.display = 'none'
document.querySelector('#rowCategory').style.display = 'block'
document.querySelector('#rowSubCategory').style.display = 'block'
document.querySelector('#rowCode').style.display = 'block'
document.querySelector('#rowMessage').style.display = 'block'
break
case '3': // Get Logs
document.querySelector('#rowProfileKey').style.display = 'block'
document.querySelector('#rowLogProfileKey').style.display = 'none'
document.querySelector('#rowQry').style.display = 'block'
document.querySelector('#rowFieldsToReturn').style.display = 'block'
document.querySelector('#rowQryOptions').style.display = 'block'
document.querySelector('#rowPage').style.display = 'block'
document.querySelector('#rowPageLimit').style.display = 'block'
document.querySelector('#rowCategory').style.display = 'none'
document.querySelector('#rowSubCategory').style.display = 'none'
document.querySelector('#rowCode').style.display = 'none'
document.querySelector('#rowMessage').style.display = 'none'
break
case '4': // Reset Logs
document.querySelector('#rowProfileKey').style.display = 'block'
document.querySelector('#rowLogProfileKey').style.display = 'none'
document.querySelector('#rowQry').style.display = 'none'
document.querySelector('#rowFieldsToReturn').style.display = 'none'
document.querySelector('#rowQryOptions').style.display = 'none'
document.querySelector('#rowPage').style.display = 'none'
document.querySelector('#rowPageLimit').style.display = 'none'
document.querySelector('#rowCategory').style.display = 'none'
document.querySelector('#rowSubCategory').style.display = 'none'
document.querySelector('#rowCode').style.display = 'none'
document.querySelector('#rowMessage').style.display = 'none'
break
default:
document.querySelector('#rowProfileKey').style.display = 'none'
document.querySelector('#rowLogProfileKey').style.display = 'none'
document.querySelector('#rowQry').style.display = 'none'
document.querySelector('#rowFieldsToReturn').style.display = 'none'
document.querySelector('#rowQryOptions').style.display = 'none'
document.querySelector('#rowPage').style.display = 'none'
document.querySelector('#rowPageLimit').style.display = 'none'
document.querySelector('#rowCategory').style.display = 'none'
document.querySelector('#rowSubCategory').style.display = 'none'
document.querySelector('#rowCode').style.display = 'none'
document.querySelector('#rowMessage').style.display = 'none'
break
}
}
}
RED.nodes.registerType('batch-logging',{
category: 'agilite',
inputs: 1,
outputs:1,
icon: 'font-awesome/fa-connectdevelop',
color: '#ffa4a2',
label: function () {
return this.name || 'Batch Logging'
},
paletteLabel : 'batch logging',
defaults: {
server: {
value: '',
required: true,
type: 'agilite-login'
},
name: {
value: ''
},
profileKey: {
value: ''
},
logProfileKey: {
value: ''
},
qry: {
value: ''
},
fieldsToReturn: {
value: ''
},
qryOptions: {
value: ''
},
page: {
value: ''
},
pageLimit: {
value: ''
},
field: {
value: 'payload',
},
fieldType: {
value: 'msg'
},
failFlow: {
value: true
},
actionType: {
value : '',
required : true
},
category: {
value: ''
},
subCategory: {
value: ''
},
code: {
value: ''
},
message: {
value: ''
}
},
oneditprepare: function () {
$('#node-input-actionType').change(function(){agiliteBatchLoggingFunctions.updateActionType()})
agiliteBatchLoggingFunctions.updateActionType()
if (!this.fieldType) this.fieldType = 'msg'
$('#node-input-field').typedInput({
default: 'msg',
types: ['msg','flow','global'],
typeField: $('#node-input-fieldType')
})
}
})
</script>
<script type='text/x-red' data-template-name='batch-logging'>
<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="1">Get By Profile Key</option>
<option value="2">Create Log Entry</option>
<option value="3">Get Logs</option>
<option value="4">Reset Logs</option>
</select>
</div>
<div class="form-row" id="rowProfileKey">
<label for="node-input-profileKey"><i class="fa fa-key"></i> Profile Key {{}}</label>
<input type="text" id="node-input-profileKey" />
</div>
<div class="form-row" id="rowLogProfileKey">
<label for="node-input-logProfileKey"><i class="fa fa-key"></i> Profile Key {{}}</label>
<input type="text" id="node-input-logProfileKey" />
</div>
<div class="form-row" id="rowCategory">
<label for="node-input-category">Category {{}}</label>
<input type="text" id="node-input-category" />
</div>
<div class="form-row" id="rowSubCategory">
<label for="node-input-subCategory">Sub Category {{}}</label>
<input type="text" id="node-input-subCategory" />
</div>
<div class="form-row" id="rowCode">
<label for="node-input-code">Code {{}}</label>
<input type="text" id="node-input-code" />
</div>
<div class="form-row" id="rowMessage">
<label for="node-input-message">Message {{}}</label>
<input type="text" id="node-input-message" />
</div>
<div class="form-row" id="rowQry">
<label for="node-input-qry">Query {{}}</label>
<input type="text" id="node-input-qry" />
</div>
<div class="form-row" id="rowFieldsToReturn">
<label for="node-input-fieldsToReturn">Fields To Return {{}}</label>
<input type="text" id="node-input-fieldsToReturn" />
</div>
<div class="form-row" id="rowQryOptions">
<label for="node-input-qryOptions">Query Options {{}}</label>
<input type="text" id="node-input-qryOptions" />
</div>
<div class="form-row" id="rowPage">
<label for="node-input-page">Page {{}}</label>
<input type="text" id="node-input-page" />
</div>
<div class="form-row" id="rowPageLimit">
<label for="node-input-pageLimit">Page Limit {{}}</label>
<input type="text" id="node-input-pageLimit" />
</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='batch-logging'>
<p>A node to have Agilit-e process Batch Logging operations</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">Get By Profile Key</h4>
<dt>Profile Key</dtspan class="property-type">string</span></dt>
<dd>The unique <b>key</b> of the Batch Logging Profile that needs to be retrieved</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Create Log Entry</h4>
<dt>Log Profile Key<span class="property-type">string</span></dt>
<dd>The unique <b>key</b> of the Batch Logging Profile that is used to create a Log entry against</dd>
<dt>Category<span class="property-type">string</span></dt>
<dd>The category the log entry belongs to</dd>
<dt>Sub Category<span class="property-type">string</span></dt>
<dd>The sub category of a category this log entry belongs to</dd>
<dt>Code<span class="property-type">string</span></dt>
<dd>The status code or code of the log entry being created. i.e. 200 - OK or 404 - Not Found </dd>
<dt>Message<span class="property-type">string</span></dt>
<dd>The message of the log entry. Could be an error or success response message</dd>
<dt>msg.payload<span class="property-type">object</span></dt>
<dd>The body of the Log entry that needs to be created</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Get Logs</h4>
<dt>Log Profile Key<span class="property-type">string</span></dt>
<dd>The unique <b>key</b> of the Batch Logging Profile that is used to get logs</dd>
<dt>Query<span class="property-type">string</span></dt>
<dd>A query that can be used to only retrieve logs with certain conditions</dd>
<dd>Example: { "data.responseCode": 400 }</dd>
<dt>Fields To Return<span class="property-type">string</span></dt>
<dd>The relevant Fields that need to be returned</dd>
<dt>Query Options<span class="property-type">string</span></dt>
<dd>Options for the query</dd>
<dt>Page<span class="property-type">string</span></dt>
<dd>The relevant Page to return</dd>
<dt>Page Limit<span class="property-type">string</span></dt>
<dd>Used to limit the amount of pages returned</dd>
</dl>
<dl class="message-properties">
<h3 style="margin: 5px 5px 5px 5px">Reset Logs</h4>
<dt>Profile Key</dtspan class="property-type">string</span></dt>
<dd>The unique <b>key</b> of the Batch Logging Profile's Logs that need to be reset</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>