mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed an issue while creating a new database throwing an error that failed to retrieve data. Fixes #7322
This commit is contained in:
committed by
Akshay Joshi
parent
f28e8126af
commit
ab8e9a8ea5
@@ -41,3 +41,4 @@ Bug fixes
|
|||||||
| `Issue #7299 <https://redmine.postgresql.org/issues/7299>`_ - Fixed sorting issue in the statistics panel.
|
| `Issue #7299 <https://redmine.postgresql.org/issues/7299>`_ - Fixed sorting issue in the statistics panel.
|
||||||
| `Issue #7307 <https://redmine.postgresql.org/issues/7307>`_ - Fixed an issue where the table showed duplicate columns when creating multiple sequences on the same column.
|
| `Issue #7307 <https://redmine.postgresql.org/issues/7307>`_ - Fixed an issue where the table showed duplicate columns when creating multiple sequences on the same column.
|
||||||
| `Issue #7308 <https://redmine.postgresql.org/issues/7308>`_ - Ensure that sorting should be preserved on refresh for Server Activity.
|
| `Issue #7308 <https://redmine.postgresql.org/issues/7308>`_ - Ensure that sorting should be preserved on refresh for Server Activity.
|
||||||
|
| `Issue #7322 <https://redmine.postgresql.org/issues/7322>`_ - Fixed an issue while creating a new database throwing an error that failed to retrieve data.
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ define(
|
|||||||
|
|
||||||
pgBrowser.Events.on('pgadmin:database:connected', () => {
|
pgBrowser.Events.on('pgadmin:database:connected', () => {
|
||||||
|
|
||||||
if(myPanel.isVisible() && myPanel._type == 'dashboard' && myPanel._type !== 'properties') {
|
if(myPanel.isVisible() && myPanel._type !== 'properties') {
|
||||||
getPanelView(
|
getPanelView(
|
||||||
pgBrowser.tree,
|
pgBrowser.tree,
|
||||||
$container[0],
|
$container[0],
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ export function getPanelView(
|
|||||||
nodeData={nodeData}
|
nodeData={nodeData}
|
||||||
node={node}
|
node={node}
|
||||||
item={item}
|
item={item}
|
||||||
|
did={((!_.isUndefined(treeNodeInfo)) && (!_.isUndefined(treeNodeInfo['database']))) ? treeNodeInfo['database']._id: 0}
|
||||||
|
dbConnected={!_.isUndefined(treeNodeInfo) && !_.isUndefined(treeNodeInfo['database']) ? treeNodeInfo.database.connected: false}
|
||||||
/>
|
/>
|
||||||
</Theme>,
|
</Theme>,
|
||||||
container
|
container
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { PgIconButton } from '../../static/js/components/Buttons';
|
|||||||
import DeleteIcon from '@material-ui/icons/Delete';
|
import DeleteIcon from '@material-ui/icons/Delete';
|
||||||
import DeleteSweepIcon from '@material-ui/icons/DeleteSweep';
|
import DeleteSweepIcon from '@material-ui/icons/DeleteSweep';
|
||||||
import EmptyPanelMessage from '../../static/js/components/EmptyPanelMessage';
|
import EmptyPanelMessage from '../../static/js/components/EmptyPanelMessage';
|
||||||
|
import Loader from 'sources/components/Loader';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
emptyPanel: {
|
emptyPanel: {
|
||||||
@@ -87,6 +88,7 @@ export function CollectionNodeView({
|
|||||||
const [infoMsg, setInfoMsg] = React.useState('Please select an object in the tree view.');
|
const [infoMsg, setInfoMsg] = React.useState('Please select an object in the tree view.');
|
||||||
const [selectedObject, setSelectedObject] = React.useState([]);
|
const [selectedObject, setSelectedObject] = React.useState([]);
|
||||||
const [reload, setReload] = React.useState(false);
|
const [reload, setReload] = React.useState(false);
|
||||||
|
const [loaderText, setLoaderText] = React.useState('');
|
||||||
|
|
||||||
const [pgTableColumns, setPgTableColumns] = React.useState([
|
const [pgTableColumns, setPgTableColumns] = React.useState([
|
||||||
{
|
{
|
||||||
@@ -192,6 +194,7 @@ export function CollectionNodeView({
|
|||||||
|
|
||||||
let tableColumns = [];
|
let tableColumns = [];
|
||||||
var column = {};
|
var column = {};
|
||||||
|
setLoaderText('Loading...');
|
||||||
|
|
||||||
if (itemNodeData._type.indexOf('coll-') > -1 && !_.isUndefined(nodeObj.getSchema)) {
|
if (itemNodeData._type.indexOf('coll-') > -1 && !_.isUndefined(nodeObj.getSchema)) {
|
||||||
let schema = nodeObj.getSchema?.call(nodeObj, treeNodeInfo, itemNodeData);
|
let schema = nodeObj.getSchema?.call(nodeObj, treeNodeInfo, itemNodeData);
|
||||||
@@ -248,6 +251,7 @@ export function CollectionNodeView({
|
|||||||
setPgTableColumns(tableColumns);
|
setPgTableColumns(tableColumns);
|
||||||
setData(res.data);
|
setData(res.data);
|
||||||
setInfoMsg('No properties are available for the selected object.');
|
setInfoMsg('No properties are available for the selected object.');
|
||||||
|
setLoaderText('');
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
Notify.alert(
|
Notify.alert(
|
||||||
@@ -311,7 +315,9 @@ export function CollectionNodeView({
|
|||||||
:
|
:
|
||||||
(
|
(
|
||||||
<div className={classes.emptyPanel}>
|
<div className={classes.emptyPanel}>
|
||||||
<EmptyPanelMessage text={gettext(infoMsg)}/>
|
{loaderText ? (<Loader message={loaderText} className={classes.loading} />) :
|
||||||
|
<EmptyPanelMessage text={gettext(infoMsg)}/>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import Notify from '../../../../static/js/helpers/Notifier';
|
|||||||
import getApiInstance from 'sources/api_instance';
|
import getApiInstance from 'sources/api_instance';
|
||||||
import { makeStyles } from '@material-ui/core/styles';
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
import CodeMirror from '../../../../static/js/components/CodeMirror';
|
import CodeMirror from '../../../../static/js/components/CodeMirror';
|
||||||
|
import Loader from 'sources/components/Loader';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
textArea: {
|
textArea: {
|
||||||
@@ -27,10 +28,10 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export default function SQL({ nodeData, node, ...props }) {
|
export default function SQL({ nodeData, node, did, ...props }) {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const [nodeSQL, setNodeSQL] = React.useState('');
|
const [nodeSQL, setNodeSQL] = React.useState('');
|
||||||
|
const [loaderText, setLoaderText] = React.useState('');
|
||||||
const [msg, setMsg] = React.useState('');
|
const [msg, setMsg] = React.useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -44,12 +45,13 @@ export default function SQL({ nodeData, node, ...props }) {
|
|||||||
true,
|
true,
|
||||||
node.url_jump_after_node
|
node.url_jump_after_node
|
||||||
);
|
);
|
||||||
|
setLoaderText('Loading...');
|
||||||
|
if (did && !props.dbConnected) return;
|
||||||
sql =
|
sql =
|
||||||
'-- ' + gettext('No SQL could be generated for the selected object.');
|
'-- ' + gettext('No SQL could be generated for the selected object.');
|
||||||
|
|
||||||
if (node.hasSQL) {
|
if (node.hasSQL) {
|
||||||
const api = getApiInstance();
|
const api = getApiInstance();
|
||||||
|
|
||||||
api({
|
api({
|
||||||
url: url,
|
url: url,
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
@@ -57,6 +59,7 @@ export default function SQL({ nodeData, node, ...props }) {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data.length > 0) {
|
if (res.data.length > 0) {
|
||||||
setNodeSQL(res.data);
|
setNodeSQL(res.data);
|
||||||
|
setLoaderText('');
|
||||||
} else {
|
} else {
|
||||||
setMsg(sql);
|
setMsg(sql);
|
||||||
}
|
}
|
||||||
@@ -68,7 +71,11 @@ export default function SQL({ nodeData, node, ...props }) {
|
|||||||
);
|
);
|
||||||
// show failed message.
|
// show failed message.
|
||||||
setMsg(gettext('Failed to retrieve data from the server.'));
|
setMsg(gettext('Failed to retrieve data from the server.'));
|
||||||
|
setLoaderText('');
|
||||||
});
|
});
|
||||||
|
}else{
|
||||||
|
setMsg(sql);
|
||||||
|
setLoaderText('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sql != '') {
|
if (sql != '') {
|
||||||
@@ -77,31 +84,20 @@ export default function SQL({ nodeData, node, ...props }) {
|
|||||||
return () => {
|
return () => {
|
||||||
setNodeSQL([]);
|
setNodeSQL([]);
|
||||||
};
|
};
|
||||||
}, [nodeData]);
|
}, [nodeData, props.dbConnected]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{nodeSQL.length > 0 ? (
|
<Loader message={loaderText} className={classes.loading} />
|
||||||
<CodeMirror
|
<CodeMirror
|
||||||
className={classes.textArea}
|
className={classes.textArea}
|
||||||
value={nodeSQL}
|
value={nodeSQL.length > 0 ? nodeSQL : msg}
|
||||||
options={{
|
readonly={true}
|
||||||
lineNumbers: true,
|
options={{
|
||||||
mode: 'text/x-pgsql',
|
lineNumbers: true,
|
||||||
readOnly: true,
|
mode: 'text/x-pgsql',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
<CodeMirror
|
|
||||||
className={classes.textArea}
|
|
||||||
value={msg}
|
|
||||||
options={{
|
|
||||||
lineNumbers: true,
|
|
||||||
mode: 'text/x-pgsql',
|
|
||||||
readOnly: true,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -111,4 +107,6 @@ SQL.propTypes = {
|
|||||||
nodeData: PropTypes.object,
|
nodeData: PropTypes.object,
|
||||||
treeNodeInfo: PropTypes.object,
|
treeNodeInfo: PropTypes.object,
|
||||||
node: PropTypes.func,
|
node: PropTypes.func,
|
||||||
|
dbConnected: PropTypes.bool,
|
||||||
|
did: PropTypes.number
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ function getColumn(data, singleLineStatistics) {
|
|||||||
if (!_.isNull(rowB.values[id]) && typeof (rowB.values[id]) == 'string' && rowB.values[id].indexOf(t) > -1) {
|
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);
|
val2 = parseInt(rowB.values[id]) * Math.pow(1024, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if ((val1) > (val2) || _.isNull(val2)) {
|
if ((val1) > (val2) || _.isNull(val2)) {
|
||||||
@@ -273,9 +274,8 @@ export default function Statistics({ nodeData, item, node, ...props }) {
|
|||||||
></PgTable>
|
></PgTable>
|
||||||
) : (
|
) : (
|
||||||
<div className={classes.emptyPanel}>
|
<div className={classes.emptyPanel}>
|
||||||
{loaderText ? (<Loader message={loaderText} className={classes.loading} />) :
|
<Loader message={loaderText} className={classes.loading} />
|
||||||
<EmptyPanelMessage text={gettext(msg)}/>
|
<EmptyPanelMessage text={gettext(msg)}/>
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user