From 578446d79cd3d1af1eb5a90793094fa70dbeb56f Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 16 Aug 2017 12:01:25 +0200 Subject: [PATCH] ImportSourceDetails: new dedicated class, plus.. ...a missing new controller class --- .../controllers/ImportsourcesController.php | 22 +++++ .../Web/Widget/ImportSourceDetails.php | 83 +++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 application/controllers/ImportsourcesController.php create mode 100644 library/Director/Web/Widget/ImportSourceDetails.php diff --git a/application/controllers/ImportsourcesController.php b/application/controllers/ImportsourcesController.php new file mode 100644 index 00000000..70e2fbf7 --- /dev/null +++ b/application/controllers/ImportsourcesController.php @@ -0,0 +1,22 @@ +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); + } +} diff --git a/library/Director/Web/Widget/ImportSourceDetails.php b/library/Director/Web/Widget/ImportSourceDetails.php new file mode 100644 index 00000000..171fa71c --- /dev/null +++ b/library/Director/Web/Widget/ImportSourceDetails.php @@ -0,0 +1,83 @@ +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() + ); + } +}