Skip to content

Commit

Permalink
changed the list view
Browse files Browse the repository at this point in the history
  • Loading branch information
Soo Hwan Park committed Nov 27, 2012
1 parent e916502 commit 0cb5b50
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 15 deletions.
33 changes: 31 additions & 2 deletions lib/lib/main_controller.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions public/app/database_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ function DatabaseCtrl($scope, $http, $rootScope) {
else if (type === "list") {
$http.get("/redis/list/" + key).success(function(data){
$scope.show_key = key;
$scope.show_list_result = _.map(data, function(ele, i) {
return {key: i, value: json2string(ele)};
});
$scope.show_list_result = data;
// $scope.show_list_result = _.map(data, function(ele, i) {
// return {key: i, value: json2string(ele)};
// });
jQuery('#showListModal').modal();
});
}
Expand Down Expand Up @@ -173,6 +174,15 @@ function DatabaseCtrl($scope, $http, $rootScope) {
}
};

$scope.list_value = "";

$scope.showListValue = function(key, index) {
$http.get("/redis/list/" + key + "/" + index).success(function(data){
$scope.list_value = json2string(data);
console.dir($scope.list_value);
});
};

$scope.filterByType = function(keys, type) {
return _.filter(keys, function(key){
return key.type === type;
Expand Down
16 changes: 8 additions & 8 deletions public/template/database.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ <h3>{{show_key}} </h3>
</div>
<div class="modal-body">
<h5>Length: {{show_list_result.length}}</5>
<table class="table table-striped table-hover">
<thead><tr><th>Key</th><th>Value</th></tr></thead>
<tbody>
<tr ng-repeat="val in show_list_result">
<td>{{val.key}}</td><td><pre class="prettyprint">{{val.value}}</pre></td>
</tr>
</tbody>
</table>
<div>
<select ng-model="list_index" class="ng-pristine ng-valid">
<option ng-repeat="val in show_list_result" value="{{val}}">{{val}}</option>
</select>
<a href="" class="btn btn-primary" ng-click="showListValue(show_key, list_index)">Show Value</a>
</div>
<pre class="prettyprint">{{list_value}}</pre>

</div>
<div class="modal-footer">
<a href="#" class="btn close" data-dismiss="modal" aria-hidden="true">Close</a>
Expand Down
21 changes: 19 additions & 2 deletions src/lib/main_controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MainController
, {path: "/redis/set", http_method: "post", method: "redis_set" }
, {path: "/redis/command", http_method: "post", method: "redis_command" }
, {path: "/redis/list/:key", http_method: "get", method: "redis_get_list" }
, {path: "/redis/list/:key/:index", http_method: "get", method: "redis_get_list_index" }
, {path: "/redis/hash/:key", http_method: "get", method: "redis_get_hash" }
, {path: "/redis/set/:key", http_method: "get", method: "redis_get_set" }
, {path: "/redis/zset/:key", http_method: "get", method: "redis_get_zset" }
Expand Down Expand Up @@ -57,11 +58,27 @@ class MainController

redis_get_list: (req, res) ->
key = req.params.key
@redis.client.lrange [key, 0, -1], (err, data) ->
@redis.client.llen [key], (err, data) ->
if err
res.json []
else
res.json data
len = parseInt(data)
res.json [0...len]

redis_get_list_index: (req, res) ->
key = req.params.key
index = req.params.index
@redis.client.lindex [key, index], (err, data) ->
if err
res.json err
else
try
json_data = JSON.parse(data)
res.json json_data
catch error
res.send data



redis_get_set: (req, res) ->
key = req.params.key
Expand Down

0 comments on commit 0cb5b50

Please sign in to comment.