Skip to content

Commit 403fea8

Browse files
committed
Add option to customize separator in tree view
1 parent 93ed26d commit 403fea8

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

config.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
//'path' => '/var/run/redis/redis-server.sock', // Unix domain socket (optional).
4444
//'databases' => 16, // Number of databases, use this if the CONFIG command is disabled (optional).
4545
//'scansize' => 1000, // Number of keys, the server will use the SCAN command instead of KEYS (optional).
46+
//'separator' => ':', // Separator for tree view (optional)
4647
],
4748
],
4849
'memcached' => [

src/Dashboards/Redis/RedisTrait.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,18 +394,20 @@ private function keysTableView(array $keys): array {
394394
private function keysTreeView(array $keys): array {
395395
$keys_array = array_column($keys, 'key');
396396
$pipeline = $this->redis->pipelineKeys($keys_array);
397+
$separator = $this->servers[$this->current_server]['separator'] ?? ':';
398+
$this->template->addGlobal('separator', $separator);
397399

398400
$tree = [];
399401

400402
foreach ($keys_array as $key) {
401-
$parts = explode(':', $key);
403+
$parts = explode($separator, $key);
402404
/** @var array<int|string, mixed> $current */
403405
$current = &$tree;
404406
$path = '';
405407

406408
foreach ($parts as $i => $p_value) {
407409
$part = $p_value;
408-
$path = $path ? $path.':'.$part : $part;
410+
$path = $path ? $path.$separator.$part : $part;
409411

410412
if ($i === count($parts) - 1) {
411413
$ttl = $pipeline[$key]['ttl'];

templates/partials/tree_view.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="flex items-center gap-1 py-1 px-6 hover:bg-gray-50 dark:hover:bg-white/5" style="padding-left: calc({{ level }} * 20px + 1.5rem)">
77
<button class="tree-toggle flex gap-1 items-center" data-path="{{ item.path }}">
88
{{ svg('down', 10, '-rotate-90') }}
9-
<span class="tree">{{ item.name }}:*</span>
9+
<span class="tree">{{ item.name }}{{ separator }}*</span>
1010
</button>
1111
<span class="items-count text-gray-500 dark:text-gray-400 text-xs">({{ item.count }})</span>
1212
</div>

0 commit comments

Comments
 (0)