-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move ModuleController from incubator
The Notification dependency is removed and uses exceptions now, otherwise it's mostly the same like in the incubator refs #4092
- Loading branch information
Jannis Moßhammer
committed
Jun 21, 2013
1 parent
076b8a9
commit fd48948
Showing
9 changed files
with
221 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
// @codingStandardsIgnoreStart | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
|
||
# namespace Icinga\Application\Controllers; | ||
|
||
|
||
use Icinga\Web\ActionController; | ||
use Icinga\Application\Icinga; | ||
|
||
class ModulesController extends ActionController | ||
{ | ||
protected $manager; | ||
|
||
public function init() | ||
{ | ||
$this->manager = Icinga::app()->moduleManager(); | ||
} | ||
|
||
public function indexAction() | ||
{ | ||
$this->view->modules = $this->manager->select() | ||
->from('modules') | ||
->order('name'); | ||
$this->render('overview'); | ||
} | ||
|
||
public function overviewAction() | ||
{ | ||
$this->indexAction(); | ||
|
||
} | ||
|
||
public function enableAction() | ||
{ | ||
$this->manager->enableModule($this->_getParam('name')); | ||
$this->redirectNow('modules/overview?_render=body'); | ||
} | ||
|
||
public function disableAction() | ||
{ | ||
$this->manager->disableModule($this->_getParam('name')); | ||
$this->redirectNow('modules/overview?_render=body'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?= $this->layout()->moduleStart ?> | ||
<?= $this->layout()->content ?> | ||
<?= $this->layout()->moduleEnd ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<? if ($this->pageCount > 1): ?> | ||
<?php | ||
if (is_array($this->preserve)) { | ||
$preserve = $this->preserve; | ||
} else { | ||
$preserve = array(); | ||
} | ||
|
||
$fromto = t('%d to %d of %d'); | ||
$total = $this->totalItemCount; | ||
?> | ||
<div class="pagination pagination-mini" style="margin:0px"> | ||
<ul> | ||
<!-- Previous page link --> | ||
<? if (isset($this->previous)): ?> | ||
<li><a href="<?= $this->url($preserve + array('page' => $this->previous)); ?>" title="<?= | ||
sprintf($fromto, | ||
($this->current - 2) * $this->itemCountPerPage + 1, | ||
($this->current - 1) * $this->itemCountPerPage, | ||
$this->totalItemCount) | ||
?>">« <?= t('Back') ?></a></li> | ||
<? else: ?> | ||
<li class="disabled"><span>« <?= t('Back') ?></span></li> | ||
<?php | ||
endif; | ||
?> | ||
<!-- Numbered page links --> | ||
<? foreach ($this->pagesInRange as $page): ?> | ||
<?php | ||
|
||
$start = ($page - 1) * $this->itemCountPerPage + 1; | ||
$end = $page * $this->itemCountPerPage; | ||
if ($end > $total) { | ||
$end = $total; | ||
} | ||
$title = sprintf($fromto, $start, $end, $total); | ||
$active_class = $page === $this->current ? ' class="active"' : ''; | ||
|
||
?> | ||
<?php if ($page === '...'): ?> | ||
<li class="disabled"><span>...</span></li> | ||
<?php else: ?> | ||
<li<?= $active_class ?>><a href="<?= $this->url( | ||
$preserve + array('page' => $page) | ||
); ?>" title="<?= $title ?>"><?= $page; ?></a></li> | ||
<? endif ?> | ||
<? endforeach ?> | ||
<!-- Next page link --> | ||
<? if (isset($this->next)): ?> | ||
<li><a href="<?= $this->url($preserve + array('page' => $this->next)); ?>" title="<?= | ||
sprintf($fromto, | ||
($this->current) * $this->itemCountPerPage + 1, | ||
($this->current + 1) * $this->itemCountPerPage, | ||
$total) | ||
?>"><?= t('Next') ?> »</a></li> | ||
<? else: ?> | ||
<li class="disabled"><span><?= t('Next') ?> »</span></li> | ||
<? endif ?> | ||
</ul> | ||
</div> | ||
<? endif ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
$this->modules->limit(10); | ||
$modules = $this->modules->paginate(); | ||
|
||
?> | ||
<h3>Installed Modules</h3> | ||
<?= $this->paginationControl($modules, null, null, array( | ||
'preserve' => $this->preserve | ||
)); ?> | ||
<table > | ||
<tbody> | ||
<? foreach ($modules as $module): ?> | ||
<tr> | ||
<td> | ||
<? if ($module->enabled): ?> | ||
<i class="icon-ok-sign"></i> <?= $this->qlink( | ||
$module->name, | ||
'modules/disable', | ||
array('name' => $module->name), | ||
array('target'=>'body') | ||
) ?> | ||
<? else: ?> | ||
<i class="icon-remove-sign"></i> <?= $this->qlink( | ||
$module->name, | ||
'modules/enable', | ||
array('name' => $module->name), | ||
array('target'=>'body') | ||
) ?> | ||
<? endif ?> | ||
(<?= | ||
$module->enabled | ||
? ($module->loaded ? 'enabled' : 'failed') | ||
: 'disabled' | ||
?>)</td> | ||
</tr> | ||
<? endforeach ?> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php $container = $this->container('modules-container',array( | ||
"class" => "expanded_absolute" | ||
))->beginContent() ?> | ||
<table class="table table-bordered" style="width:100%"> | ||
<thead> | ||
<tr style="text-align:left"> | ||
<th width="70%">Module</th> | ||
<th width="15%">Type</th> | ||
<th width="15%">Active</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php foreach($this->modules as $module): ?> | ||
<tr> | ||
<td><?= $module["name"] ?></td> | ||
<td><?= $module["type"] ?></td> | ||
<td><?= $module["active"] ?></td> | ||
</tr> | ||
|
||
<?php endforeach; ?> | ||
</tbody> | ||
</table> | ||
|
||
<?= $container; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters