This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Add objects to Visu by Tag
#1
Is it possible to auto fill a table (or similar) in visu by adding tags to objects?
Reply
#2
Can you provide a picture of what you want to achieve?
Reply
#3
(28.12.2022, 07:18)admin Wrote: Can you provide a picture of what you want to achieve?

I do not have a screenshot, but to explain more detailed: If I add a tag to a object, I would like for it to automaticly be added to visu. and show value + name. Like a excel spreadsheet of sorts.
Reply
#4
You can use .lp server-side script and iframe element to display a table. Upload via FTP using apps login to user directory as objects.lp
Then use /user/objects.lp as iframe source.
Code:
<?
require('apps')
objs = grp.tag('tag_name_here')
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Objects</title>
<link rel="stylesheet" href="/apps/css/bootstrap.css">
<link rel="stylesheet" href="/apps/css/font-awesome.css">
<link rel="stylesheet" href="/apps/css/style.css">
<script src="/apps/js/jquery.js.gz"></script>
</head>
<body>
<table class="table table-hover" style="margin-bottom:0">
  <thead>
    <tr>
      <th>Name</th>
      <th>Value</th>
      <th>Date</th>
    </tr>
  </thead>
  <tbody></tbody>
</table>
<script>
var data = <?=json.encode(objs)?>;

// sort data by name
data.sort(function(a, b) {
  var na = a.name.toLowerCase()
     , nb = b.name.toLowerCase();

  if (na > nb) {
    return 1;
  }
  else if (na < nb) {
    return -1;
  }
  else {
    return 0;
  }
});

// show each object name/value/update time
$.each(data, function(index, item) {
  var trs = $('<tr><td></td><td></td><td></td></tr>').appendTo('tbody')
    , tds = trs.find('td')
    , d = new Date(item.updatetime * 1000);

  $(tds[ 0 ]).text(item.name);
  $(tds[ 1 ]).text(item.value);
  $(tds[ 2 ]).text(d.toString().split(' GMT')[0]);
});
</script>
</body>
</html>
Reply


Forum Jump: