Simplifying the viz interface (#2005)

This commit is contained in:
Maxime Beauchemin
2017-01-24 14:03:17 -08:00
committed by GitHub
parent 1c338ba742
commit e46ba2b4a4
26 changed files with 1899 additions and 2192 deletions

View File

@@ -8,34 +8,22 @@ import 'datatables.net';
import dt from 'datatables.net-bs';
dt(window, $);
module.exports = function (slice) {
module.exports = function (slice, payload) {
const container = slice.container;
function refresh() {
$.getJSON(slice.jsonEndpoint(), function (json) {
const fd = json.form_data;
container.html(json.data);
if (fd.groupby.length === 1) {
const height = container.height();
const table = container.find('table').DataTable({
paging: false,
searching: false,
bInfo: false,
scrollY: height + 'px',
scrollCollapse: true,
scrollX: true,
});
table.column('-1').order('desc').draw();
fixDataTableBodyHeight(
container.find('.dataTables_wrapper'), height);
}
slice.done(json);
}).fail(function (xhr) {
slice.error(xhr.responseText, xhr);
const fd = payload.form_data;
container.html(payload.data);
if (fd.groupby.length === 1) {
const height = container.height();
const table = container.find('table').DataTable({
paging: false,
searching: false,
bInfo: false,
scrollY: height + 'px',
scrollCollapse: true,
scrollX: true,
});
table.column('-1').order('desc').draw();
fixDataTableBodyHeight(
container.find('.dataTables_wrapper'), height);
}
return {
render: refresh,
resize: refresh,
};
};