Fixed sorting issue in the statistics panel. Fixes #7299

This commit is contained in:
Pradip Parkale 2022-04-20 10:32:51 +05:30 committed by Akshay Joshi
parent 9c30d983bd
commit 58e4f766d8
2 changed files with 43 additions and 8 deletions

View File

@ -36,4 +36,5 @@ Bug fixes
| `Issue #7262 <https://redmine.postgresql.org/issues/7262>`_ - Ensure that Autocomplete should work after changing the connection.
| `Issue #7294 <https://redmine.postgresql.org/issues/7294>`_ - Fixed an issue where the copy and paste row does not work if the first column contains no data.
| `Issue #7296 <https://redmine.postgresql.org/issues/7296>`_ - Ensure that after deleting multiple objects from the properties panel, the browser tree should be refreshed.
| `Issue #7299 <https://redmine.postgresql.org/issues/7299>`_ - Fixed sorting issue in the statistics panel.
| `Issue #7308 <https://redmine.postgresql.org/issues/7308>`_ - Ensure that sorting should be preserved on refresh for Server Activity.

View File

@ -57,17 +57,51 @@ const useStyles = makeStyles((theme) => ({
}));
function getColumn(data, singleLineStatistics) {
let columns = [];
let columns = [], column;
if (!singleLineStatistics) {
if (!_.isUndefined(data)) {
data.forEach((row) => {
var column = {
Header: row.name,
accessor: row.name,
sortble: true,
resizable: false,
disableGlobalFilter: false,
};
if (row.name == 'Size') {
column = {
Header: row.name,
accessor: row.name,
sortble: true,
resizable: false,
disableGlobalFilter: false,
sortType: ((rowA, rowB, id) => {
let val1 = rowA.values[id];
let val2 = rowB.values[id];
const sizes = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
sizes.some((t, i) => {
if (!_.isNull(rowA.values[id]) && typeof (rowA.values[id]) == 'string' && rowA.values[id].indexOf(t) > -1) {
val1 = (parseInt(rowA.values[id]) * Math.pow(1024, i));
}
if (!_.isNull(rowB.values[id]) && typeof (rowB.values[id]) == 'string' && rowB.values[id].indexOf(t) > -1) {
val2 = parseInt(rowB.values[id]) * Math.pow(1024, i);
}
});
if ((val1) > (val2) || _.isNull(val2)) {
return 1;
}
if ((val2) > (val1) || _.isNull(val1)) {
return -1;
}
return 0;
})
};
}else{
column = {
Header: row.name,
accessor: row.name,
sortble: true,
resizable: false,
disableGlobalFilter: false,
};
}
columns.push(column);
});
}