mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that sorting should be preserved on refresh for Server Activity. Fixes #7308
This commit is contained in:
parent
7b0a6e7377
commit
131ff4de48
@ -35,3 +35,4 @@ Bug fixes
|
|||||||
| `Issue #7262 <https://redmine.postgresql.org/issues/7262>`_ - Ensure that Autocomplete should work after changing the connection.
|
| `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 #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 #7296 <https://redmine.postgresql.org/issues/7296>`_ - Ensure that after deleting multiple objects from the properties panel, the browser tree should be refreshed.
|
||||||
|
| `Issue #7308 <https://redmine.postgresql.org/issues/7308>`_ - Ensure that sorting should be preserved on refresh for Server Activity.
|
||||||
|
@ -27,6 +27,7 @@ import ActiveQuery from './ActiveQuery.ui';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import CachedIcon from '@mui/icons-material/Cached';
|
import CachedIcon from '@mui/icons-material/Cached';
|
||||||
import EmptyPanelMessage from '../../../static/js/components/EmptyPanelMessage';
|
import EmptyPanelMessage from '../../../static/js/components/EmptyPanelMessage';
|
||||||
|
import TabPanel from '../../../static/js/components/TabPanel';
|
||||||
|
|
||||||
function parseData(data) {
|
function parseData(data) {
|
||||||
var res = [];
|
var res = [];
|
||||||
@ -123,20 +124,19 @@ export default function Dashboard({
|
|||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
let tab = ['Sessions', 'Locks', 'Prepared Transactions'];
|
let tabs = ['Sessions', 'Locks', 'Prepared Transactions'];
|
||||||
const [dashData, setdashData] = useState([]);
|
const [dashData, setdashData] = useState([]);
|
||||||
const [msg, setMsg] = useState('');
|
const [msg, setMsg] = useState('');
|
||||||
const[infoMsg, setInfo] = useState('');
|
const [tabVal, setTabVal] = useState(0);
|
||||||
const [val, setVal] = useState(0);
|
|
||||||
const [refresh, setRefresh] = useState(false);
|
const [refresh, setRefresh] = useState(false);
|
||||||
const [schemaDict, setSchemaDict] = React.useState({});
|
const [schemaDict, setSchemaDict] = React.useState({});
|
||||||
|
|
||||||
if (!did) {
|
if (!did) {
|
||||||
tab.push('Configuration');
|
tabs.push('Configuration');
|
||||||
}
|
}
|
||||||
val == 3 && did && setVal(0);
|
tabVal == 3 && did && setTabVal(0);
|
||||||
const tabChanged = (e, tabVal) => {
|
const tabChanged = (e, tabVal) => {
|
||||||
setVal(tabVal);
|
setTabVal(tabVal);
|
||||||
};
|
};
|
||||||
|
|
||||||
const serverConfigColumns = [
|
const serverConfigColumns = [
|
||||||
@ -233,11 +233,9 @@ export default function Dashboard({
|
|||||||
.delete(url)
|
.delete(url)
|
||||||
.then(function (res) {
|
.then(function (res) {
|
||||||
if (res.data == gettext('Success')) {
|
if (res.data == gettext('Success')) {
|
||||||
setInfo(txtSuccess);
|
|
||||||
Notify.success(txtSuccess);
|
Notify.success(txtSuccess);
|
||||||
setRefresh(!refresh);
|
setRefresh(!refresh);
|
||||||
} else {
|
} else {
|
||||||
setInfo(txtError);
|
|
||||||
Notify.error(txtError);
|
Notify.error(txtError);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -302,11 +300,12 @@ export default function Dashboard({
|
|||||||
.delete(url)
|
.delete(url)
|
||||||
.then(function (res) {
|
.then(function (res) {
|
||||||
if (res.data == gettext('Success')) {
|
if (res.data == gettext('Success')) {
|
||||||
setInfo(txtSuccess);
|
|
||||||
Notify.success(txtSuccess);
|
Notify.success(txtSuccess);
|
||||||
|
setRefresh(!refresh);
|
||||||
} else {
|
} else {
|
||||||
setInfo(txtError);
|
|
||||||
Notify.error(txtError);
|
Notify.error(txtError);
|
||||||
|
setRefresh(!refresh);
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
@ -722,6 +721,10 @@ export default function Dashboard({
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
// Reset Tab values to 0, so that it will select "Sessions" on node changed.
|
||||||
|
nodeData?._type === 'database' && setTabVal(0);
|
||||||
|
},[nodeData]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let url,
|
let url,
|
||||||
@ -731,11 +734,11 @@ export default function Dashboard({
|
|||||||
|
|
||||||
if (sid && props.serverConnected) {
|
if (sid && props.serverConnected) {
|
||||||
|
|
||||||
if (val === 0) {
|
if (tabVal === 0) {
|
||||||
url = url_for('dashboard.activity');
|
url = url_for('dashboard.activity');
|
||||||
} else if (val === 1) {
|
} else if (tabVal === 1) {
|
||||||
url = url_for('dashboard.locks');
|
url = url_for('dashboard.locks');
|
||||||
} else if (val === 2) {
|
} else if (tabVal === 2) {
|
||||||
url = url_for('dashboard.prepared');
|
url = url_for('dashboard.prepared');
|
||||||
} else {
|
} else {
|
||||||
url = url_for('dashboard.config');
|
url = url_for('dashboard.config');
|
||||||
@ -755,10 +758,10 @@ export default function Dashboard({
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
setdashData(parseData(res.data));
|
setdashData(parseData(res.data));
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((error) => {
|
||||||
Notify.alert(
|
Notify.alert(
|
||||||
gettext('Failed to retrieve data from the server.'),
|
gettext('Failed to retrieve data from the server.'),
|
||||||
gettext(e.message)
|
_.isUndefined(error.response) ? error.message : error.response.data.errormsg
|
||||||
);
|
);
|
||||||
// show failed message.
|
// show failed message.
|
||||||
setMsg(gettext('Failed to retrieve data from the server.'));
|
setMsg(gettext('Failed to retrieve data from the server.'));
|
||||||
@ -770,7 +773,7 @@ export default function Dashboard({
|
|||||||
if (message != '') {
|
if (message != '') {
|
||||||
setMsg(message);
|
setMsg(message);
|
||||||
}
|
}
|
||||||
}, [nodeData, val, did, preferences, infoMsg, refresh, props.dbConnected]);
|
}, [nodeData, tabVal, did, preferences, refresh, props.dbConnected]);
|
||||||
|
|
||||||
const RefreshButton = () =>{
|
const RefreshButton = () =>{
|
||||||
return(
|
return(
|
||||||
@ -810,33 +813,47 @@ export default function Dashboard({
|
|||||||
>
|
>
|
||||||
{gettext('Server activity')}{' '}
|
{gettext('Server activity')}{' '}
|
||||||
</Box>
|
</Box>
|
||||||
<Box display="flex">
|
<Box height="100%" display="flex" flexDirection="column">
|
||||||
<Tabs
|
<Box>
|
||||||
value={val}
|
<Tabs
|
||||||
onChange={tabChanged}
|
value={tabVal}
|
||||||
className={classes.searchInput}
|
onChange={tabChanged}
|
||||||
>
|
>
|
||||||
{tab.map((tabValue, i) => {
|
{tabs.map((tabValue, i) => {
|
||||||
return <Tab key={i} label={tabValue} />;
|
return <Tab key={i} label={tabValue} />;
|
||||||
})}
|
})}
|
||||||
</Tabs>
|
<RefreshButton/>
|
||||||
<RefreshButton/>
|
</Tabs>
|
||||||
</Box>
|
</Box>
|
||||||
<Box flexGrow={1}>
|
<TabPanel value={tabVal} index={0} classNameRoot={classes.tabPanel}>
|
||||||
<PgTable
|
<PgTable
|
||||||
caveTable={false}
|
caveTable={false}
|
||||||
columns={
|
columns={activityColumns}
|
||||||
val === 0
|
data={dashData}
|
||||||
? activityColumns
|
schema={schemaDict}
|
||||||
: val === 1
|
></PgTable>
|
||||||
? databaseLocksColumns
|
</TabPanel>
|
||||||
: val == 2
|
<TabPanel value={tabVal} index={1} classNameRoot={classes.tabPanel}>
|
||||||
? databasePreparedColumns
|
<PgTable
|
||||||
: serverConfigColumns
|
caveTable={false}
|
||||||
}
|
columns={databaseLocksColumns}
|
||||||
data={dashData}
|
data={dashData}
|
||||||
schema={schemaDict}
|
></PgTable>
|
||||||
></PgTable>
|
</TabPanel>
|
||||||
|
<TabPanel value={tabVal} index={2} classNameRoot={classes.tabPanel}>
|
||||||
|
<PgTable
|
||||||
|
caveTable={false}
|
||||||
|
columns={databasePreparedColumns}
|
||||||
|
data={dashData}
|
||||||
|
></PgTable>
|
||||||
|
</TabPanel>
|
||||||
|
<TabPanel value={tabVal} index={3} classNameRoot={classes.tabPanel}>
|
||||||
|
<PgTable
|
||||||
|
caveTable={false}
|
||||||
|
columns={serverConfigColumns}
|
||||||
|
data={dashData}
|
||||||
|
></PgTable>
|
||||||
|
</TabPanel>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -274,6 +274,7 @@ export default function PgTable({ columns, data, isSelectRow, caveTable=true, ..
|
|||||||
data,
|
data,
|
||||||
defaultColumn,
|
defaultColumn,
|
||||||
isSelectRow,
|
isSelectRow,
|
||||||
|
autoResetSortBy: false,
|
||||||
},
|
},
|
||||||
useGlobalFilter,
|
useGlobalFilter,
|
||||||
useSortBy,
|
useSortBy,
|
||||||
|
Loading…
Reference in New Issue
Block a user