mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-27 07:44:05 +02:00
ImportSourceDetails: new dedicated class, plus..
...a missing new controller class
This commit is contained in:
parent
a943b0c70f
commit
578446d79c
22
application/controllers/ImportsourcesController.php
Normal file
22
application/controllers/ImportsourcesController.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Director\Controllers;
|
||||||
|
|
||||||
|
use Icinga\Module\Director\Web\Table\ImportsourceTable;
|
||||||
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||||
|
use Icinga\Module\Director\Web\Tabs\ImportTabs;
|
||||||
|
|
||||||
|
class ImportsourcesController extends ActionController
|
||||||
|
{
|
||||||
|
public function indexAction()
|
||||||
|
{
|
||||||
|
$this->addTitle($this->translate('Import source'))
|
||||||
|
->setAutoRefreshInterval(10)
|
||||||
|
->addAddLink(
|
||||||
|
$this->translate('Add a new Import Source'),
|
||||||
|
'director/importsource/add'
|
||||||
|
)->tabs(new ImportTabs())->activate('importsource');
|
||||||
|
|
||||||
|
(new ImportsourceTable($this->db()))->renderTo($this);
|
||||||
|
}
|
||||||
|
}
|
83
library/Director/Web/Widget/ImportSourceDetails.php
Normal file
83
library/Director/Web/Widget/ImportSourceDetails.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Director\Web\Widget;
|
||||||
|
|
||||||
|
use Icinga\Module\Director\Forms\ImportCheckForm;
|
||||||
|
use Icinga\Module\Director\Forms\ImportRunForm;
|
||||||
|
use Icinga\Module\Director\Objects\ImportSource;
|
||||||
|
use ipl\Html\Html;
|
||||||
|
use ipl\Translation\TranslationHelper;
|
||||||
|
|
||||||
|
class ImportSourceDetails extends Html
|
||||||
|
{
|
||||||
|
use TranslationHelper;
|
||||||
|
|
||||||
|
protected $source;
|
||||||
|
|
||||||
|
public function __construct(ImportSource $source)
|
||||||
|
{
|
||||||
|
$this->source = $source;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assemble()
|
||||||
|
{
|
||||||
|
$source = $this->source;
|
||||||
|
$description = $source->get('description');
|
||||||
|
if (strlen($description)) {
|
||||||
|
$this->add(Html::p($description));
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($source->get('import_state')) {
|
||||||
|
case 'unknown':
|
||||||
|
$this->add(Html::p(
|
||||||
|
$this->translate(
|
||||||
|
"It's currently unknown whether we are in sync with this Import Source."
|
||||||
|
. ' You should either check for changes or trigger a new Import Run.'
|
||||||
|
)
|
||||||
|
));
|
||||||
|
break;
|
||||||
|
case 'in-sync':
|
||||||
|
$this->add(Html::p(sprintf(
|
||||||
|
$this->translate(
|
||||||
|
'This Import Source was last found to be in sync at %s.'
|
||||||
|
),
|
||||||
|
$source->last_attempt
|
||||||
|
)));
|
||||||
|
// TODO: check whether...
|
||||||
|
// - there have been imports since then, differing from former ones
|
||||||
|
// - there have been activities since then
|
||||||
|
break;
|
||||||
|
case 'pending-changes':
|
||||||
|
$this->add(Html::p(['class' => 'warning'], $this->translate(
|
||||||
|
'There are pending changes for this Import Source. You should trigger a new'
|
||||||
|
. ' Import Run.'
|
||||||
|
)));
|
||||||
|
break;
|
||||||
|
case 'failing':
|
||||||
|
$this->add(Html::p(['class' => 'error'], sprintf(
|
||||||
|
$this->translate(
|
||||||
|
'This Import Source failed when last checked at %s: %s'
|
||||||
|
),
|
||||||
|
$source->last_attempt,
|
||||||
|
$source->last_error_message
|
||||||
|
)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->add(Html::p(['class' => 'error'], sprintf(
|
||||||
|
$this->translate('This Import Source has an invalid state: %s'),
|
||||||
|
$source->get('import_state')
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->add(
|
||||||
|
ImportCheckForm::load()
|
||||||
|
->setImportSource($source)
|
||||||
|
->handleRequest()
|
||||||
|
);
|
||||||
|
$this->add(
|
||||||
|
ImportRunForm::load()
|
||||||
|
->setImportSource($source)
|
||||||
|
->handleRequest()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user