1
0
Fork 0

aql tabular output

This commit is contained in:
hkernbach 2016-07-20 10:48:36 +02:00
parent 8d1e818d79
commit 6e62c003b5
2 changed files with 120 additions and 59 deletions

View File

@ -1475,13 +1475,19 @@
var result = self.analyseQuery(data.result);
console.log('Using ' + result.defaultType + ' as data format.');
if (result.defaultType === 'table') {
$('#outputEditorWrapper' + counter).append('<div id="outputTable' + counter + '"></div>');
$('#outputEditorWrapper' + counter + ' .arangoToolbarTop').after('<div id="outputTable' + counter + '"></div>');
$('#outputTable' + counter).show();
self.renderOutputTable(result, counter);
// apply max height for table output dynamically
var maxHeight = $('.centralRow').height() - 250;
$('.outputEditorWrapper .tableWrapper').css('max-height', maxHeight);
$('#outputEditor' + counter).hide();
} else if (result.defaultType === 'graph') {
$('#outputEditorWrapper' + counter).append('<div id="outputGraph' + counter + '"></div>');
$('#outputEditorWrapper' + counter + ' .arangoToolbarTop').after('<div id="outputGraph' + counter + '"></div>');
$('#outputGraph' + counter).show();
self.renderOutputGraph(result, data);
$('#outputEditor' + counter).hide();
}
@ -1618,6 +1624,7 @@
// check if result could be displayed as graph
// case a) result has keys named vertices and edges
if (result[0]) {
if (result[0].vertices && result[0].edges) {
var hitsa = 0;
var totala = 0;
@ -1659,13 +1666,20 @@
// then display as graph
}
}
}
// check if result could be displayed as table
if (!found) {
var maxAttributeCount = 0;
var check = true;
var length;
var attributes = {};
if (result.length <= 1) {
check = false;
}
if (check) {
_.each(result, function (obj) {
length = _.keys(obj).length;
@ -1683,17 +1697,19 @@
});
var rate;
var check = true;
console.log(attributes);
_.each(attributes, function (val, key) {
rate = (val / result.length) * 100;
console.log(rate);
if (check !== false) {
if (rate <= 95) {
check = false;
}
}
});
}
if (check) {
found = true;
@ -1784,6 +1800,42 @@
});
},
renderOutputTable: function (data, counter) {
var tableDescription = {
id: 'outputTableData' + counter,
titles: [],
rows: []
};
var first = true;
var part = [];
// self.tableDescription.rows.push(;
_.each(data.original, function (obj) {
if (first === true) {
tableDescription.titles = Object.keys(obj);
first = false;
}
_.each(obj, function (val) {
if (typeof val === 'object') {
val = JSON.stringify(val);
}
part.push(val);
});
tableDescription.rows.push(part);
part = [];
});
console.log(counter);
$('#outputTable' + counter).append(this.table.render({content: tableDescription}));
console.log(tableDescription.titles);
console.log(tableDescription.rows);
},
renderOutputGraph: function () {
},
getAQL: function (originCallback) {
var self = this;

View File

@ -328,7 +328,6 @@
.ui-resizable-e {
cursor: ew-resize;
}
}
.queryContent {
@ -356,6 +355,16 @@
padding-top: 20px;
width: 100%;
.tableWrapper {
max-width: 100%;
overflow-x: scroll;
.arango-table {
border-left: 1px solid $c-content-border;
border-right: 1px solid $c-content-border;
}
}
.switchAce {
background-color: rgba(0, 0, 0, .6);
border-radius: 3px;