mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
index: re-style overview page, show stats
This commit is contained in:
parent
449769d151
commit
eb0759a364
13
application/views/scripts/index/actions.phtml
Normal file
13
application/views/scripts/index/actions.phtml
Normal file
@ -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>
|
||||||
|
|
@ -3,35 +3,108 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1><?= $this->translate('Welcome to the Icinga Director') ?></h1>
|
|
||||||
<?php if ($this->errorMessage): ?>
|
<?php if ($this->errorMessage): ?>
|
||||||
<p class="error"><?= $this->errorMessage ?></p>
|
<p class="error"><?= $this->errorMessage ?></p>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php
|
<?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) {
|
if ($this->stats && (int) $this->stats['apiuser']->cnt_total === 0) {
|
||||||
echo $this->form . "</div>\n";
|
echo $this->form . "</div>\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$actions = array(
|
$all = array(
|
||||||
array('cloud', $this->translate('Monitoring Nodes'), 'director/commands'),
|
$this->translate('Manage your monitored objects') => array(
|
||||||
array('host', $this->translate('Host objecs'), 'director/hosts'),
|
array('wrench', $this->translate('Commands'), 'director/commands', statSummary($this, 'command')),
|
||||||
array('services', $this->translate('Monitored Services'), 'director/services'),
|
array('host', $this->translate('Host objects'), 'director/hosts', statSummary($this, 'host')),
|
||||||
array('users', $this->translate('Users / Contacts'), 'director/users'),
|
array('services', $this->translate('Monitored Services'), 'director/services', statSummary($this, 'service')),
|
||||||
array('chat', $this->translate('Alarms and notifications'), 'director/notificatios'),
|
),
|
||||||
array('database', $this->translate('Sync / Import'), 'director/list/importsource'),
|
$this->translate('Alert your users') => array(
|
||||||
array('wrench', $this->translate('Configuration'), 'director/list/generatedconfig'),
|
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): ?>
|
<?php foreach ($all as $title => $actions): ?>
|
||||||
<li>
|
<?= $this->partial(
|
||||||
<a href="<?= $this->url($a[2]) ?>">
|
'index/actions.phtml',
|
||||||
<?= $this->icon($a[0]) ?>
|
array(
|
||||||
<?= $this->escape($a[1]) ?>
|
'actions' => $actions,
|
||||||
</a>
|
'title' => $title
|
||||||
</li>
|
)
|
||||||
|
) ?>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -142,32 +142,36 @@ select option[value=""] {
|
|||||||
|
|
||||||
ul.main-actions {
|
ul.main-actions {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
li {
|
li {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
width: 20em;
|
|
||||||
|
|
||||||
text-align: center;
|
text-align: left;
|
||||||
display: block;
|
display: inline-block;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
float: left;
|
clear: both;
|
||||||
|
width: 24%;
|
||||||
|
vertical-align: top;
|
||||||
|
margin: 0 0.5% 0.5% 0;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
i {
|
i {
|
||||||
width: 100%;
|
height: 1.6em;
|
||||||
height: 1.3em;
|
font-size: 3em;
|
||||||
font-size: 2em;
|
display: block;
|
||||||
display: inline-block;
|
height: 100%;
|
||||||
|
float: left;
|
||||||
line-height: 1em;
|
line-height: 1em;
|
||||||
|
margin-right: 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
border: 1px solid #666;
|
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
margin: 0.5em;
|
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
color: #666;
|
color: #666;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
display: block;
|
display: block;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
height: 10em;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: #666;
|
background-color: #666;
|
||||||
@ -175,6 +179,39 @@ ul.main-actions {
|
|||||||
text-decoration: none;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user