remove switches, add icons, add tablesorter and filters

This commit is contained in:
Derek Macias 2016-01-17 19:15:16 -07:00
parent 49e821662f
commit ce9cf274d7
6 changed files with 68 additions and 75 deletions

View File

@ -15,6 +15,7 @@ $theme = $display["theme"];
<link type="text/css" rel="stylesheet" href="/plugins/ipmitool-plugin/css/ipmitool-plugin.css"> <link type="text/css" rel="stylesheet" href="/plugins/ipmitool-plugin/css/ipmitool-plugin.css">
<link type="text/css" rel="stylesheet" href="/plugins/tablesorter/css/tablesorter.css"> <link type="text/css" rel="stylesheet" href="/plugins/tablesorter/css/tablesorter.css">
<link type="text/css" rel="stylesheet" href="/plugins/tablesorter/css/tablesorter-<?=$theme;?>.css"> <link type="text/css" rel="stylesheet" href="/plugins/tablesorter/css/tablesorter-<?=$theme;?>.css">
<link type="text/css" rel="stylesheet" href="/webGui/styles/jquery.switchbutton.css">
<div> <div>
<span class="status" style="margin-top: -22px;"><input type="checkbox" class="advancedview"></span> <span class="status" style="margin-top: -22px;"><input type="checkbox" class="advancedview"></span>
@ -36,17 +37,13 @@ $theme = $display["theme"];
<tbody> <tbody>
</tbody> </tbody>
</table> </table>
<button type="button" onClick="done();">Done</button>
</div> </div>
<form markdown="1">
&nbsp;
: <button type="button" onClick="done();">Done</button>
</form>
<script type="text/javascript" src="/plugins/ipmitool-plugin/js/jquery.ipmitool-plugin.js"></script> <script type="text/javascript" src="/plugins/ipmitool-plugin/js/jquery.ipmitool-plugin.js"></script>
<script type="text/javascript" src="/plugins/tablesorter/js/jquery.tablesorter.combined.min.js"></script> <script type="text/javascript" src="/plugins/tablesorter/js/jquery.tablesorter.combined.min.js"></script>
<script type="text/javascript" src="/plugins/tablesorter/js/pager/jquery.tablesorter.pager.js"></script> <script type="text/javascript" src="/plugins/tablesorter/js/pager/jquery.tablesorter.pager.js"></script>
<script type="text/javascript" src="/webGui/javascript/jquery.switchbutton.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var Password = '<?=$ipmitool_password?>'; var Password = '<?=$ipmitool_password?>';

View File

@ -2,3 +2,7 @@
.tablesorter { .tablesorter {
margin-top:-21px; margin-top:-21px;
} }
.tablesorter td.reading{
font-weight: bold;
}

View File

@ -1,4 +1,4 @@
<?php <?php
$command = "/usr/bin/ipmitool sel ".$_POST["options"]; $cmd = "/usr/bin/ipmitool sel ".$_POST["options"];
exec($command); exec($cmd);
?> ?>

View File

