Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/en_US/images/preferences_browser_display.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/en_US/preferences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Use the fields on the *Display* panel to specify general display preferences:
all the shared servers from the object explorer. **Note:** This option is visible only when
pgAdmin is running in server mode.

* When the *Show column data type?* switch is turned off, then the data types
of the columns will not be displayed alongside their column names.

* When the *Show empty object collections?* switch is turned off, then all object
collections which are empty will be hidden from browser tree.

Expand Down
10 changes: 10 additions & 0 deletions web/pgadmin/browser/register_browser_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ def register_browser_preferences(self):
)
)

self.show_column_datatype = self.preference.register(
'display', 'show_column_datatype',
gettext("Show column data type?"), 'boolean', True,
category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'If turned off, then the data types of the columns '
'will not be displayed alongside their column names.'
)
)

self.show_user_defined_templates = self.preference.register(
'display', 'show_user_defined_templates',
gettext("Show template databases?"), 'boolean', False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ def nodes(self, gid, sid, did, scid, tid, clid=None):
row['name'],
icon="icon-column",
datatype=row['datatype'], # We need datatype somewhere in,
description=row['description']
description=row['description'],
displaytypname=row['displaytypname'],
),
status=200
)
Expand All @@ -318,7 +319,8 @@ def nodes(self, gid, sid, did, scid, tid, clid=None):
row['name'],
icon="icon-column",
datatype=row['datatype'], # We need datatype somewhere in
description=row['description']
description=row['description'],
displaytypname=row['displaytypname'],
)) # exclusion constraint.

return make_json_response(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { getNodeColumnSchema } from './column.ui';
import _ from 'lodash';
import usePreferences from '../../../../../../../../../preferences/static/js/store';

define('pgadmin.node.column', [
'sources/gettext', 'sources/url_for', 'pgadmin.browser',
Expand Down Expand Up @@ -41,6 +42,14 @@ define('pgadmin.node.column', [
sqlAlterHelp: 'sql-altertable.html',
sqlCreateHelp: 'sql-altertable.html',
dialogHelp: url_for('help.static', {'filename': 'column_dialog.html'}),
// Overriding getNodeInfoLabel to add datatype alongside column name
getNodeInfoLabel: function(data) {
let show_column_datatype = usePreferences.getState().getPreferences('browser', 'show_column_datatype');
if (show_column_datatype?.value && data.datatype && data.displaytypname) {
return data.displaytypname;
}
return null;
},
canDrop: function(itemData, item){
let node = pgBrowser.tree.findNodeByDomElement(item);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SELECT DISTINCT att.attname as name, att.attnum as OID, pg_catalog.format_type(ty.oid,NULL) AS datatype,
pg_catalog.format_type(ty.oid,att.atttypmod) AS displaytypname,
att.attnotnull as not_null,
CASE WHEN att.atthasdef OR att.attidentity != '' OR ty.typdefault IS NOT NULL THEN True
ELSE False END as has_default_val, des.description, seq.seqtypid
Expand Down
8 changes: 8 additions & 0 deletions web/pgadmin/browser/static/js/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ define('pgadmin.browser.node', [
// during the copying process of any node.
return d;
},
getNodeInfoLabel: function(data) {
// Adds an extra informational label appended to the node label.
// Override this function to return a string to display, or null for no extra label.
if(data.info_label)
return data.info_label;
else
return null;
},
hasId: true,
///////
// Initialization function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default function PreferencesComponent({panelId}) {
});
} else {
const requiresTreeRefresh = _data.some((s) =>
['show_system_objects', 'show_empty_coll_nodes', 'hide_shared_server', 'show_user_defined_templates'].includes(s.name) || s.name.startsWith('show_node_')
['show_system_objects', 'show_empty_coll_nodes', 'hide_shared_server', 'show_user_defined_templates', 'show_column_datatype'].includes(s.name) || s.name.startsWith('show_node_')
);

let requiresFullPageRefresh = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export class FileTreeItem extends React.Component<IItemRendererXProps & IItemRen
<span className='file-name'>
{ _.unescape(this.props.item.getMetadata('data')._label)}
</span>
<span className="text-muted" style={{fontSize: '0.9em', whiteSpace: 'nowrap'}}>
{_.unescape(this.props.item.getMetadata('data').info_label)}
</span>
<span className='children-count'>{itemChildren}</span>
{tags.map((tag)=>(
<div key={tag.text} className='file-tag' style={{'--tag-color': tag.color} as React.CSSProperties}>
Expand Down
3 changes: 3 additions & 0 deletions web/pgadmin/static/js/tree/tree_nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export class ManageTreeNodes {
public addNode = (_parent: string, _path: string, _data: []) => new Promise((res) => {
_data.type = _data.inode ? FileType.Directory : FileType.File;
_data._label = _data.label;

_data.info_label = pgAdmin.Browser.Nodes[_data._type]?.getNodeInfoLabel(_data);

_data.label = _.escape(_data.label);

_data.is_collection = isCollectionNode(_data._type);
Expand Down
Loading