Clear the node cache, when an node is created/updated to make sure - we

will always have latest data related to that type of node. Also, fixed
the cache_level for different node types.

This commit also contains fixes for the following issue:
* In extension module - use the 'node-list-by-name' instead of using a
  custom 'node-ajax-options' control, and removed redundant template
  schemas from it.
* When we tries to destroy the select2 object from
  Select2Cell/Select2Control while releasing the properties view,
  sometimes select2 can not find the instance related it for some
  unknown reason. Hence - before removing it we will check for manual
  instance existance using $.data('select2').
* When we traverse through the browser tree nodes very quickly, it tries
  to remove the object before it gets created completely, and results
  into an exception.
* Icon in the select2 drop down list was not visible due to some CSS
  issues.

Apart of that, we will generate two new browser events -
'pgadmin-node:created:<NODE-TYPE>', 'pgadmin-node:updated:<NODE-TYPE>'
whenever a new node is created, or an existing node will be updated.
This commit is contained in:
Ashesh Vashi
2016-04-29 15:41:24 +05:30
parent dac514a4ae
commit 32e0a0d4b6
14 changed files with 148 additions and 66 deletions

View File

@@ -173,27 +173,20 @@ function($, _, S, pgAdmin, pgBrowser) {
},
{
id: 'owner', label:'{{ _('Owner') }}', control: 'node-list-by-name',
mode: ['properties'], node: 'role', cell: 'string'
mode: ['properties'], node: 'role', cell: 'string',
cache_level: 'server'
},
{
id: 'schema', label: '{{ _('Schema')}}', type: 'text', control: 'node-ajax-options',
mode: ['properties', 'create', 'edit'], group: '{{ _('Definition')}}', deps: ['relocatable'],
url: 'schemas', first_empty: true, disabled: function(m) {
id: 'schema', label: '{{ _('Schema')}}', type: 'text',
control: 'node-list-by-name', group: '{{ _('Definition')}}',
mode: ['properties', 'create', 'edit'], deps: ['relocatable'],
node: 'schema', first_empty: true,
disabled: function(m) {
/*
* enable or disable schema field if model's relocatable
* attribute is True or False
*/
return (m.has('relocatable') ? !m.get('relocatable') : false);
},
transform: function(data) {
var res = [];
if (data && _.isArray(data)) {
_.each(data, function(d) {
res.push({label: d.schema, value: d.schema});
})
}
return res;
}
},
{

View File

@@ -1,3 +0,0 @@
{#===================fetch all schemas==========================#}
SELECT nspname As schema FROM pg_namespace
ORDER BY nspname

View File

@@ -62,7 +62,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
lc_collate: undefined,
description: undefined
},
// Default values!
initialize: function(attrs, args) {
var isNew = (_.size(attrs) === 0);
@@ -76,7 +76,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
}
pgAdmin.Browser.Node.Model.prototype.initialize.apply(this, arguments);
},
schema: [{
id: 'name', label: '{{ _('Name') }}', cell: 'string',
type: 'text', mode: ['properties', 'create', 'edit'],
@@ -87,7 +87,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
},{
id: 'owner', label:'{{ _('Owner') }}', cell: 'string',
type: 'text', mode: ['properties', 'create', 'edit'],
disabled: 'inSchema', control: 'node-list-by-name', node: 'role'
disabled: 'inSchema', control: 'node-list-by-name',
node: 'role'
},{
id: 'schema', label:'{{ _('Schema') }}', cell: 'string',
type: 'text', mode: ['create', 'edit'], node: 'schema',

View File

@@ -205,10 +205,12 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
id: 'description', label:'{{ _('Comment') }}', cell: 'string',
type: 'multiline'
},{
id: 'basetype', label:'{{ _('Base type') }}', cell: 'string', control: 'node-ajax-options',
type: 'text', mode:['properties', 'create', 'edit'], group: '{{ _('Definition') }}', url: 'get_types',
disabled: function(m) { return !m.isNew(); }, first_empty: true,
transform: function(d){
id: 'basetype', label:'{{ _('Base type') }}', cell: 'string',
control: 'node-ajax-options', type: 'text', url: 'get_types',
mode:['properties', 'create', 'edit'], group: '{{ _('Definition') }}',
cache_level: 'database', cache_node: 'schema', disabled: function(m) {
return !m.isNew();
}, first_empty: true, transform: function(d) {
this.model.type_options = d;
return d;
}
@@ -279,8 +281,10 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
'size': 'small'
}
},{
id: 'collname', label:'{{ _('Collation') }}', cell: 'string', control: 'node-ajax-options',
type: 'text', group: '{{ _('Definition') }}', url: 'get_collations', disabled: function(m) {
id: 'collname', label:'{{ _('Collation') }}', cell: 'string',
control: 'node-ajax-options', type: 'text', url: 'get_collations',
group: '{{ _('Definition') }}', cache_level: 'database',
cache_node: 'schema', disabled: function(m) {
return !m.isNew();
}
},{

View File

@@ -126,14 +126,15 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
},{
id: 'schema', label: '{{ _('Schema')}}', cell: 'string',
type: 'text', mode: ['create','edit'], node: 'schema',
control: 'node-list-by-id'
cache_node: 'database', control: 'node-list-by-id'
},{
id: 'description', label:'{{ _('Comment') }}', cell: 'string',
type: 'multiline', cellHeaderClasses: 'width_percent_50'
},{
id: 'template', label: '{{ _('Template')}}',type: 'text',
disabled: function(m) { return !m.isNew(); }, url: 'fetch_templates',
group: '{{ _('Definition') }}',control: 'node-ajax-options'
group: '{{ _('Definition') }}', control: 'node-ajax-options',
cache_node: 'database'
},{
id: 'options', label: '{{ _('Option') }}', type: 'collection',
group: '{{ _('Options') }}', control: 'unique-col-collection',
@@ -182,4 +183,4 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
}
return pgBrowser.Nodes['coll-fts_dictionary'];
});
});

