-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from abhardwaj/landing_page
Update the landing page and console
- Loading branch information
Showing
7 changed files
with
232 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
django==1.5 | ||
south | ||
psycopg2 | ||
numpy | ||
thrift | ||
sqlalchemy | ||
scorpionsql | ||
python-dateutil | ||
pycrypto | ||
nltk | ||
textblob | ||
sqlparse | ||
Django==1.5 | ||
nltk==3.0.2 | ||
numpy==1.9.1 | ||
psycopg2==2.5.4 | ||
pycrypto==2.6.1 | ||
pyparsing==2.0.3 | ||
python-dateutil==2.3 | ||
scorpionsql==0.0.4 | ||
six==1.8.0 | ||
South==1.0.1 | ||
SQLAlchemy==0.9.8 | ||
sqlparse==0.1.15 | ||
textblob==0.9.0 | ||
thrift==0.9.2 | ||
viz==0.0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,157 +1,172 @@ | ||
{% extends "layout.html" %} | ||
{% block content %} | ||
<div class="container"> | ||
<div id="dh-console-container"> | ||
<div id="dh-console"> | ||
<pre class="ascii-art-console"> | ||
{% extends "layout.html" %} {% block content %} | ||
<div class="container-fluid"> | ||
<div id="dh-console-container"> | ||
<div id="dh-console"> | ||
<pre class="ascii-art-console"> | ||
_____ _ _ _ _ | ||
| __ \ | | | | | | | | | ||
| | | | __ _| |_ __ _| |__| |_ _| |__ | ||
| | | |/ _` | __/ _` | __ | | | | '_ \ | ||
| |__| | (_| | || (_| | | | | |_| | |_) | | ||
|_____/ \__,_|\__\__,_|_| |_|\__,_|_.__/ | ||
</pre> | ||
<br /><br /> | ||
<div class="punch">DataHub is a (GitHub like) hosted platform for organizing, managing, sharing, collaborating, and making sense of data. | ||
</pre> | ||
<br /> | ||
<br /> | ||
<div class="punch">DataHub is a (GitHub-Like) Data Ecosystem for Individuals, Teams and People. | ||
</div> | ||
<br /> | ||
</div> | ||
</div> | ||
</div> | ||
<br /> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
|
||
if (typeof String.prototype.startsWith != 'function') { | ||
// see below for better implementation! | ||
String.prototype.startsWith = function (str){ | ||
return this.indexOf(str) == 0; | ||
}; | ||
// see below for better implementation! | ||
String.prototype.startsWith = function(str) { | ||
return this.indexOf(str) == 0; | ||
}; | ||
} | ||
|
||
function print_result (res, term) { | ||
if (res.num_tuples >= 0) { | ||
var col_names = [] | ||
var separator = [] | ||
function print_result(res, term) { | ||
if (res.num_tuples >= 0) { | ||
var col_names = [] | ||
var separator = [] | ||
|
||
$.each(res.field_names, function(field_idx, field) { | ||
col_names.push(field) | ||
separator.push('------------') | ||
}); | ||
$.each(res.field_names, function(field_idx, field) { | ||
col_names.push(field) | ||
separator.push('------------') | ||
}); | ||
|
||
term.echo(col_names.join('\t')) | ||
term.echo(separator.join('')) | ||
term.echo(col_names.join('\t')) | ||
term.echo(separator.join('')) | ||
|
||
$.each(res.tuples, function(tuple_idx, tuple) { | ||
values = [] | ||
$.each(tuple.cells, function(cell_idx, cell) { | ||
values.push(cell) | ||
}); | ||
term.echo(values.join('\t')) | ||
}); | ||
$.each(res.tuples, function(tuple_idx, tuple) { | ||
values = [] | ||
$.each(tuple.cells, function(cell_idx, cell) { | ||
values.push(cell) | ||
}); | ||
term.echo(values.join('\t')) | ||
}); | ||
|
||
term.echo('') | ||
term.echo(res.num_tuples + ' rows returned.') | ||
if (res.num_more_tuples && res.num_more_tuples > 0) { | ||
term.echo(res.num_more_tuples + ' more rows available. Type \'more\' to see more rows.') | ||
} | ||
} else { | ||
if (res.status) { | ||
term.echo('success') | ||
term.echo('') | ||
term.echo(res.num_tuples + ' rows returned.') | ||
if (res.num_more_tuples && res.num_more_tuples > 0) { | ||
term.echo(res.num_more_tuples + ' more rows available. Type \'more\' to see more rows.') | ||
} | ||
} else { | ||
term.echo('error') | ||
if (res.status) { | ||
term.echo('success') | ||
} else { | ||
term.echo('error') | ||
} | ||
} | ||
} | ||
} | ||
|
||
function set_console_height() { | ||
var h = window.innerHeight; | ||
$("#dh-console").height(h * .8); | ||
return; | ||
} | ||
|
||
$(document).ready(function($) { | ||
var kCmdList = [ | ||
'** Any SQL Query **', | ||
'connect <repo-base> \t -- connect to a repo-base', | ||
'mkrepo <repo-name> \t -- to create a new repository', | ||
'rm <repo-name [-f]> \t\t -- to remove a repository', | ||
'ls \t\t\t\t\t -- to list repositories', | ||
'ls <repo-name> \t\t -- to list tables in a repository', | ||
'schema <table-name> \t\t -- to print schema info of a table' | ||
] | ||
|
||
set_console_height(); | ||
|
||
var login = '{{login}}' | ||
var transport = new Thrift.Transport(window.location.protocol + '//' + window.location.host + '/service/json'); | ||
var protocol = new Thrift.Protocol(transport); | ||
var client = new DataHubClient(protocol); | ||
var con = new Connection({'user': login, 'repo_base': login}); | ||
var kCmdList = [ | ||
'** Any SQL Query **', | ||
'connect <repo-base> \t -- connect to a repo-base', | ||
'mkrepo <repo-name> \t -- to create a new repository', | ||
'rm <repo-name [-f]> \t\t -- to remove a repository', | ||
'ls \t\t\t\t\t -- to list repositories', | ||
'ls <repo-name> \t\t -- to list tables in a repository', | ||
'schema <table-name> \t\t -- to print schema info of a table' | ||
] | ||
|
||
$('#dh-console').terminal( | ||
function (command, term) { | ||
try{ | ||
var cmd = $.trim(command.toLowerCase()) | ||
var login = '{{login}}' | ||
var transport = new Thrift.Transport(window.location.protocol + '//' + window.location.host + '/service/json'); | ||
var protocol = new Thrift.Protocol(transport); | ||
var client = new DataHubClient(protocol); | ||
var con = new Connection({ | ||
'user': login, | ||
'repo_base': login | ||
}); | ||
|
||
if (cmd == ''){ | ||
return | ||
} | ||
if (cmd.startsWith('connect')) { | ||
var args = cmd.split(' ', 2) | ||
if (args.length > 1) { | ||
con.repo_base = args[1] | ||
term.echo("Connected to: " + con.repo_base) | ||
} else { | ||
term.error ('HELP: connect <repo-base>') | ||
} | ||
} else if (cmd.startsWith('mkrepo')) { | ||
var args = cmd.split(' ', 2) | ||
if (args.length > 1) { | ||
res = client.create_repo(con, args[1]) | ||
print_result(res, term) | ||
} else { | ||
term.error ('HELP: mkrepo <repo-name>') | ||
} | ||
} else if (cmd.startsWith('rm')) { | ||
var args = cmd.split(' ', 3) | ||
if (args.length > 1) { | ||
force = false | ||
if (args.length == 3 && args[2] == '-f') { | ||
force = true | ||
$('#dh-console').terminal( | ||
function(command, term) { | ||
try { | ||
var cmd = $.trim(command.toLowerCase()) | ||
|
||
if (cmd == '') { | ||
return | ||
} | ||
if (cmd.startsWith('connect')) { | ||
var args = cmd.split(' ', 2) | ||
if (args.length > 1) { | ||
|
||
// trim blank spaces and semicolons from usernames | ||
var username = args[1].trim(); | ||
if (username.substr(username.length - 1) === ";") { | ||
username = username.substring(0, username.length - 1); | ||
} | ||
|
||
con.repo_base = username; | ||
term.echo("Connected to: " + con.repo_base) | ||
} else { | ||
term.error('HELP: connect <repo-base>') | ||
} | ||
} else if (cmd.startsWith('mkrepo')) { | ||
var args = cmd.split(' ', 2) | ||
if (args.length > 1) { | ||
res = client.create_repo(con, args[1]) | ||
print_result(res, term) | ||
} else { | ||
term.error('HELP: mkrepo <repo-name>') | ||
} | ||
} else if (cmd.startsWith('rm')) { | ||
var args = cmd.split(' ', 3) | ||
if (args.length > 1) { | ||
force = false | ||
if (args.length == 3 && args[2] == '-f') { | ||
force = true | ||
} | ||
res = client.delete_repo(con, args[1], force) | ||
print_result(res, term) | ||
} else { | ||
term.error('HELP: rm <repo-name> [-f]') | ||
} | ||
} else if (cmd.startsWith('desc')) { | ||
var args = cmd.split(' ', 2) | ||
if (args.length > 1) { | ||
res = client.get_schema(con, args[1]) | ||
print_result(res, term) | ||
} else { | ||
term.error('HELP: desc <table-name>') | ||
} | ||
} else if (cmd.startsWith('ls')) { | ||
var args = cmd.split(' ', 2) | ||
res = null | ||
if (args.length > 1) { | ||
res = client.list_tables(con, args[1]) | ||
} else { | ||
res = client.list_repos(con) | ||
} | ||
print_result(res, term) | ||
} else if (cmd.startsWith('help')) { | ||
for (var cmd in kCmdList) { | ||
term.echo(kCmdList[cmd]) | ||
} | ||
} else { | ||
res = client.execute_sql(con, cmd); | ||
print_result(res, term) | ||
} | ||
} catch (error) { | ||
term.error(error.message); | ||
} | ||
res = client.delete_repo(con, args[1], force) | ||
print_result(res, term) | ||
} else { | ||
term.error ('HELP: rm <repo-name> [-f]') | ||
} | ||
} else if (cmd.startsWith('desc')) { | ||
var args = cmd.split(' ', 2) | ||
if (args.length > 1) { | ||
res = client.get_schema(con, args[1]) | ||
print_result(res, term) | ||
} else { | ||
term.error ('HELP: desc <table-name>') | ||
} | ||
} else if (cmd.startsWith('ls')) { | ||
var args = cmd.split(' ', 2) | ||
res = null | ||
if (args.length > 1) { | ||
res = client.list_tables(con, args[1]) | ||
} else { | ||
res = client.list_repos(con) | ||
} | ||
print_result(res, term) | ||
} else if (cmd.startsWith('help')) { | ||
for (var cmd in kCmdList) { | ||
term.echo(kCmdList[cmd]) | ||
} | ||
} else { | ||
res = client.execute_sql(con, cmd); | ||
print_result(res, term) | ||
}, { | ||
prompt: '{{login}}@' + con.repo_base + '> ', | ||
greetings: 'Welcome to DataHub!\nConnected to: ' + con.repo_base | ||
} | ||
} catch(error){ | ||
term.error(error.message); | ||
} | ||
}, { | ||
prompt: '{{login}}@' + con.repo_base + '> ', | ||
greetings: 'Welcome to DataHub!\nConnected to: ' + con.repo_base} | ||
); | ||
|
||
}); | ||
); | ||
|
||
}); | ||
</script> | ||
{% endblock %} | ||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.