[icinga-checkins] icinga.org: icingaweb2-module-director/feature/job-scheduling-11627: index : allow to apply migrations from dashboard

git at icinga.org git at icinga.org
Mon May 2 10:43:11 CEST 2016


Module: icingaweb2-module-director
Branch: feature/job-scheduling-11627
Commit: 8dda8a6a9a78f992be48b01472d5f3969e34de28
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=8dda8a6a9a78f992be48b01472d5f3969e34de28

Author: Thomas Gelf <thomas at gelf.net>
Date:   Mon May  2 10:21:22 2016 +0200

index: allow to apply migrations from dashboard

---

 application/controllers/IndexController.php |   19 ++++++++++++++++---
 application/views/scripts/index/index.phtml |    5 +++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php
index 9e0ac31..34f0679 100644
--- a/application/controllers/IndexController.php
+++ b/application/controllers/IndexController.php
@@ -3,6 +3,7 @@
 namespace Icinga\Module\Director\Controllers;
 
 use Exception;
+use Icinga\Module\Director\Db\Migrations;
 use Icinga\Module\Director\Objects\DirectorJob;
 use Icinga\Module\Director\Objects\ImportSource;
 use Icinga\Module\Director\Objects\SyncRule;
@@ -33,9 +34,21 @@ class IndexController extends ActionController
                 'label' => $this->translate('Overview')
             ))->activate('overview');
 
-            $this->fetchSyncState()
-                 ->fetchImportState()
-                 ->fetchJobState();
+            $migrations = new Migrations($this->db());
+
+            if ($migrations->hasPendingMigrations()) {
+                $this->view->migrationsForm = $this
+                    ->loadForm('applyMigrations')
+                    ->setMigrations($migrations)
+                    ->handleRequest();
+            }
+
+            try {
+                $this->fetchSyncState()
+                     ->fetchImportState()
+                     ->fetchJobState();
+            } catch (Exception $e) {
+            }
         }
     }
 
diff --git a/application/views/scripts/index/index.phtml b/application/views/scripts/index/index.phtml
index 8b49452..30423a7 100644
--- a/application/views/scripts/index/index.phtml
+++ b/application/views/scripts/index/index.phtml
@@ -84,6 +84,11 @@ if (!$this->hasDeploymentEndpoint) {
     echo $this->form;
 }
 
+if ($this->migrationsForm) {
+    echo '<h1>' . $this->translate('There are pending database schema migrations') . "</h2>\n";
+    echo $this->migrationsForm;
+}
+
 $all = array(
     $this->translate('Define whatever you want to be monitored') => array(
         array('host',     $this->translate('Host objects'), 'director/hosts', statSummary($this, 'host')),



More information about the icinga-checkins mailing list