redis-browser 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be0e2ba8d6a3009374dc91c621899fbb8d247ba5
|
4
|
+
data.tar.gz: c37ef89c7903b1902a1b8b86ea2851ae09182647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0302aa3ad6b395a35e4de6b04fb159e9df086834d14c6f7f5748c271db56923cb52607e748db48b71e215f443abd808d9268fd0c6f1e0110b6112735e9674d37
|
7
|
+
data.tar.gz: 87a612ae892bb71b4099b03f64e7b2edb1d6635cbd1d6f72df24372c8a157200baa617c382863fea4eff526410569f6112dc017dd88bf5a01b381437d1b7a117
|
data/lib/redis-browser/app.rb
CHANGED
@@ -21,34 +21,38 @@ class Browser
|
|
21
21
|
@db = db
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
24
|
+
def split_key(key)
|
25
|
+
if key =~ /^(.+?)(:+|\/+|\.+).+$/
|
26
|
+
[$1, $2]
|
27
|
+
else
|
28
|
+
[key, nil]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def keys(namespace = nil)
|
33
|
+
if namespace.to_s.strip.empty?
|
34
|
+
pattern = "*"
|
35
|
+
namespace = ""
|
36
|
+
else
|
37
|
+
pattern = namespace + "*"
|
37
38
|
end
|
38
39
|
|
39
|
-
|
40
|
+
redis.keys(pattern).inject({}) do |acc, key|
|
41
|
+
key.slice!(namespace) if namespace
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
:
|
46
|
-
:
|
43
|
+
ns, sep = split_key(key)
|
44
|
+
|
45
|
+
unless ns.strip.empty?
|
46
|
+
acc[ns] ||= {
|
47
|
+
:name => ns,
|
48
|
+
:full => namespace + ns + sep.to_s,
|
49
|
+
:count => 0
|
47
50
|
}
|
48
|
-
|
49
|
-
|
51
|
+
acc[ns][:count] += 1
|
52
|
+
end
|
50
53
|
|
51
|
-
|
54
|
+
acc
|
55
|
+
end.values.sort_by {|e| e[:name] }
|
52
56
|
end
|
53
57
|
|
54
58
|
def item_type(e)
|
@@ -137,6 +141,13 @@ class Browser
|
|
137
141
|
}.merge(data)
|
138
142
|
end
|
139
143
|
|
144
|
+
def ping
|
145
|
+
redis.ping == "PONG"
|
146
|
+
{:ok => 1}
|
147
|
+
rescue => ex
|
148
|
+
{:error => ex.message}
|
149
|
+
end
|
150
|
+
|
140
151
|
def redis
|
141
152
|
@redis ||= begin
|
142
153
|
conn = @conn || "127.0.0.1:6379"
|
@@ -167,12 +178,12 @@ class App < Sinatra::Base
|
|
167
178
|
slim :index
|
168
179
|
end
|
169
180
|
|
170
|
-
get '/
|
171
|
-
json browser.
|
181
|
+
get '/ping.json' do
|
182
|
+
json browser.ping
|
172
183
|
end
|
173
184
|
|
174
185
|
get '/keys.json' do
|
175
|
-
json browser.keys(params[:
|
186
|
+
json browser.keys(params[:namespace])
|
176
187
|
end
|
177
188
|
|
178
189
|
get '/key.json' do
|
@@ -40,3 +40,14 @@ body {
|
|
40
40
|
.per-page { margin-top: 25px; }
|
41
41
|
.connection-info { padding-right: 20px; }
|
42
42
|
.keys-search { width: 100px; }
|
43
|
+
|
44
|
+
#http-loader {
|
45
|
+
position: fixed;
|
46
|
+
left: 0;
|
47
|
+
top: 0;
|
48
|
+
display: none;
|
49
|
+
background: gold;
|
50
|
+
padding: 5px 10px;
|
51
|
+
font-weight: bold;
|
52
|
+
z-index: 10000;
|
53
|
+
}
|
@@ -1,15 +1,35 @@
|
|
1
1
|
app = angular.module('browser', ['ui.bootstrap', 'LocalStorageModule'])
|
2
2
|
|
3
|
-
|
3
|
+
app.config ($httpProvider) ->
|
4
|
+
funShow = (data, headersGetter) ->
|
5
|
+
document.getElementById('http-loader').style.display = "block"
|
6
|
+
data
|
7
|
+
|
8
|
+
$httpProvider.defaults.transformRequest.push(funShow)
|
9
|
+
$httpProvider.responseInterceptors.push('HttpLoader')
|
10
|
+
|
11
|
+
app.factory 'HttpLoader', ['$q', ($q) ->
|
12
|
+
(promise) ->
|
13
|
+
promise.then (response) ->
|
14
|
+
document.getElementById('http-loader').style.display = "none"
|
15
|
+
response
|
16
|
+
, (response) ->
|
17
|
+
document.getElementById('http-loader').style.display = "none"
|
18
|
+
response
|
19
|
+
]
|
4
20
|
|
5
|
-
|
21
|
+
app.factory 'API', ['$http', ($http) ->
|
6
22
|
(connection, database) ->
|
7
23
|
ps = {connection: connection, database: database}
|
8
24
|
{
|
9
|
-
|
25
|
+
ping: () -> $http.get("/ping.json", {
|
10
26
|
params: ps
|
11
27
|
}).then (e) -> e.data,
|
12
28
|
|
29
|
+
keys: (namespace) -> $http.get("/keys.json", {
|
30
|
+
params: angular.extend({}, ps, {namespace: namespace})
|
31
|
+
}).then (e) -> e.data,
|
32
|
+
|
13
33
|
get: (params) -> $http.get("/key.json", {
|
14
34
|
params: angular.extend({}, ps, params)
|
15
35
|
}).then (e) -> e.data
|
@@ -53,14 +73,22 @@ angular.module('browser').factory 'API', ['$http', ($http) ->
|
|
53
73
|
close: ->
|
54
74
|
$scope.config.show = false
|
55
75
|
save: ->
|
56
|
-
|
57
|
-
|
58
|
-
$scope.api = API($scope.config.connection, $scope.config.database)
|
76
|
+
# Check connection
|
77
|
+
$scope.config.error = null
|
59
78
|
|
60
|
-
$scope.
|
61
|
-
|
79
|
+
test = API($scope.config.connection, $scope.config.database)
|
80
|
+
test.ping().then (resp) ->
|
81
|
+
if resp.ok
|
82
|
+
db.add("connection", $scope.config.connection)
|
83
|
+
db.add("database", $scope.config.database)
|
84
|
+
$scope.api = API($scope.config.connection, $scope.config.database)
|
85
|
+
|
86
|
+
$scope.fetchKeys()
|
87
|
+
$scope.show($scope.key)
|
62
88
|
|
63
|
-
|
89
|
+
$scope.config.close()
|
90
|
+
else
|
91
|
+
$scope.config.error = resp.error
|
64
92
|
|
65
93
|
setHashView: (view) ->
|
66
94
|
$scope.config.hashView = view
|
@@ -75,10 +103,10 @@ angular.module('browser').factory 'API', ['$http', ($http) ->
|
|
75
103
|
|
76
104
|
# Scope functions
|
77
105
|
$scope.fetchKeys = ->
|
78
|
-
$scope.keys = $scope.api.
|
106
|
+
$scope.keys = $scope.api.keys()
|
79
107
|
|
80
108
|
$scope.show = (key) ->
|
81
|
-
key
|
109
|
+
$scope.keyOpen(key)
|
82
110
|
$scope.api.get(key: key.full).then((e) ->
|
83
111
|
$scope.key = e
|
84
112
|
|
@@ -97,6 +125,17 @@ angular.module('browser').factory 'API', ['$http', ($http) ->
|
|
97
125
|
e.json[k] = v.value
|
98
126
|
)
|
99
127
|
|
128
|
+
$scope.keyOpen = (key) ->
|
129
|
+
console.log key.children
|
130
|
+
if key.count > 1 && !key.children
|
131
|
+
$scope.api.keys(key.full).then (keys) ->
|
132
|
+
key.children = keys
|
133
|
+
|
134
|
+
key.open = true
|
135
|
+
|
136
|
+
$scope.keyClose = (key) ->
|
137
|
+
key.open = false
|
138
|
+
|
100
139
|
|
101
140
|
$scope.setPerPage = (i) ->
|
102
141
|
db.add("per_page", i)
|
@@ -12,12 +12,15 @@ html ng-app="browser"
|
|
12
12
|
link rel="stylesheet" href="/css/app.css"
|
13
13
|
|
14
14
|
script type="text/ng-template" id="nav-tree-item.html"
|
15
|
-
span ng-show="key.
|
16
|
-
button.btn.tree-toggle ng-hide="key.open" ng-click="key
|
17
|
-
button.btn.tree-toggle ng-show="key.open" ng-click="key
|
18
|
-
span ng-show="key.
|
15
|
+
span ng-show="key.count > 1"
|
16
|
+
button.btn.tree-toggle ng-hide="key.open" ng-click="keyOpen(key)" +
|
17
|
+
button.btn.tree-toggle ng-show="key.open" ng-click="keyClose(key)" -
|
18
|
+
span ng-show="key.count == 1" -
|
19
19
|
|
20
|
-
a href="#" ng-click="show(key)"
|
20
|
+
a href="#" ng-click="show(key)"
|
21
|
+
' {{ key.name }}
|
22
|
+
small ng-show="key.count > 1"
|
23
|
+
| ({{ key.count }})
|
21
24
|
|
22
25
|
ul.tree ng-show="key.open"
|
23
26
|
li ng-repeat="key in key.children" ng-include="'nav-tree-item.html'"
|
@@ -25,6 +28,7 @@ html ng-app="browser"
|
|
25
28
|
|
26
29
|
|
27
30
|
body ng-controller="BrowserCtrl"
|
31
|
+
#http-loader Loading...
|
28
32
|
div modal="config.show" close="config.close()" options="config.modalOpts"
|
29
33
|
.form-horizontal
|
30
34
|
.modal-header
|
@@ -48,6 +52,8 @@ html ng-app="browser"
|
|
48
52
|
select id="config-database" ng-model="config.database" ng-options="i for i in config.databases"
|
49
53
|
|
50
54
|
.modal-footer
|
55
|
+
span.alert.alert-error.pull-left ng-show="config.error"
|
56
|
+
' {{ config.error }}
|
51
57
|
button.btn.btn-success type="submit" ng-click="config.save()" Save
|
52
58
|
|
53
59
|
.navbar.navbar-inverse.navbar-fixed-top
|
@@ -63,7 +69,10 @@ html ng-app="browser"
|
|
63
69
|
button.btn.btn-success ng-click="config.open()" Configure
|
64
70
|
p.navbar-text.pull-right.connection-info
|
65
71
|
' Connected to
|
66
|
-
strong
|
72
|
+
strong
|
73
|
+
' {{ config.connection }}
|
74
|
+
small
|
75
|
+
' ({{ config.database }})
|
67
76
|
|
68
77
|
|
69
78
|
.container-fluid
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-browser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tymon Tobolski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|