Hello,
i hope its ok that i ask that question here, i didnt found an answer yet.
I would like to link Media in my Intranet on a HTML Table.
My template Node gets the data from a function node with following code:
let arr = []
let obj
var Grundpfad = " file:\\\\\\sourcepath to the media";
var k = 0 //Komponentenzähler
for(k=0;k<1000;k++){
if(msg.payload[k]){
}else{
break
}
}
function isNull() {
for (var i = 0; i < arguments.length; i++) {
if (
typeof arguments[i] !== 'undefined'
&& arguments[i] !== undefined
&& arguments[i] != null
&& arguments[i] != NaN
&& arguments[i]
) return arguments[i];
}
}
for(let i=0;i<k;i++){
obj = {}
obj.Device_Name = msg.payload[i].Device_Name
obj.Device_Nr = msg.payload[i].Device_Nr
obj.Device_Serial = msg.payload[i].Device_Serial
obj.Device_Type = msg.payload[i].Device_Type
obj.Booking_DateTime = msg.payload[i].Booking_DateTime
obj.Booking_Remarks = msg.payload[i].Booking_Remarks
obj.Location_Name = msg.payload[i].Location_Name
if(isNull(msg.payload[i].Documents)){
obj.Documents = "<a href=" + Grundpfad + msg.payload[i].Documents + "</a>"//the last part of the path
}else{
obj.Documents = "Kein Dokument hinterlegt"
}
arr.push(obj)
}
const komps = arr;
function compare(a, b) {
const Device_TypeA = a.Device_Type.toUpperCase();
const Device_TypeB = b.Device_Type.toUpperCase();
let comparison = 0;
if (Device_TypeA > Device_TypeB) {
comparison = 1;
} else if (Device_TypeA < Device_TypeB) {
comparison = -1;
}
return comparison;
}
komps.sort(compare);
//node.warn(arr)
msg.payload = komps
msg.topic = k
return msg;
The table in the template node looks like this:
<script>
var grundpfad = "teststuff"
</script>
<table id="table" border="1">
<tr>
<th style="width: 10%;" >Gerätename</th>
<th style="width: 10%;" >Laufende Nummer</th>
<th style="width: 10%;" >Seriennummer</th>
<th style="width: 5%;" >Typ</th>
<th style="width: 5%;" >Buchungsdatum</th>
<th style="width: 16%;" >Remark</th>
<th style="width: 6%;" >Ort</th>
<th style="width: 60%;" >Medium1</th>
<th style="width: 20%;" >Medium2</th>
<th style="width: 20%;" >Medium3</th>
</tr>
<tbody>
<tr ng-repeat="row in msg.payload">
<td ng-repeat="item in row" >{{item}}</td>
</tr>
</tbody>
</table>
What i dont get is a working Link for Pics or PDFs for the Browser to open, or a way to display the media in the table.
I am not good in html, perhaps somebody may help ?
Greetings
Chorum