Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(monitoring) fix host filter #7511

Merged
merged 6 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion www/include/monitoring/status/Common/commonJS.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ function change_page(page_number) {
function change_type_order(_type) {
if (_sort_type != _type){
_sort_type = _type;
monitoring_refresh();
}
monitoring_refresh();
}

function change_order(_odr) {
Expand Down
52 changes: 21 additions & 31 deletions www/include/monitoring/status/Hosts/host.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,17 @@
$centreon->historySearch[$url] = $filters['host_search'];
}

/*
* ACL Actions
*/
//ACL Actions
$GroupListofUser = array();
$GroupListofUser = $centreon->user->access->getAccessGroups();

$allActions = false;
/*
* Get list of actions allowed for user
*/
//Get list of actions allowed for user
if (count($GroupListofUser) > 0 && $is_admin == 0) {
$authorized_actions = array();
$authorized_actions = $centreon->user->access->getActions();
} else {
/*
* if user is admin, or without ACL, he cans perform all actions
*/
//if user is admin, or without ACL, he cans perform all actions
$allActions = true;
}

Expand Down Expand Up @@ -183,9 +177,7 @@

include_once("hostJS.php");

/*
* Smarty template Init
*/
//Smarty template Init
$tpl = new Smarty();
$tpl = initSmartyTpl($path, $tpl, "/templates/");

Expand Down Expand Up @@ -221,10 +213,10 @@
array('id' => 'statusHost', 'onChange' => "statusHosts(this.value);")
);

