[pgadmin-hackers] [pgAdmin4] [Patch]: Grant Wizard

2016-03-03 Thread Surinder Kumar
Hi,

PFA patch for Grant Wizard.

Before applying grant wizard patch:

1. Apply patch for "wizard JS file" which Khushboo had shared with
Ashesh personally.
I am using that patch with few changes in that. Ashesh will
review
and commit that patch.

2. Apply patches of "Sequence" and "Functions" macros.


Please review the patch and Let me know for any comments.


Thanks
Surinder Kumar


grant_wizard.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] PATCH: Preferences/Options dialog

2016-03-03 Thread Dave Page
Hi

On Mon, Feb 29, 2016 at 6:22 PM, Ashesh Vashi  wrote:

> Hi Dave,
>
> Please find the patch adding support for the preferences/options dialog.
> Initial patch was shared by Khushboo with me, but - I made some design
> changes.
>
> With this patch:
> * Each preferences can be saved/retrieved per module basis.
> * An object is created which represent that module in the preferences by
> default.
> * Module needs to override the register_preferences(...) method to
> register certain preference.
> * You can access other modules preference using static methods of the
> preferences.
> * A collection module (PGChildModule) will register show_node_,
> and also refers the 'show_system_objects' in it, which can be accessed
> using self.pref_show_system_objects, or can use class property
> 'show_system_obejcts', also there is one more property 'show_node', which
> uses the 'pref_show_node' object of that module.
>

I've done an initial review:

- The patch has bit-rotted, and needs to be rebased.

- web/pgadmin/preferences/__init__.py has an out of date copyright notice
with no blank line after it, and no pydoc comment to introduce the file.

I don't see anything else that seems horrendously wrong at the moment, but
will look more closely once the rebase has been done.

Thanks.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


[pgadmin-hackers] pgAdmin 4 commit: In the current Backgrid implementation, a cell can be

2016-03-03 Thread Dave Page
In the current Backgrid implementation, a cell can be made editable through 
"editable: true/false" settings. It takes only a boolean value.

Add support for a function that can be set as an editable option value.

For Example:

editable: function(m) { return false; }

Branch
--
master

Details
---
http://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=789ece89fb3dfba660801b03446c5b8bf6066154
Author: Khushboo Vashi 

Modified Files
--
web/pgadmin/static/js/backform.pgadmin.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] [pgAdmin4][Patch]: Backgrid cell editable settings

2016-03-03 Thread Dave Page
Thanks - applied.

On Thu, Mar 3, 2016 at 6:44 AM, Khushboo Vashi
 wrote:
> Hi,
>
> In the current Backgrid implementation, the cell can be made editable
> through "editable: true/false" settings. It takes only boolean value.
>
> So, added support for the function, that can be set as an editable option
> value.
>
> For Example:
>
> editable: function(m) { return false; }
>
> Please find attached patch for the same.
>
> Thanks,
> Khushboo
>
>
>
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] pgAdmin 4 commit: Security Labels, Privileges and Variables macros for

2016-03-03 Thread Dave Page
Security Labels, Privileges and Variables macros for the functions modules.

Usage of the macros:

Security labels:

SECLABLE.SET(conn, 'FUNCTION', func_name, provider, security_label, 
func_schema, func_args)

SECLABLE.UNSET(conn, 'FUNCTION', func_name, provider, func_schema, func_args)

Privileges:

PRIVILEGE.SET(conn, 'FUNCTION', grantee, func_name, privileges_without_grant, 
privileges_with_grant, func_schema, func_args)

PRIVILEGE.UNSETALL(conn, 'FUNCTION', grantee, func_name, func_schema, func_args)

Variables:

VARIABLES.SET(conn, 'FUNCTION', func_name, options, func_schema, func_args)

VARIABLES.UNSET(conn, 'FUNCTION', func_name, options, func_schema, func_args)

Branch
--
master

Details
---
http://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=3ff06da772b27274dc28702a09abe7eece37a38d
Author: Khushboo Vashi 

Modified Files
--
.../schemas/templates/macros/functions/privilege.macros| 14 ++
.../schemas/templates/macros/functions/security.macros |  9 +
.../schemas/templates/macros/functions/variable.macros | 13 +
3 files changed, 36 insertions(+)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] [pgAdmin4][Patch]: Macros for the functions module

2016-03-03 Thread Dave Page
Thanks - applied.

On Thu, Mar 3, 2016 at 7:31 AM, Khushboo Vashi
 wrote:
