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

Commit

Permalink
XIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sc979 committed Mar 12, 2019
1 parent 79f9244 commit d354979
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@
"ack_0" => _("Not Acknowledged"),
);

/*
* Check search value in Host search field
*/
// Check search value in Host search field
if (isset($_GET["host_search"])) {
$centreon->historySearch[$url] = $_GET["host_search"];
}

// Check search value in Hostgroup list. $_GET["host_group_filter"] return the id of the HG
if (isset($_GET["hg_search"])) {
$centreon->historySearch[$hostgroup] = $_GET["hg_search"];
}

$tab_class = array("0" => "list_one", "1" => "list_two");
$rows = 10;
Expand Down Expand Up @@ -101,6 +103,24 @@

$form = new HTML_QuickFormCustom('select_form', 'GET', "?p=" . $p);

//adding hostgroup's select2 list
$hostgroupsRoute = './include/common/webServices/rest/internal.php?object=centreon_configuration_hostgroup&action=list';
$attrHostGroup = array(
'datasourceOrigin' => 'ajax',
'availableDatasetRoute' => $hostgroupsRoute,
'defaultDatasetRoute' => "",
'multiple' => false,
'onChange' => "",
'linkedObject' => 'centreonHostgroups'
);
$form->addElement(
'select2',
'hg_search',
_('Hostgroup List'),
array('id' => 'hg_search'),
$attrHostGroup
);

