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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
function renderPlugin_stablebit(data) {
var directives = {
IsHot: {
html: function () {
return (this.IsHot === "1") ? "<span class=\"badge badge-danger\">YES</span>" : "<span class=\"badge badge-success\">NO</span>";
}
},
IsSmartWarning: {
html: function () {
return (this.IsSmartWarning === "1") ? "<span class=\"badge badge-danger\">YES</span>" : "<span class=\"badge badge-success\">NO</span>";
}
},
IsSmartPastThresholds: {
html: function () {
return (this.IsSmartPastThresholds === "1") ? "<span class=\"badge badge-danger\">YES</span>" : "<span class=\"badge badge-success\">NO</span>";
}
},
IsSmartPastAdvisoryThresholds: {
html: function () {
return (this.IsSmartPastAdvisoryThresholds === "1") ? "<span class=\"badge badge-danger\">YES</span>" : "<span class=\"badge badge-success\">NO</span>";
}
},
IsSmartFailurePredicted: {
html: function () {
return (this.IsSmartFailurePredicted === "1") ? "<span class=\"badge badge-danger\">YES</span>" : "<span class=\"badge badge-success\">NO</span>";
}
},
IsDamaged: {
html: function () {
return (this.IsDamaged === "1") ? "<span class=\"badge badge-danger\">YES</span>" : "<span class=\"badge badge-success\">NO</span>";
}
},
TemperatureC: {
html: function () {
return formatTemp(this.TemperatureC, data.Options["@attributes"].tempFormat);
}
},
Size: {
html: function () {
return formatBytes(this.Size, data.Options["@attributes"].byteFormat);
}
}
};
if (data.Plugins.Plugin_StableBit !== undefined) {
var disks = items(data.Plugins.Plugin_StableBit.Disk);
if (disks.length > 0) {
var i, proc_param;
var html = "";
var paramlist = {SerialNumber:4, Firmware:5, Size:6, PowerState:7, TemperatureC:8, IsHot:9, IsSmartWarning:10, IsSmartPastThresholds:11, IsSmartPastAdvisoryThresholds:12, IsSmartFailurePredicted:13, IsDamaged:14};
for (i = 0; i < disks.length; i++) {
try {
html+="<tr id=\"stablebit-" + i + "\" class=\"treegrid-stablebit-" + i + "\" style=\"display:none;\" >";
html+="<td><span class=\"treegrid-spanbold\" data-bind=\"Name\"></span></td>";
html+="<td></td>";
html+="</tr>";
for (proc_param in paramlist) {
if (disks[i]["@attributes"][proc_param] !== undefined) {
html+="<tr id=\"stablebit-" + i + "-" + proc_param + "\" class=\"treegrid-parent-stablebit-" + i + "\">";
html+="<td><span class=\"treegrid-spanbold\">" + genlang(paramlist[proc_param], 'stablebit') + "</span></td>";
html+="<td class=\"rightCell\"><span data-bind=\"" + proc_param + "\"></span></td>";
html+="</tr>";
}
}
}
catch (err) {
$("#stablebit-" + i).hide();
}
}
$("#stablebit-data").empty().append(html);
for (i = 0; i < disks.length; i++) {
try {
$('#stablebit-'+ i).render(disks[i]["@attributes"]);
$("#stablebit-" + i).show();
for (proc_param in paramlist) {
if (disks[i]["@attributes"][proc_param] !== undefined) {
$('#stablebit-'+ i+ "-" + proc_param).render(disks[i]["@attributes"], directives);
}
}
}
catch (err) {
$("#stablebit-" + i).hide();
}
}
$('#stablebit').treegrid({
initialState: 'expanded',
expanderExpandedClass: 'normalicon normalicon-down',
expanderCollapsedClass: 'normalicon normalicon-right'
});
$('#block_stablebit').show();
} else {
$('#block_stablebit').hide();
}
} else {
$('#block_stablebit').hide();
}
}
|