function renderPlugin_raid(data) {
function raid_buildaction(data) {
var html = "", name = "", percent = 0;
if (data !== undefined) {
name = data.Name;
if ((name !== undefined) && (parseInt(name, 10) !== -1)) {
percent = Math.round(parseFloat(data.Percent));
html += "
" + genlang(11,'raid') + ":" + String.fromCharCode(160) + name + "
";
html += '
';
if ((data.Time_To_Finish !== undefined) && (data.Time_Unit !== undefined)) {
html += genlang(12,'raid') + ":" + String.fromCharCode(160) + data.Time_To_Finish + String.fromCharCode(160) + data.Time_Unit;
}
html += "
";
}
}
return html;
}
function raid_diskicon(data , id, itemid, byteFormat, tempFormat) {
var info = data.Info;
if (info === undefined) info = "";
var parentid = parseInt(data.ParentID, 10);
var imgh = "", imgs = "", alt = "", bcolor = "", bus = "", cap = "", minfo = "", serial = "";
switch (data.Status) {
case "ok":
imgh = "harddriveok.png";
imgs = "soliddriveok.png";
alt = "ok";
bcolor = "green";
break;
case "F":
imgh = "harddrivefail.png";
imgs = "soliddrivefail.png";
alt = "fail";
bcolor = "red";
break;
case "S":
imgh = "harddrivespare.png";
imgs = "soliddrivespare.png";
alt = "spare";
bcolor = "gray";
break;
case "U":
imgh = "harddriveunc.png";
imgs = "soliddriveunc.png";
alt = "unconfigured";
bcolor = "purple";
break;
case "W":
imgh = "harddrivewarn.png";
imgs = "soliddrivewarn.png";
alt = "warning";
bcolor = "orange";
break;
default:
// alert("--" + diskstatus + "--");
imgh = "error.png";
imgs = "error.png";
alt = "error";
break;
}
if (!isNaN(parentid)) {
if (data.Type !== undefined) {
if (data.Model !== undefined) {
minfo = ""+raiditems[i]["@attributes"].Device_Name+" | ";
if (raiditems[i].RaidItems !== undefined) {
html += "";
html += " | ";
if (raiditems[i].Action !== undefined) {
var buildedaction = raid_buildaction(raiditems[i].Action['@attributes']);
if (buildedaction) {
html += "" + buildedaction + " | ";
}
}
html += "";
html += "";
html += "" + genlang(2, "raid") + " | | ";
html += ""+genlang(22, 'raid')+" | " + raiditems[i]["@attributes"].Program + " | "; // Program
if (raiditems[i]["@attributes"].Name !== undefined) html += ""+genlang(3, 'raid')+" | " + raiditems[i]["@attributes"].Name + " | "; // Name
html += ""+genlang(4, 'raid')+" | " + raiditems[i]["@attributes"].Status + " | "; // Status
if (raiditems[i]["@attributes"].Level !== undefined) html += ""+genlang(5, 'raid')+" | " + raiditems[i]["@attributes"].Level + " | "; // RAID-Level
if (!isNaN(parseInt(raiditems[i]["@attributes"].Capacity, 10))) html += ""+genlang(6, 'raid')+" | " + formatBytes(parseInt(raiditems[i]["@attributes"].Capacity, 10), data.Options["@attributes"].byteFormat) + " | ";// Capacity
if (!isNaN(parseInt(raiditems[i]["@attributes"].Stride, 10))) html += ""+genlang(7, 'raid')+" | " + parseInt(raiditems[i]["@attributes"].Stride, 10) + " | "; // Stride
if (!isNaN(parseInt(raiditems[i]["@attributes"].Subsets, 10))) html += ""+genlang(8, 'raid')+" | " + parseInt(raiditems[i]["@attributes"].Subsets, 10) + " | "; // Subsets
if (raiditems[i]["@attributes"].Devs !== undefined) html += ""+genlang(9, 'raid')+" | " + parseInt(raiditems[i]["@attributes"].Devs, 10) + " | "; // Devices
if (!isNaN(parseInt(raiditems[i]["@attributes"].Spares, 10))) html += ""+genlang(10, 'raid')+" | " + parseInt(raiditems[i]["@attributes"].Spares, 10) + " | "; // Spares
if (!isNaN(parseInt(raiditems[i]["@attributes"].Chunk_Size, 10))) html += ""+genlang(13, 'raid')+" | " + formatBytes(1024*parseInt(raiditems[i]["@attributes"].Chunk_Size, 10), data.Options["@attributes"].byteFormat) + " | ";
if (!isNaN(parseInt(raiditems[i]["@attributes"].Stripe_Size, 10))) html += ""+genlang(28, 'raid')+" | " + formatBytes(parseInt(raiditems[i]["@attributes"].Stripe_Size, 10), data.Options["@attributes"].byteFormat) + " | ";
if (raiditems[i]["@attributes"].Algorithm !== undefined) html += ""+genlang(14, 'raid')+" | " + raiditems[i]["@attributes"].Algorithm + " | ";
if (!isNaN(parseInt(raiditems[i]["@attributes"].Persistend_Superblock, 10))) {
if (parseInt(raiditems[i]["@attributes"].Persistend_Superblock, 10) == 1) {
html += ""+genlang(15, 'raid')+" | "+genlang(16, 'raid')+" | ";
} else {
html += ""+genlang(15, 'raid')+" | "+genlang(17, 'raid')+" | ";
}
}
if (!isNaN(parseInt(raiditems[i]["@attributes"].Disks_Registered, 10)) && !isNaN(parseInt(raiditems[i]["@attributes"].Disks_Active, 10))) {
html += ""+genlang(18, 'raid')+" | " + parseInt(raiditems[i]["@attributes"].Disks_Registered, 10) + "/" + parseInt(raiditems[i]["@attributes"].Disks_Active, 10) + " | ";
}
if (raiditems[i]["@attributes"].Controller !== undefined) html += ""+genlang(19, 'raid')+" | " + raiditems[i]["@attributes"].Controller + " | "; // Controller
if (raiditems[i]["@attributes"].Firmware !== undefined) html += ""+genlang(29, 'raid')+" | " + raiditems[i]["@attributes"].Firmware + " | "; // Firmware
if (isFinite(parseFloat(raiditems[i]["@attributes"].Temperature))) html += ""+genlang(30, 'raid')+" | " + formatTemp(parseFloat(raiditems[i]["@attributes"].Temperature), data.Options["@attributes"].tempFormat) + " | "; // Temperature
if (raiditems[i]["@attributes"].Battery !== undefined) html += ""+genlang(20, 'raid')+" | " + raiditems[i]["@attributes"].Battery + " | "; // Battery Condition
if (isFinite(parseFloat(raiditems[i]["@attributes"].Batt_Volt))) html += ""+genlang(31, 'raid')+" | " + round(parseFloat(raiditems[i]["@attributes"].Batt_Volt), 3) + " " + genlang(82) + " | "; // Battery Voltage
if (isFinite(parseFloat(raiditems[i]["@attributes"].Batt_Temp))) html += ""+genlang(32, 'raid')+" | " + formatTemp(parseFloat(raiditems[i]["@attributes"].Batt_Temp), data.Options["@attributes"].tempFormat) + " | "; // Battery Temperature
if (raiditems[i]["@attributes"].Supported !== undefined) html += ""+genlang(21, 'raid')+" | " + raiditems[i]["@attributes"].Supported + " | "; // Supported RAID-Types
if (raiditems[i]["@attributes"].Cache_Size !== undefined) html += ""+genlang(25, 'raid')+" | " + formatBytes(parseInt(raiditems[i]["@attributes"].Cache_Size, 10), data.Options["@attributes"].byteFormat) + " | "; // Cache_Size
if (raiditems[i]["@attributes"].ReadPolicy !== undefined) html += ""+genlang(23, 'raid')+" | " + raiditems[i]["@attributes"].ReadPolicy + " | "; // Read Policy
if (raiditems[i]["@attributes"].WritePolicy !== undefined) html += ""+genlang(24, 'raid')+" | " + raiditems[i]["@attributes"].WritePolicy + " | "; // Write Policy
if (raiditems[i]["@attributes"].Cachevault_Size !== undefined) html += ""+genlang(33, 'raid')+" | " + formatBytes(parseInt(raiditems[i]["@attributes"].Cachevault_Size, 10), data.Options["@attributes"].byteFormat) + " | "; // Cachevault_Size
if (raiditems[i]["@attributes"].DiskCache !== undefined) html += ""+genlang(27, 'raid')+" | " + raiditems[i]["@attributes"].DiskCache + " | "; // Disk Cache
if (raiditems[i]["@attributes"].Bad_Blocks !== undefined) html += ""+genlang(26, 'raid')+" | " + parseInt(raiditems[i]["@attributes"].Bad_Blocks, 10) + " | "; // Bad_Blocks
html += " ";
html += " | ";
html += " ";
}
/*if (i < raiditems.length-1) { // not last element
html += " ";
}*/
html +=" |
";
}
$('#raid-data').empty().append(html);
for (var k = 0; k < raiditems.length ; k++) {
if (raiditems[k].RaidItems !== undefined) {
var diskitems = items(raiditems[k].RaidItems.Item);
for (var j = 0; j < diskitems.length ; j++) {
raid_diskicon(diskitems[j]["@attributes"], k, j, data.Options["@attributes"].byteFormat, data.Options["@attributes"].tempFormat);
}
$('#raid-'+k).treegrid({
initialState: 'collapsed',
expanderExpandedClass: 'normalicon normalicon-down',
expanderCollapsedClass: 'normalicon normalicon-right'
});
}
}
$('#block_raid').show();
} else {
$('#block_raid').hide();
}
} else {
$('#block_raid').hide();
}
}