Skip to content

Commit

Permalink
Merge pull request apache#13 from netops/dt_scroll
Browse files Browse the repository at this point in the history
Datatables scrolling
  • Loading branch information
Varun Varma authored and GitHub Enterprise committed Aug 18, 2017
2 parents 551c6ba + 6c2d2be commit b9cfdc1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
7 changes: 6 additions & 1 deletion superset/assets/javascripts/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ export function toggleCheckbox(apiUrlPrefix, selector) {
*/
export const fixDataTableBodyHeight = function ($tableDom, height) {
const headHeight = $tableDom.find('.dataTables_scrollHead').height();
$tableDom.find('.dataTables_scrollBody').css('max-height', height - headHeight);
const headerFooterHeight = $tableDom.find('.table-header').height() +
$tableDom.find('.table-footer').height();
$tableDom.find('.dataTables_scrollBody').css('max-height', height - (headerFooterHeight + headHeight));
$tableDom.find('.table-body').css('max-height', height - headerFooterHeight);
$tableDom.find('.dataTables_scroll').css('max-height', height - headerFooterHeight);
$tableDom.find('.table-data').css('max-height', height - headerFooterHeight);
};

export function d3format(format, number) {
Expand Down
5 changes: 5 additions & 0 deletions superset/assets/stylesheets/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,8 @@ div.widget .chart-controls {
.slice_container .alert {
margin: 10px;
}

.row {
margin-left: 0px;
margin-right: 0px;
}
5 changes: 5 additions & 0 deletions superset/assets/visualizations/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ table.table thead th.sorting:after, table.table thead th.sorting_asc:after, tabl
.dataTables_filter {
margin: 4px;
}

.dataTables_scroll {
height: 100%;
}

10 changes: 9 additions & 1 deletion superset/assets/visualizations/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function tableVis(slice, payload) {
const table = div.append('table')
.classed(
'dataframe dataframe table table-striped table-bordered ' +
'table-condensed table-hover dataTable no-footer', true)
'table-condensed table-hover dataTable', true)
.attr('width', '100%');

const cols = data.columns.map(c => slice.datasource.verbose_map[c] || c);
Expand Down Expand Up @@ -77,9 +77,13 @@ function tableVis(slice, payload) {
data: data.records,
columns: columns,
paging: paging,
scrollY: true,
deferRender: true,
pageLength: pageLength,
searching: fd.include_search,
dom: '<"row table-header"<"col-sm-6"lB><"col-sm-6"f>>' +
'<"row table-body"<"col-sm-12 table-data"tr>>' +
'<"row table-footer"<"col-sm-5"i><"col-sm-7"p>>',
buttons: buttons,
});
} else {
Expand Down Expand Up @@ -151,12 +155,16 @@ function tableVis(slice, payload) {

datatable = container.find('.dataTable').DataTable({
paging: paging,
scrollY: true,
deferRender: true,
pageLength: pageLength,
aaSorting: [],
searching: fd.include_search,
bInfo: false,
buttons: buttons,
dom: '<"row table-header"<"col-sm-6"lB><"col-sm-6"f>>' +
'<"row table-body"<"col-sm-12 table-data"tr>>' +
'<"row table-footer"<"col-sm-5"i><"col-sm-7"p>>',
});
}
datatable.buttons().container().appendTo( '.dataTables_wrapper .col-sm-6:eq(0)' );
Expand Down
4 changes: 1 addition & 3 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2199,10 +2199,8 @@ def show_traceback(self):
@expose("/welcome")
def welcome(self):
"""Personalized welcome page"""
print (appbuilder.sm.auth_view)
return appbuilder.sm.auth_view.login()
if not g.user or not g.user.get_id():
return redirect(appbuilder.get_url_for_login)
return appbuilder.sm.auth_view.login()
return self.render_template('superset/welcome.html', utils=utils)

@has_access
Expand Down

0 comments on commit b9cfdc1

Please sign in to comment.