Skip to content

Commit

Permalink
Show number of keys per DB in navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Fidelin authored and sasanrose committed Jan 16, 2014
1 parent 58490e9 commit 2dfb838
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
12 changes: 10 additions & 2 deletions libraries/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,17 @@ public function __construct($config)
if (!in_array($config['dbId'], $dbs)) {
$config['dbId'] = $dbs[0];
}

$current['database'] = $config['dbId'];
$current['dbs'] = $dbs;

// Extract number of keys
foreach ($dbs as $i) {
if (preg_match('/^keys=([0-9]+),expires=([0-9]+)$/', $info["db{$i}"], $matches)) {
$current['dbs'][] = array(
'id' => $i,
'keys' => $matches[1],
);
}
}

$this->db->select($current['database']);

Expand Down
3 changes: 3 additions & 0 deletions public/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ textarea {
padding-right: 6px;
font-size: 90%;
}
.nav-pills>li.database .label {
margin-top: -2px;
}
6 changes: 3 additions & 3 deletions views/navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</li>
<?php foreach ($this->app->current['dbs'] as $database): ?>
<?php
if ($database == $this->app->current['database']) {
if ($database['id'] == $this->app->current['database']) {
$dbClass = 'active';
$dbIcon = 'icon-ok-sign';
}
Expand All @@ -17,8 +17,8 @@
}
?>
<li class="database <?= $dbClass ?>">
<a href="<?=$this->router->url?>/welcome/index/<?= $this->app->current['serverId'] . '/' . $database ?>">
<i class="<?= $dbIcon ?>"></i> DB <?= $database ?>
<a href="<?=$this->router->url?>/welcome/index/<?= $this->app->current['serverId'] . '/' . $database['id'] ?>">
<i class="<?= $dbIcon ?>"></i> DB <?= $database['id'] ?> <span class="label pull-right" title="Number of keys"><?= $database['keys'] ?></span>
</a>
</li>
<?php endforeach; ?>
Expand Down

0 comments on commit 2dfb838

Please sign in to comment.