> Hi,
>
> Please find attached patch for the Security Labels, Privileges and Variables
> macros for the functions modules.
>
>
> Usage of the macros:
>
>
> Security labels:
>
> SECLABLE.SET(conn, 'FUNCTION', func_name, provider, security_label,
> func_schema, func_args)
>
> SECLABLE.UNSET(conn, 'FUNCTION', func_name, provider, func_schema,
> func_args)
>
> Privileges:
>
> PRIVILEGE.SET(conn, 'FUNCTION', grantee, func_name,
> privileges_without_grant, privileges_with_grant, func_schema, func_args)
>
> PRIVILEGE.UNSETALL(conn, 'FUNCTION', grantee, func_name, func_schema,
> func_args)
>
> Variables:
>
> VARIABLES.SET(conn, 'FUNCTION', func_name, options, func_schema, func_args)
>
> VARIABLES.UNSET(conn, 'FUNCTION', func_name, options, func_schema,
> func_args)
>
>
> Thanks,
> Khushboo
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] pgAdmin 4 commit: Security Label and ACL template macros:

2016-03-03 Thread Dave Page
Security Label and ACL template macros:

Way to use in template:

1) Security labels:

SECLABLE.SET(conn, object_type, object_name, provider, security_label,
object.schema)

SECLABLE.UNSET(conn, object_type, object_name, provider, object.schema)

2) Privileges:

PRIVILEGE.SET(conn, object_type, grantee, object_name,
privileges_without_grant, privileges_with_grant,
object.schema)

PRIVILEGE.UNSETALL(conn, object_type, grantee, object_name, schema)

privileges_without_grant = comma separated string of privileges.
privileges_with_grant = comma separated string of privileges.

Branch
--
master

Details
---
http://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=d2e372114b538067956aa06ca8d7bba27e9bac11
Author: Harshal Dhumal 

Modified Files
--
.../schemas/templates/macros/schemas/privilege.macros  | 14 ++
.../schemas/templates/macros/schemas/security.macros   |  9 +
2 files changed, 23 insertions(+)


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] New macros for sequence node [pgadmin4]

2016-03-03 Thread Dave Page
Thanks - patch applied.

On Wed, Feb 10, 2016 at 2:00 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> + Usage of macros
>
>
> Way to use in template:
>
> *1] Security labels:*
>
> SECLABLE.SET(conn, object_type, object_name, provider, security_label,
> object.schema)
>
> SECLABLE.UNSET(conn, object_type, object_name, provider, object.schema)
>
> *2] Privileges:*
>
> PRIVILEGE.SET(conn, object_type, grantee, object_name,
> privileges_without_grant, privileges_with_grant,
> object.schema)
>
> PRIVILEGE.UNSETALL(conn, object_type, grantee, object_name, schema)
>
>
>
> privileges_without_grant = comma separated string of privileges.
> privileges_with_grant = comma separated string of privileges.
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB 
>
> On Wed, Feb 10, 2016 at 6:57 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch for schema macros for security and privilege.
>>
>> Now I have moved macros related to schema and its child object under
>> schemas/templates/macros/schemas folder
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB 
>>
>> On Wed, Feb 10, 2016 at 5:41 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> Here is updated patch for macros. I have added required validation in
>>> macros.
>>>
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer *
>>>
>>>
>>>
>>> EenterpriseDB 
>>>
>>> On Wed, Feb 10, 2016 at 1:06 PM, Ashesh Vashi <
>>> ashesh.va...@enterprisedb.com> wrote:
>>>
 On Tue, Feb 9, 2016 at 3:48 PM, Harshal Dhumal <
 harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA of macros  (privilege, security) for sequence node.
>
> Also fixed minor issue in security macro (removed unwanted qtIdent for
> provider)
>
 This is not allowed.
 We can't pass on the data coming from the client blindly to the server.
 It is an area, which can introduce the SQL injection in our code.

 Hence - I can't allowed that.

 --

 Thanks & Regards,

 Ashesh Vashi
 EnterpriseDB INDIA: Enterprise PostgreSQL Company
 


 *http://www.linkedin.com/in/asheshvashi*
 

>
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB 
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
>

>>>
>>
>


-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: [pgadmin-hackers] PATCH: Preferences/Options dialog

2016-03-03 Thread Ashesh Vashi
On Thu, Mar 3, 2016 at 7:09 PM, Dave Page  wrote:

