[icinga-checkins] icinga.org: icingaweb2-module-director/master: index: re-style overview page, show stats

git at icinga.org git at icinga.org
Wed Feb 17 18:55:00 CET 2016


Module: icingaweb2-module-director
Branch: master
Commit: eb0759a364310a226390f3cbd9310f73d80a47ea
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=eb0759a364310a226390f3cbd9310f73d80a47ea

Author: Thomas Gelf <thomas at gelf.net>
Date:   Wed Feb 17 18:54:46 2016 +0100

index: re-style overview page, show stats

---

 application/views/scripts/index/actions.phtml |   13 +++
 application/views/scripts/index/index.phtml   |  109 +++++++++++++++++++++----
 public/css/module.less                        |   57 ++++++++++---
 3 files changed, 151 insertions(+), 28 deletions(-)

diff --git a/application/views/scripts/index/actions.phtml b/application/views/scripts/index/actions.phtml
new file mode 100644
index 0000000..656e30f
--- /dev/null
+++ b/application/views/scripts/index/actions.phtml
@@ -0,0 +1,13 @@
+<h1><?= $this->escape($title) ?></h1>
+<ul class="main-actions" data-base-target="_next">
+<?php foreach ($actions as $a): ?>
+<li>
+  <a href="<?= $this->url($a[2]) ?>">
+  <?= $this->icon($a[0]) ?>
+  <?= $this->escape($a[1]) ?>
+  <p><?= $this->escape($a[3]) ?></p>
+  </a>
+</li>
+<?php endforeach ?>
+</ul>
+
diff --git a/application/views/scripts/index/index.phtml b/application/views/scripts/index/index.phtml
index ef6b29c..01663f3 100644
--- a/application/views/scripts/index/index.phtml
+++ b/application/views/scripts/index/index.phtml
@@ -3,35 +3,108 @@
 </div>
 
 <div class="content">
-<h1><?= $this->translate('Welcome to the Icinga Director') ?></h1>
 <?php if ($this->errorMessage): ?>
 <p class="error"><?= $this->errorMessage ?></p>
 <?php endif ?>
 <?php
 
+function statSummary($self, $type) {
+    $stat = $self->stats[$type];
+
+    if ((int) $stat->cnt_total === 0) {
+        return $self->translate('No object has been defined yet');
+    }
+
+    if ((int) $stat->cnt_total === 1) {
+        if ($stat->cnt_template > 0) {
+            $msg = $self->translate('One template has been defined');
+        } elseif ($stat->cnt_external > 0) {
+            $msg = $self->translate('One external object has been defined, it will not be deployed');
+        } else {
+            $msg = $self->translate('One object has been defined');
+        }
+
+        return $msg;
+    } else {
+        $msg = sprintf(
+            $self->translate('%d objects have been defined'),
+            $stat->cnt_total
+        );
+    }
+
+    if ($stat->cnt_total === $stat->cnt_object) {
+        return $msg;
+    }
+
+    $extra = array();
+    if ($stat->cnt_template > 0) {
+        $extra[] = sprintf(
+            $self->translate('%d of them are templates'),
+            $stat->cnt_template
+        );
+    }
+    if ($stat->cnt_external > 0) {
+        $extra[] = sprintf(
+            $self->translate('%d have been externally defined and will not be deployed'),
+            $stat->cnt_external
+        );
+    }
+
+    if (array_key_exists($type . 'group', $self->stats)) {
+        $groupstat = $self->stats[$type . 'group'];
+        if ((int) $groupstat->cnt_total === 0) {
+            $extra[] = $self->translate('no related group exists');
+        } elseif ((int) $groupstat->cnt_total === 1) {
+            $extra[] = $self->translate('one related group exists');
+        } else {
+            $extra[] = sprintf(
+                $self->translate('%s related group objects have been created', $groupstat->cnt_total)
+            );
+        }
+    }
+
+    return $msg . ', ' . implode(', ', $extra);
+}
+
+function renderActions($title, $actions) {
+
+}
+
 if ($this->stats && (int) $this->stats['apiuser']->cnt_total === 0) {
     echo $this->form . "</div>\n";
     return;
 }
 