View File

@@ -93,27 +93,33 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
id: 'prsstart', label: '{{ _('Start function')}}',
type: 'text', disabled: function(m) { return !m.isNew(); },
control: 'node-ajax-options', url: 'start_functions',
group: '{{ _('Definition') }}'
group: '{{ _('Definition') }}', cache_level: 'database',
cache_node: 'schema'
},{
id: 'prstoken', label: '{{ _('Get next token function')}}',
type: 'text', disabled: function(m) { return !m.isNew(); },
control: 'node-ajax-options', url: 'token_functions',
group: '{{ _('Definition') }}'
group: '{{ _('Definition') }}', cache_level: 'database',
cache_node: 'schema'
},{
id: 'prsend', label: '{{ _('End function')}}',
type: 'text', disabled: function(m) { return !m.isNew(); },
control: 'node-ajax-options', url: 'end_functions',
group: '{{ _('Definition') }}'
group: '{{ _('Definition') }}', cache_level: 'database',
cache_node: 'schema',
cache_node: 'schema'
},{
id: 'prslextype', label: '{{ _('Lextypes function')}}',
type: 'text', disabled: function(m) { return !m.isNew(); },
control: 'node-ajax-options', url: 'lextype_functions',
group: '{{ _('Definition') }}'
group: '{{ _('Definition') }}', cache_level: 'database',
cache_node: 'schema'
},{
id: 'prsheadline', label: '{{ _('Headline function')}}',
type: 'text', disabled: function(m) { return !m.isNew(); },
control: 'node-ajax-options', url: 'headline_functions',
group: '{{ _('Definition') }}'
group: '{{ _('Definition') }}', cache_level: 'database',
cache_node: 'schema'
}],
/*
@@ -192,4 +198,4 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
}
return pgBrowser.Nodes['coll-fts_parser'];
});
});

View File

@@ -83,13 +83,16 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
id: 'description', label:'{{ _('Comment') }}', cell: 'string',
type: 'multiline', cellHeaderClasses: 'width_percent_50'
},{
id: 'tmplinit', label: '{{ _('Init function')}}', group: '{{ _('Definition') }}',
type: 'text', disabled: function(m) { return !m.isNew(); },
control: 'node-ajax-options', url: 'get_init'
id: 'tmplinit', label: '{{ _('Init function')}}',
group: '{{ _('Definition') }}', type: 'text', disabled: function(m) {
return !m.isNew();
}, control: 'node-ajax-options', url: 'get_init',
cache_level: 'database', cache_node: 'schema'
},{
id: 'tmpllexize', label: '{{ _('Lexize function')}}', group: '{{ _('Definition') }}',
type: 'text', disabled: function(m) { return !m.isNew(); },
control: 'node-ajax-options', url: 'get_lexize'
control: 'node-ajax-options', url: 'get_lexize', cache_level: 'database',
cache_node: 'schema'
}],
/*
@@ -132,4 +135,4 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
}
return pgBrowser.Nodes['coll-fts_template'];
});
});

View File

@@ -257,12 +257,12 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
id: 'encoding', label: '{{ _('Encoding') }}',
editable: false, type: 'text', group: 'Definition',
disabled: function(m) { return !m.isNew(); }, url: 'get_encodings',
control: 'node-ajax-options'
control: 'node-ajax-options', cache_level: 'server'
},{
id: 'template', label: '{{ _('Template') }}',
editable: false, type: 'text', group: 'Definition',
disabled: function(m) { return !m.isNew(); },
control: 'node-list-by-name', node: 'database'
control: 'node-list-by-name', node: 'database', cache_level: 'server'
},{
id: 'spcname', label: '{{ _('Tablespace') }}',
editable: false, type: 'text', group: 'Definition',
@@ -275,12 +275,12 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
id: 'datcollate', label: '{{ _('Collation') }}',
editable: false, type: 'text', group: 'Definition',
disabled: function(m) { return !m.isNew(); }, url: 'get_ctypes',
control: 'node-ajax-options'
control: 'node-ajax-options', cache_level: 'server'
},{
id: 'datctype', label: '{{ _('Character Type') }}',
editable: false, type: 'text', group: 'Definition',
disabled: function(m) { return !m.isNew(); }, url: 'get_ctypes',
control: 'node-ajax-options'
control: 'node-ajax-options', cache_level: 'server'
},{
id: 'datconnlimit', label: '{{ _('Connection Limit') }}',
editable: false, type: 'int', group: 'Definition', min: -1

View File

@@ -3,7 +3,7 @@ SELECT
has_database_privilege(db.oid, 'CREATE') as cancreate, datdba as owner
FROM
pg_database db
LEFT OUTER JOIN pg_tablespace ta ON db.dattablespace = ta.oid{% if did %}
LEFT OUTER JOIN pg_tablespace ta ON db.dattablespace = ta.oid
WHERE {% if did %}
db.oid = {{ did|qtLiteral }}::OID{% else %}
db.oid > {{ last_system_oid }}::OID