Added abililty to filter by alert state Ok or Alert

This commit is contained in:
laf
2016-05-02 19:40:12 +00:00
parent c260adeb5b
commit aefbde3df0
2 changed files with 17 additions and 1 deletions

View File

@@ -7,6 +7,11 @@ if (is_numeric($_POST['device_id'])) {
$param[] = $_POST['device_id']; $param[] = $_POST['device_id'];
} }
if ($_POST['state'] >= 0) {
$where .= ' AND `E`.`state` = ?';
$param[] = mres($_POST['state']);
}
if ($_SESSION['userlevel'] >= '5') { if ($_SESSION['userlevel'] >= '5') {
$sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where"; $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where";
} }

View File

@@ -59,6 +59,16 @@ foreach (get_all_devices() as $hostname) {
} }
} }
?> ?>
"</select>"+
"</div>"+
"<div class=\"form-group\">"+
"<label>"+
"<strong>&nbsp;State&nbsp;</strong>"+
"</label>"+
"<select name=\"state\" id=\"state\" class=\"form-control input-sm\">"+
"<option value=\"-1\"></option>"+
"<option value=\"0\">Ok</option>"+
"<option value=\"1\">Alert</option>"+
"</select>"+ "</select>"+
"</div>"+ "</div>"+
"<button type=\"submit\" class=\"btn btn-default input-sm\">Filter</button>"+ "<button type=\"submit\" class=\"btn btn-default input-sm\">Filter</button>"+
@@ -69,7 +79,8 @@ foreach (get_all_devices() as $hostname) {
{ {
return { return {
id: "alertlog", id: "alertlog",
device_id: '<?php echo htmlspecialchars($_POST['device_id']); ?>' device_id: '<?php echo htmlspecialchars($_POST['device_id']); ?>',
state: '<?php echo htmlspecialchars($_POST['state']); ?>'
}; };
}, },
url: "ajax_table.php" url: "ajax_table.php"