analyse icon indicating copy to clipboard operation
analyse copied to clipboard

Feature request: Ability to sort assets by size in chunk view

Open QuentinFchx opened this issue 8 years ago • 2 comments

It's currently only possible in the main view

QuentinFchx avatar Feb 21 '17 16:02 QuentinFchx

@QuentinFchx OK I marked this as an enhancement, I will merge this in if anyone can do the work and create a PR!

a-r-d avatar May 16 '17 17:05 a-r-d

Before this will be merged.

Just open console and run

const dataTablesScript = document.createElement('script');
dataTablesScript.src = "https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js";
dataTablesScript.onload = function () {
    jQuery.fn.dataTable.ext.type.order["file-size-pre"] = function ( data ) {
        var matches = data.match( /^(\d+(?:\.\d+)?)\s*([a-z]+)/i );
    
        var multipliers = {
            b:  1,
            bytes: 1,
            kb: 1000,
            kib: 1024,
            mb: 1000000,
            mib: 1048576,
            gb: 1000000000,
            gib: 1073741824,
            tb: 1000000000000,
            tib: 1099511627776,
            pb: 1000000000000000,
            pib: 1125899906842624
        };
     
        if (matches) {
            var multiplier = multipliers[matches[2].toLowerCase()];
            return parseFloat( matches[1] ) * multiplier;
        } else {
            return -1;
        };
    };
    
    $('.table').eq(1).DataTable({
        columnDefs: [
           	{ type: "file-size", targets: 2 },
            { className: "sortable-th size-th", targets: [ 2 ] }
        ],
        order: [[ 2, "desc" ]],
        paging: false,
  		searching: false,
    });
};
document.body.appendChild(dataTablesScript);

davityavryan avatar Dec 28 '17 11:12 davityavryan