Misc fixes and additions for pgAgent support:

- Added DatetimepickerControl, MomentCell (using moment.js)
- Used the 'DatetimepickerControl' in Role (Also - resolved an issue, when unset the datetime for 'Valid Until'.)
- Added a 'Select All/Unselect All' adaptor for Select2 used by pgAgent nodes.
- Fixed an issue with SubNodeCollectionControl, which was not starting the modification session of the child model, when created default value for collection is not null/undefined. And, hence - validation on the child model was not working.
- Fixed a memory leak with SqlFieldControl, and SqlTabControl, which was not releasing the CodeMirror properly.
This commit is contained in:
Ashesh Vashi
2016-09-22 15:27:59 +01:00
committed by Dave Page
parent a113b43a1f
commit 163ae4d53d
19 changed files with 16304 additions and 75 deletions

View File

@@ -6,7 +6,6 @@
# This software is released under the PostgreSQL Licence
#
##########################################################################
import datetime
import re
from functools import wraps
@@ -14,6 +13,7 @@ import pgadmin.browser.server_groups as sg
import simplejson as json
from flask import render_template, request, jsonify, current_app
from flask_babel import gettext as _
import dateutil.parser as dateutil_parser
from pgadmin.browser.collection import CollectionNodeModule
from pgadmin.browser.utils import PGChildNodeView
from pgadmin.utils.ajax import make_json_response, \
@@ -142,11 +142,10 @@ class RoleView(PGChildNodeView):
if data[u'rolvaliduntil'] is not None and \
data[u'rolvaliduntil'] != '' and \
len(data[u'rolvaliduntil']) > 0:
date = datetime.datetime.strptime(
data[u'rolvaliduntil'], '%m/%d/%Y'
)
data[u'rolvaliduntil'] = date.strftime("%Y-%m-%d")
except Exception as e:
data[u'rolvaliduntil'] = dateutil_parser.parse(
data[u'rolvaliduntil']
).isoformat()
except Exception:
return precondition_required(
_("Date format is invalid.")
)
@@ -640,8 +639,6 @@ rolmembership:{
'admin': True if role.group(1) == '1' else False
})
row['rolmembership'] = res
if row['rolvaliduntil'] is not None:
row['rolvaliduntil'] = row['rolvaliduntil'].split(' ')[0]
if 'seclabels' in row and row['seclabels'] is not None:
res = []
for sec in row['seclabels']:

View File

