Skip to content

Commit

Permalink
viewing luwak files list works!
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhunter committed May 18, 2011
1 parent 2dc7179 commit 27f6330
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 4 deletions.
18 changes: 18 additions & 0 deletions app/luwak-row.html.template
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,18 @@
<tr>
<th>
<em><%= Rekon.luwakUrl() %>/</em><%= file %>
</th>
<td>
<a href="#/luwak/<%= file %>" class="view icon" onclick="alert('This feature is pending');return false;">View</a>
</td>
<td>
<a href="<%= Rekon.luwakUrl() %>/<%= file %>" class="riak icon" target="_blank">Riak</a>
</td>
<td>
<a href="#" class="edit icon" onclick="alert('This feature is pending');return false;">Edit</a>
</td>
<td>
<a href="#" class="delete icon" onclick="alert('This feature is pending');return false;">Delete</a>
</td>
</tr>

28 changes: 27 additions & 1 deletion app/luwak.html.template
Original file line number Original file line Diff line number Diff line change
@@ -1 +1,27 @@
Luwak! <div id="luwak" class="screen">
<table id="files">
<thead>
<tr>
<th>
<input id="row_search" type="text" />
<em class="hint">Type to filter rows</em>
</th>
<th>View</th>
<th>Riak</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<tr class="pending">
<td colspan='5'>
<p class="spinner">
<img src="spinner.gif" alt="Loading..." />
Loading Files... <em class="hint">(This may take a minute if you have a lot)</em>
</p>
</tr>
</tbody>
</table>
</div>


25 changes: 24 additions & 1 deletion app/rekon.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -223,17 +223,40 @@ rekonApp = Sammy('#container', function(){
}); });


this.get('#/luwak', function(context){ this.get('#/luwak', function(context){
luwak = new Luwak(Rekon.client);

// TODO: check Luwak is enabled

header('Luwak', document.location.origin + "/luwak"); header('Luwak', document.location.origin + "/luwak");
context.render('luwak.html.template').appendTo('#main'); context.render('luwak.html.template').appendTo('#main');

luwak.files(function(files) {
if (files.length > 0) {
fileRows = files.map(function(file){ return {file:file};});
context.renderEach('luwak-row.html.template', fileRows).replace('#files tbody').then(
function() { searchable('#luwak tbody'); }
);
} else{
alert("Luwak is empty!");
}
});
}); });


}); });


Rekon = { Rekon = {
client : new RiakClient(), client : new RiakClient(),


locationUrl : function() {
return document.location.protocol + '//' + document.location.host;
},

baseUrl : function() { baseUrl : function() {
return document.location.protocol + '//' + document.location.host + this.client.baseUrl; return this.locationUrl() + this.client.baseUrl;
},

luwakUrl : function() {
return this.locationUrl() + this.client.luwakUrl;
}, },


riakUrl : function(append) { riakUrl : function(append) {
Expand Down
14 changes: 12 additions & 2 deletions app/riak.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1013,5 +1013,15 @@ function Luwak(client) {
this.client = client; this.client = client;
} }



/**

* Gets the file names for luwak, currently only uses keys=true
* and doesn't support streaming keys.
* @param callback function
* callback - function(keys)
* @param files Array
*/
Luwak.prototype.files = function(callback) {
jQuery.getJSON(this.client.luwakUrl + "?keys=true", function(data){
callback(data.keys);
});
};

0 comments on commit 27f6330

Please sign in to comment.