Hello,
I want to share my work for an horizontal progress bar.
Known restrictions (for the moment) :
- Value must be a 0/100 range because I don't know how to get the maximum value
- Object height is hard coded. I wasn't able to match the PRTG Map Editor size
- Text inside the progress is not V-centered
Maybe only a few things is needed to acheive it :
<!--Status Icons: Progress Bar--> <div class="map_object map_icon mapicon_status_white" id="<@itemid>" objectid="<@objectid>" subid="<@subid>" style="<#mapobject type="topleftcoordinates" subid="<@subid>" mode="<@editmode>">"> <#mapobject type="objectgrip" mode="<@editmode>"> <#mapobject type="htmlbefore" subid="<@subid>"> <#checkobjecttype objecttype="sensor" nicemessage="true" id="<@objectid>"> <style> .progress-bar { background-color:rgb(176,176,176); color:rgb(255,255,255); font-size:14px; text-align:center; padding:10px 5px 8px 5px; border-radius: 3px; width: 150px; } .progress-bar-inner { display: block; font-weight: bold; margin : 2px; padding : 2px; border-radius: 3px; position: relative; vertical-align: 20%; } </style> <!-- list des name : https://www.paessler.com/manuals/prtg/live_single_object_status --> <div class='progress-bar'> <span id="myspan<@objectid>" class='progress-bar-inner'>VALUE</span> </div> <script> var str = "<#objectstatus name="lastvalue" id="<@objectid>">"; var res = str.split(" ", 1); var prtgValue = parseInt(res); document.getElementById("myspan<@objectid>").textContent="<#objectstatus name="lastvalue" id="<@objectid>">"; document.getElementById("myspan<@objectid>").style.width=res[0]+"%"; if (prtgValue < 15) { document.getElementById("myspan<@objectid>").style.background="rgb(227,6,19)"; } else if (prtgValue < 25) { document.getElementById("myspan<@objectid>").style.background="rgb(245,197, 0)"; } else { document.getElementById("myspan<@objectid>").style.background="rgb(184,196,25)"; } </script> <#mapobject type="htmlafter" subid="<@subid>"> </div>
Add comment