Skip to content

Commit

Permalink
Merge pull request #63 from netniV/develop
Browse files Browse the repository at this point in the history
Fix for issue #57
  • Loading branch information
cigamit authored Mar 14, 2018
2 parents 417e703 + 879e868 commit 03a387a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 37 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ Bug and feature enhancements for the webseer plugin are handled in GitHub. If yo

## Changelog
--- 2.3.3 ---
* issue: correct issue with themes
* issue#60: Fixed issue with themes
* issue#57: Fixed issue with mute not working
* issue: Fixed issue with audio constantly playing
* issue: Fixed issue with audio attempting to play files that do not exist

--- 2.3.2 ---
* feature: Allow "from" email address/name to be set
Expand Down
70 changes: 34 additions & 36 deletions monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function draw_page() {
// If the host is down, we need to insert the embedded wav file
$monitor_sound = get_monitor_sound();
if (is_monitor_audible()) {
print "<audio id='audio' loop autoplay src='" . htmlspecialchars($config['url_path'] . "plugins/monitor/sounds/" . $monitor_sound) . "'></audio>\n";
print "<audio id='audio' loop src='" . htmlspecialchars($config['url_path'] . "plugins/monitor/sounds/" . $monitor_sound) . "'></audio>\n";
}

?>
Expand Down Expand Up @@ -196,11 +196,14 @@ function closeTip() {
$(document).tooltip('close');
}

function applyFilter() {
function applyFilter(action = '') {
clearTimeout(myTimer);
$('.fa-server, .fa-first-order').unbind();

strURL = 'monitor.php?header=false';
if (action >= '') {
strURL += '&action='+action;
}
strURL += '&refresh='+$('#refresh').val();
strURL += '&grouping='+$('#grouping').val();
strURL += '&tree='+$('#tree').val();
Expand Down Expand Up @@ -241,13 +244,11 @@ function setupTooltips() {
if ($('#mute').val() == 'false') {
$('#mute').val('true');
muteUnmuteAudio(true);
$('#sound').val('<?php print get_unmute_text();?>');
loadPageNoHeader('monitor.php?header=false&action=ajax_mute_all');
applyFilter('ajax_mute_all');
} else {
$('#mute').val('false');
muteUnmuteAudio(false);
$('#sound').val('<?php print get_mute_text();?>');
loadPageNoHeader('monitor.php?header=false&action=ajax_unmute_all');
applyFilter('ajax_unmute_all');
}
});

Expand Down Expand Up @@ -308,7 +309,6 @@ function() {
} else {
muteUnmuteAudio(false);
}

$('#main').css('margin-right', '15px');
});

Expand All @@ -321,16 +321,15 @@ function() {
}

function is_monitor_audible() {
$sound = get_monitor_sound();
if ($sound != '' && $sound != __('None', 'monitor')) {
return true;
} else {
return false;
}
return get_monitor_sound() != '';
}

function get_monitor_sound() {
return read_user_setting('monitor_sound', read_config_option('monitor_sound'));
$sound = read_user_setting('monitor_sound', read_config_option('monitor_sound'));
clearstatcache();
$file = dirname(__FILE__) . '/sounds/' . $sound;
$exists = file_exists($file);
return $exists ? $sound : '';
}

function find_down_hosts() {
Expand All @@ -340,26 +339,35 @@ function find_down_hosts() {
if (isset($_SESSION['muted_hosts'])) {
$unmuted_hosts = array_diff($dhosts, $_SESSION['muted_hosts']);
if (sizeof($unmuted_hosts)) {
set_request_var('mute', 'false');
unmute_user();
}
} else {
set_request_var('mute', 'false');
}
} else {
$_SESSION['muted_hosts'] = array();
set_request_var('mute', 'false');
unmute_all_hosts();
set_request_var('downhosts', 'false');
}
}

function mute_all_hosts() {
$_SESSION['muted_hosts'] = get_hosts_down_by_permission();
set_request_var('mute', 'true');
mute_user();
}

function unmute_all_hosts() {
$_SESSION['muted_hosts'] = array();
unmute_user();
}

function mute_user() {
set_request_var('mute', 'true');
set_user_setting('monitor_mute','true');
}

function unmute_user() {
set_request_var('mute', 'false');
set_user_setting('monitor_mute','false');
}

function check_tholds() {
Expand Down Expand Up @@ -1500,26 +1508,16 @@ function get_hosts_down_by_permission() {
}
}

if ($render_style == 'default') {
$hosts = get_allowed_devices("h.monitor='on' $sql_add_where AND h.disabled='' AND h.status < 2 AND (h.availability_method>0 OR h.snmp_version>0)");
// do a quick loop through to pull the hosts that are down
if (sizeof($hosts)) {
foreach($hosts as $host) {
$result[] = $host['id'];
sort($result);
}
}
} else {
/* Only get hosts */
$hosts = get_allowed_devices("h.monitor='on' $sql_add_where AND h.disabled='' AND h.status < 2 AND (h.availability_method>0 OR h.snmp_version>0)");
if (sizeof($hosts) > 0) {
foreach ($hosts as $host) {
$result[] = $host['id'];
sort($result);
}
$sql_where = "h.monitor='on' $sql_add_where AND h.disabled='' AND h.status < 2 AND (h.availability_method>0 OR h.snmp_version>0)";

// do a quick loop through to pull the hosts that are down
$hosts = get_allowed_devices($sql_where);
if (sizeof($hosts)) {
foreach($hosts as $host) {
$result[] = $host['id'];
sort($result);
}
}

return $result;
}

Expand Down

0 comments on commit 03a387a

Please sign in to comment.