Posts: 179
Threads: 43
Joined: Jul 2015
Reputation:
2
Hi
As subject indicated iam wondering if it is possible to get a "tooltip" when holding mouse over objects in visu that grabs the updated at from group adress?
This is to indicate if the value is new or old?
Posts: 942
Threads: 161
Joined: Jul 2015
Reputation:
33
06.11.2019, 23:27
(This post was last modified: 06.11.2019, 23:29 by buuuudzik .)
As I know only by Custom Javascript + .lp file.
Custom JS could lhave such code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
$(
function (){
const updatetimes = {};
const marked =
document.querySelectorAll (
".when-updated" );
const gaMatcher = /
wh\- ([
0 -
9 ]+)
_ ([
0 -
9 ]+)
_ ([
0 -
9 ]+)/
i ;
const isDef =
n =>
typeof n !==
"undefined" ;
const showDate =
updatetime =>
new Date (
updatetime *
1000 ).
toString ();
marked.forEach (
element => {
let loaded =
false ;
const [
matching ,
a ,
b ,
c ] =
element.className.match (
gaMatcher );
if (!
matching )
return ;
const ga = `${
a }/${
b }/${
c }`;
if (
typeof updatetimes [
ga ] ===
"undefined" )
updatetimes [
ga ] =
0 ;
grp.listen (
ga , (
object ,
state ) => {
if (
state ===
"value" &&
loaded ) {
updatetimes [
ga ] =
Date.now ()/
1000 ;
element.title =
updatetimes [
ga ] ?
showDate (
updatetimes [
ga ]) :
null ;
}
},
true );
});
const updateUpdatetimes =
data => {
if (!
data )
return ;
const objects =
JSON.parse (
data );
Object.keys (
updatetimes ).
forEach (
ga => {
const found =
objects.find (
obj =>
obj.address ===
ga );
if (
found.updatetime >
updatetimes [
ga ]) {
updatetimes [
ga ] =
found.updatetime ;
document.querySelectorAll (`.
wh- ${
ga.split (
"/" ).
join (
"_" )}`).
forEach (
element =>
element.title =
showDate (
updatetimes [
ga ]))
}
});
loaded =
true ;
}
//
download current grp.all ()
from object.lp
$.
get (
"/user/objects.lp" ,
data =>
updateUpdatetimes (
data ));
});
You need also /user/objects.lp file with such content:
Code:
1 2 3 4 5 6 7 8
<?
require (
"json" )
require (
"genohm-scada" )
require (
"apps" )
objects =
json.encode (
grp.all ())
print (
objects )
?>
Then all controls on the visu which will have special classes e.g. "when-updated wh-1_1_1" (for 1/1/1 address) will have title with last updated info ().
This is only some scratch, for a start
Done is better than perfect