public inbox for [email protected]help / color / mirror / Atom feed
[pgAdmin][RM7308]: Server activity - Preserve sorting on refresh 3+ messages / 2 participants [nested] [flat]
* [pgAdmin][RM7308]: Server activity - Preserve sorting on refresh @ 2022-04-13 17:20 Pradip Parkale <[email protected]> 0 siblings, 1 reply; 3+ messages in thread From: Pradip Parkale @ 2022-04-13 17:20 UTC (permalink / raw) To: pgadmin-hackers Hi Hackers, Please find attached for #7308. 1. Sorting should be preserved when the server activity is refreshed and the tab changes. 2. Also, I have fixed the issue where on database selection, 'Session' should be selected by default. -- Thanks & Regards, Pradip Parkale Software Engineer | EnterpriseDB Corporation Attachments: [application/octet-stream] RM7308.patch (6.2K, 3-RM7308.patch) download | inline diff: diff --git a/web/pgadmin/dashboard/static/js/Dashboard.jsx b/web/pgadmin/dashboard/static/js/Dashboard.jsx index 4b7d779cc..a7f33e712 100644 --- a/web/pgadmin/dashboard/static/js/Dashboard.jsx +++ b/web/pgadmin/dashboard/static/js/Dashboard.jsx @@ -27,6 +27,7 @@ import ActiveQuery from './ActiveQuery.ui'; import _ from 'lodash'; import CachedIcon from '@mui/icons-material/Cached'; import EmptyPanelMessage from '../../../static/js/components/EmptyPanelMessage'; +import TabPanel from '../../../static/js/components/TabPanel'; function parseData(data) { var res = []; @@ -123,16 +124,15 @@ export default function Dashboard({ ...props }) { const classes = useStyles(); - let tab = ['Sessions', 'Locks', 'Prepared Transactions']; + let tabs = ['Sessions', 'Locks', 'Prepared Transactions']; const [dashData, setdashData] = useState([]); const [msg, setMsg] = useState(''); - const[infoMsg, setInfo] = useState(''); const [val, setVal] = useState(0); const [refresh, setRefresh] = useState(false); const [schemaDict, setSchemaDict] = React.useState({}); if (!did) { - tab.push('Configuration'); + tabs.push('Configuration'); } val == 3 && did && setVal(0); const tabChanged = (e, tabVal) => { @@ -233,11 +233,9 @@ export default function Dashboard({ .delete(url) .then(function (res) { if (res.data == gettext('Success')) { - setInfo(txtSuccess); Notify.success(txtSuccess); setRefresh(!refresh); } else { - setInfo(txtError); Notify.error(txtError); } }) @@ -302,11 +300,12 @@ export default function Dashboard({ .delete(url) .then(function (res) { if (res.data == gettext('Success')) { - setInfo(txtSuccess); Notify.success(txtSuccess); + setRefresh(!refresh); } else { - setInfo(txtError); Notify.error(txtError); + setRefresh(!refresh); + } }) .catch(function (error) { @@ -722,6 +721,10 @@ export default function Dashboard({ return false; } }; + useEffect(() => { + // Reset Tab values to 0, so that it will select "Sessions" on node changed. + nodeData?._type === 'database' && setVal(0); + },[nodeData]); useEffect(() => { let url, @@ -770,7 +773,7 @@ export default function Dashboard({ if (message != '') { setMsg(message); } - }, [nodeData, val, did, preferences, infoMsg, refresh, props.dbConnected]); + }, [nodeData, val, did, preferences, refresh, props.dbConnected]); const RefreshButton = () =>{ return( @@ -810,33 +813,47 @@ export default function Dashboard({ > {gettext('Server activity')}{' '} </Box> - <Box display="flex"> - <Tabs - value={val} - onChange={tabChanged} - className={classes.searchInput} - > - {tab.map((tabValue, i) => { - return <Tab key={i} label={tabValue} />; - })} - </Tabs> - <RefreshButton/> - </Box> - <Box flexGrow={1}> - <PgTable - caveTable={false} - columns={ - val === 0 - ? activityColumns - : val === 1 - ? databaseLocksColumns - : val == 2 - ? databasePreparedColumns - : serverConfigColumns - } - data={dashData} - schema={schemaDict} - ></PgTable> + <Box height="100%" display="flex" flexDirection="column"> + <Box> + <Tabs + value={val} + onChange={tabChanged} + > + {tabs.map((tabValue, i) => { + return <Tab key={i} label={tabValue} />; + })} + <RefreshButton/> + </Tabs> + </Box> + <TabPanel value={val} index={0} classNameRoot={classes.tabPanel}> + <PgTable + caveTable={false} + columns={activityColumns} + data={dashData} + schema={schemaDict} + ></PgTable> + </TabPanel> + <TabPanel value={val} index={1} classNameRoot={classes.tabPanel}> + <PgTable + caveTable={false} + columns={databaseLocksColumns} + data={dashData} + ></PgTable> + </TabPanel> + <TabPanel value={val} index={2} classNameRoot={classes.tabPanel}> + <PgTable + caveTable={false} + columns={databasePreparedColumns} + data={dashData} + ></PgTable> + </TabPanel> + <TabPanel value={val} index={3} classNameRoot={classes.tabPanel}> + <PgTable + caveTable={false} + columns={serverConfigColumns} + data={dashData} + ></PgTable> + </TabPanel> </Box> </Box> </Box> diff --git a/web/pgadmin/static/js/components/PgTable.jsx b/web/pgadmin/static/js/components/PgTable.jsx index 35ed86488..b3e99f740 100644 --- a/web/pgadmin/static/js/components/PgTable.jsx +++ b/web/pgadmin/static/js/components/PgTable.jsx @@ -274,6 +274,7 @@ export default function PgTable({ columns, data, isSelectRow, caveTable=true, .. data, defaultColumn, isSelectRow, + autoResetSortBy: false, }, useGlobalFilter, useSortBy, ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [pgAdmin][RM7308]: Server activity - Preserve sorting on refresh @ 2022-04-14 03:12 Pradip Parkale <[email protected]> parent: Pradip Parkale <[email protected]> 0 siblings, 1 reply; 3+ messages in thread From: Pradip Parkale @ 2022-04-14 03:12 UTC (permalink / raw) To: pgadmin-hackers Hi Hackers, Please ignore my previous email. Here is the updated patch. On Wed, Apr 13, 2022 at 10:50 PM Pradip Parkale < [email protected]> wrote: > Hi Hackers, > > Please find attached for #7308. > > 1. Sorting should be preserved when the server activity is refreshed > and the tab changes. > 2. Also, I have fixed the issue where on database selection, 'Session' > should be selected by default. > > > -- > Thanks & Regards, > Pradip Parkale > Software Engineer | EnterpriseDB Corporation > -- Thanks & Regards, Pradip Parkale Software Engineer | EnterpriseDB Corporation Attachments: [application/octet-stream] RM7308.patch (7.3K, 3-RM7308.patch) download | inline diff: diff --git a/web/pgadmin/dashboard/static/js/Dashboard.jsx b/web/pgadmin/dashboard/static/js/Dashboard.jsx index 4b7d779cc..ebf4c082b 100644 --- a/web/pgadmin/dashboard/static/js/Dashboard.jsx +++ b/web/pgadmin/dashboard/static/js/Dashboard.jsx @@ -27,6 +27,7 @@ import ActiveQuery from './ActiveQuery.ui'; import _ from 'lodash'; import CachedIcon from '@mui/icons-material/Cached'; import EmptyPanelMessage from '../../../static/js/components/EmptyPanelMessage'; +import TabPanel from '../../../static/js/components/TabPanel'; function parseData(data) { var res = []; @@ -123,20 +124,19 @@ export default function Dashboard({ ...props }) { const classes = useStyles(); - let tab = ['Sessions', 'Locks', 'Prepared Transactions']; + let tabs = ['Sessions', 'Locks', 'Prepared Transactions']; const [dashData, setdashData] = useState([]); const [msg, setMsg] = useState(''); - const[infoMsg, setInfo] = useState(''); - const [val, setVal] = useState(0); + const [tabVal, setTabVal] = useState(0); const [refresh, setRefresh] = useState(false); const [schemaDict, setSchemaDict] = React.useState({}); if (!did) { - tab.push('Configuration'); + tabs.push('Configuration'); } - val == 3 && did && setVal(0); + tabVal == 3 && did && setTabVal(0); const tabChanged = (e, tabVal) => { - setVal(tabVal); + setTabVal(tabVal); }; const serverConfigColumns = [ @@ -233,11 +233,9 @@ export default function Dashboard({ .delete(url) .then(function (res) { if (res.data == gettext('Success')) { - setInfo(txtSuccess); Notify.success(txtSuccess); setRefresh(!refresh); } else { - setInfo(txtError); Notify.error(txtError); } }) @@ -302,11 +300,12 @@ export default function Dashboard({ .delete(url) .then(function (res) { if (res.data == gettext('Success')) { - setInfo(txtSuccess); Notify.success(txtSuccess); + setRefresh(!refresh); } else { - setInfo(txtError); Notify.error(txtError); + setRefresh(!refresh); + } }) .catch(function (error) { @@ -722,6 +721,10 @@ export default function Dashboard({ return false; } }; + useEffect(() => { + // Reset Tab values to 0, so that it will select "Sessions" on node changed. + nodeData?._type === 'database' && setTabVal(0); + },[nodeData]); useEffect(() => { let url, @@ -731,11 +734,11 @@ export default function Dashboard({ if (sid && props.serverConnected) { - if (val === 0) { + if (tabVal === 0) { url = url_for('dashboard.activity'); - } else if (val === 1) { + } else if (tabVal === 1) { url = url_for('dashboard.locks'); - } else if (val === 2) { + } else if (tabVal === 2) { url = url_for('dashboard.prepared'); } else { url = url_for('dashboard.config'); @@ -755,10 +758,10 @@ export default function Dashboard({ .then((res) => { setdashData(parseData(res.data)); }) - .catch((e) => { + .catch((error) => { Notify.alert( gettext('Failed to retrieve data from the server.'), - gettext(e.message) + _.isUndefined(error.response) ? error.message : error.response.data.errormsg ); // show failed message. setMsg(gettext('Failed to retrieve data from the server.')); @@ -770,7 +773,7 @@ export default function Dashboard({ if (message != '') { setMsg(message); } - }, [nodeData, val, did, preferences, infoMsg, refresh, props.dbConnected]); + }, [nodeData, tabVal, did, preferences, refresh, props.dbConnected]); const RefreshButton = () =>{ return( @@ -810,33 +813,47 @@ export default function Dashboard({ > {gettext('Server activity')}{' '} </Box> - <Box display="flex"> - <Tabs - value={val} - onChange={tabChanged} - className={classes.searchInput} - > - {tab.map((tabValue, i) => { - return <Tab key={i} label={tabValue} />; - })} - </Tabs> - <RefreshButton/> - </Box> - <Box flexGrow={1}> - <PgTable - caveTable={false} - columns={ - val === 0 - ? activityColumns - : val === 1 - ? databaseLocksColumns - : val == 2 - ? databasePreparedColumns - : serverConfigColumns - } - data={dashData} - schema={schemaDict} - ></PgTable> + <Box height="100%" display="flex" flexDirection="column"> + <Box> + <Tabs + value={tabVal} + onChange={tabChanged} + > + {tabs.map((tabValue, i) => { + return <Tab key={i} label={tabValue} />; + })} + <RefreshButton/> + </Tabs> + </Box> + <TabPanel value={tabVal} index={0} classNameRoot={classes.tabPanel}> + <PgTable + caveTable={false} + columns={activityColumns} + data={dashData} + schema={schemaDict} + ></PgTable> + </TabPanel> + <TabPanel value={tabVal} index={1} classNameRoot={classes.tabPanel}> + <PgTable + caveTable={false} + columns={databaseLocksColumns} + data={dashData} + ></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> diff --git a/web/pgadmin/static/js/components/PgTable.jsx b/web/pgadmin/static/js/components/PgTable.jsx index 35ed86488..b3e99f740 100644 --- a/web/pgadmin/static/js/components/PgTable.jsx +++ b/web/pgadmin/static/js/components/PgTable.jsx @@ -274,6 +274,7 @@ export default function PgTable({ columns, data, isSelectRow, caveTable=true, .. data, defaultColumn, isSelectRow, + autoResetSortBy: false, }, useGlobalFilter, useSortBy, ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [pgAdmin][RM7308]: Server activity - Preserve sorting on refresh @ 2022-04-14 05:43 Akshay Joshi <[email protected]> parent: Pradip Parkale <[email protected]> 0 siblings, 0 replies; 3+ messages in thread From: Akshay Joshi @ 2022-04-14 05:43 UTC (permalink / raw) To: Pradip Parkale <[email protected]>; +Cc: pgadmin-hackers Thanks, the patch applied. On Thu, Apr 14, 2022 at 8:42 AM Pradip Parkale < [email protected]> wrote: > Hi Hackers, > > Please ignore my previous email. Here is the updated patch. > > On Wed, Apr 13, 2022 at 10:50 PM Pradip Parkale < > [email protected]> wrote: > >> Hi Hackers, >> >> Please find attached for #7308. >> >> 1. Sorting should be preserved when the server activity is refreshed >> and the tab changes. >> 2. Also, I have fixed the issue where on database selection, >> 'Session' should be selected by default. >> >> >> -- >> Thanks & Regards, >> Pradip Parkale >> Software Engineer | EnterpriseDB Corporation >> > > > -- > Thanks & Regards, > Pradip Parkale > Software Engineer | EnterpriseDB Corporation > -- *Thanks & Regards* *Akshay Joshi* *pgAdmin Hacker | Principal Software Architect* *EDB Postgres <http://edbpostgres.com>* *Mobile: +91 976-788-8246* ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-04-14 05:43 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-04-13 17:20 [pgAdmin][RM7308]: Server activity - Preserve sorting on refresh Pradip Parkale <[email protected]> 2022-04-14 03:12 ` Pradip Parkale <[email protected]> 2022-04-14 05:43 ` Akshay Joshi <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox