* Mon May 12 2025 Brian Read <brianr@koozali.org> 11.0.0-1.sme

- Adding SM2 panel [SME: 13004]
- Upgrade to phpsysinfo 3.4.4
- Add code to delete inline styles and add css to make it look better.
- version saved / built uses the static version, which means no drops downs and choices.
This commit is contained in:
2025-05-14 16:14:01 +01:00
parent 80b1da5fa5
commit c8ce77259d
952 changed files with 51341 additions and 28699 deletions

View File

@@ -32,23 +32,29 @@ var snmppinfo_show = false;
* @param {jQuery} xml plugin-XML
*/
function snmppinfo_buildTable(xml) {
var html = "", tree = [], closed = [];
var html = "", tree = [], closed = [], hostname = "";
$("#Plugin_SNMPPInfo #Plugin_SNMPPInfoTable").remove();
html += " <table id=\"Plugin_SNMPPInfoTable\" class=\"tablemain\" style=\"width:100%;\">\n";
html += " <thead>\n";
html += " <tr>\n";
html += " <th>" + genlang(3, false, "SNMPPInfo") + "</th>\n";
html += " <th style=\"width:120px;\">" + genlang(4, false, "SNMPPInfo") + "</th>\n";
html += " <th style=\"width:80px;\">" + genlang(5, false, "SNMPPInfo") + "</th>\n";
html += " </tr>\n";
html += " </thead>\n";
html += " <tbody class=\"tree\">\n";
hostname = $("Plugins Plugin_SNMPInfo", xml).attr('Hostname');
if (hostname !== undefined) {
$('span[class=Hostname_SNMPInfo]').html(hostname);
}
html += " <div style=\"overflow-x:auto;\">\n";
html += " <table id=\"Plugin_SNMPPInfoTable\" class=\"tablemain\">\n";
html += " <thead>\n";
html += " <tr>\n";
html += " <th>" + genlang(2, "SNMPPInfo") + "</th>\n";
html += " <th style=\"width:31%;\">" + genlang(3, "SNMPPInfo") + "</th>\n";
html += " <th class=\"right\" style=\"width:28.7%;\">" + genlang(4, "SNMPPInfo") + "</th>\n";
html += " </tr>\n";
html += " </thead>\n";
html += " <tbody class=\"tree\">\n";
var lastdev="", index = 0 ;
$("Plugins Plugin_SNMPPInfo Printer MarkerSupplies", xml).each(function snmppinfo_getprinters(id) {
var close = 0, name = "", device = "", desc = "", unit = 0, max = 0, level = 0, percent = 0, units = "";
var close = 0, name = "", device = "", desc = "", unit = 0, max = 0, level = 0, percent = 0, units = "", supply = 0, sunits = "";
name = $(this).parent().attr("Name");
device = $(this).parent().attr("Device");
desc = $(this).attr("Description");
@@ -56,6 +62,7 @@ function snmppinfo_buildTable(xml) {
unit = parseInt($(this).attr("SupplyUnit"), 10);
max = parseInt($(this).attr("MaxCapacity"), 10);
level = parseInt($(this).attr("Level"), 10);
supply = parseInt($(this).attr("SupplyUnit"), 10);
if (max>0 && (level>=0) && (level<=max) ) {
percent = Math.round(100*level/max);
@@ -65,25 +72,43 @@ function snmppinfo_buildTable(xml) {
units = level+" / 100";
} else if (level==-3) {
percent = 100;
units = genlang(6, false, "SNMPPInfo")
units = genlang(5, "SNMPPInfo");
} else {
percent = 0;
units = genlang(7, false, "SNMPPInfo")
units = genlang(6, "SNMPPInfo");
}
if (device!=lastdev) {
html += " <tr><td><strong>" + device + " (" + name + ") </strong></td></tr>\n";
html += " <tr><td colspan=\"3\"><div class=\"treediv\"><span class=\"treespanbold\">" + device + " (" + name + ") </div></span></td></tr>\n";
index = tree.push(0);
lastdev = device;
}
html += " <tr><td>" + desc + "</td><td>" + createBar(percent) +"</td><td>" + units +"</td></tr>\n";
if (!isNaN(supply)) {
switch (supply) {
case 7:
sunits = "<br>" + genlang(9, "SNMPPInfo");
break;
case 13:
sunits = "<br>" + genlang(8, "SNMPPInfo");
break;
case 15:
sunits = "<br>" + genlang(7, "SNMPPInfo");
break;
case 19:
sunits = "<br>" + genlang(3, "SNMPPInfo");
break;
}
}
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + desc + "</div></span></td><td>" + createBar(percent) +"</td><td class=\"right\">" + units + sunits + "</td></tr>\n";
tree.push(index);
snmppinfo_show = true;
});
html += " </tbody>\n";
html += " </table>\n";
html += " </tbody>\n";
html += " </table>\n";
html += " </div>\n";
$("#Plugin_SNMPPInfo").append(html);
@@ -109,6 +134,7 @@ function snmppinfo_buildTable(xml) {
* load the xml via ajax
*/
function snmppinfo_request() {
$("#Reload_SNMPPInfoTable").attr("title", "reload");
$.ajax({
url: "xml.php?plugin=SNMPPInfo",
dataType: "xml",
@@ -128,12 +154,12 @@ function snmppinfo_request() {
$(document).ready(function snmppinfo_buildpage() {
$("#footer").before(buildBlock("SNMPPInfo", 1, true));
$("#Plugin_SNMPPInfo").css("width", "451px");
$("#Plugin_SNMPPInfo").addClass("halfsize");
snmppinfo_request();
$("#Reload_SNMPPInfoTable").click(function snmppinfo_reload(id) {
snmppinfo_request();
$("#Reload_SNMPPInfoTable").attr("title",datetime());
$(this).attr("title", datetime());
});
});

View File

@@ -3,14 +3,14 @@ function renderPlugin_snmppinfo(data) {
var directives = {
Device: {
text: function () {
var Name = (this["Name"] !== undefined) ? (' (' + this["Name"] + ')'): '';
return this["Device"] + Name;
var Name = (this.Name !== undefined) ? (' (' + this.Name + ')'): '';
return this.Device + Name;
}
},
Percent: {
html: function () {
var max = parseInt(this["MaxCapacity"]);
var level = parseInt(this["Level"]);
var max = parseInt(this.MaxCapacity, 10);
var level = parseInt(this.Level, 10);
var percent = 0;
if (max>0 && (level>=0) && (level<=max) ) {
@@ -20,76 +20,87 @@ function renderPlugin_snmppinfo(data) {
} else if (level==-3) {
percent = 100;
}
return '<div class="progress"><div class="progress-bar progress-bar-info" style="width: ' + percent + '%;"></div>' +
return '<div class="progress"><div class="progress-bar progress-bar-info" style="width:' + percent + '%;"></div>' +
'</div><div class="percent">' + percent + '%</div>';
}
},
Units: {
text: function () {
var max = parseInt(this["MaxCapacity"]);
var level = parseInt(this["Level"]);
html: function () {
var max = parseInt(this.MaxCapacity, 10);
var level = parseInt(this.Level, 10);
if (max>0 && (level>=0) && (level<=max) ) {
return level+" / "+max;
} else if (max==-2 && (level>=0) && (level<=100) ) {
return level+" / 100";
} else if (level==-3) {
return "enough";
return genlang(5, 'snmppinfo'); // enough
} else {
return "unknown";
return genlang(6, 'snmppinfo'); // unknown
}
}
},
SUnits: {
html: function () {
var supply = parseInt(this.SupplyUnit, 10);
if (isNaN(supply)) {
return "";
} else {
switch (supply) {
case 7:
return "<br>" + genlang(9, "snmppinfo");
case 13:
return "<br>" + genlang(8, "snmppinfo");
case 15:
return "<br>" + genlang(7, "snmppinfo");
case 19:
return "<br>" + genlang(3, "snmppinfo");
}
}
}
}
};
if (data['Plugins']['Plugin_SNMPPInfo'] !== undefined) {
var printers = items(data['Plugins']['Plugin_SNMPPInfo']['Printer']);
if (data.Plugins.Plugin_SNMPPInfo !== undefined) {
var printers = items(data.Plugins.Plugin_SNMPPInfo.Printer);
if (printers.length > 0) {
var i, j, datas;
var html = "";
html+="<thead>";
html+="<tr>";
html+="<th>Printer</th>";
html+="<th>Percent</th>";
html+="<th class=\"rightCell\">Units</th>";
html+="</tr>";
html+="</thead>";
for (var i = 0; i < printers.length; i++) {
html+="<tr id=\"snmppinfo-" + i + "\" class=\"treegrid-snmppinfo-" + i + "\" style=\"display:none\" >";
html+="<td><b><span data-bind=\"Device\"></span></b></td>";
html+="<td></td>";
html+="<td></td>";
for (i = 0; i < printers.length; i++) {
html+="<tr id=\"snmppinfo-" + i + "\" class=\"treegrid-snmppinfo-" + i + "\" style=\"display:none;\" >";
html+="<td colspan=\"3\"><span class=\"treegrid-spanbold\" data-bind=\"Device\"></span></td>";
html+="</tr>";
try {
var datas = items(printers[i]["MarkerSupplies"]);
for (var j = 0; j < datas.length; j++) {
datas = items(printers[i].MarkerSupplies);
for (j = 0; j < datas.length; j++) {
html+="<tr id=\"snmppinfo-" + i + "-" + j +"\" class=\"treegrid-parent-snmppinfo-" + i + "\">";
html+="<th><span data-bind=\"Description\"></span></th>";
html+="<td><span class=\"treegrid-spanbold\" data-bind=\"Description\"></span></td>";
html+="<td><span data-bind=\"Percent\"></span></td>";
html+="<td class=\"rightCell\"><span data-bind=\"Units\"></span></td>";
html+="<td class=\"rightCell\"><span data-bind=\"Units\"></span><span data-bind=\"SUnits\"></span></td>";
html+="</tr>";
}
}
catch (err) {
$("#snmppinfo-" + i).hide();
}
}
}
$("#snmppinfo").empty().append(html);
for (var i = 0; i < printers.length; i++) {
$("#snmppinfo-data").empty().append(html);
for (i = 0; i < printers.length; i++) {
$('#snmppinfo-'+ i).render(printers[i]["@attributes"], directives);
try {
var datas = items(printers[i]["MarkerSupplies"]);
for (var j = 0; j < datas.length; j++) {
datas = items(printers[i].MarkerSupplies);
for (j = 0; j < datas.length; j++) {
$('#snmppinfo-'+ i+ "-" + j).render(datas[j]["@attributes"], directives);
}
}
catch (err) {
$("#snmppinfo-" + i).hide();
}
}
}
$('#snmppinfo').treegrid({
initialState: 'expanded',
expanderExpandedClass: 'normalicon normalicon-down',