Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'luwak'

  • Loading branch information...
commit 35148bb25450fb0e2b29ebe4cadc8d0357dc9776 2 parents 34d8cd4 + 2d66cd6
@adamhunter adamhunter authored
View
3  app/go
@@ -25,6 +25,9 @@
<a href="#/stats">Stats</a>
</li>
<li class="perm">
+ <a href="#/luwak">Luwak</a>
+ </li>
+ <li class="perm">
<a href="#/buckets">Buckets</a>
</li>
</ul>
View
18 app/luwak-row.html.template
@@ -0,0 +1,18 @@
+<tr>
+ <th>
+ <em><%= Rekon.luwakUrl() %>/</em><%= file %>
+ </th>
+ <td>
+ <a href="<%= Rekon.luwakUrl() %>/<%= file %>" class="riak icon" target="_blank">Riak</a>
+ </td>
+ <!--<td>
+ <a href="#/luwak/<%= file %>" class="view icon" onclick="alert('This feature is pending');return false;">View</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>
+
View
27 app/luwak.html.template
@@ -0,0 +1,27 @@
+<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>Riak</th>
+ <!--<th>View</th>
+ <th>Edit</th>
+ <th>Delete</th>-->
+ </tr>
+ </thead>
+ <tbody>
+ <tr class="pending">
+ <td colspan='2'>
+ <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>
+
+
View
36 app/rekon.js
@@ -222,13 +222,47 @@ rekonApp = Sammy('#container', function(){
});
});
+ this.get('#/luwak', function(context){
+ luwak = new Luwak(Rekon.client);
+
+ // TODO: check Luwak is enabled
+
+ header('Luwak', document.location.origin + "/luwak");
+ context.render('luwak.html.template').appendTo('#main').then(function(){
+
+ luwak.files(function(files) {
+ if (files === null) {
+ console.log('not working');
+ $('#files .pending td').html(
+ '<p><b>Luwak is not enabled.</b> Please add <code>{luwak, [{enabled, true}]}</code> to your app.config.</p>');
+ }
+ else 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{
+ $('#files .pending td').html('<p>You have not added any files to luwak.</p>');
+ }
+ });
+ });
+ });
+
});
Rekon = {
client : new RiakClient(),
+ locationUrl : function() {
+ return document.location.protocol + '//' + document.location.host;
+ },
+
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) {
View
33 app/riak.js
@@ -883,8 +883,9 @@ RiakBucket.prototype._handleGetObject = function(key, req, callback, createEmpty
* Entry point for interacting with Riak
* @param baseUrl - URL for 'raw' interface (optional, default: '/riak')
* @param mapredUrl - URL for map/reduce jobs (optional, default: '/mapred')
+ * @param luwakUrl - URL for luwak endpoint (optional, default: '/luwak')
*/
-function RiakClient(baseUrl, mapredUrl) {
+function RiakClient(baseUrl, mapredUrl, luwakUrl) {
if (baseUrl === undefined) {
baseUrl = '/riak/';
}
@@ -898,12 +899,20 @@ function RiakClient(baseUrl, mapredUrl) {
}
this.baseUrl = baseUrl;
this.clientId = "js_" + RiakUtil.base64Encode(Math.floor(Math.random() * 4294967296));
+
if (mapredUrl !== undefined) {
this.mapredUrl = mapredUrl;
}
else {
this.mapredUrl = '/mapred';
}
+
+ if (luwakUrl !== undefined) {
+ this.luwakUrl = luwakUrl;
+ }
+ else {
+ this.luwakUrl = '/luwak';
+ }
}
/**
@@ -994,3 +1003,25 @@ RiakClient.prototype._buildPath = function(method, bucket, key) {
};
/** End RiakClient internal Functions **/
+
+
+function Luwak(client) {
+ if (client === undefined) {
+ throw("Cannot construct Luwak without client reference");
+ }
+
+ 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").success(
+ function(data){callback(data.keys);}
+ ).error(function(){ callback(null);});
+};
Please sign in to comment.
Something went wrong with that request. Please try again.