node-red-contrib-tableify
Version:
Uses npm package tableify to convert json into an html table. Returns the html in msg.payload
86 lines (79 loc) • 3.3 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('tableify',{
category: 'function',
color: '#e7e8a2',
defaults: {
name: {value:""},
before: {value:""},
after: {value:""},
tableStyle: {value:""},
theadStyle: {value:""},
tbodyStyle: {value:""},
trStyle: {value:""},
tdStyle: {value:""}
},
inputs:1,
outputs:1,
icon: "serial.png",
align: 'left',
paletteLabel:"tableify",
label: function() {
return this.name||"tableify";
}
});
</script>
<script type="text/x-red" data-template-name="tableify">
<div class="form-row">
<label for="node-input-before"><i class="icon-tag"></i> Text Before Table </label>
<input type="text" id="node-input-before" placeholder="Hi, Few words about table's content'">
</div>
<div class="form-row">
<label for="node-input-after"><i class="icon-tag"></i> Text After Table </label>
<input type="text" id="node-input-after" placeholder="Thanks & Regards">
</div>
<div class="form-row">
Default styles can be found in info tab.
</div>
<div class="form-row">
<label for="node-input-tableStyle"><i class="icon-tag"></i> table Style </label>
<input type="text" id="node-input-tableStyle" placeholder="padding:2px;margin:5px;">
</div>
<div class="form-row">
<label for="node-input-theadStyle"><i class="icon-tag"></i> thead Style </label>
<input type="text" id="node-input-theadStyle" placeholder="padding:2px;margin:5px;">
</div>
<div class="form-row">
<label for="node-input-tbodyStyle"><i class="icon-tag"></i> tbody Style </label>
<input type="text" id="node-input-tbodyStyle" placeholder="padding:2px;margin:5px;">
</div>
<div class="form-row">
<label for="node-input-trStyle"><i class="icon-tag"></i> tr Style </label>
<input type="text" id="node-input-trStyle" placeholder="padding:2px;margin:5px;">
</div>
<div class="form-row">
<label for="node-input-tdStyle"><i class="icon-tag"></i> td Style </label>
<input type="text" id="node-input-tdStyle" placeholder="padding:2px;margin:5px;">
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="tableify">
<p>Converts your valid JSON object or array of objects into a HTML table. Suppports nested objects. </p>
<h2>Definable properties</h2>
<p>msg.payload</p>
<p>msg.before</p>
<p>msg.after</p>
<p>msg.tableStyle</p>
<p>msg.theadStyle</p>
<p>msg.tbodyStyle</p>
<p>msg.trStyle</p>
<p>msg.tdStyle</p>
<h2> Default Styles: </h2>
<p> table: font-family:Arial;width:100%;border:1px solid #ccc;border-collapse: collapse;color:#667677; </p>
<p> thead: border:1px solid #ccc;background:#6a9ef2;color:white !important; height:50px;padding:2px; </p>
<p> tbody: </p>
<p> tr: border:1px solid #ccc;</p>
<p> td: border:1px solid #ccc;text-align:center;padding:3px; </p>
</script>