Unverified Commit f944085a authored by Kevin Duret's avatar Kevin Duret Committed by GitHub
Browse files

enh(ui): redirect links to resource status listing (#23)

Refs: MON-5657
parent f3a509bd
......@@ -75,6 +75,18 @@ $path = $centreon_path . "www/widgets/tactical-overview/src/";
$template = new Smarty();
$template = initSmartyTplForPopup($path, $template, "./", $centreon_path);
$kernel = \App\Kernel::createForWeb();
$resourceController = $kernel->getContainer()->get(
\Centreon\Application\Controller\MonitoringResourceController::class
);
$buildParameter = function(string $id, string $name) {
return [
'id' => $id,
'name' => $name,
];
};
if (isset($preferences['object_type'])
&& ($preferences['object_type'] === "hosts" || $preferences['object_type'] == "")
) {
......
......@@ -17,44 +17,44 @@
<table class='StyleTable ListTable'>
<tr class="listHeader">
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20202&o=h_down&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].status}</span>Down</a>
<a href='{$dataDO[0].listing_uri}' target="_blank"><span class="badge host_down margin_right">{$dataDO[0].status}</span>Down</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20202&o=h_unreachable&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].status}</span>Unreachable</a>
<a href='{$dataUN[0].listing_uri}' target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].status}</span>Unreachable</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20202&o=h_up&search=" target="_blank"><span class="badge host_up margin_right">{$dataUP[0].status}</span>Up</a>
<a href='{$dataUP[0].listing_uri}' target="_blank"><span class="badge host_up margin_right">{$dataUP[0].status}</span>Up</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20202&o=h_pending&search=" target="_blank"><span class="badge pending margin_right">{$dataPEND[0].status}</span>Pending</a>
<a href='{$dataPEND[0].listing_uri}' target="_blank"><span class="badge pending margin_right">{$dataPEND[0].status}</span>Pending</a>
</td>
</tr>
<tr class="line_ack">
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_down&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].ack}</span>Acknowledge</a>
<a href='{$dataDO[0].listing_ack_uri}' target="_blank"><span class="badge host_down margin_right">{$dataDO[0].ack}</span>Acknowledge</a>
</td>
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_unreachable&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].ack}</span>Acknowledge</a>
<a href='{$dataUN[0].listing_ack_uri}' target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].ack}</span>Acknowledge</a>
</td>
<td></td>
<td></td>
</tr>
<tr class ="line_downtime">
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_down&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].down}</span>Downtimes</a>
<a href='{$dataDO[0].listing_downtime_uri}' target="_blank"><span class="badge host_down margin_right">{$dataDO[0].down}</span>Downtimes</a>
</td>
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_unreachable&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].down}</span>Downtimes</a>
<a href='{$dataUN[0].listing_downtime_uri}' target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].down}</span>Downtimes</a>
</td>
<td></td>
<td></td>
</tr>
<tr class="list_two">
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_unhandled&search=" target="_blank"><span class="badge host_down margin_right">{$dataDO[0].un}</span>Unhandled</a>
<a href='{$dataDO[0].listing_unhandled_uri}' target="_blank"><span class="badge host_down margin_right">{$dataDO[0].un}</span>Unhandled</a>
</td>
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=h_unhandled&search=" target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].un}</span>Unhandled</a>
<a href='{$dataUN[0].listing_unhandled_uri}' target="_blank"><span class="badge host_unreachable margin_right">{$dataUN[0].un}</span>Unhandled</a>
</td>
<td></td>
<td></td>
......
......@@ -40,6 +40,27 @@ $dataPEND = array();
$dataList = array();
$db = new CentreonDB("centstorage");
$buildHostUri = function(array $states, array $statuses) use ($resourceController, $buildParameter) {
return $resourceController->buildListingUri([
'filter' => json_encode([
'criterias' => [
'resourceTypes' => [$buildParameter('host', 'Host')],
'states' => $states,
'statuses' => $statuses,
],
]),
]);
};
$pendingStatus = $buildParameter('PENDING', 'Pending');
$upStatus = $buildParameter('UP', 'Up');
$downStatus = $buildParameter('DOWN', 'Down');
$unreachableStatus = $buildParameter('UNREACHABLE', 'Unreachable');
$unhandledState = $buildParameter('unhandled_problems', 'Unhandled');
$acknowledgedState = $buildParameter('acknowledged', 'Acknowledged');
$inDowntimeState = $buildParameter('in_downtime', 'In downtime');
// query for DOWN status
$res = $db->query(
"SELECT
......@@ -75,6 +96,10 @@ $res = $db->query(
);
while ($row = $res->fetch()) {
$row['un'] = $row['status'] - ($row['ack'] + $row['down']);
$row['listing_uri'] = $buildHostUri([], [$downStatus]);
$row['listing_ack_uri'] = $buildHostUri([$acknowledgedState], [$downStatus]);
$row['listing_downtime_uri'] = $buildHostUri([$inDowntimeState], [$downStatus]);
$row['listing_unhandled_uri'] = $buildHostUri([$unhandledState], [$downStatus]);
$dataDO[] = $row;
}
......@@ -113,6 +138,10 @@ $res = $db->query(
);
while ($row = $res->fetch()) {
$row['un'] = $row['status'] - ($row['ack'] + $row['down']);
$row['listing_uri'] = $buildHostUri([], [$unreachableStatus]);
$row['listing_ack_uri'] = $buildHostUri([$acknowledgedState], [$unreachableStatus]);
$row['listing_downtime_uri'] = $buildHostUri([$inDowntimeState], [$unreachableStatus]);
$row['listing_unhandled_uri'] = $buildHostUri([$unhandledState], [$unreachableStatus]);
$dataUN[] = $row;
}
......@@ -136,6 +165,7 @@ $res = $db->query(
) . ";"
);
while ($row = $res->fetch()) {
$row['listing_uri'] = $buildHostUri([], [$upStatus]);
$dataUP[] = $row;
}
......@@ -159,6 +189,7 @@ $res = $db->query(
) . ";"
);
while ($row = $res->fetch()) {
$row['listing_uri'] = $buildHostUri([], [$pendingStatus]);
$dataPEND[] = $row;
}
......
......@@ -17,19 +17,19 @@
<table class='StyleTable ListTable'>
<tr class="ListHeader">
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20201&o=svc_critical&search=" target="_blank"><span class="badge service_critical margin_right">{$dataCRI[0].status}</span>Critical</a>
<a href='{$dataCRI[0].listing_uri}' target="_blank"><span class="badge service_critical margin_right">{$dataCRI[0].status}</span>Critical</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20201&o=svc_warning&search=" target="_blank"><span class="badge service_warning margin_right">{$dataWA[0].status}</span>Warning</a>
<a href='{$dataWA[0].listing_uri}' target="_blank"><span class="badge service_warning margin_right">{$dataWA[0].status}</span>Warning</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20201&o=svc_unknown&search=" target="_blank"><span class="badge service_unknown margin_right">{$dataUNK[0].status}</span>Unknown</a>
<a href='{$dataUNK[0].listing_uri}' target="_blank"><span class="badge service_unknown margin_right">{$dataUNK[0].status}</span>Unknown</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20201&o=svc_ok&search=" target="_blank"><span class="badge service_ok margin_right">{$dataOK[0].status}</span>Ok</a>
<a href='{$dataOK[0].listing_uri}' target="_blank"><span class="badge service_ok margin_right">{$dataOK[0].status}</span>Ok</a>
</td>
<td class='ListColHeaderLeft'>
<a href="/centreon/main.php?p=20201&o=svc_pending&search=" target="_blank"><span class="badge pending margin_right">{$dataPEND[0].status}</span>Pending</a>
<a href='{$dataPEND[0].listing_uri}' target="_blank"><span class="badge pending margin_right">{$dataPEND[0].status}</span>Pending</a>
</td>
</tr>
<tr class="line_ack">
......@@ -48,13 +48,13 @@
</tr>
<tr class="list_two">
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=svc_unhandled&search=" target="_blank"><span class="badge service_critical margin_right">{$dataCRI[0].un}</span>Unhandled</a>
<a href='{$dataCRI[0].listing_unhandled_uri}' target="_blank"><span class="badge service_critical margin_right">{$dataCRI[0].un}</span>Unhandled</a>
</td>
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=svc_unhandled&search=" target="_blank"><span class="badge service_warning margin_right">{$dataWA[0].un}</span>Unhandled</a>
<a href='{$dataWA[0].listing_unhandled_uri}' target="_blank"><span class="badge service_warning margin_right">{$dataWA[0].un}</span>Unhandled</a>
</td>
<td class='ListColLeft'>
<a href="/centreon/main.php?p=20202&o=svc_unhandled&search=" target="_blank"><span class="badge service_unknown margin_right">{$dataUNK[0].un}</span>Unhandled</a>
<a href='{$dataUNK[0].listing_unhandled_uri}' target="_blank"><span class="badge service_unknown margin_right">{$dataUNK[0].un}</span>Unhandled</a>
</td>
<td></td>
<td></td>
......
......@@ -40,6 +40,28 @@ $dataUNK = array();
$dataPEND = array();
$db = new CentreonDB("centstorage");
$buildServiceUri = function(array $states, array $statuses) use ($resourceController, $buildParameter) {
return $resourceController->buildListingUri([
'filter' => json_encode([
'criterias' => [
'resourceTypes' => [$buildParameter('service', 'Service')],
'states' => $states,
'statuses' => $statuses,
],
]),
]);
};
$pendingStatus = $buildParameter('PENDING', 'Pending');
$okStatus = $buildParameter('OK', 'Ok');
$warningStatus = $buildParameter('WARNING', 'Warning');
$criticalStatus = $buildParameter('CRITICAL', 'Critical');
$unknownStatus = $buildParameter('UNKNOWN', 'Unknown');
$unhandledState = $buildParameter('unhandled_problems', 'Unhandled');
$acknowledgedState = $buildParameter('acknowledged', 'Acknowledged');
$inDowntimeState = $buildParameter('in_downtime', 'In downtime');
// query for CRITICAL state
$res = $db->query(
"SELECT
......@@ -97,6 +119,10 @@ $res = $db->query(
) . ";"
);
while ($row = $res->fetch()) {
$row['listing_uri'] = $buildServiceUri([], [$criticalStatus]);
$row['listing_ack_uri'] = $buildServiceUri([$acknowledgedState], [$criticalStatus]);
$row['listing_downtime_uri'] = $buildServiceUri([$inDowntimeState], [$criticalStatus]);
$row['listing_unhandled_uri'] = $buildServiceUri([$unhandledState], [$criticalStatus]);
$dataCRI[] = $row;
}
......@@ -157,6 +183,10 @@ $res = $db->query(
) . ";"
);
while ($row = $res->fetch()) {
$row['listing_uri'] = $buildServiceUri([], [$warningStatus]);
$row['listing_ack_uri'] = $buildServiceUri([$acknowledgedState], [$warningStatus]);
$row['listing_downtime_uri'] = $buildServiceUri([$inDowntimeState], [$warningStatus]);
$row['listing_unhandled_uri'] = $buildServiceUri([$unhandledState], [$warningStatus]);
$dataWA[] = $row;
}
......@@ -183,6 +213,7 @@ $res = $db->query(
) . ";"
);
while ($row = $res->fetch()) {
$row['listing_uri'] = $buildServiceUri([], [$okStatus]);
$dataOK[] = $row;
}
......@@ -208,6 +239,7 @@ $res = $db->query(
: "") . ";"
);
while ($row = $res->fetch()) {
$row['listing_uri'] = $buildServiceUri([], [$pendingStatus]);
$dataPEND[] = $row;
}
......@@ -268,6 +300,10 @@ $res = $db->query(
) . ";"
);
while ($row = $res->fetch()) {
$row['listing_uri'] = $buildServiceUri([], [$unknownStatus]);
$row['listing_ack_uri'] = $buildServiceUri([$acknowledgedState], [$unknownStatus]);
$row['listing_downtime_uri'] = $buildServiceUri([$inDowntimeState], [$unknownStatus]);
$row['listing_unhandled_uri'] = $buildServiceUri([$unhandledState], [$unknownStatus]);
$dataUNK[] = $row;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment