-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VmController and others: lots of changes
* moved titles to tables and detail classes * more texts with hints * move location-related information to dedicated table * refactor some code into BackupToolInfo * improved snapshot table styling * two-column layout in detail view if possible fixes #186
- Loading branch information
1 parent
aceb86e
commit bcf6cf3
Showing
15 changed files
with
273 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Icinga\Module\Vspheredb\Controllers; | ||
|
||
use ipl\Html\Html; | ||
|
||
trait DetailSections | ||
{ | ||
protected function section($content) | ||
{ | ||
return Html::tag('div', [ | ||
'class' => 'section', | ||
], $content); | ||
} | ||
|
||
protected function addSection($content) | ||
{ | ||
$this->content()->add($this->section($content)); | ||
|
||
return $this; | ||
} | ||
|
||
protected function addSections(array $sections) | ||
{ | ||
foreach ($sections as $section) { | ||
$this->addSection($section); | ||
} | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
library/Vspheredb/Web/Table/Object/VmLocationInfoTable.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Icinga\Module\Vspheredb\Web\Table\Object; | ||
|
||
use gipfl\IcingaWeb2\Link; | ||
use gipfl\Translation\TranslationHelper; | ||
use gipfl\IcingaWeb2\Widget\NameValueTable; | ||
use Icinga\Module\Vspheredb\DbObject\VCenter; | ||
use Icinga\Module\Vspheredb\DbObject\VirtualMachine; | ||
use Icinga\Module\Vspheredb\Hint\ConnectionStateDetails; | ||
use Icinga\Module\Vspheredb\PathLookup; | ||
use Icinga\Module\Vspheredb\Web\Widget\Link\MobLink; | ||
use Icinga\Module\Vspheredb\Web\Widget\SubTitle; | ||
use ipl\Html\Html; | ||
|
||
class VmLocationInfoTable extends NameValueTable | ||
{ | ||
use TranslationHelper; | ||
|
||
/** @var VirtualMachine */ | ||
protected $vm; | ||
|
||
/** @var VCenter */ | ||
protected $vCenter; | ||
|
||
public function __construct(VirtualMachine $vm, VCenter $vCenter) | ||
{ | ||
$this->prepend(new SubTitle($this->translate('Location'), 'home')); | ||
$this->vm = $vm; | ||
$this->vCenter = $vCenter; | ||
} | ||
|
||
protected function getDb() | ||
{ | ||
return $this->vm->getConnection(); | ||
} | ||
|
||
/** | ||
* @throws \Icinga\Exception\NotFoundError | ||
*/ | ||
protected function assemble() | ||
{ | ||
$vm = $this->vm; | ||
/** @var \Icinga\Module\Vspheredb\Db $connection */ | ||
$connection = $vm->getConnection(); | ||
$lookup = new PathLookup($connection); | ||
|
||
$this->addNameValuePairs([ | ||
$this->translate('Host') => [ | ||
$lookup->linkToObject($vm->get('runtime_host_uuid')), | ||
Html::tag('br'), | ||
ConnectionStateDetails::getFor($vm->get('connection_state')) | ||
], | ||
$this->translate('Resource Pool') => $lookup->linkToObject($vm->get('resource_pool_uuid')), | ||
$this->translate('Path') => $this->renderPathToObject(), | ||
$this->translate('MO Ref') => new MobLink($this->vCenter, $vm), | ||
]); | ||
} | ||
|
||
protected function renderPathToObject() | ||
{ | ||
$uuid = $this->vm->get('uuid'); | ||
/** @var \Icinga\Module\Vspheredb\Db $connection */ | ||
$connection = $this->vm->getConnection(); | ||
$lookup = new PathLookup($connection); | ||
$path = Html::tag('span', ['class' => 'dc-path']); | ||
$parts = []; | ||
foreach ($lookup->getObjectNames($lookup->listPathTo($uuid, false)) as $parentUuid => $name) { | ||
if (! empty($parts)) { | ||
$parts[] = ' > '; | ||
} | ||
$parts[] = Link::create( | ||
$name, | ||
'vspheredb/vms', | ||
// TODO: nice UUID | ||
['uuid' => bin2hex($parentUuid)], | ||
['data-base-target' => '_main'] | ||
); | ||
} | ||
$path->add($parts); | ||
|
||
return $path; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.