CubeLinks: fit modified Cube API

This commit is contained in:
Thomas Gelf 2016-11-25 20:50:31 +01:00
parent ac3e541317
commit 42f98e9bbf
1 changed files with 21 additions and 8 deletions

View File

@ -10,11 +10,12 @@ use Icinga\Web\View;
class CubeLinks extends ActionLinksHook class CubeLinks extends ActionLinksHook
{ {
public function getHtml(View $view, Cube $cube) public function prepareActionLinks(Cube $cube, View $view)
{ {
if (! $cube instanceof IdoHostStatusCube) { if (! $cube instanceof IdoHostStatusCube) {
return ''; return;
} }
$cube->finalizeInnerQuery(); $cube->finalizeInnerQuery();
$query = $cube->innerQuery() $query = $cube->innerQuery()
->reset('columns') ->reset('columns')
@ -23,9 +24,16 @@ class CubeLinks extends ActionLinksHook
$hosts = $cube->db()->fetchCol($query); $hosts = $cube->db()->fetchCol($query);
if (count($hosts) === 1) { $count = count($hosts);
if ($count === 1) {
$url = 'director/host/edit'; $url = 'director/host/edit';
$params = array('name' => $hosts[0]); $params = array('name' => $hosts[0]);
$title = $view->translate('Modify a host');
$description = sprintf(
$view->translate('This allows you to modify properties for "%s"'),
$hosts[0]
);
} else { } else {
$params = null; $params = null;
@ -37,13 +45,18 @@ class CubeLinks extends ActionLinksHook
} }
$url = 'director/hosts/edit?' . $filter->toQueryString(); $url = 'director/hosts/edit?' . $filter->toQueryString();
$title = sprintf($view->translate('Modify %d hosts'), $count);
$description = $view->translate(
'This allows you to modify properties for all chosen hosts at once'
);
} }
return $view->qlink( $this->addActionLink(
$view->translate('Modify hosts'), $this->makeUrl($url, $params),
$url, $title,
$params, $description,
array('class' => 'icon-wrench') 'wrench'
); );
} }
} }