> Hi
>
> On Mon, Feb 29, 2016 at 6:22 PM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Please find the patch adding support for the preferences/options dialog.
>> Initial patch was shared by Khushboo with me, but - I made some design
>> changes.
>>
>> With this patch:
>> * Each preferences can be saved/retrieved per module basis.
>> * An object is created which represent that module in the preferences by
>> default.
>> * Module needs to override the register_preferences(...) method to
>> register certain preference.
>> * You can access other modules preference using static methods of the
>> preferences.
>> * A collection module (PGChildModule) will register
>> show_node_, and also refers the 'show_system_objects' in it,
>> which can be accessed using self.pref_show_system_objects, or can use class
>> property 'show_system_obejcts', also there is one more property
>> 'show_node', which uses the 'pref_show_node' object of that module.
>>
>
> I've done an initial review:
>
Thanks.

>
> - The patch has bit-rotted, and needs to be rebased.
>
Done.

>
> - web/pgadmin/preferences/__init__.py has an out of date copyright notice
> with no blank line after it, and no pydoc comment to introduce the file.
>
Done.

>
> I don't see anything else that seems horrendously wrong at the moment, but
> will look more closely once the rebase has been done.
>
Please find the updated patch.

--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company



*http://www.linkedin.com/in/asheshvashi*


>
> Thanks.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


preferences_v3.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] [pgAdmin IV] PATCH: Add support for the notices/messages from the backend server.

2016-03-03 Thread Ashesh Vashi
Hi,

This patch implements the supports in the connection driver to fetch the
notices/messages returned by the database server. This will be used by
tools like debugger, sql-editor, etc.

--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company



*http://www.linkedin.com/in/asheshvashi*



postgresql_driver_notices.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] Numeric control optionally allow null values [pgadmin4]

2016-03-03 Thread Harshal Dhumal
Hi,


Please find attached patch for numeric control with optionally allow null
values

Null values: undefined/empty string/null
By default numeric control value can not be null. Use flag *allowNull: true*
to allow null values.

Usage:

id: 'fillfactor', label: '{{ _('Fill factor') }}', deps: ['index'],
type: 'numeric', group: '{{ _('Definition') }}', allowNull: true,



-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB 
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 4346156..82963bb 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1333,49 +1333,56 @@
 checkNumeric: function(e) {
   var field = _.defaults(this.field.toJSON(), this.defaults),
   attrArr = this.field.get("name").split('.'),
+  allowNull = this.field.get("allowNull"),
   name = attrArr.shift(),
   value = this.getValueFromDOM(),
   min_value = field.min,
   max_value = field.max,
   isValid = true,
-  intPattern = new RegExp("^-?[0-9]+(\.?[0-9]*)?$"),
-  isMatched = intPattern.test(value);
+  intPattern = new RegExp("^-?[0-9]+(\.?[0-9]*)?$");
 
-  // Below logic will validate input
-  if (!isMatched) {
-isValid = false;
-this.model.errorModel.unset(name);
-this.model.errorModel.set(
-name,
-S(pgAdmin.Browser.messages.MUST_BE_NUM).sprintf(
-  field.label
-  ).value()
-);
-  }
+  if (allowNull && (_.isUndefined(value) ||
+   _.isNull(value) || value == '')) {
+// Check for undefined/empty/null value if it's allowed.
+value = null;
+  } else {
+var isMatched = intPattern.test(value);
+// Below logic will validate input
+if (!isMatched) {
+  isValid = false;
+  this.model.errorModel.unset(name);
+  this.model.errorModel.set(
+  name,
+  S(pgAdmin.Browser.messages.MUST_BE_NUM).sprintf(
+field.label
+).value()
+  );
+}
 
-  // Below will check if entered value is in-between min & max range
-  if (isValid && (!_.isUndefined(min_value) && value < min_value)) {
-isValid = false;
-this.model.errorModel.unset(name);
-this.model.errorModel.set(
-name,
-S(pgAdmin.Browser.messages.MUST_GR_EQ).sprintf(
-  field.label,
-  min_value
-  ).value()
-);
-  }
+// Below will check if entered value is in-between min & max range
+if (isValid && (!_.isUndefined(min_value) && value < min_value)) {
+  isValid = false;
+  this.model.errorModel.unset(name);
+  this.model.errorModel.set(
+  name,
+  S(pgAdmin.Browser.messages.MUST_GR_EQ).sprintf(
+field.label,
+min_value
+).value()
+  );
+}
 
-  if (isValid && (!_.isUndefined(max_value) && value > max_value)) {
-isValid = false;
-this.model.errorModel.unset(name);
-this.model.errorModel.set(
-name,
-S(pgAdmin.Browser.messages.MUST_LESS_EQ).sprintf(
-  field.label,
-  max_value
-  ).value()
-);
+if (isValid && (!_.isUndefined(max_value) && value > max_value)) {
+  isValid = false;
+  this.model.errorModel.unset(name);
+  this.model.errorModel.set(
+  name,
+  S(pgAdmin.Browser.messages.MUST_LESS_EQ).sprintf(
+field.label,
+max_value
+).value()
+  );
+}
   }
 
   // After validation we need to set that value into model (only if all flags are true)

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Numeric control optionally allow null values [pgadmin4]

2016-03-03 Thread Harshal Dhumal
Hi,

Please find attached patch for numeric and integer control with optionally
null value support.

Usage:

1] Integer

id: 'fillfactor', label: '{{ _('Fill factor') }}', deps: ['index'],
type: 'int', group: '{{ _('Definition') }}', allowNull: true,


2] Numeric

