<?php use Icinga\Web\Url;  ?>
<?= $this->tabs->render($this); ?>

<h3>Monitoring Backends</h3>

<div>
  <a href="<?= Url::fromPath('/monitoring/config/createbackend')->getAbsoluteUrl();?>">
    {{CREATE_ICON}} Create New Monitoring Backend
  </a>
</div>
<br/>

<?php foreach ($this->backends as $backendName => $config): ?>
<div>
  <?php $removeUrl = Url::fromPath('/monitoring/config/removebackend', array('backend' => $backendName)); ?>
  <?php $editUrl = Url::fromPath('/monitoring/config/editbackend', array('backend' => $backendName)); ?>
  <b><?= $this->escape($backendName); ?></b>
  <small>(Type: <?= $this->escape($config['type'] === 'ido' ? 'IDO' : ucfirst($config['type'])); ?>)</small>
  <?php if ($config['disabled']): ?>
    - <b>{{DISABLED_ICON}} Disabled</b>
  <?php endif; ?>
  <div>
    <a href="<?= $removeUrl; ?>">{{REMOVE_ICON}} Remove This Backend</a><br/>
    <a href="<?= $editUrl; ?>">{{EDIT_ICON}} Edit This Backend</a>
  </div>
</div>
<br/>
<?php endforeach; ?>

<br/>

<h3>Monitoring Instances</h3>

<div>
  <a href="<?= Url::fromPath('/monitoring/config/createinstance')->getAbsoluteUrl();?>">
    {{CREATE_ICON}} Create New Instance
  </a>
</div>

<br/>
<?php foreach ($this->instances as $instanceName => $config): ?>
  <?php $removeUrl = Url::fromPath('/monitoring/config/removeinstance', array('instance' => $instanceName)); ?>
  <?php $editUrl = Url::fromPath('/monitoring/config/editinstance', array('instance' => $instanceName)); ?>
<div>
  <b><?= $this->escape($instanceName); ?></b>
  <small>(Type: <?= isset($config['host']) ? 'Remote' : 'Local'; ?>)</small>

  <div>
    <a href="<?= $removeUrl; ?>">{{REMOVE_ICON}} Remove This Instance</a><br/>
    <a href="<?= $editUrl; ?>">{{EDIT_ICON}} Edit This Instance</a>
  </div>
</div>
<br/>
<?php endforeach; ?>

