Skip to content

Commit a0e47b7

Browse files
It is possible to delete whole trees now. Made the keys column a bit wider.
1 parent 6025082 commit a0e47b7

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

css/index.css

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ position: absolute;
44
top: 0;
55
bottom: 0;
66
left: 0;
7-
width: 18em;
7+
width: 24em;
88
height: 100%;
99
padding-left: 1em;
1010
border-right: 1px solid #000;
@@ -28,7 +28,7 @@ text-decoration: underline;
2828
position: fixed;
2929
top: 15.5em;
3030
bottom: 0;
31-
width: 18em;
31+
width: 24em;
3232
padding-bottom: 1em;
3333
overflow: auto;
3434
}
@@ -59,6 +59,7 @@ display: none;
5959
#keys .icon {
6060
padding: 1px 0 1px 20px;
6161
background: url(http://github.com/..%3Cspan%20class=pl-c1%3E/%3C/span%3Eimages/folder-open.png) left center no-repeat;
62+
white-space: nowrap;
6263
}
6364

6465
#keys li.collapsed ul {
@@ -96,11 +97,19 @@ background-image: url(http://github.com/images/tree-lastnode-expanded.gif);
9697
background-image: url(http://github.com/..%3Cspan%20class=pl-c1%3E/%3C/span%3Eimages/tree-lastnode-collapsed.gif);
9798
}
9899

100+
#keys .deltree {
101+
display: none;
102+
}
103+
104+
#keys .icon:hover .deltree {
105+
display: inline;
106+
}
107+
99108

100109
#frame {
101110
position: fixed;
102111
top: 0;
103-
left: 19em;
112+
left: 25em;
104113
right: 0;
105114
bottom: 0;
106115
padding-left: 1em;

delete.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,15 @@
4949
die('?view&s='.$server['id'].'&key='.urlencode($_GET['key']));
5050
}
5151

52+
53+
if (isset($_GET['tree'])) {
54+
$keys = $redis->keys($_GET['tree'].'*');
55+
56+
foreach ($keys as $key) {
57+
$redis->delete($key);
58+
}
59+
60+
die;
61+
}
62+
5263
?>

index.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ function print_namespace($item, $name, $fullkey, $islast) {
123123
// Does this namespace also contain subkeys?
124124
if (count($item) > 0) {
125125
?>
126-
<li class="folder<?php echo empty($fullkey) ? '' : ' collapsed'?><?php echo $islast ? ' last' : ''?>"><div class="icon"><?php echo format_html($name)?> <span class="info">(<?php echo count($item)?>)</span></div>
127-
<ul>
126+
<li class="folder<?php echo empty($fullkey) ? '' : ' collapsed'?><?php echo $islast ? ' last' : ''?>">
127+
<div class="icon"><?php echo format_html($name)?>&nbsp;<span class="info">(<?php echo count($item)?>)</span>
128+
<?php if (!empty($fullkey)) { ?><a href="delete.php?s=<?php echo $server['id']?>&amp;tree=<?php echo urlencode($fullkey)?>:" class="deltree"><img src="images/delete.png" width="10" height="10" title="Delete tree" alt="[X]"></a><?php } ?>
129+
</div><ul>
128130
<?php
129131

130132
$l = count($item);

js/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,20 @@ $(function() {
8484
}
8585
});
8686
});
87+
88+
$('.deltree').click(function(e) {
89+
e.preventDefault();
90+
91+
if (confirm('Are you sure you want to delete this whole tree and all it\'s keys?')) {
92+
$.ajax({
93+
type: "POST",
94+
url: this.href,
95+
data: 'post=1',
96+
success: function(url) {
97+
top.location.href = top.location.pathname;
98+
}
99+
});
100+
}
101+
});
87102
});
88103

0 commit comments

Comments
 (0)