$form->addElement(
'select',
'typeDisplay',
Expand All @@ -126,6 +146,8 @@
<script type="text/javascript">
_tm = <?php echo $tM ?>;



function setO(_i) {
document.forms['form'].elements['cmd'].value = _i;
document.forms['form'].elements['o1'].selectedIndex = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
var _addrXML = "./include/monitoring/status/ServicesHostGroups/xml/serviceGridByHGXML.php";
var _addrXSL = "./include/monitoring/status/ServicesHostGroups/xsl/serviceGridByHG.xsl";

// hostgroup select2 value
var hg_search = "";

<?php include_once "./include/monitoring/status/Common/commonJS.php"; ?>

function set_header_title() {
Expand Down Expand Up @@ -150,6 +153,14 @@ function initM(_time_reload, _sid, _o) {
_host_search = "";
}

// checking if an hostgroup was selected
if (document.getElementById("select2-hg_search-container") &&
document.getElementById("select2-hg_search-container").title
) {
this.hg_search = document.getElementById("select2-hg_search-container").title;
viewDebugInfo('search: ' + document.getElementById("select2-hg_search-container").title);
}

if (_first) {
mainLoopLocal();
_first = 0;
Expand All @@ -166,9 +177,9 @@ function goM(_time_reload, _sid, _o) {
var proc = new Transformation();
proc.setCallback(function(t){monitoringCallBack(t); proc = null;});
proc.setXml(
_addrXML + "?" + '&search=' + _host_search + '&num=' + _num + '&limit=' + _limit +
'&sort_type=' + _sort_type + '&order=' + _order + '&date_time_format_status=' + _date_time_format_status +
'&o=' + _o + '&p=' + _p + '&time=<?php print time(); ?>'
_addrXML + "?" + '&search=' + _host_search + '&hg_search=' + this.hg_search + '&num=' + _num +
'&limit=' + _limit + '&sort_type=' + _sort_type + '&order=' + _order + '&date_time_format_status=' +
_date_time_format_status + '&o=' + _o + '&p=' + _p + '&time=<?php print time(); ?>'
);
proc.setXslt(_addrXSL);
if (handleVisibilityChange()) {
Expand All @@ -187,4 +198,4 @@ function goM(_time_reload, _sid, _o) {
set_header_title();
}

</SCRIPT>
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{if $poller_listing}
<td><span id="instance_selected"></span></td>
{/if}
<td><span id="hostgroups_selected"></span></td>
<td><span id="hostgroups_selected">{$form.hg_search.html}</span></td>
<td>{$form.typeDisplay.html}</td>
<td>{$form.typeDisplay2.html}</td>
</tr>
Expand Down Expand Up @@ -62,3 +62,14 @@
<input type='hidden' id='limit' name='limit' value='{$limit}'>
{$form.hidden}
</form>
<script>
{literal}
console.log("here");
//reloading the page after selecting an hg in the select2 field
jQuery('#hostgroups_selected').on('change', function(e) {
console.log("hg changed");
monitoring_refresh();
});
{/literal}
</script>

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
require_once realpath(__DIR__ . "/../../../../../../bootstrap.php");

include_once _CENTREON_PATH_ . "www/class/centreonUtils.class.php";

include_once _CENTREON_PATH_ . "www/class/centreonXMLBGRequest.class.php";
include_once _CENTREON_PATH_ . "www/include/monitoring/status/Common/common-Func.php";
include_once _CENTREON_PATH_ . "www/include/common/common-Func.php";
Expand Down Expand Up @@ -72,7 +71,7 @@
$num = $obj->checkArgument("num", $_GET, 0);
$limit = $obj->checkArgument("limit", $_GET, 20);
$instance = $obj->checkArgument("instance", $_GET, $obj->defaultPoller);
$hostgroups = $obj->checkArgument("hostgroups", $_GET, $obj->defaultHostgroups);
$hostgroup = $obj->checkArgument("hg_search", $_GET, "");
$search = $obj->checkArgument("search", $_GET, "");
$sort_type = $obj->checkArgument("sort_type", $_GET, "host_name");
$order = $obj->checkArgument("order", $_GET, "ASC");
Expand Down Expand Up @@ -123,12 +122,13 @@
PDO::PARAM_STR => "%" . $search . "%"
];
}
if ($hostgroups) {
$rq1 .= " AND hg.hostgroup_id IN :hostgroups";
$queryValues[':hostgroups'] = [
PDO::PARAM_STR => "(" . $hostgroups . ")"
if ($hostgroup !== "") {
$rq1 .= " AND hg.name LIKE :hgName";
$queryValues[':hgName'] = [
PDO::PARAM_STR => $hostgroup
];
}

$rq1 .= " AND h.enabled = 1 ORDER BY :sort_type :order, host_name ASC LIMIT :numLimit, :limit";
$queryValues[':sort_type'] = [
PDO::PARAM_STR => $sort_type
Expand Down Expand Up @@ -201,7 +201,7 @@
];
}
if ($instance != -1) {
$rq1 .= " AND h.instance_id = instance ";
$rq1 .= " AND h.instance_id = :instance ";
$queryValues[":instance"] = [
PDO::PARAM_INT => $instance
];
Expand Down
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 @@ -35,7 +35,7 @@

ini_set("display_errors", "Off");

require_once realpath(dirname(__FILE__) . "/../../../../../../config/centreon.config.php");
require_once realpath(__DIR__ . "/../../../../../../config/centreon.config.php");
require_once realpath(__DIR__ . "/../../../../../../bootstrap.php");

include_once _CENTREON_PATH_ . "www/class/centreonUtils.class.php";
Expand All @@ -58,14 +58,10 @@
exit();
}

/*
* Set Default Poller
*/
// Set Default Poller
$obj->getDefaultFilters();

/* **************************************************
* Check Arguments From GET tab
*/
// Check Arguments From GET tab
$o = $obj->checkArgument("o", $_GET, "h");
$p = $obj->checkArgument("p", $_GET, "2");
$nc = $obj->checkArgument("nc", $_GET, "0");
Expand All @@ -78,31 +74,28 @@
$sort_type = $obj->checkArgument("sort_type", $_GET, "host_name");
$order = $obj->checkArgument("order", $_GET, "ASC");
$dateFormat = $obj->checkArgument("date_time_format_status", $_GET, "Y/m/d H:i:s");
$queryValues = array();

/*
* Backup poller selection
*/
// Backup poller selection
$obj->setInstanceHistory($instance);


$_SESSION['monitoring_service_groups'] = $sgSearch;

/** **********************************************
* Prepare pagination
*/
// Prepare pagination

$s_search = "";
/* Display service problems */
// Display service problems
if ($o == "svcgridSG_pb" || $o == "svcOVSG_pb") {
$s_search .= " AND s.state != 0 AND s.state != 4 ";
}

/* Display acknowledged services */
// Display acknowledged services
if ($o == "svcgridSG_ack_1" || $o == "svcOVSG_ack_1") {
$s_search .= " AND s.acknowledged = '1' ";
}

/* Display not acknowledged services */
// Display not acknowledged services
if ($o == "svcgridSG_ack_0" || $o == "svcOVSG_ack_0") {
$s_search .= " AND s.state != 0 AND s.state != 4 AND s.acknowledged = 0 ";
}
Expand All @@ -128,36 +121,72 @@
. $obj->access->queryBuilder("AND", "sg.servicegroup_id", $obj->access->getServiceGroupsString("ID")) . " ";
}

/* Servicegroup search */
// Servicegroup search
if ($sgSearch != "") {
$query .= "AND sg.name = '" . $sgSearch . "' ";
$query .= "AND sg.name = :sgSearch ";
$queryValues[':sgSearch'] = [
PDO::PARAM_STR => $sgSearch
];
}

/* Host search */
// Host search
$h_search = '';
if ($hSearch != "") {
$h_search .= "AND h.name like '%" . $hSearch . "%' ";
$h_search .= "AND h.name like :hSearch ";
$queryValues[':hSearch'] = [
PDO::PARAM_STR => "%" . $hSearch . "%"
];
}
$query .= $h_search;

/* Service search */
// Service search
$query .= $s_search;

/* Poller search */
// Poller search
if ($instance != -1) {
$query .= " AND h.instance_id = " . $instance . " ";
$query .= " AND h.instance_id = :instance ";
$queryValues[':instance'] = [
PDO::PARAM_INT => $instance
];
}





$query .= "ORDER BY sg.name " . $order . " "
. "LIMIT " . ($num * $limit) . "," . $limit;
. "LIMIT :numLimit, :limit";
/*$queryValues[':order'] = [
PDO::PARAM_INT => $instance
];*/
$queryValues[':numLimit'] = [
PDO::PARAM_INT => (int) ($num * $limit)
];
$queryValues[':limit'] = [
PDO::PARAM_INT => (int) $limit
];

$DBRESULT = $obj->DBC->query($query);

$numRows = $obj->DBC->numberRows();

/** ***************************************************
* Create XML Flow
*/


echo "<PRE>";
var_dump($order);
var_dump($queryValues);
echo "</PRE>";
exit();

$DBRESULT = $obj->DBC->prepare($query);
foreach ($queryValues as $bindId => $bindData) {
foreach ($bindData as $bindType => $bindValue) {
$DBRESULT->bindValue($bindId, $bindValue, $bindType);
}
}
$DBRESULT->execute();

$numRows = $DBRESULT->rowCount();

// Create XML Flow
$obj->XML = new CentreonXML();
$obj->XML->startElement("reponse");
$obj->XML->startElement("i");
Expand All @@ -170,7 +199,7 @@
$obj->XML->writeElement("s", "1");
$obj->XML->endElement();

/* Construct query for servigroups search */
// Construct query for servicegroups search
$aTab = array();
$sg_search = "";
$aTab = array();
Expand Down Expand Up @@ -299,15 +328,10 @@
$obj->XML->endElement();
}


$obj->XML->endElement();

/*
* Send Header
*/
// Send Header
$obj->header();

/*
* Send XML
*/
// Send XML
$obj->XML->output();

0 comments on commit d354979

Please sign in to comment.