UNPKG

@isaac-platform/isaac-node-red

Version:

Set of Node-RED nodes to communicate with an ISAAC system

165 lines (152 loc) 5.8 kB
<script type="text/javascript"> // isaac prefix ensures that node appears when filtering by "isaac" RED.nodes.registerType('isaac log entry', { category: 'ISAAC', color: '#C0C0C0', icon: 'isaac.svg', inputs: 1, outputs: 1, paletteLabel: 'log entry', label: function () { if (this.name) { return this.name; } return this.paletteLabel; }, defaults: { isaacConnection: { type: 'isaac-connection', required: true }, name: { value: '' }, key: { value: '' }, value: { value: '' }, severity: { value: 'info' }, tags: { value: '' }, }, oneditprepare: function () { const updateLinks = () => { const configNodeId = $('#node-input-isaacConnection').val(); if (!configNodeId) { return; } const configNode = RED.nodes.node(configNodeId); if (!configNode || !configNode.ipAddress) { const links = document.querySelectorAll('.isaac-workspace-link, .isaac-doc-link'); links.forEach((link) => { link.style.display = 'none'; }); return; } const getDisplay = (linkEl) => { return linkEl.classList.contains('isaac-full-width') ? 'block' : 'inline'; }; const docLink = document.querySelector('.isaac-doc-link'); if (docLink) { docLink.style.display = getDisplay(docLink); docLink.href = `${configNode.ipAddress}/docs/v1/?urls.primaryName=Logs`; } const workspaceLinks = document.querySelectorAll('.isaac-workspace-link'); workspaceLinks.forEach((link) => { link.style.display = getDisplay(link); link.href = `${configNode.ipAddress}/logging/activity`; }); }; updateLinks(); $('#node-input-isaacConnection').change(updateLinks); }, }); </script> <script type="text/html" data-template-name="isaac log entry"> <div class="form-row"> <label for="node-input-isaacConnection"><i class="fa fa-server"></i> Connection</label> <input type="text" id="node-input-isaacConnection" /> </div> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Node Name</label> <input type="text" id="node-input-name" /> </div> <div class="form-row"> <label for="node-input-key" title="Can be overwritten by msg.config.key"> <i class="fa fa-key"></i> Key <strong>*</strong> </label> <input type="text" id="node-input-key" /> </div> <div class="form-row"> <label for="node-input-value" title="Can be overwritten by msg.payload"> <i class="fa fa-comment"></i> Message </label> <input type="text" id="node-input-value" /> </div> <div class="form-row"> <label for="node-input-severity" title="Can be overwritten by msg.config.severity"> <i class="fa fa-exclamation-circle"></i> Severity <strong>*</strong> </label> <select id="node-input-severity"> <option value="debug">Debug</option> <option value="info">Info</option> <option value="warn">Warn</option> <option value="moderate">Moderate</option> <option value="error">Error</option> <option value="critical">Critical</option> </select> </div> <div class="form-row"> <label for="node-input-tags" title="Can be overwritten by msg.config.tags"><i class="fa fa-tags"></i> Tags </label> <input type="text" id="node-input-tags" placeholder="Comma separated" /> </div> <div style="color:#A3A3A3; display:flex; gap:16px; align-items:center; padding:8px 16px; border: 1px solid #a3a3a3; border-radius:12px; margin-top:12px" > <i class="fa fa-info" style="width:16px; text-align:center;"></i> <p style="margin: 0; padding: 0;"> All properties can be overwritten by incoming messages.<br /> Hover a property label to see how it can be overwritten.<br /> Required properties (*) can be provided either in the UI or in messages. </p> </div> <div style="margin-top:12px"> <a href="" target="_blank" class="isaac-workspace-link isaac-full-width" style="text-decoration:underline"> <i class="fa fa-external-link" style="margin-right:8px"></i>Workspace: Activity Logs </a> <a href="" target="_blank" class="isaac-doc-link isaac-full-width" style="margin-top:12px; text-decoration:underline" > <i class="fa fa-book" style="margin-right:8px"></i>API Documentation: Logs </a> </div> </script> <script type="text/html" data-help-name="isaac log entry"> <p> Creates new Activity log entries. Values passed in <code>msg.config</code> will override values enterred in the UI editor dialog. </p> <h3>Inputs</h3> <dl class="message-properties"> <dt class="optional">payload <span class="property-type">string</span></dt> <dd>Optional. Value of the log entry. Will be stringified. Example: Call off the search, Mitch is found</dd> <dt>config.key <span class="property-type">string</span></dt> <dd>Example: Entry by Admin (admin)</dd> <dt class="optional">config.tags <span class="property-type">string | array of strings</span></dt> <dd>Optional. Can be a string of coma separated tags or an array of strings</dd> <dt>config.createdByType <span class="property-type">string</span></dt> <dd>Can be <code>subsystem</code> or <code>user</code>.</dd> <dt>config.createdBy <span class="property-type">string</span></dt> <dd> If created by a subsystem, externalId of that subsystem. If created by a user, string containing the ID of that user. </dd> <dt>config.severity <span class="property-type">string</span></dt> <dd> Can be <code>debug</code>, <code>info</code>, <code>warn</code>, <code>moderate</code>, <code>error</code>, or <code>critical</code>. </dd> </dl> <h3>Outputs</h3> <dl class="message-properties"> <dt>payload <span class="property-type">object</span></dt> <dd>The created log entry.</dd> <dt>statusCode <span class="property-type">number</span></dt> <dd>The status code of the response.</dd> </dl> </script>