@@ -239,7 +239,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backform) {
});
var msg = '{{ _('Select the checkbox for roles to include WITH ADMIN OPTION.') }}';
this.$el.find('div.note').html("<span>NOTE:<br/>" + msg + "</span>");
this.$el.find('div.note').html("<span>NOTE: " + msg + "</span>");
return this;
},
@@ -404,20 +404,20 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backform) {
}
},{
id: 'rolvaliduntil', disabled: 'readonly', type: 'text',
group: '{{ _('Definition') }}', label: '{{ _('Account Expires') }}',
cell: 'string', mode: ['properties', 'edit', 'create'], retype: true,
deps: ['rolcanlogin'], options: { autoclose: true }, control: 'datepicker'
group: '{{ _('Definition') }}', label: '{{ _('Account expires') }}',
mode: ['properties', 'edit', 'create'], control: 'datetimepicker',
deps: ['rolcanlogin']
},{
id: 'rolconnlimit', type: 'int', group: '{{ _('Definition') }}',
label: '{{ _('Connection Limit') }}', cell: 'number',
label: '{{ _('Connection limit') }}', cell: 'number',
mode: ['properties', 'edit', 'create'], disabled: 'readonly'
},{
id: 'rolcanlogin', label:'{{ _('Can login?') }}', type: 'switch',
group: '{{ _('Role Privileges') }}', options: switchOptions,
group: '{{ _('Privileges') }}', options: switchOptions,
disabled: 'readonly'
},{
id: 'rolsuper', label:'{{ _('Superuser') }}', type: 'switch',
group: '{{ _('Role Privileges') }}', options: switchOptions,
group: '{{ _('Privileges') }}', options: switchOptions,
control: Backform.SwitchControl.extend({
onChange: function() {
Backform.SwitchControl.prototype.onChange.apply(this, arguments);
@@ -430,7 +430,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backform) {
disabled: 'readonly'
},{
id: 'rolcreaterole', label:'{{ _('Create roles?') }}',
group: '{{ _('Role Privileges') }}', type: 'switch',
group: '{{ _('Privileges') }}', type: 'switch',
options: switchOptions, disabled: 'readonly'
},{
id: 'description', label:'{{ _('Comments') }}', type: 'multiline',
@@ -438,26 +438,26 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backform) {
options: switchOptions, disabled: 'readonly'
},{
id: 'rolcreatedb', label:'{{ _('Create databases?') }}',
group: '{{ _('Role Privileges') }}', type: 'switch',
group: '{{ _('Privileges') }}', type: 'switch',
options: switchOptions, disabled: 'readonly'
},{
id: 'rolcatupdate', label:'{{ _('Update Catalog?') }}',
type: 'switch', max_version: 90400, options: switchOptions,
group: '{{ _('Role Privileges') }}', disabled: function(m) {
group: '{{ _('Privileges') }}', disabled: function(m) {
return (m.get('read_only') || (!m.get('rolsuper')));
}
},{
id: 'rolinherit', group: '{{ _('Role Privileges') }}',
id: 'rolinherit', group: '{{ _('Privileges') }}',
label:'{{ _('Inherit rights from the parent roles?') }}',
type: 'switch', options: switchOptions, disabled: 'readonly'
},{
id: 'rolreplication', group: '{{ _('Role Privileges') }}',
id: 'rolreplication', group: '{{ _('Privileges') }}',
label:'{{ _('Can initiate streaming replication and backups?') }}',
type: 'switch', min_version: 90100, options: switchOptions,
disabled: 'readonly'
},{
id: 'rolmembership', label: '{{ _('Role Membership') }}',
group: '{{ _('Role Privileges') }}', type: 'collection',
id: 'rolmembership', label: '{{ _('Roles') }}',
group: '{{ _('Membership') }}', type: 'collection',
cell: 'string', disabled: 'readonly',
mode: ['properties', 'edit', 'create'],
control: RoleMembersControl, model: pgBrowser.Node.Model.extend({

View File

@@ -35,9 +35,8 @@ ALTER {% if rolCanLogin %}USER{% else %}ROLE{% endif %} {{ conn|qtIdent(rolname)
NOREPLICATION{% endif %}{% endif %}{% if 'rolconnlimit' in data and data.rolconnlimit is number and data.rolconnlimit >= -1 %}
CONNECTION LIMIT {{ data.rolconnlimit }}
{% endif %}{% if 'rolvaliduntil' in data and data.rolvaliduntil %}
VALID UNTIL {% if data.rolvaliduntil is not none %}{{ data.rolvaliduntil|qtLiteral }}{% else %}'infinity'
{% endif %}{% if 'rolvaliduntil' in data %}
VALID UNTIL {% if data.rolvaliduntil %}{{ data.rolvaliduntil|qtLiteral }}{% else %}'infinity'
{% endif %}{% endif %}{% if 'rolpassword' in data %}
PASSWORD{% if data.rolpassword is none %} NULL{% else %}{% if dummy %} 'xxxxxx'{% else %} {{ data.rolpassword|qtLiteral }}{% endif %}{% endif %}{% endif %};{% endif %}

View File

@@ -31,9 +31,9 @@ ALTER {% if rolCanLogin %}USER{% else %}ROLE{% endif %} {{ conn|qtIdent(rolname)
NOINHERIT{% endif %}{% endif %}{% if 'rolconnlimit' in data and data.rolconnlimit is number and data.rolconnlimit >= -1 %}
CONNECTION LIMIT {{ data.rolconnlimit }}
{% endif %}{% if 'rolvaliduntil' in data and data.rolvaliduntil %}
{% endif %}{% if 'rolvaliduntil' in data %}
VALID UNTIL {% if data.rolvaliduntil is not none %}{{ data.rolvaliduntil|qtLiteral }}{% else %}'infinity'
VALID UNTIL {% if data.rolvaliduntil %}{{ data.rolvaliduntil|qtLiteral }}{% else %}'infinity'
{% endif %}{% endif %}{% if 'rolpassword' in data %}
PASSWORD{% if data.rolpassword is none %} NULL{% else %}{% if dummy %} 'xxxxxx'{% else %} {{ data.rolpassword|qtLiteral }}{% endif %}{% endif %}{% endif %};{% endif %}

View File

@@ -36,9 +36,9 @@ ALTER {% if rolCanLogin %}USER{% else %}ROLE{% endif %} {{ conn|qtIdent(rolname)
NOREPLICATION{% endif %}{% endif %}{% if 'rolconnlimit' in data and data.rolconnlimit is number and data.rolconnlimit >= -1 %}
CONNECTION LIMIT {{ data.rolconnlimit }}
{% endif %}{% if 'rolvaliduntil' in data and data.rolvaliduntil %}
{% endif %}{% if 'rolvaliduntil' in data %}
VALID UNTIL {% if data.rolvaliduntil is not none %}{{ data.rolvaliduntil|qtLiteral }}{% else %}'infinity'
VALID UNTIL {% if data.rolvaliduntil %}{{ data.rolvaliduntil|qtLiteral }}{% else %}'infinity'
{% endif %}{% endif %}{% if 'rolpassword' in data %}
PASSWORD{% if data.rolpassword is none %} NULL{% else %}{% if dummy %} 'xxxxxx'{% else %} {{ data.rolpassword|qtLiteral }}{% endif %}{% endif %}{% endif %};{% endif %}

View File

@@ -36,9 +36,9 @@ ALTER {% if rolCanLogin %}USER{% else %}ROLE{% endif %} {{ conn|qtIdent(rolname)
NOREPLICATION{% endif %}{% endif %}{% if 'rolconnlimit' in data and data.rolconnlimit is number and data.rolconnlimit >= -1 %}
CONNECTION LIMIT {{ data.rolconnlimit }}
{% endif %}{% if 'rolvaliduntil' in data and data.rolvaliduntil %}
{% endif %}{% if 'rolvaliduntil' in data %}
VALID UNTIL {% if data.rolvaliduntil is not none %}{{ data.rolvaliduntil|qtLiteral }}{% else %}'infinity'
VALID UNTIL {% if data.rolvaliduntil %}{{ data.rolvaliduntil|qtLiteral }}{% else %}'infinity'
{% endif %}{% endif %}{% if 'rolpassword' in data %}
PASSWORD{% if data.rolpassword is none %} NULL{% else %}{% if dummy %} 'xxxxxx'{% else %} {{ data.rolpassword|qtLiteral }}{% endif %}{% endif %}{% endif %};{% endif %}