/* Get default host status by GET */
// Get default host status by GET
if (isset($_GET['o']) && in_array($_GET['o'], array_keys($aStatusHost))) {
$form->setDefaults(array('statusHost' => $_GET['o']));
/* Get default host status in SESSION */
//Get default host status in SESSION
} elseif ((!isset($_GET['o']) || empty($_GET['o'])) && isset($_SESSION['monitoring_host_status'])) {
$form->setDefaults(array('statusHost' => $_SESSION['monitoring_host_status']));
$sDefaultOrder = "1";
Expand All @@ -248,9 +240,7 @@ function setO(_i) {
$informationsService = $dependencyInjector['centreon_remote.informations_service'];
$serverIsMaster = $informationsService->serverIsMaster();

/*
* Showing actions allowed for current user
*/
//Showing actions allowed for current user
if (isset($authorized_actions) && $allActions == false) {
if (isset($authorized_actions) && $allActions == false) {
$action_list[94] = _("Hosts : Schedule immediate check");
Expand Down Expand Up @@ -400,7 +390,6 @@ function setO(_i) {
var down = '<?php echo _("Down");?>';
var unreachable = '<?php echo _("Unreachable");?>';
var pending = '<?php echo _("Pending");?>';

var _keyPrefix;

jQuery('#statusHost').change(function () {
Expand All @@ -410,37 +399,43 @@ function setO(_i) {
function updateSelect() {
var oldStatus = jQuery('#statusFilter').val();
var opts = document.getElementById('statusFilter').options;
var newTypeOrder = null;
if (jQuery('#statusHost').val() == 'hpb' || jQuery('#statusHost').val() == 'h_unhandled') {
opts.length = 0;
opts[opts.length] = new Option("", "");
opts[opts.length] = new Option(down, "down");
opts[opts.length] = new Option(unreachable, "unreachable");
change_type_order(tabSortPb['champ']);
newTypeOrder = tabSortPb['champ'];
} else {
opts.length = 0;
opts[opts.length] = new Option("", "");
opts[opts.length] = new Option(up, "up");
opts[opts.length] = new Option(down, "down");
opts[opts.length] = new Option(unreachable, "unreachable");
opts[opts.length] = new Option(pending, "pending");
change_type_order(tabSortAll['champ']);
newTypeOrder = tabSortAll['champ'];
}

// We define the statusFilter before calling ajax
if (jQuery("#statusFilter option[value='" + oldStatus + "']").length > 0) {
jQuery("#statusFilter option[value='" + oldStatus + "']").prop('selected', true);
} else {
jQuery("#statusFilter option[value='']").prop('selected', true);
}
change_type_order(newTypeOrder);
}

jQuery(function () {
preInit();
});

function preInit() {
_keyPrefix = '<?php echo $keyPrefix; ?>';
_sid = '<?php echo $sid ?>';
_tm = <?php echo $tM ?>;
_o = '<?php echo $o; ?>';
_sDefaultOrder = '<?php echo $sDefaultOrder; ?>';
sSetOrderInMemory = '<?php echo $sSetOrderInMemory; ?>';
_keyPrefix = '<?= $keyPrefix; ?>';
_sid = '<?= $sid ?>';
_tm = <?= $tM ?>;
_o = '<?= $o; ?>';
_sDefaultOrder = '<?= $sDefaultOrder; ?>';
sSetOrderInMemory = '<?= $sSetOrderInMemory; ?>';

if (_sDefaultOrder == "0") {
if (_o == 'h') {
Expand All @@ -464,9 +459,6 @@ function preInit() {
}
}
filterStatus(document.getElementById('statusFilter').value, 1);

window.clearTimeout(_timeoutID);
initM(_tm, _sid, _o);
}

function filterStatus(value, isInit) {
Expand All @@ -487,7 +479,5 @@ function filterCrit(value) {

function statusHosts(value, isInit) {
_o = value;
window.clearTimeout(_timeoutID);
initM(_tm, _sid, _o);
}
</script>
20 changes: 12 additions & 8 deletions www/include/monitoring/status/Hosts/hostJS.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Copyright 2005-2015 Centreon
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* Copyright 2005-2019 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
Expand Down Expand Up @@ -37,16 +37,16 @@
exit();
}

if (!isset($centreon->optGen["AjaxFirstTimeReloadMonitoring"]) ||
$centreon->optGen["AjaxFirstTimeReloadMonitoring"] == 0
if (!isset($centreon->optGen["AjaxFirstTimeReloadMonitoring"])
|| $centreon->optGen["AjaxFirstTimeReloadMonitoring"] == 0
) {
$tFM = 10;
} else {
$tFM = $centreon->optGen["AjaxFirstTimeReloadMonitoring"] * 1000;
}

if (!isset($centreon->optGen["AjaxFirstTimeReloadStatistic"]) ||
$centreon->optGen["AjaxFirstTimeReloadStatistic"] == 0
if (!isset($centreon->optGen["AjaxFirstTimeReloadStatistic"])
|| $centreon->optGen["AjaxFirstTimeReloadStatistic"] == 0
) {
$tFS = 10;
} else {
Expand Down Expand Up @@ -239,7 +239,9 @@ function initM(_time_reload, _sid, _o) {
}

function goM(_time_reload, _sid, _o) {

if (_on == 0) {
return;
}
_lock = 1;
var proc = new Transformation();

Expand All @@ -264,6 +266,9 @@ function goM(_time_reload, _sid, _o) {
}

_lock = 0;
if (_timeoutID) { // Kill next execution if in queue
clearTimeout(_timeoutID);
}
_timeoutID = cycleVisibilityChange(function(){goM(_time_reload, _sid, _o)}, _time_reload);
_time_live = _time_reload;
_on = 1;
Expand Down Expand Up @@ -398,7 +403,6 @@ function send_the_command() {
}
xhr_cmd.send(null);
window.currentPopin.centreonPopin("close");
//Modalbox.hide();
unsetCheckboxes();
}

Expand Down
4 changes: 2 additions & 2 deletions www/include/monitoring/status/Services/serviceJS.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Copyright 2005-2010 Centreon
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* Copyright 2005-2019 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ function setO(_i) {
}

function displayingLevel1(val) {
_o = val;
if (_o == 'svcOVHG') {
var filterDetails = document.getElementById("typeDisplay2").value;
_o = val + "_" + filterDetails;

if (val == 'svcOVHG') {
_addrXML = "./include/monitoring/status/ServicesHostGroups/xml/serviceGridByHGXML.php";
_addrXSL = "./include/monitoring/status/ServicesHostGroups/xsl/serviceGridByHG.xsl";
} else {
Expand Down
40 changes: 20 additions & 20 deletions www/include/monitoring/status/monitoringHost.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Copyright 2005-2015 Centreon
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* Copyright 2005-2019 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
Expand Down Expand Up @@ -59,11 +59,11 @@
$param = $_GET;
}

if (isset($param["cmd"]) &&
$param["cmd"] == 14 &&
isset($param["author"]) &&
isset($param["en"]) &&
$param["en"] == 1
if (isset($param["cmd"])
&& $param["cmd"] == 14
&& isset($param["author"])
&& isset($param["en"])
&& $param["en"] == 1
) {
if (!isset($param["sticky"])) {
$param["sticky"] = 0;
Expand All @@ -78,11 +78,11 @@
$param["ackhostservice"] = 0;
}
acknowledgeHost($param);
} elseif (isset($param["cmd"]) &&
$param["cmd"] == 14 &&
isset($param["author"]) &&
isset($param["en"]) &&
$param["en"] == 0
} elseif (isset($param["cmd"])
&& $param["cmd"] == 14
&& isset($param["author"])
&& isset($param["en"])
&& $param["en"] == 0
) {
acknowledgeHostDisable();
}
Expand All @@ -94,7 +94,7 @@
if ($min) {
switch ($o) {
default:
require_once($pathTools . "tools.php");
require_once $pathTools . "tools.php";
break;
}
} else {
Expand All @@ -104,25 +104,25 @@
if ($continue) {
switch ($o) {
case "h":
require_once($path . "host.php");
require_once $path . "host.php";
break;
case "hpb":
require_once($path . "host.php");
require_once $path . "host.php";
break;
case "h_unhandled":
require_once($path . "host.php");
require_once $path . "host.php";
break;
case "hd":
require_once($pathDetails . "hostDetails.php");
require_once $pathDetails . "hostDetails.php";
break;
case "hpc":
require_once("./include/monitoring/submitPassivResults/hostPassiveCheck.php");
require_once "./include/monitoring/submitPassivResults/hostPassiveCheck.php";
break;
case "hak":
require_once($pathRoot . "acknowlegement/hostAcknowledge.php");
require_once $pathRoot . "acknowlegement/hostAcknowledge.php";
break;
default:
require_once($path . "host.php");
require_once $path . "host.php";
break;
}
}
Expand Down
Loading