added performance data to frontend. cutting results display at 100 rows

This commit is contained in:
Pedro 2014-11-05 12:20:29 +01:00
parent 19994085da
commit 107dffc0c5
1 changed files with 65 additions and 22 deletions

View File

@ -29,30 +29,45 @@
</div> </div>
<!-- Submit --> <!-- Submit -->
<div class="row"> <div class="row" style="margin: 10px 0px;">
<div class="col-sm-12"> <div class="col-sm-12">
<button type="button" class="btn btn-primary" id="submitBtn">Submit Query</button> <button type="button" class="btn btn-primary" id="submitBtn">Submit Query</button>
</div> </div>
</div> </div>
<div class="row">
<div class="col-sm-12">
<!-- View: Performance Data -->
<table id="performanceDataTable" class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Duration</th>
<th>Start Time</th>
<th>End Time</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
<!-- Result --> <!-- View: Result Table -->
<div class="result-view">
<table id="resultTable" class="table table-bordered table-striped table-hover"></table> <table id="resultTable" class="table table-bordered table-striped table-hover"></table>
</div> </div>
</div> </div>
</div> </div>
</div>
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
$('#submitBtn').click(function() { function createElement(tag, value) {
var host = $('#hostInput').val(); return $('<' + tag + '>' + value + '</' + tag + '>');
var port = $('#portInput').val(); };
var query = $('#queryInput').val();
var hyrise = new HyriseSqlConnector(host, port); function updateResultTable(result) {
hyrise.executeQuery(query, function(result) {
console.log("Query result: ", result);
// Present result json in result-view // Present result json in result-view
var table = $('#resultTable'); var table = $('#resultTable');
table.html(''); table.html('');
@ -63,13 +78,41 @@ $(function() {
}); });
table.append(th); table.append(th);
$.each(result.rows, function(i, row) { // Limit the rows to be displayed to 100
for (var i = 0; i < 100 && i < result.real_size; ++i) {
var row = result.rows[i];
var tr = $('<tr>'); var tr = $('<tr>');
$.each(row, function(j, val) { $.each(row, function(j, val) {
tr.append($('<td>' + val + '</td>')); tr.append($('<td>' + val + '</td>'));
}); });
table.append(tr); table.append(tr);
}
};
function updatePerformanceData(result) {
var tbody = $('#performanceDataTable tbody');
tbody.html('');
$.each(result.performanceData, function(i, data) {
var tr = $('<tr>');
tr.append(createElement('td', data.id))
tr.append(createElement('td', data.name))
tr.append(createElement('td', data.duration))
tr.append(createElement('td', data.startTime))
tr.append(createElement('td', data.endTime))
tbody.append(tr);
}); });
};
$('#submitBtn').click(function() {
var host = $('#hostInput').val();
var port = $('#portInput').val();
var query = $('#queryInput').val();
var hyrise = new HyriseSqlConnector(host, port);
hyrise.executeQuery(query, function(result) {
console.log("Query result: ", result);
updateResultTable(result);
updatePerformanceData(result);
}); });
}) })
}); });