@ -20,19 +20,13 @@ $(function(){
}); });
//sensor refresh //sensor refresh
(function sensorRefresh() { function sensorRefresh() {
sensorArray(true); sensorArray(true);
setTimeout(sensorRefresh, 30000); setTimeout(sensorRefresh, 3000);
}()); };
//load ipmi sensor table //load ipmi sensor table
function sensorArray(Refresh){ function sensorArray(Refresh){
var Display = 'none';
if ($.cookie('ipmitool_sensor_mode') == 'advanced') {
$('.advanced').show();
Display = 'table-cell';
}
$.ajax({ $.ajax({
type: "POST", type: "POST",
dataType: "json", dataType: "json",
@ -52,10 +46,12 @@ function sensorArray(Refresh){
var Name = data[i][0].replace('+', 'plus_').replace('-', 'minus_').replace(' ', '_').replace('.', '_'); var Name = data[i][0].replace('+', 'plus_').replace('-', 'minus_').replace(' ', '_').replace('.', '_');
if (data[i][6]=="Voltage"){ if (data[i][6]=="Voltage"){
if (parseFloat(Reading) < parseFloat(LowerNonRec) || parseFloat(Reading) > parseFloat(UpperNonRec))
Color = "red";
if (parseFloat(Reading) > parseFloat(LowerNonRec) && parseFloat(Reading) < parseFloat(UpperNonRec)) if (parseFloat(Reading) > parseFloat(LowerNonRec) && parseFloat(Reading) < parseFloat(UpperNonRec))
Color = "red"; Color = "red";
if (parseFloat(Reading) > parseFloat(LowerCritical) && parseFloat(Reading) < parseFloat(UpperCritical)) if (parseFloat(Reading) > parseFloat(LowerCritical) && parseFloat(Reading) < parseFloat(UpperCritical))
Color = "yellow"; Color = "orange";
if (parseFloat(Reading) > parseFloat(LowerNonCrit) && parseFloat(Reading) < parseFloat(UpperNonCrit)) if (parseFloat(Reading) > parseFloat(LowerNonCrit) && parseFloat(Reading) < parseFloat(UpperNonCrit))
Color = "green"; Color = "green";
} else if (data[i][6]=="Fan"){ } else if (data[i][6]=="Fan"){
@ -73,19 +69,25 @@ function sensorArray(Refresh){
.append("<tr id='"+Name+"'>"+ .append("<tr id='"+Name+"'>"+
"<td title='"+data[i][3]+"'><img src='/plugins/ipmitool-plugin/images/green-on.png'/></td>"+ //status "<td title='"+data[i][3]+"'><img src='/plugins/ipmitool-plugin/images/green-on.png'/></td>"+ //status
"<td>"+data[i][0]+"</td>"+ //sensor name "<td>"+data[i][0]+"</td>"+ //sensor name
"<td class='advanced' style='display:" + Display + ";'>" + LowerNonRec + "</td>"+ "<td class='advanced'>"+ LowerNonRec +"</td>"+
"<td class='advanced' style='display:" + Display + ";'>" + LowerCritical + "</td>"+ "<td class='advanced'>"+ LowerCritical +"</td>"+
"<td class='advanced' style='display:" + Display + ";'>" + LowerNonCrit + "</td>"+ "<td class='advanced'>"+ LowerNonCrit +"</td>"+
"<td class='reading'>" + "<font color='" + Color + "'>" + Reading + "</font>" + "</td>"+ //sensor reading "<td class='reading "+ Color +"-text'>"+ Reading +"</td>"+ //sensor reading
"<td>"+data[i][2]+"</td>"+ //sensor units "<td>"+data[i][2]+"</td>"+ //sensor units
"<td class='advanced' style='display:" + Display + ";'>" + UpperNonCrit + "</td>"+ "<td class='advanced'>"+ UpperNonCrit +"</td>"+
"<td class='advanced' style='display:" + Display + ";'>" + UpperCritical + "</td>"+ "<td class='advanced'>"+ UpperCritical +"</td>"+
"<td class='advanced' style='display:" + Display + ";'>" + UpperNonRec + "</td>"+ "<td class='advanced'>"+ UpperNonRec +"</td>"+
"</tr>"); "</tr>");
} }
} }
}); });
$("#tblSensor").trigger("update"); //update sensor table $("#tblSensor").trigger("update"); //update sensor table
if ($.cookie('ipmitool_sensor_mode') == 'advanced')
$('.advanced').show();
else
$('.advanced').hide();
$('#tblSensor').tablesorter(); $('#tblSensor').tablesorter();
}, },
error : function() {}, error : function() {},
@ -106,7 +108,7 @@ function eventArray(){
$.each(data, function (i, val) { $.each(data, function (i, val) {
var Status = (data[i][5] == 'Asserted') ? 'red' : 'green'; var Status = (data[i][5] == 'Asserted') ? 'red' : 'green';
$("#tblEvent tbody") $("#tblEvent tbody")
.append("<tr>"+ .append("<tr id='"+data[i][0]+"'>"+
"<td title='"+data[i][5]+"'><img src='/plugins/ipmitool-plugin/images/" + Status + "-on.png'/></td>"+ //status "<td title='"+data[i][5]+"'><img src='/plugins/ipmitool-plugin/images/" + Status + "-on.png'/></td>"+ //status
"<td>" + data[i][0] + "</td>"+ //event id "<td>" + data[i][0] + "</td>"+ //event id
"<td>" + data[i][1] + " "+data[i][2]+"</td>"+ //time stamp "<td>" + data[i][1] + " "+data[i][2]+"</td>"+ //time stamp
@ -133,7 +135,20 @@ function eventArray(){
filter_saveFilters : true, filter_saveFilters : true,
filter_reset : 'a.reset', filter_reset : 'a.reset',
filter_functions: { filter_functions: {
'.filter-time' : true, '.filter-time' : {
"3 days" : function(e, n, f, i, $r, c, data) {
return ($.now() - n <= 259200000); }, //3*24*60*60 3 days
"1 week" : function(e, n, f, i, $r, c, data) {
return ($.now() - n <= 604800000); }, //7*24*60*60 1 week
"2 weeks" : function(e, n, f, i, $r, c, data) {
return ($.now() - n <= 1209600000); }, //14*24*60*60 2 weeks
"1 month" : function(e, n, f, i, $r, c, data) {
return ($.now() - n <= 2592000000); }, //30*24*60*60 1 month
"6 months" : function(e, n, f, i, $r, c, data) {
return ($.now() - n <= 15724800000); }, //26*7*24*60*60 6 months
"1 year" : function(e, n, f, i, $r, c, data) {
return ($.now() - n <= 31449600000); } //52*7*24*60*60 1 year
},
'.filter-name' : true '.filter-name' : true
} }
} }
@ -143,6 +158,11 @@ function eventArray(){
fixedHeight: false, fixedHeight: false,
size: 10 size: 10
}); });
$("#allEvents").click(function() {
Delete('all');
});
}, },
complete: function () { complete: function () {
@ -152,49 +172,21 @@ function eventArray(){
}; };
function Delete(Row) { function Delete(Row) {
var Confirm = (Row == "all") ? confirm("Are your sure you want to remove all speedtests!?"): true; var Confirm = (Row == "all") ? confirm("Are your sure you want to remove all events!?"): true;
/* if (Confirm){ if (Confirm){
var EventId = $(this).val(); //get event id var Method = (Row == "all") ? "clear " : "delete ";
var par = $(this).parent().parent(); //get table row var EventId = (Row == "all") ? "" : Row;
$.ajax({ $.ajax({
type : "POST", type : "POST",
url : "/plugins/ipmitool-plugin/include/delete_event.php", url : "/plugins/ipmitool-plugin/include/delete_event.php",
data : {options: "delete " + EventId + Options + atob(Password)}, data : {options: Method + EventId + Options + atob(Password)},
success: function(data) { success: function(data) {
par.remove(); //remove table row if (Row == "all")
$("#tblEvent tbody").empty(); // empty table
else
$('#'+Row).remove(); //remove table row
}, },
error : function() { } error : function() { }
}); });
} }
*/};
function clearEvents() {
//if all events checked clear all
if($('#allEvents').prop('checked')) {
$('#allEvents').switchButton({checked: false});
$.ajax({
type : "POST",
url : "/plugins/ipmitool-plugin/include/delete_event.php",
data : {options: "clear" + Options + atob(Password)},
success: function(data) {
$("#tblEvent tbody").empty();
},
error : function() { }
});
} else {
// clear only checked events
$(':checkbox:checked').each(function(){
var EventId = $(this).val(); //get event id
var par = $(this).parent().parent(); //get table row
$.ajax({
type : "POST",
url : "/plugins/ipmitool-plugin/include/delete_event.php",
data : {options: "delete " + EventId + Options + atob(Password)},
success: function(data) {
par.remove(); //remove table row
},
error : function() { }
});
});
}
}; };