-$actions = array(
-    array('cloud',    $this->translate('Monitoring Nodes'), 'director/commands'),
-    array('host',     $this->translate('Host objecs'), 'director/hosts'),
-    array('services', $this->translate('Monitored Services'), 'director/services'),
-    array('users',    $this->translate('Users / Contacts'), 'director/users'),
-    array('chat',     $this->translate('Alarms and notifications'), 'director/notificatios'),
-    array('database', $this->translate('Sync / Import'), 'director/list/importsource'),
-    array('wrench',   $this->translate('Configuration'), 'director/list/generatedconfig'),
+$all = array(
+    $this->translate('Manage your monitored objects') => array(
+        array('wrench',   $this->translate('Commands'), 'director/commands', statSummary($this, 'command')),
+        array('host',     $this->translate('Host objects'), 'director/hosts', statSummary($this, 'host')),
+        array('services', $this->translate('Monitored Services'), 'director/services', statSummary($this, 'service')),
+    ),
+    $this->translate('Alert your users') => array(
+        array('users',    $this->translate('Users / Contacts'), 'director/users', statSummary($this, 'user')),
+        array('calendar', $this->translate('Timeperiods'), 'director/timeperiods', statSummary($this, 'timeperiod')),
+        array('chat',     $this->translate('Notifications'), '#', $this->translate('Schedule your notifications')),
+    ),
+    $this->translate('Deploy to your Icinga nodes') => array(
+        array('globe',    $this->translate('Zones'), 'director/zones', statSummary($this, 'zone')),
+        array('cloud',    $this->translate('Endpoints'), 'director/endpoints', statSummary($this, 'endpoint')),
+        array('lock-open-alt', $this->translate('Api users'), 'director/apiusers', statSummary($this, 'apiuser')),
+        array('wrench',   $this->translate('Deployment'), 'director/list/deploymentlog', $this->translate('Manage deployments, access audit log and history')),
+    ),
+    $this->translate('Data') => array(
+        array('database', $this->translate('Sync / Import'), 'director/list/importsource', ''),
+    )
 );
 ?>
-<ul class="main-actions">
-<?php foreach ($actions as $a): ?>
- <li>
-  <a href="<?= $this->url($a[2]) ?>">
-  <?= $this->icon($a[0]) ?>
-  <?= $this->escape($a[1]) ?>
-  </a>
- </li>
+
+<?php foreach ($all as $title => $actions): ?>
+<?= $this->partial(
+    'index/actions.phtml',
+    array(
+        'actions' => $actions,
+        'title'   => $title
+    )
+) ?>
 <?php endforeach ?>
-</ul>
 </div>
diff --git a/public/css/module.less b/public/css/module.less
index 5b29382..5695ec8 100644
--- a/public/css/module.less
+++ b/public/css/module.less
@@ -142,32 +142,36 @@ select option[value=""] {
 
 ul.main-actions {
   margin: 0;
+  padding: 0;
   li {
     list-style-type: none;
-    width: 20em;
 
-    text-align: center;
-    display: block;
+    text-align: left;
+    display: inline-block;
     padding: 0;
-    float: left;
+    clear: both;
+    width: 24%;
+    vertical-align: top;
+    margin: 0 0.5% 0.5% 0;
 
     a {
         i {
-            width: 100%;
-            height: 1.3em;
-            font-size: 2em;
-            display: inline-block;
+            height: 1.6em;
+            font-size: 3em;
+            display: block;
+            height: 100%;
+            float: left;
             line-height: 1em;
+            margin-right: 0.3em;
         }
 
-        border: 1px solid #666;
         padding: 1em;
-        margin: 0.5em;
         font-size: 1.1em;
         color: #666;
         font-weight: bold;
         display: block;
         text-decoration: none;
+        height: 10em;
 
         &:hover {
             background-color: #666;
@@ -175,6 +179,39 @@ ul.main-actions {
             text-decoration: none;
         }
     }
+
+    p {
+        font-weight: normal;
+        margin-bottom: 0.5em;
+    }
+  }
+}
+
+#layout.compact-layout ul.main-actions {
+  li {
+    width: 32%;
+    margin: 0 1% 1% 0;
+  }
+}
+
+#layout.poor-layout ul.main-actions {
+  li {
+    width: 30%;
+    margin: 0 0.5% 0.5% 0;
+  }
+}
+
+#layout.minimal-layout ul.main-actions {
+  li {
+    width: 48%;
+    margin: 0 1% 1% 0;
+  }
+}
+
+#layout.twocols ul.main-actions {
+  li {
+    width: 48%;
+    margin: 0 1% 1% 0;
   }
 }
 



More information about the icinga-checkins mailing list