id: 'fillfactor', label: '{{ _('Fill factor') }}', deps: ['index'],
type: 'numeric', group: '{{ _('Definition') }}', allowNull: true,






-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB 

On Fri, Mar 4, 2016 at 10:55 AM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
>
> Please find attached patch for numeric control with optionally allow null
> values
>
> Null values: undefined/empty string/null
> By default numeric control value can not be null. Use flag *allowNull:
> true* to allow null values.
>
> Usage:
>
> id: 'fillfactor', label: '{{ _('Fill factor') }}', deps: ['index'],
> type: 'numeric', group: '{{ _('Definition') }}', allowNull: true,
>
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB 
>
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 4346156..7497f4f 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1240,51 +1240,56 @@
 checkInt: function(e) {
   var field = _.defaults(this.field.toJSON(), this.defaults),
   attrArr = this.field.get("name").split('.'),
+  allowNull = this.field.get("allowNull"),
   name = attrArr.shift(),
   value = this.getValueFromDOM(),
   min_value = field.min,
   max_value = field.max,
   isValid = true,
-  intPattern = new RegExp("^-?[0-9]*$"),
-  isMatched = intPattern.test(value);
-
-  // Below logic will validate input
-  if (!isMatched) {
-isValid = false;
-this.model.errorModel.unset(name);
-this.model.errorModel.set(
-name,
-S(pgAdmin.Browser.messages.MUST_BE_INT).sprintf(
-  field.label
-  ).value()
-);
-  }
+  intPattern = new RegExp("^-?[0-9]+$");
 
-  // Below will check if entered value is in-between min & max range
-  if (isValid && (!_.isUndefined(min_value) && value < min_value)) {
-isValid = false;
-this.model.errorModel.unset(name);
-this.model.errorModel.set(
-name,
-S(pgAdmin.Browser.messages.MUST_GR_EQ).sprintf(
-  field.label,
-  min_value
-  ).value()
-);
-  }
+  if (allowNull && (_.isUndefined(value) ||
+   _.isNull(value) || value == '')) {
+// Check for undefined/empty/null value if it's allowed.
+value = null;
+  } else {
+// Below logic will validate input
+if (!intPattern.test(value)) {
+  isValid = false;
+  this.model.errorModel.unset(name);
+  this.model.errorModel.set(
+  name,
+  S(pgAdmin.Browser.messages.MUST_BE_INT).sprintf(
+field.label
+).value()
+  );
+}
 
-  if (isValid && (!_.isUndefined(max_value) && value > max_value)) {
-isValid = false;
-this.model.errorModel.unset(name);
-this.model.errorModel.set(
-name,
-S(pgAdmin.Browser.messages.MUST_LESS_EQ).sprintf(
-  field.label,
-  max_value
-  ).value()
-);
-  }
+// Below will check if entered value is in-between min & max range
+if (isValid && (!_.isUndefined(min_value) && value < min_value)) {
+  isValid = false;
+  this.model.errorModel.unset(name);
+  this.model.errorModel.set(
+  name,
+  S(pgAdmin.Browser.messages.MUST_GR_EQ).sprintf(
+field.label,
+min_value
+).value()
+  );
+}
 
+if (isValid && (!_.isUndefined(max_value) && value > max_value)) {
+  isValid = false;
+  this.model.errorModel.unset(name);
+  this.model.errorModel.set(
+  name,
+  S(pgAdmin.Browser.messages.MUST_LESS_EQ).sprintf(
+field.label,
+max_value
+).value()
+  );
+}
+  }
   // After validation we need to set that value into model (only if all flags are true)
   if (isValid) {
 this.stopListening(this.model, "change:" + name, this.render);
@@ -1333,49 +1338,55 @@
 checkNumeric: function(e) {
   var field = _.defaults(this.field.toJSON(), this.defaults),
   attrArr = this.field.get("name").split('.'),
+  allowNull = this.field.get("allowNull"),
   name = attrArr.shift(),
   value = this.getValueFromDOM(),
   min_value = field.min,
   max_value = field.max,