initial commit of file from CVS for smeserver-phpsysinfo on Sat Sep 7 20:53:46 AEST 2024
This commit is contained in:
153
root/opt/phpsysinfo/plugins/ipmiinfo/js/ipmiinfo.js
Normal file
153
root/opt/phpsysinfo/plugins/ipmiinfo/js/ipmiinfo.js
Normal file
@@ -0,0 +1,153 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by phpSysInfo - A PHP System Information Script *
|
||||
* http://phpsysinfo.sourceforge.net/ *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
//$Id: ipmiinfo.js 661 2012-08-27 11:26:39Z namiltd $
|
||||
|
||||
|
||||
/*global $, jQuery, buildBlock, datetime, plugin_translate, genlang, createBar */
|
||||
|
||||
"use strict";
|
||||
|
||||
var ipmiinfo_show = false;
|
||||
/**
|
||||
* insert content into table
|
||||
* @param {jQuery} xml plugin-XML
|
||||
*/
|
||||
function ipmiinfo_populate(xml) {
|
||||
|
||||
var html = "";
|
||||
$("#Plugin_ipmiinfoTable").html(" ");
|
||||
|
||||
$("Plugins Plugin_ipmiinfo Temperatures Item", xml).each(function ipmiinfo_getitem(idp) {
|
||||
if(idp==0) {
|
||||
html += "<tr><th colspan=\"2\" style=\"font-weight:bold\">" + genlang(3, true, "ipmiinfo") + "</th></tr>\n";
|
||||
}
|
||||
html += " <tr>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Label") + "</td>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Value") + "</td>\n";
|
||||
html += " </tr>\n";
|
||||
ipmiinfo_show = true;
|
||||
});
|
||||
|
||||
$("Plugins Plugin_ipmiinfo Fans Item", xml).each(function ipmiinfo_getitem(idp) {
|
||||
if(idp==0) {
|
||||
html += "<tr><th colspan=\"2\" style=\"font-weight:bold\">" + genlang(4, true, "ipmiinfo") + "</th></tr>\n";
|
||||
}
|
||||
html += " <tr>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Label") + "</td>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Value") + "</td>\n";
|
||||
html += " </tr>\n";
|
||||
ipmiinfo_show = true;
|
||||
});
|
||||
|
||||
$("Plugins Plugin_ipmiinfo Voltages Item", xml).each(function ipmiinfo_getitem(idp) {
|
||||
if(idp==0) {
|
||||
html += "<tr><th colspan=\"2\" style=\"font-weight:bold\">" + genlang(5, true, "ipmiinfo") + "</th></tr>\n";
|
||||
}
|
||||
html += " <tr>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Label") + "</td>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Value") + "</td>\n";
|
||||
html += " </tr>\n";
|
||||
ipmiinfo_show = true;
|
||||
});
|
||||
|
||||
$("Plugins Plugin_ipmiinfo Currents Item", xml).each(function ipmiinfo_getitem(idp) {
|
||||
if(idp==0) {
|
||||
html += "<tr><th colspan=\"2\" style=\"font-weight:bold\">" + genlang(7, true, "ipmiinfo") + "</th></tr>\n";
|
||||
}
|
||||
html += " <tr>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Label") + "</td>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Value") + "</td>\n";
|
||||
html += " </tr>\n";
|
||||
ipmiinfo_show = true;
|
||||
});
|
||||
|
||||
$("Plugins Plugin_ipmiinfo Powers Item", xml).each(function ipmiinfo_getitem(idp) {
|
||||
if(idp==0) {
|
||||
html += "<tr><th colspan=\"2\" style=\"font-weight:bold\">" + genlang(8, true, "ipmiinfo") + "</th></tr>\n";
|
||||
}
|
||||
html += " <tr>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Label") + "</td>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Value") + "</td>\n";
|
||||
html += " </tr>\n";
|
||||
ipmiinfo_show = true;
|
||||
});
|
||||
$("Plugins Plugin_ipmiinfo Misc Item", xml).each(function ipmiinfo_getitem(idp) {
|
||||
if(idp==0) {
|
||||
html += "<tr><th colspan=\"2\" style=\"font-weight:bold\">" + genlang(6, true, "ipmiinfo") + "</th></tr>\n";
|
||||
}
|
||||
html += " <tr>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Label") + "</td>\n";
|
||||
html += " <td style=\"font-weight:normal\">" + $(this).attr("Value") + "</td>\n";
|
||||
html += " </tr>\n";
|
||||
ipmiinfo_show = true;
|
||||
});
|
||||
|
||||
$("#Plugin_ipmiinfoTable").append(html);
|
||||
$('#Plugin_ipmiinfoTable tr:nth-child(even)').addClass('even');
|
||||
|
||||
}
|
||||
|
||||
function ipmiinfo_buildTable() {
|
||||
var html = "";
|
||||
|
||||
html += "<table id=\"Plugin_ipmiinfoTable\" class=\"stripeMe\" style=\"border-spacing:0;\">\n";
|
||||
html += " <thead>\n";
|
||||
html += " </thead>\n";
|
||||
html += " <tbody>\n";
|
||||
html += " </tbody>\n";
|
||||
html += "</table>\n";
|
||||
$("#Plugin_ipmiinfo").append(html);
|
||||
}
|
||||
|
||||
/**
|
||||
* load the xml via ajax
|
||||
*/
|
||||
function ipmiinfo_request() {
|
||||
$.ajax({
|
||||
url: "xml.php?plugin=ipmiinfo",
|
||||
dataType: "xml",
|
||||
error: function ipmiinfo_error() {
|
||||
$.jGrowl("Error loading XML document for Plugin ipmiinfo!");
|
||||
},
|
||||
success: function ipmiinfo_buildblock(xml) {
|
||||
populateErrors(xml);
|
||||
ipmiinfo_populate(xml);
|
||||
if (ipmiinfo_show) {
|
||||
plugin_translate("ipmiinfo");
|
||||
$("#Plugin_ipmiinfo").show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function ipmiinfo_buildpage() {
|
||||
$("#footer").before(buildBlock("ipmiinfo", 1, true));
|
||||
$("#Plugin_ipmiinfo").css("width", "451px");
|
||||
|
||||
ipmiinfo_buildTable();
|
||||
|
||||
ipmiinfo_request();
|
||||
|
||||
$("#Reload_ipmiinfoTable").click(function ipmiinfo_reload(id) {
|
||||
ipmiinfo_request();
|
||||
$("#Reload_ipmiinfoTable").attr("title",datetime());
|
||||
});
|
||||
});
|
@@ -0,0 +1,36 @@
|
||||
function renderPlugin_ipmiinfo(data) {
|
||||
|
||||
var directives = {
|
||||
Label: {
|
||||
html: function () {
|
||||
if (this["Value"] == undefined) {
|
||||
return '<b>' + this["Label"] + '</b>';
|
||||
} else {
|
||||
return this["Label"];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (data['Plugins']['Plugin_ipmiinfo'] !== undefined) {
|
||||
var data_ipmiinfo = [];
|
||||
var valuelist = {Temperatures:"Temperatures [C]", Voltages:"Voltages [V]", Fans:"Fans [RPM]", Powers:"Powers [W]", Currents:"Currents [A]", Misc:"Misc [0/1]"};
|
||||
for (var ipmiinfo_value in valuelist) {
|
||||
if (data['Plugins']['Plugin_ipmiinfo'][ipmiinfo_value] !== undefined) {
|
||||
var datas = items(data['Plugins']['Plugin_ipmiinfo'][ipmiinfo_value]["Item"]);
|
||||
if (datas.length > 0) {
|
||||
data_ipmiinfo.push({Label:valuelist[ipmiinfo_value]});
|
||||
data_ipmiinfo.push_attrs(datas);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data_ipmiinfo.length > 0) {
|
||||
$('#ipmiinfo-data').render(data_ipmiinfo, directives);
|
||||
$('#block_ipmiinfo').show();
|
||||
} else {
|
||||
$('#block_ipmiinfo').hide();
|
||||
}
|
||||
} else {
|
||||
$('#block_ipmiinfo').hide();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user