Commit dccaea14 authored by Kevin Duret's avatar Kevin Duret
Browse files

fix(api): clean MonitoringResourceController to align develop

parent 8246b576
......@@ -85,9 +85,6 @@ class MonitoringResourceController extends AbstractController
private const SERVICE_REPORTING_URI =
'/main.php?p=30702&period=yesterday&start=&end=&host_id={parent_resource_id}&item={resource_id}';
private const HOSTGROUP_CONFIGURATION_URI = '/main.php?p=60102&o=c&hg_id={resource_group_id}';
private const SERVICEGROUP_CONFIGURATION_URI = '/main.php?p=60203&o=c&sg_id={resource_group_id}';
private const RESOURCE_LISTING_URI = '/monitoring/resources';
public const TAB_DETAILS_NAME = 'details';
......@@ -598,48 +595,6 @@ class MonitoringResourceController extends AbstractController
}
}
/**
* This function adds to the group the redirection URI to the configuration
*
* @param ResourceEntity $resource
* @param Contact $contact
* @return void
*/
private function provideResourceGroupInternalUris(ResourceEntity $resource, Contact $contact): void
{
if ($resource->getType() === ResourceEntity::TYPE_HOST) {
if (
$contact->hasTopologyRole(Contact::ROLE_CONFIGURATION_HOSTS_HOST_GROUPS_READ_WRITE)
|| $contact->hasTopologyRole(Contact::ROLE_CONFIGURATION_HOSTS_HOST_GROUPS_READ)
|| $contact->isAdmin()
) {
foreach ($resource->getGroups() as $group) {
$group->setConfigurationUri(
$this->generateResourceGroupConfigurationUri(
$group,
self::HOSTGROUP_CONFIGURATION_URI
)
);
}
}
} elseif ($resource->getType() === ResourceEntity::TYPE_SERVICE) {
if (
$contact->hasTopologyRole(Contact::ROLE_CONFIGURATION_SERVICES_SERVICE_GROUPS_READ_WRITE)
|| $contact->hasTopologyRole(Contact::ROLE_CONFIGURATION_SERVICES_SERVICE_GROUPS_READ)
|| $contact->isAdmin()
) {
foreach ($resource->getGroups() as $group) {
$group->setConfigurationUri(
$this->generateResourceGroupConfigurationUri(
$group,
self::SERVICEGROUP_CONFIGURATION_URI
)
);
}
}
}
}
/**
* Generate full uri from relative path
*
......@@ -660,19 +615,6 @@ class MonitoringResourceController extends AbstractController
return $this->getBaseUri() . $relativeUri;
}
/**
* Generate full uri from relative path for ResourceGroup
*
* @param ResourceGroup $group
* @param string $relativeUri
* @return string
*/
private function generateResourceGroupConfigurationUri(ResourceGroup $group, string $relativeUri): string
{
$relativeUri = str_replace('{resource_group_id}', (string) $group->getId(), $relativeUri);
return $this->getBaseUri() . $relativeUri;
}
/**
* Build uri to access host panel with details tab
*
......
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