mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix the sorting of size on the statistics panel. #6459
This commit is contained in:
parent
46a8c1ad6a
commit
4bc6dcca67
@ -17,7 +17,7 @@ import { makeStyles } from '@material-ui/core/styles';
|
|||||||
import { getURL } from '../../../static/utils/utils';
|
import { getURL } from '../../../static/utils/utils';
|
||||||
import Loader from 'sources/components/Loader';
|
import Loader from 'sources/components/Loader';
|
||||||
import EmptyPanelMessage from '../../../../static/js/components/EmptyPanelMessage';
|
import EmptyPanelMessage from '../../../../static/js/components/EmptyPanelMessage';
|
||||||
import { compareSizeVals, toPrettySize } from '../../../../static/js/utils';
|
import { toPrettySize } from '../../../../static/js/utils';
|
||||||
import withStandardTabInfo from '../../../../static/js/helpers/withStandardTabInfo';
|
import withStandardTabInfo from '../../../../static/js/helpers/withStandardTabInfo';
|
||||||
import { BROWSER_PANELS } from '../../../../browser/static/js/constants';
|
import { BROWSER_PANELS } from '../../../../browser/static/js/constants';
|
||||||
import { usePgAdmin } from '../../../../static/js/BrowserComponent';
|
import { usePgAdmin } from '../../../../static/js/BrowserComponent';
|
||||||
@ -54,7 +54,7 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function getColumn(data, singleLineStatistics) {
|
function getColumn(data, singleLineStatistics, prettifyFields=[]) {
|
||||||
let columns = [], column;
|
let columns = [], column;
|
||||||
if (!singleLineStatistics) {
|
if (!singleLineStatistics) {
|
||||||
if (!_.isUndefined(data)) {
|
if (!_.isUndefined(data)) {
|
||||||
@ -66,9 +66,6 @@ function getColumn(data, singleLineStatistics) {
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
disableGlobalFilter: false,
|
disableGlobalFilter: false,
|
||||||
sortType: ((rowA, rowB, id) => {
|
|
||||||
return compareSizeVals(rowA.values[id], rowB.values[id]);
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
column = {
|
column = {
|
||||||
@ -83,7 +80,6 @@ function getColumn(data, singleLineStatistics) {
|
|||||||
columns.push(column);
|
columns.push(column);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return columns;
|
|
||||||
} else {
|
} else {
|
||||||
columns = [
|
columns = [
|
||||||
{
|
{
|
||||||
@ -102,6 +98,13 @@ function getColumn(data, singleLineStatistics) {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
columns.forEach((c)=>{
|
||||||
|
// Prettify the cell view
|
||||||
|
if(prettifyFields.includes(c.Header)) {
|
||||||
|
// eslint-disable-next-line react/display-name,react/prop-types
|
||||||
|
c.Cell = ({value})=><>{toPrettySize(value)}</>;
|
||||||
|
}
|
||||||
|
});
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,15 +115,9 @@ function getTableData(res, node) {
|
|||||||
let data = res.data.data;
|
let data = res.data.data;
|
||||||
if (node.hasCollectiveStatistics || data['rows'].length > 1) {
|
if (node.hasCollectiveStatistics || data['rows'].length > 1) {
|
||||||
data.rows.forEach((row) => {
|
data.rows.forEach((row) => {
|
||||||
// Prettify the field values
|
|
||||||
if (!_.isEmpty(node.statsPrettifyFields)) {
|
|
||||||
node.statsPrettifyFields.forEach((field) => {
|
|
||||||
row[field] = toPrettySize(row[field]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
nodeStats.push({ ...row, icon: '' });
|
nodeStats.push({ ...row, icon: '' });
|
||||||
});
|
});
|
||||||
colData = getColumn(data.columns, false);
|
colData = getColumn(data.columns, false, node.statsPrettifyFields);
|
||||||
} else {
|
} else {
|
||||||
nodeStats = createSingleLineStatistics(data, node.statsPrettifyFields);
|
nodeStats = createSingleLineStatistics(data, node.statsPrettifyFields);
|
||||||
colData = getColumn(data.columns, true);
|
colData = getColumn(data.columns, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user