var date_format = 'YYYY-MM-DD'; var time_format = 'hh:mm a'; $.ajax({ url: 'get_date_formats', type: 'GET', success: function (data) { date_format = data.date_format; time_format = data.time_format; } }); export_table_options = { "destroy": true, "language": { "search": "Search: ", "lengthMenu": "Show _MENU_ entries per page", "info": "Showing _START_ to _END_ of _TOTAL_ library items", "infoEmpty": "Showing 0 to 0 of 0 entries", "infoFiltered": "", "emptyTable": "No data in table", "loadingRecords": ' Loading items...' }, "pagingType": "full_numbers", "stateSave": true, "stateDuration": 0, "processing": false, "serverSide": true, "pageLength": 25, "order": [0, 'desc'], "autoWidth": false, "scrollX": true, "columnDefs": [ { "targets": [0], "data": "timestamp", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '') { $(td).html(moment(cellData, "X").format(date_format + ' ' + time_format)); } }, "width": "10%", "className": "no-wrap" }, { "targets": [1], "data": "media_type_title", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '') { $(td).html(cellData); } }, "width": "8%", "className": "no-wrap" }, { "targets": [2], "data": "rating_key", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '') { $(td).html('' + cellData + ''); } }, "width": "6%", "className": "no-wrap" }, { "targets": [3], "data": "filename", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '') { $(td).html(cellData); } }, "width": "50%", "className": "no-wrap" }, { "targets": [4], "data": "file_format", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '') { $(td).html(cellData); } }, "width": "6%", "className": "no-wrap" }, { "targets": [5], "data": "file_size", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '' && cellData !== null) { $(td).html(humanFileSize(cellData)); } }, "width": "6%", "className": "no-wrap" }, { "targets": [6], "data": "complete", "createdCell": function (td, cellData, rowData, row, col) { if (cellData === 1 && rowData['exists']) { $(td).html(''); } else if (cellData === 0) { $(td).html(' Processing'); } else if (cellData === -1) { $(td).html(' Failed'); } else { $(td).html(' Not Found'); } }, "width": "7%", "className": "export_download" }, { "targets": [7], "data": null, "createdCell": function (td, cellData, rowData, row, col) { if (rowData['complete'] !== 0) { $(td).html(''); } else { $(td).html(' Delete'); } }, "width": "7%", "className": "export_delete" } ], "drawCallback": function (settings) { // Jump to top of page //$('html,body').scrollTop(0); $('#ajaxMsg').fadeOut(); if (timer) { clearTimeout(timer); } if ($('.export-processing').length && $("#tabs-export").hasClass("active")) { timer = setTimeout(redrawExportTable.bind(null, false), 5000); } }, "preDrawCallback": function(settings) { var msg = "  Fetching rows..."; showMsg(msg, false, false, 0) }, "rowCallback": function (row, rowData, rowIndex) { if (rowData['complete'] === 0) { $(row).addClass('current-activity-row'); } } }; $('.export_table').on('click', '> tbody > tr > td.export_download > button', function (e) { var tr = $(this).closest('tr'); var row = export_table.row(tr); var rowData = row.data(); e.preventDefault(); window.location.href = 'download_export?export_id=' + rowData['export_id']; }); $('.export_table').on('click', '> tbody > tr > td.export_delete > button', function (e) { var tr = $(this).closest('tr'); var row = export_table.row(tr); var rowData = row.data(); var msg = 'Are you sure you want to delete the following export?

' + rowData['filename'] + ''; var url = 'delete_export?export_id=' + rowData['export_id']; confirmAjaxCall(url, msg, null, null, redrawExportTable); }); function redrawExportTable(paging) { export_table.draw(paging); } var timer;