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>
<!-- Submit -->
<div class="row">
<div class="row" style="margin: 10px 0px;">
<div class="col-sm-12">
<button type="button" class="btn btn-primary" id="submitBtn">Submit Query</button>
</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 class="col-lg-6">
<!-- Result -->
<div class="result-view">
<!-- View: Result Table -->
<table id="resultTable" class="table table-bordered table-striped table-hover"></table>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
$('#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);
function createElement(tag, value) {
return $('<' + tag + '>' + value + '</' + tag + '>');
};
function updateResultTable(result) {
// Present result json in result-view
var table = $('#resultTable');
table.html('');
@ -63,13 +78,41 @@ $(function() {
});
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>');
$.each(row, function(j, val) {
tr.append($('<td>' + val + '</td>'));
});
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);
});
})
});