[pgadmin-hackers] backgrid select2 cell

2016-01-06 Thread Harshal Dhumal
Hi,

Please find patch for backgrid select2 cell

Usage:

schema: [
{id: 'name', label:'Name', type:'text', cell:
Backgrid.Extension.Select2Cell, editable: true,
optionValues: [['Allow','allow'], ['Prefer','prefer'],
['Require','require'], ['Disable','disable']],
select2:{placeholder: "Select an option"}},
.
.



-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
index b12c089..de73b63 100644
--- a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
+++ b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
@@ -289,6 +289,78 @@
 }
   });
 
+
+  /*
+   *  Select2Cell for backgrid.
+   */
+  var Select2Cell = Backgrid.Extension.Select2Cell = Backgrid.Cell.extend({
+
+className: "select2-cell",
+
+events: {
+  "change": "onSave",
+  "select2:unselect": "onSave"
+},
+render: function () {
+  var col = _.defaults(this.column.toJSON(), this.defaults),
+  model = this.model, column = this.column,
+  editable = Backgrid.callByNeed(col.editable, column, model),
+  optionValues = this.column.get('optionValues');
+
+  this.$el.empty();
+
+  if (!_.isArray(optionValues)) throw new TypeError("optionValues must be an array");
+
+  /* Add empty option as Select2 requires any empty '' for
+   * some of its functionality to work.
+   */
+  optionValues.unshift([null, null]);
+
+  var optionText = null,
+  optionValue = null,
+  template = _.template('><%- text %>', null, {variable: null}),
+  model = this.model,
+  selectedValues = model.get(this.column.get("name"));
+
+  delete this.$select;
+
+  this.$select = $("", {tabIndex: -1}),
+  this.$el.append(this.$select);
+
+  for (var i = 0; i < optionValues.length; i++) {
+var optionValue = optionValues[i];
+
+if (_.isArray(optionValue)) {
+  optionText  = optionValue[0];
+  optionValue = optionValue[1];
+
+  this.$select.append(template({
+text: optionText,
+value: optionValue,
+selected: _.indexOf(selectedValues, optionValue) > -1
+  }));
+} else {
+  throw new TypeError("optionValues elements must be a name-value pair.");
+}
+  }
+  // Initialize select2 control.
+  this.$select.select2(_.defaults(
+  {'disabled': !editable}, col.select2));
+
+  this.delegateEvents();
+
+  return this;
+},
+
+/**
+   Saves the value of the selected option to the model attribute.
+*/
+onSave: function (e) {
+  var model = this.model;
+  var column = this.column;
+  model.set(column.get("name"), this.$select.val(),{silent:true});
+}
+  });
   return Backgrid;
 
 }));

-- 
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] backform select2 control

2016-01-05 Thread Harshal Dhumal
Hi,

Please find patch for backform select2 and select2ajaxoptoins controls

Usage:

schema: [{
  id: 'name', label: '{{ _('Name') }}', cell: 'string',
  type: 'select2', select2:{tags: "true", placeholder: "Select an
option", allowClear: true}
}
.
.
.




-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index a251200..c9729a8 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -174,5 +174,53 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
 })
   });
+
+  /*
+   *  Backform Select2AjaxOptions control.
+   */
+  var Select2AjaxOptionsControl = Backform.Select2AjaxOptionsControl = Backform.NodeAjaxOptionsControl.extend({
+render: function() {
+
+  var options = this.field.get('options') || [];
+
+  /* Add empty option as Select2 requires any empty '' for
+   * some of its functionality to work.
+   */
+  options.unshift({label: undefined, value: undefined});
+
+  Backform.NodeAjaxOptionsControl.prototype.render.apply(this, arguments);
+
+  var col = _.defaults(this.field.toJSON(), this.defaults)
+  // Initialize select2 control.
+  this.$el.find("select").select2(col.select2);
+  return this;
+}
+  });
   return Backform.NodeListControl;
 });
diff --git a/web/pgadmin/static/css/overrides.css b/web/pgadmin/static/css/overrides.css
index 6d0f662..3ec4d6f 100755
--- a/web/pgadmin/static/css/overrides.css
+++ b/web/pgadmin/static/css/overrides.css
@@ -611,3 +611,20 @@ table.backgrid tr.new {
 right: 0px;
 bottom :0;
 }
+.select2 {
+  width: 100% !important;
+}
+.select2-search__field, select{
+  background:inherit !important;
+}
\ No newline at end of file
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 7423909..86b9416 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -74,7 +74,8 @@
 'multiline': ['textarea', 'textarea', 'string'],
 'collection': ['sub-node-collection', 'sub-node-collection', 'string'],
 'uniqueColCollection': ['unique-col-collection', 'unique-col-collection', 'string'],
-'switch' : 'switch'
+'switch' : 'switch',
+'select2': 'select2',
   };
@@ -1174,5 +1210,25 @@
 return groups;
   }
+  /*
+   *  Backform Select2 control.
+   */
+  var Select2Control = Backform.Select2Control = Backform.SelectControl.extend({
+render: function() {
+  var options = this.field.get('options') || [];
+  /* Add empty option as Select2 requires any empty '' for
+   * some of its functionality to work.
+   */
+
+  options.unshift({label: undefined, value: undefined});
+
+  Backform.SelectControl.prototype.render.apply(this, arguments);
+
+  var col = _.defaults(this.field.toJSON(), this.defaults)
+  // Initialize select2 control.
+  this.$el.find("select").select2(col.select2);
+  return this;
+}
+  });
   return Backform;
 }));

-- 
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] backgrid select2 cell fixed issue for optionsValues

2016-01-06 Thread Harshal Dhumal
Hi,

Please find minor patch to fix optionsValues for backgrid cell.

*Issue:*
Fixed issue when accessing OptionValues from view



-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
index 41143a3..56932f2 100644
--- a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
+++ b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
@@ -310,7 +310,7 @@
   var col = _.defaults(this.column.toJSON(), this.defaults),
   model = this.model, column = this.column,
   editable = Backgrid.callByNeed(col.editable, column, model),
-  optionValues = this.column.get('optionValues');
+  optionValues = this.optionValues;
 
   this.$el.empty();
 

-- 
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] backform select2 control

2016-01-06 Thread Harshal Dhumal
Hi,

Updated patch. As yesterdays patch for backform select2 and
select2ajaxoptoins controls was throwing malformed patch error.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Wed, Jan 6, 2016 at 12:01 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> Please find patch for backform select2 and select2ajaxoptoins controls
>
> Usage:
>
> schema: [{
>   id: 'name', label: '{{ _('Name') }}', cell: 'string',
>   type: 'select2', select2:{tags: "true", placeholder: "Select an option", 
> allowClear: true}
> }
> .
> .
> .
>
>
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index a251200..c9729a8 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -174,5 +174,53 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
 })
   });
 
+
+  /*
+   *  Backform Select2AjaxOptions control.
+   */
+  var Select2AjaxOptionsControl = Backform.Select2AjaxOptionsControl = Backform.NodeAjaxOptionsControl.extend({
+render: function() {
+
+  var options = this.field.get('options') || [];
+
+  /* Add empty option as Select2 requires any empty '' for
+   * some of its functionality to work.
+   */
+  options.unshift({label: undefined, value: undefined});
+
+  Backform.NodeAjaxOptionsControl.prototype.render.apply(this, arguments);
+
+  var col = _.defaults(this.field.toJSON(), this.defaults)
+  // Initialize select2 control.
+  this.$el.find("select").select2(col.select2);
+  return this;
+}
+  });
   return Backform.NodeListControl;
 });

diff --git a/web/pgadmin/static/css/overrides.css b/web/pgadmin/static/css/overrides.css
index 6d0f662..3ec4d6f 100755
--- a/web/pgadmin/static/css/overrides.css
+++ b/web/pgadmin/static/css/overrides.css
@@ -611,3 +611,20 @@ table.backgrid tr.new {
 right: 0px;
 bottom :0;
 }
+.select2 {
+  width: 100% !important;
+}
+.select2-search__field, select{
+  background:inherit !important;
+}
\ No newline at end of file
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 7423909..86b9416 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -74,7 +74,8 @@
 'multiline': ['textarea', 'textarea', 'string'],
 'collection': ['sub-node-collection', 'sub-node-collection', 'string'],
 'uniqueColCollection': ['unique-col-collection', 'unique-col-collection', 'string'],
-'switch' : 'switch'
+'switch' : 'switch',
+'select2': 'select2',
   };
@@ -1174,5 +1210,25 @@
 return groups;
   }
+  /*
+   *  Backform Select2 control.
+   */
+  var Select2Control = Backform.Select2Control = Backform.SelectControl.extend({
+render: function() {
+  var options = this.field.get('options') || [];
+  /* Add empty option as Select2 requires any empty '' for
+   * some of its functionality to work.
+   */
+
+  options.unshift({label: undefined, value: undefined});
+
+  Backform.SelectControl.prototype.render.apply(this, arguments);
+
+  var col = _.defaults(this.field.toJSON(), this.defaults)
+  // Initialize select2 control.
+  this.$el.find("select").select2(col.select2);
+  return this;
+}
+  });
   return Backform;
 }));

-- 
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] variable.js number formatting and sesschanged atrrib fix [pgadmin4]

2016-01-12 Thread Harshal Dhumal
Hi,

Please find attached patch for number formating issue in variable.js and
session changed duplicate values issue.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
index 660b65d..5c49955 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
@@ -151,7 +151,7 @@
 
   var formatter = self.formatter;
 
-  formatter.decimals = self.decimals;
+  formatter.decimals = 0;
   formatter.decimalSeparator = self.decimalSeparator;
   formatter.orderSeparator = self.orderSeparator;
 
@@ -297,7 +297,6 @@
   self.listenTo(self.headerData, "select2", self.headerDataChanged);
   self.listenTo(self.collection, "remove", self.onRemoveVariable);
 },
-
 /*
  * Get the variable data for this node.
  */
@@ -455,6 +454,30 @@
   });
   }
 
+  // Change format of each of the data
+  // Because - data coming from the server is in string format
+  self.collection.each(function(model){
+var name = model.get("name");
+
+if (name in self.availVariables) {
+  switch(self.availVariables[name].vartype) {
+case 'real':
+  var v = parseFloat(model.get('value'));
+  model.set('value', (isNaN(v) ? undefined : v), {silent: true});
+
+  break;
+case 'integer':
+  var v = parseInt(model.get('value'));
+  model.set('value', (isNaN(v) ? undefined : v), {silent: true});
+
+  break;
+default:
+  break;
+  }
+}
+  });
+  self.collection.startNewSession();
+
   // Initialize a new Grid instance
   var grid = self.grid = new Backgrid.Grid({
 columns: gridSchema.columns,
diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js
index fe999bb..622e9e1 100644
--- a/web/pgadmin/browser/templates/browser/js/node.js
+++ b/web/pgadmin/browser/templates/browser/js/node.js
@@ -1289,7 +1289,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
 }
 idx = _.indexOf(self.sessAttrs['changed'], obj);
 if (!'sessChanged' in obj) {
-  if (idx > 0) {
+  if (idx >= 0) {
 return true;
   }
   self.sessAttrs['changed'].push(obj);
@@ -1301,7 +1301,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
 
   return true;
 }
-if (idx > 0) {
+if (idx >= 0) {
 
   (self || self.handler).trigger(
   'pgadmin-session:changed',

-- 
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] Patch for TypeError: this.field is undefined error

2016-01-11 Thread Harshal Dhumal
Hi,


Please find attached minor patch for TypeError: this.field is undefined
error in pgadmin.backform.js


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index a753f5d..6ef634c 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -858,7 +859,7 @@
   this.clearInvalid();
 
   this.$el.find('.subnode-body').each(function(ix, el) {
-var error = self.keyPathAccessor(errorModel.toJSON(), this.field.get('name'));
+var error = self.keyPathAccessor(errorModel.toJSON(), self.field.get('name'));
 
 if (_.isEmpty(error)) return;
 

-- 
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] User management functionality patch [pgadmin4]

2016-06-03 Thread Harshal Dhumal
Hi,


PFA attached patch (V5) for user management functionality.

Note: If you've applied any of the previous patch of this functionality
then set ConfigDB value to 10 in version table of and also delete role
'Standard' from role table before applying this patch.


On Fri, Jun 3, 2016 at 4:39 PM, Dave Page  wrote:

>
>
> On Fri, Jun 3, 2016 at 11:37 AM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> Hi Harshal,
>>
>> Dave asked to put the User Management menu under the 'Change Password'
>> (right top side).
>>
> Done


>
> Correct - that way it won't be displayed in desktop mode. Other comments:
>
> - If I type an email address, then hit tab to select a Role, I immediately
> get an error saying that the role cannot be empty and the control loses
> focus. I should be able to add a user using just the keyboard.
>

Fixed the issue to not to show error immediately. Also role cell does not
lose focus after tab hit, it is select2 cell which does not respond to
focus-in event of tab. This is general issue for all select2 cells.


>
> - In general I'm seeing validation errors before I've had a chance to
> enter values. I should only see them if the appropriate field has lost
> focus.
>

Fixed.


>
> - Role names should be "Administrator" and "User".
>
Fixed (set ConfidDB to 10 before applying this patch if any of previous
patch was applied.)


>
> - The Close button should be disabled if errors are present.
>

I'm not convinced that to deny superuser from closing dialog for his
mistakes (accidental mistakes).

Consider a case when superuser clears email for any old user inadvertently
(obviously this won't reflect on server). At this point there is no proper
way that he can roll back or close the dialog without saving it if we
disable close button. He has to either enter correct email for that user or
refresh the browser.

Another case while adding new user if he plans not to add user then he has
to clear that partially filled user from grid before he can close the
dialog.

Let me know if we still want to implement this.


>
> - If I enter all the details for a new user and then hit Close, the dialog
> is closed and the new user is NOT added. I have to click something else
> first so the row loses focus, and then click close.
>

I was not able to reproduce this issue. I tried with both close buttons
(top-right and bottom-right). Users were created in both the cases by
adding all details and directly closing dialog without clicking anywhere on
the dialog.


>
> - The styling of the Add button and header does not match other grids
> (blue background for the header, title in white on the left, grey "ADD"
> button with no icon. The search box should be pushed right, to the left of
> the button as well I think.
>

Fixed.


>
> - s/Search by email/Filter by email
>
> - s/New Password/New password
>
> - s/Confirm Password/Confirm password
>

Fixed.

>
> - The font on the Close button doesn't match what's on the properties
> dialogues (looks like a global issue)
>
>
Fixed.


>
>
- The minimum size of the dialogue should be set such that the dialogue is
> usable at mimimum size, e.g. all columns shown, with 2 rows.
>
> Fixed.



> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/TODO.txt b/TODO.txt
index 93abba0..1df1305 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -45,3 +45,11 @@ Graphical Explain
 * Explanation on the statistic for the graphical explain plan.
 * Arrow colouring based on the percentage of the cost, and time taken on each
   explain node.
+
+User management
+---
+1. Pagination should be there if there are large number of users.
+2. There should be a way of notifying the user once its password is changed by any administrator.
+3. We can add 'created by' column.
+4. User creation and last modified time.
+5. If current user changes its own name/email, main page should reflect new changes.
\ No newline at end of file
diff --git a/web/config.py b/web/config.py
index ebb85aa..8545add 100644
--- a/web/config.py
+++ b/web/config.py
@@ -150,7 +150,7 @@ MAX_SESSION_IDLE_TIME = 60
 
 # The schema version number for the configuration database
 # DO NOT CHANGE UNLESS YOU ARE A PGADMIN DEVELOPER!!
-SETTINGS_SCHEMA_VERSION = 10
+SETTINGS_SCHEMA_VERSION = 11
 
 # The default path to the SQLite database used to store user accounts and
 # settings. This default places the file in the same directory as this
diff --git a/web/pgadmin/browser/templates/browser/index.html b/web/pgadmin/browser/templates/browser/index.html
index 89fe2a8..ed85c78 100644
--- a/web/pgadmin/browser/templates/browser/index.html
+++ b/web/pgadmin/browser/templates/browser/index.html
@@ -68,6 +68,8 @@ try {
   
 {{ _('Change Password') }}
 
+{{ _('Users') }}
+
 {{ _('Logout') }}
   
 
diff 

Re: [pgadmin-hackers] User management functionality patch [pgadmin4]

2016-06-07 Thread Harshal Dhumal
Hi,


PFA patch for user management issues.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Jun 6, 2016 at 6:06 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> Thanks - I've commit as-is (with some minor tweaks), however the
> following issues are present:
>
> 1) I get an error: "Invalid Email id: dpage...@pgadmin.org". That is a
> perfectly valid email address, but I guess we're not recognising the
> +.
>
Fixed.



>
> 2) When I mouse-over the Users menu option, the cursor isn't changing
> to a pointer.
>
Fixed.


>
> 3) The font in the Close button is still not quite the same as for the
> other dialogues.
>
Fixed font size issue.



>
> Please fix and submit patch(es).
>
> Thanks.
>
> On Mon, Jun 6, 2016 at 11:58 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA updated patch (V6) for user management functionality.
> >
> > Changes: As per Ashesh's suggestion I have disabled email update of
> existing
> > user.
> >
> >
> > --
> > Harshal Dhumal
> > Software Engineer
> >
> > EnterpriseDB India: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> >
> > On Mon, Jun 6, 2016 at 2:16 PM, Dave Page <dp...@pgadmin.org> wrote:
> >>
> >> Hi
> >>
> >> On Fri, Jun 3, 2016 at 10:52 PM, Harshal Dhumal
> >> <harshal.dhu...@enterprisedb.com> wrote:
> >> > Hi,
> >> >
> >> >
> >> > PFA attached patch (V5) for user management functionality.
> >> >
> >> > Note: If you've applied any of the previous patch of this
> functionality
> >> > then
> >> > set ConfigDB value to 10 in version table of and also delete role
> >> > 'Standard'
> >> > from role table before applying this patch.
> >>
> >> Done - also restarted my app server, and done a hard refresh of the
> >> browser...
> >>
> >> And I get "(index):310 Uncaught TypeError: Cannot read property
> >> 'show_users' of undefined" when I try to open the Users menu option.
> >
> >
> > This was an issue. Ideally Users menu shouldn't be visible to non admin
> > users. I have fixed in this patch.
> >
> >>
> >>
> >> >> - The Close button should be disabled if errors are present.
> >> >
> >> >
> >> > I'm not convinced that to deny superuser from closing dialog for his
> >> > mistakes (accidental mistakes).
> >> >
> >> > Consider a case when superuser clears email for any old user
> >> > inadvertently
> >> > (obviously this won't reflect on server). At this point there is no
> >> > proper
> >> > way that he can roll back or close the dialog without saving it if we
> >> > disable close button. He has to either enter correct email for that
> user
> >> > or
> >> > refresh the browser.
> >> >
> >> > Another case while adding new user if he plans not to add user then he
> >> > has
> >> > to clear that partially filled user from grid before he can close the
> >> > dialog.
> >>
> >> Well we either need that, or a message box asking the user if he wants
> >> to discard his changes and offering OK/Cancel options.
> >
> >
> > I have added confirmation before closing dialog if any unsaved changes
> are
> > present.
> >
> >
> >>
> >>
> >> >> - If I enter all the details for a new user and then hit Close, the
> >> >> dialog
> >> >> is closed and the new user is NOT added. I have to click something
> else
> >> >> first so the row loses focus, and then click close.
> >> >
> >> >
> >> > I was not able to reproduce this issue. I tried with both close
> buttons
> >> > (top-right and bottom-right). Users were created in both the cases by
> >> > adding
> >> > all details and directly closing dialog without clicking anywhere on
> the
> >> > dialog.
> >>
> >> Hmm, I'll re-test when I get an updated patch.
> >
> > Ok
> >
> >>
> >>
> >> --
> >> Dave Page
> >> Blog: http://pgsnake.blogspot.com
> >> Twitter: @pgsnake
> >>
> >> EnterpriseDB UK: http://www.enterprisedb.com
> >> The Enterprise PostgreSQL Company
> >
> &

[pgadmin-hackers] Email validation in setup.py [pgadmin4]

2016-06-09 Thread Harshal Dhumal
Hi,

PFA patch for email validation in setup.py

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/setup.py b/web/setup.py
index 4ea28e1..5f13e83 100644
--- a/web/setup.py
+++ b/web/setup.py
@@ -15,6 +15,7 @@ import sys
 import getpass
 import random
 import string
+import re
 
 from flask import Flask
 from flask.ext.security import Security, SQLAlchemyUserDatastore
@@ -48,9 +49,15 @@ def do_setup(app):
 print("""
 Enter the email address and password to use for the initial pgAdmin user \
 account:\n""")
+email_filter = re.compile(
+"^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9]"
+"(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9]"
+"(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
+
 email = ''
-while email == '':
-email = input("Email address: ")
+input("Email address: ")
+while email == '' or not email_filter.match(email):
+email = input("Invalid Email address: ")
 
 def pprompt():
 return getpass.getpass(), getpass.getpass('Retype password:')

-- 
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] PAtch for RM 1107 [pgadmin4]

2016-06-09 Thread Harshal Dhumal
Hi,

PAF patch for RM1107

Issue fixed:
*1]* Removed alter.sql and merged sql statement from alter.sql with create
sql wherever possible so that objects can be create in single statement to
ensure that whole operation is atomic.

*Code merged for below nodes:*
Schema, Table, all constraints.

*Nodes do not support executing other sql statements with create statement:*
Index node (To ensure that create index operation to be atomic added code
to Initiate database transaction manually before creating index object)

*Node Excluded (As they do not support **executing other sql statements
with create statement and also create statement cannot be executed inside
database transaction):*
Database, Tablespace

*2]* Fixed typo in databases/templates/databases/sql/9.3_plus/grant.sql



-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
index 1ef8270..bf22d0e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
@@ -506,6 +506,7 @@ It may have been removed by another user.
 )
 )
 try:
+self.format_request_acls(data, specific=['nspacl'])
 SQL = render_template(
 "/".join([self.template_path, 'sql/create.sql']),
 data=data, conn=self.conn, _=gettext
@@ -518,22 +519,6 @@ It may have been removed by another user.
 errormsg=res + '\n' +
 'Operation failed while running create statement'
 )
-self.format_request_acls(data, specific=['nspacl'])
-
-SQL = render_template(
-"/".join([self.template_path, 'sql/alter.sql']),
-data=data, conn=self.conn, _=gettext
-)
-# Checking if we are not executing empty query
-if SQL and SQL.strip('\n') and SQL.strip(' '):
-status, res = self.conn.execute_scalar(SQL)
-if not status:
-return make_json_response(
-status=410,
-success=0,
-errormsg=res + '\n' +
-'Operation failed while running alter statement'
-)
 
 # we need oid to to add object in tree at browser,
 # below sql will gives the same
@@ -727,11 +712,6 @@ It may have been removed by another user.
 "/".join([self.template_path, 'sql/create.sql']),
 data=data, conn=self.conn, _=gettext
 )
-SQL += "\n"
-SQL += render_template(
-"/".join([self.template_path, 'sql/alter.sql']),
-_=gettext, data=data, conn=self.conn
-)
 
 return SQL
 
@@ -774,11 +754,6 @@ It may have been removed by another user.
 "/".join([self.template_path, 'sql/create.sql']),
 _=gettext, data=data, conn=self.conn
 )
-SQL += "\n"
-SQL += render_template(
-"/".join([self.template_path, 'sql/alter.sql']),
-_=gettext, data=data, conn=self.conn
-)
 
 sql_header = """
 -- SCHEMA: {0}
@@ -867,7 +842,6 @@ It may have been removed by another user.
 return make_json_response(data=nodes)
 
 
-
 class CatalogView(SchemaView):
 """
 This class is responsible for generating routes for catalog schema node.
@@ -965,11 +939,6 @@ It may have been removed by another user.
 "/".join([self.template_path, 'sql/create.sql']),
 _=gettext, data=old_data, conn=self.conn
 )
-SQL += "\n"
-SQL += render_template(
-"/".join([self.template_path, 'sql/alter.sql']),
-_=gettext, data=old_data, conn=self.conn
-)
 
 sql_header = """
 -- CATALOG: {0}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index 3acf709..93cde7b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -1747,14 +1747,6 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 if ctype == 'p' else 'UNIQUE'
 ).strip('\n')
 )
-# sql to update comments
- 

[pgadmin-hackers] Removed unwanted empty_value form Select2 template [pgadmin4]

2016-06-09 Thread Harshal Dhumal
Hi,

PFA patch for select2 control in exclusion constraint.

Fixed template render issue.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js
index 4ede14e..82940b2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js
@@ -296,7 +296,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
   '',
   '   <%=required ? "required" : ""%> >',
   '<% if (first_empty) { %>',
-  '><%- empty_value %>',
+  '>',
   '<% } %>',
   '<% for (var i=0; i < options.length; i++) { %>',
   '<% var option = options[i]; %>',

-- 
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] Fix for RM1318 [pgadmin4]

2016-06-13 Thread Harshal Dhumal
Hi,

PFA attached patch for issue RM1318.


Issue fixed: Added help buttons on backup, restore, maintenance, user
management dialogs.



-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py
index e82b673..8cd356b 100644
--- a/web/pgadmin/browser/__init__.py
+++ b/web/pgadmin/browser/__init__.py
@@ -485,6 +485,15 @@ def index():
 def browser_js():
 layout = get_setting('Browser/Layout', default='')
 snippets = []
+
+prefs = Preferences.module('paths')
+
+pg_help_path_pref = prefs.preference('pg_help_path')
+pg_help_path = pg_help_path_pref.get()
+
+edbas_help_path_pref = prefs.preference('edbas_help_path')
+edbas_help_path = edbas_help_path_pref.get()
+
 for submodule in current_blueprint.submodules:
 snippets.extend(submodule.jssnippets)
 return make_response(
@@ -492,6 +501,8 @@ def browser_js():
 'browser/js/browser.js',
 layout=layout,
 jssnippets=snippets,
+pg_help_path=pg_help_path,
+edbas_help_path=edbas_help_path,
 _=gettext
 ),
 200, {'Content-Type': 'application/x-javascript'})
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index 12ffd6f..91aaa81 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -681,10 +681,60 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
   // Do nothing as user cancel the operation
 }
   );
+},
+// General function to handle callbacks for object or dialog help.
+showHelp: function(type, url, node, item, label) {
+  if (type == "object_help") {
+// See if we can find an existing panel, if not, create one
+pnlSqlHelp = this.docker.findPanels('pnl_sql_help')[0];
+
+if (pnlSqlHelp == null) {
+  pnlProperties = this.docker.findPanels('properties')[0];
+  this.docker.addPanel('pnl_sql_help', wcDocker.DOCK.STACKED, pnlProperties);
+  pnlSqlHelp = this.docker.findPanels('pnl_sql_help')[0];
+}
+
+// Construct the URL
+server = node.getTreeNodeHierarchy(item).server;
+
+baseUrl = '{{ pg_help_path }}'
+if (server.server_type == 'ppas') {
+  baseUrl = '{{ edbas_help_path }}'
+}
+
+major = Math.floor(server.version / 1)
+minor = Math.floor(server.version / 100) - (major * 100)
+
+baseUrl = baseUrl.replace('$VERSION$', major + '.' + minor)
+if (!S(baseUrl).endsWith('/')) {
+  baseUrl = baseUrl + '/'
+}
+fullUrl = baseUrl+ url;
+// Update the panel
+iframe = $(pnlSqlHelp).data('embeddedFrame');
+pnlSqlHelp.title('Help: '+ label);
+
+pnlSqlHelp.focus();
+iframe.openURL(fullUrl);
+  } else if(type == "dialog_help") {
+// See if we can find an existing panel, if not, create one
+pnlDialogHelp = this.docker.findPanels('pnl_online_help')[0];
+
+if (pnlDialogHelp == null) {
+  pnlProperties = this.docker.findPanels('properties')[0];
+  this.docker.addPanel('pnl_online_help', wcDocker.DOCK.STACKED, pnlProperties);
+  pnlDialogHelp = this.docker.findPanels('pnl_online_help')[0];
+}
+
+// Update the panel
+iframe = $(pnlDialogHelp).data('embeddedFrame');
+
+pnlDialogHelp.focus();
+iframe.openURL(url);
+  }
 }
   });
 
-
   window.onbeforeunload = function(ev) {
 var e = ev || window.event;
 if(onbeforeunload_flag) {
diff --git a/web/pgadmin/static/css/overrides.css b/web/pgadmin/static/css/overrides.css
index 403de28..41ffde0 100755
--- a/web/pgadmin/static/css/overrides.css
+++ b/web/pgadmin/static/css/overrides.css
@@ -1028,7 +1028,7 @@ ul.nav.nav-tabs {
 }
 
 .alertify .ajs-footer .ajs-buttons .ajs-button {
-  min-width: 80px;
+  min-width: 40px;
   min-height: 30px;
 }
 
@@ -1343,4 +1343,4 @@ height: calc(100% - 35px);
 
 .pg-panel-statistics-container > table > thead > tr > th:last-child {
   border-right: 0px;
-}
\ No newline at end of file
+}
diff --git a/web/pgadmin/tools/backup/templates/backup/js/backup.js b/web/pgadmin/tools/backup/templates/backup/js/backup.js
index dcdd2a2..8fff960 100644
--- a/web/pgadmin/tools/backup/templates/backup/js/backup.js
+++ b/web/pgadmin/tools/backup/templates/backup/js/backup.js
@@ -385,6 +385,14 @@ TODO LIST FOR BACKUP:
setup:function() {
 return {
   buttons: [{
+  text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-info',
+  attrs:{name:'object_help', type:'button', url: 'ba

[pgadmin-hackers] fix for RM1210 [pgadmin4]

2016-06-03 Thread Harshal Dhumal
Hi,

PFA patch for RM1210 <https://redmine.postgresql.org/issues/1210>

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
index 5bcb456..6e77b2e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
@@ -820,7 +820,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
   data=data, conn=self.conn)
 SQL = sql_header + '\n\n' + SQL
 
-return SQL
+return ajax_response(response=SQL.strip('\n'))
 
 except Exception as e:
 return internal_server_error(errormsg=str(e))

-- 
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] fix for RM1210 [pgadmin4]

2016-06-03 Thread Harshal Dhumal
Hi,

Issue: For column node it was showing wrong sql in sql tab

-- Column: public.test_qmg.a -- ALTER TABLE
public.test_qmg DROP COLUMN a; ALTER TABLE public.test_qmg ADD COLUMN a
integer;

Fix: I have changed response to ajax response while returning SQL for
column node.






-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Jun 3, 2016 at 12:52 PM, Ashesh Vashi <ashesh.va...@enterprisedb.com
> wrote:

> Hi Harshal,
>
>
> Can you please describe the issue, and root cause, and how did you fix it?
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com>
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi>
>
> On Fri, Jun 3, 2016 at 12:48 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch for RM1210 <https://redmine.postgresql.org/issues/1210>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer*
>>
>> EnterpriseDB India: 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
>>
>>
>


Re: [pgadmin-hackers] fix for RM1210 [pgadmin4]

2016-06-03 Thread Harshal Dhumal
Hi Ashesh,

I have used 'ajax_response' utility function (alias to make_response
pdadmin utility function) which has mime-type set to "text/json" which is
correct I guess in this case.

Also I have check all other node to check if all of them are using correct
function while returning sql.



-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Jun 3, 2016 at 1:04 PM, Ashesh Vashi <ashesh.va...@enterprisedb.com>
wrote:

> On Fri, Jun 3, 2016 at 12:59 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Issue: For column node it was showing wrong sql in sql tab
>>
>> -- Column: public.test_qmg.a -- ALTER TABLE
>> public.test_qmg DROP COLUMN a; ALTER TABLE public.test_qmg ADD COLUMN a
>> integer;
>>
>> Fix: I have changed response to ajax response while returning SQL for
>> column node.
>>
> Hi Harshal,
>
> Can you please introduce a function in pgadmin.utils regarding that, which
> set the proper mime-type for this purpose, and make sure - we do use that
> for each and every nodes, for sql and modified_sql methods?
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com/>
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi>
>
>>
>>
>>
>>
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Fri, Jun 3, 2016 at 12:52 PM, Ashesh Vashi <
>> ashesh.va...@enterprisedb.com> wrote:
>>
>>> Hi Harshal,
>>>
>>>
>>> Can you please describe the issue, and root cause, and how did you fix
>>> it?
>>>
>>> --
>>>
>>> Thanks & Regards,
>>>
>>> Ashesh Vashi
>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>> <http://www.enterprisedb.com>
>>>
>>>
>>> *http://www.linkedin.com/in/asheshvashi*
>>> <http://www.linkedin.com/in/asheshvashi>
>>>
>>> On Fri, Jun 3, 2016 at 12:48 PM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> PFA patch for RM1210 <https://redmine.postgresql.org/issues/1210>
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Software Engineer*
>>>>
>>>> EnterpriseDB India: 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] Evaluate Sellect2 cell options properly [pgadmin4]

2016-06-03 Thread Harshal Dhumal
Hi,

There are two ways we can provide options for select2 cell either by
extending select2 cell with "optionValues" array or by passing "options"
(function or array) in column definition.

Generally, if we are passing "optionValues" to select2 cell then we should
not look for "options" in column definition but still we were looking for
"options". This was causing javascript code to break if "options" were not
passed in column definition.

Error fixed:

TypeError: this.column.get(...) is not a function
(this.column.get('options'))(this) :




-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
index 5197f15..b87e84c 100644
--- a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
+++ b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
@@ -442,9 +442,9 @@
   model = this.model, column = this.column,
   editable = Backgrid.callByNeed(col.editable, column, model),
   optionValues = _.clone(this.optionValues ||
-_.isFunction(this.column.get('options')) ?
+(_.isFunction(this.column.get('options')) ?
 (this.column.get('options'))(this) :
-this.column.get('options'));
+this.column.get('options')));
 
   this.undelegateEvents();
 

-- 
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] Destroy header controls properly [pgadmin4]

2016-06-03 Thread Harshal Dhumal
Hi,

PFA patch for tokes control in fts configuration and  variable control.

Issue fixed : Destroy header controls properly.



-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/templates/fts_configuration/js/fts_configuration.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/templates/fts_configuration/js/fts_configuration.js
index 690968c..e379b0b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/templates/fts_configuration/js/fts_configuration.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/templates/fts_configuration/js/fts_configuration.js
@@ -386,6 +386,10 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
   this.listenTo(this.headerData, "select2", this.headerDataChanged);
   this.listenTo(this.collection, "remove", this.onAddorRemoveTokens);
 
+  // Remove header controls.
+  _.each(this.controls, function(control) {
+control.remove();
+  });
   TokenControl.__super__.remove.apply(this, arguments);
 
   // Remove the header model
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
index 13eedd9..2d13728 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
@@ -570,6 +570,11 @@
   this.listenTo(this.headerData, "select2", this.headerDataChanged);
   this.listenTo(this.collection, "remove", this.onRemoveVariable);
 
+  // Remove header controls.
+  _.each(this.controls, function(control) {
+control.remove();
+  });
+
   VariableCollectionControl.__super__.remove.apply(this, arguments);
 
   // Remove the header model

-- 
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] Fix for RM1318 [pgadmin4]

2016-06-13 Thread Harshal Dhumal
Hi,

PFA patch for issue RM1318 with remaining bug fixes.


On Mon, Jun 13, 2016 at 8:49 PM, Dave Page <dp...@pgadmin.org> wrote:

> On Mon, Jun 13, 2016 at 7:25 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA attached patch for issue RM1318.
> >
> >
> > Issue fixed: Added help buttons on backup, restore, maintenance, user
> > management dialogs.
>
> Thanks - I've committed this as-is, however the following issues
> should also be fixed:
>
> - The help for the User Manager dialogue cannot be used because the
> dialogue is modal.
>

Changed user dialog to non modal from modal dialog.


>
> - There's no help button on the Preferences dialogue. It should also
> be made non-modal so the user can actually use the help once it's
> displayed.
>
Added missing help button and also changed dialog to non modal.



>
> Thanks.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/preferences/templates/preferences/preferences.js b/web/pgadmin/preferences/templates/preferences/preferences.js
index 69053b3..0600a8c 100644
--- a/web/pgadmin/preferences/templates/preferences/preferences.js
+++ b/web/pgadmin/preferences/templates/preferences/preferences.js
@@ -1,8 +1,8 @@
 define(
-  ['jquery', 'alertify', 'pgadmin', 'underscore', 'backform', 'pgadmin.backform'],
+  ['jquery', 'alertify', 'pgadmin', 'underscore', 'backform', 'pgadmin.browser', 'pgadmin.backform'],
 
   // This defines the Preference/Options Dialog for pgAdmin IV.
-  function($, alertify, pgAdmin, _, Backform) {
+  function($, alertify, pgAdmin, _, Backform, pgBrowser) {
 pgAdmin = pgAdmin || window.pgAdmin || {};
 
 /*
@@ -351,12 +351,13 @@ define(
 },
 setup:function(){
   return {
-buttons:[
-  {
+buttons:[{
+text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
+attrs:{name:'dialog_help', type:'button', label: '{{ _('Preferences') }}',
+url: '{{ url_for('help.static', filename='preferences_dialog.html') }}'}
+  },{
 text: "{{ _('OK') }}", key: 13, className: "btn btn-primary fa fa-lg fa-save pg-alertify-button"
-
-  },
-  {
+  },{
 text: "{{ _('Cancel') }}", className: "btn btn-danger fa fa-lg fa-times pg-alertify-button"
   }
 ],
@@ -365,12 +366,20 @@ define(
   padding: !1,
   overflow: !1,
   title: '{{ _('Preferences')|safe }}',
-  closableByDimmer: false
+  closableByDimmer: false,
+  modal:false
 }
   };
 },
-callback: function(closeEvent){
-  if (closeEvent.button.text == "{{ _('OK') }}"){
+callback: function(e){
+  if (e.button.element.name == "dialog_help") {
+  e.cancel = true;
+  pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
+null, null, e.button.element.getAttribute('label'));
+  return;
+   }
+
+  if (e.button.text == "{{ _('OK') }}"){
 preferences.updateAll();
   }
 },
diff --git a/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js b/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js
index 4e01863..9109044 100644
--- a/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js
+++ b/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js
@@ -390,7 +390,7 @@ define([
 //disable both padding and overflow control.
 padding : !1,
 overflow: !1,
-model: 0,
+modal: false,
 resizable: true,
 maximizable: true,
 pinnable: false,

-- 
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] Fix for issue RM1348 [pgadmin4]

2016-06-13 Thread Harshal Dhumal
Hi,

PFA patch for issue RM1348.

Issue fixed: Not to show multiple 'Reset Layout' options under file menu.
Also restructured code related to reset layout functionality.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index 91aaa81..ae99ff6 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -12,8 +12,7 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
 
   // Some scripts do export their object in the window only.
   // Generally the one, which do no have AMD support.
-  var wcDocker = window.wcDocker,
-onbeforeunload_flag = true;
+  var wcDocker = window.wcDocker;
   $ = $ || window.jQuery || window.$;
   Bootstrap = Bootstrap || window.Bootstrap;
 
@@ -256,19 +255,9 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
   }], false);
 $obj_mnu.append(create_submenu.$el);
   }
-  // Drop down menu for reset layout
-  var $file_mnu = navbar.find('li#mnu_file > ul.dropdown-menu').first();
-  if($file_mnu) {
-$file_mnu.append('' +
- '' +
- '{{ _('Reset Layout') }}' +
- ''
-);
-  }
 },
 init: function() {
   var obj=this;
-  obj.save_layout = true;
   if (obj.initialized) {
 return;
   }
@@ -276,7 +265,7 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
 
   // Store the main browser layout
   $(window).bind('unload', function() {
-  if(obj.docker && obj.save_layout) {
+  if(obj.docker) {
 state = obj.docker.save();
 settings = { setting: "Browser/Layout", value: state };
 $.ajax({
@@ -650,38 +639,6 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
   navbar.children('#mnu_obj').removeClass('hide');
obj.enable_disable_menus();
 },
-// We will force unload method to not to save current layout
-// and reload the window
-reset_current_layout: function() {
-  var obj = this;
-  alertify.confirm('{{ _('Reset layout') }}',
-'{{ _('Are you sure you want to reset the current layout? This will cause the application to reload and any un-saved data will be lost.') }}',
-function() {
-  // User clicked OK button...
-  var current_url = document.URL;
-
-  // Delete the record from database as well, then only reload page
-  $.ajax({
-url: '{{ url_for('settings.reset_layout') }}',
-type: 'DELETE',
-async: false,
-error: function() {
-  console.log('Something went wrong on server while resetting layout');
-}
-  });
-
-  // Toggle flag which will prevents save again
-  obj.save_layout = false;
-  // Flag will prevent onbeforeunload function to be called
-  onbeforeunload_flag = false;
-  // Now reload page
-  location.reload(true);
-},
-function() {
-  // Do nothing as user cancel the operation
-}
-  );
-},
 // General function to handle callbacks for object or dialog help.
 showHelp: function(type, url, node, item, label) {
   if (type == "object_help") {
@@ -736,18 +693,16 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
   });
 
   window.onbeforeunload = function(ev) {
-var e = ev || window.event;
-if(onbeforeunload_flag) {
-  var msg = '{{ _('Do you really want to leave the page?') }}';
+var e = ev || window.event,
+msg = '{{ _('Do you really want to leave the page?') }}';
 
-  // For IE and Firefox prior to version 4
-  if (e) {
-e.returnValue = msg;
-  }
-
-  // For Safari
-  return msg;
+// For IE and Firefox prior to version 4
+if (e) {
+  e.returnValue = msg;
 }
+
+// For Safari
+return msg;
   };
 
   return pgAdmin.Browser;
diff --git a/web/pgadmin/settings/__init__.py b/web/pgadmin/settings/__init__.py
index a3f529e..97a34e8 100644
--- a/web/pgadmin/settings/__init__.py
+++ b/web/pgadmin/settings/__init__.py
@@ -13,14 +13,41 @@ from flask.ext.login import current_user
 
 from pgadmin.model import db, Setting
 import traceback
-from flask import Response, request, render_template
+from flask import Response, request, render_template, url_for
 from flask.ext.security import login_required
 
-from pgadmin.utils.ajax import make_json_response
+from pgadmin.utils.ajax import make_json_response, bad_request
 from pgadmin.utils import PgAdminModule
+from pgadmin.utils.menu import MenuItem
+from flask.ext.babel import gettext
 
 MODU

[pgadmin-hackers] Fix for issue RM1313 [pgadmin4]

2016-06-14 Thread Harshal Dhumal
Hi,


PFA patch for issue RM 1313.

Changes: Added connect now option in server create dialog.


-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index 6f3453b..8f4a0dd 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -576,14 +576,50 @@ class ServerNode(PGChildNodeView):
 db.session.add(server)
 db.session.commit()
 
+connected = False
+icon = "icon-server-not-connected"
+user = None
+
+if 'connect_now' in data and data['connect_now']:
+if 'password' not in data or data["password"] == '':
+db.session.delete(server)
+db.session.commit()
+raise Exception("No password provided.")
+
+password = data['password']
+password = encrypt(password, current_user.password)
+
+from pgadmin.utils.driver import get_driver
+manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(server.id)
+conn = manager.connection()
+
+status, errmsg = conn.connect(
+password=password,
+server_types=ServerType.types()
+)
+
+if not status:
+db.session.delete(server)
+db.session.commit()
+return make_json_response(
+status=401,
+success=0,
+errormsg=gettext("Unable to connect to server.")
+)
+else:
+user = manager.user_info
+connected = True
+icon = "icon-pg"
+
 return jsonify(
 node=self.blueprint.generate_browser_node(
-"%d" % (server.id), server.servergroup_id,
+"%d" % server.id, server.servergroup_id,
 server.name,
-"icon-server-not-connected",
+icon,
 True,
 self.node_type,
-connected=False,
+user=user,
+connected=connected,
 server_type='pg'  # Default server type
 )
 )
@@ -593,7 +629,7 @@ class ServerNode(PGChildNodeView):
 return make_json_response(
 status=410,
 success=0,
-errormsg=e.message
+errormsg=str(e)
 )
 
 def sql(self, gid, sid):
diff --git a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
index d1c1cd3..8c0d01f 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
+++ b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
@@ -586,7 +586,9 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
   port: 5432,
   db: 'postgres',
   username: '{{ username }}',
-  role: null
+  role: null,
+  connect_now: true,
+  password: undefined
 },
 // Default values!
 initialize: function(attrs, args) {
@@ -623,6 +625,15 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
   id: 'version', label:'{{ _('Version') }}', type: 'text', group: null,
   mode: ['properties'], visible: 'isConnected'
 },{
+  id: 'connect_now', controlLabel:'{{ _('Connect now?') }}', type: 'checkbox',
+  group: null, mode: ['create']
+},{
+  id: 'password', label:'{{ _('Password') }}', type: 'password',
+  group: null, control: 'input', mode: ['create'], deps: ['connect_now'],
+  visible: function(m) {
+return m.get('connect_now') && m.isNew();
+  }
+},{
   id: 'comment', label:'{{ _('Comments') }}', type: 'multiline', group: null,
   mode: ['properties', 'edit', 'create']
 },{
@@ -676,6 +687,15 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
 self.errorModel.unset('id');
   }
   check_for_empty('name', '{{ _('Name must be specified.') }}');
+
+  if(self.get('connect_now')) {
+check_for_empty(
+  'password', '{{ _('Password must be specified.') }}'
+);
+  } else {
+self.errorModel.unset('password');
+  }
+
   check_for_empty(
 'host', '{{ _('Hostname or address mu

Re: [pgadmin-hackers] Fix for issue RM1313 [pgadmin4]

2016-06-15 Thread Harshal Dhumal
Hi,


PFA attached patch for RM1313 updates and RM1363

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Tue, Jun 14, 2016 at 10:40 PM, Dave Page <dp...@pgadmin.org> wrote:

> On Tue, Jun 14, 2016 at 5:28 PM, Dave Page <dp...@pgadmin.org> wrote:
> > Thanks - committed with some minor changes:
> >
> > - Move the password field under the user name.
> >
> > - Remove the password requirement. The user might be using "trust" auth.
> >
> > - Adjust the vertical positioning of the checkbox.
>
> Hmm, this is actually broken:
>
> 1) I've left the password check in the Python code.
>
Removed check


>
> 2) It seems like it saves the server info on the first connection
> attempt. That means that if the connection fails, but the password is
> not the issue (mis-typed address or username perhaps), correcting that
> info doesn't allow the connection to proceed.
>
Fixed


>
> Because of 2, I haven't fixed 1 (you'll probably need to move it
> around anyway). Essentially, we need to support password-less
> connections, and if the connection fails, the user should be able to
> immediately try again having changed any of the connection options.
>

Added support for password less login


>
> Please take a look - and while you're in that code, please take a look
> at #1363. It's probably a very simple fix.
>

Fxied


>
> Thanks.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index a658b29..9e7b5c8 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -526,7 +526,7 @@ class ServerNode(PGChildNodeView):
 'port': server.port,
 'db': server.maintenance_db,
 'username': server.username,
-'gid': server.servergroup_id,
+'gid': str(server.servergroup_id),
 'group-name': sg.name,
 'comment': server.comment,
 'role': server.role,
@@ -582,22 +582,23 @@ class ServerNode(PGChildNodeView):
 user = None
 
 if 'connect_now' in data and data['connect_now']:
-if 'password' not in data or data["password"] == '':
-db.session.delete(server)
-db.session.commit()
-raise Exception("No password provided.")
-
-password = data['password']
-password = encrypt(password, current_user.password)
-
 from pgadmin.utils.driver import get_driver
 manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(server.id)
+manager.update(server)
 conn = manager.connection()
 
+if 'password' in data and data["password"] != '':
+# login with password
+password = data['password']
+password = encrypt(password, current_user.password)
+else:
+# Attempt password less login
+password = None
+
 status, errmsg = conn.connect(
-password=password,
-server_types=ServerType.types()
-)
+password=password,
+server_types=ServerType.types()
+)
 
 if not status:
 db.session.delete(server)
@@ -626,6 +627,10 @@ class ServerNode(PGChildNodeView):
 )
 
 except Exception as e:
+if server:
+db.session.delete(server)
+db.session.commit()
+
 current_app.logger.exception(e)
 return make_json_response(
 status=410,

-- 
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] User management functionality patch [pgadmin4]

2016-05-31 Thread Harshal Dhumal
Hi,

PFA updated patch for user management.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Mon, May 30, 2016 at 5:51 PM, Surinder Kumar <
surinder.ku...@enterprisedb.com> wrote:

> Hi Harshal,
>
>
> Please find the review comments so far:
>
> *Issues:*
> 1. The UI design doesn't look interactive, especially add new user button.
>
Moved to TODO


> 2. In requirements.txt, while adding new dependent library the name of
> library and version should be separate by '==' instead of '--'
>
Fixed


> 3. Under File menu, "Users" menu item should not be visible for non-admin
> users. For now it is only disabled.
>
Moved to TODO


> 4. Change role of admin user to non-admin user, then navigate to File >
> Users. It doesn't show users in Dialog and Add user doesn't work. Instead
> it is better to reload the page. Please find attached screenshot.
>

Moved to TODO (We can write code to reload the page but we have
"onbeforeunload" listener on window which is preventing page reload unless
user clicks on "Leave page" button).


> 5. The data grid content should fill the unnecessary gap above the footer.
>
Moved to TODO (This is generic issue as I'm using common dialog)

6. The title of delete user confirmation dialog should be "Delete user ?",
> instead of "Delete User".
>
Fixed

7. The Edit and Delete column shouldn't be sortable.
>
Moved to TODO (This issue exist throughout the application)


> 8. Columns 'creation time' & 'last modified' are missing.
>

Moved to TODO. (We are not recording these user properties at this stage.
The purpose of User management functionality is to only update existing
user properties, add user and delete user.)


> 9. Password should have validation of minimum number of characters.
>
Fixed


>
> *Can be added into TODO list:*
> 1. There is no way to search a user by name or email id.
> 2. Pagination should be there if there are large number of users.
> 3. There should be a way of notifying the user once its password is
> changed by any administrator.
> 4. We can add 'created by' column.
>
All of above 4 Moved to TODO.

5. One administrator shouldn't have privilege to modify the details of
> other administrator.
> This is the role of super admin.
>
As per my offline discussion with Ashesh we don't need this.



>
>
> Thanks
> Surinder Kumar
>
> On Fri, May 27, 2016 at 7:02 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA initial patch for User management functionality.
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>
diff --git a/TODO.txt b/TODO.txt
index 93abba0..05f84b3 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -45,3 +45,16 @@ Graphical Explain
 * Explanation on the statistic for the graphical explain plan.
 * Arrow colouring based on the percentage of the cost, and time taken on each
   explain node.
+
+
+User management
+---
+1. Dialog UI design improvement.
+2. Under File menu, "Users" menu item should not be visible for non-admin users. For now it is only disabled.
+3. Search a user by name or email id.
+4. Pagination should be there if there are large number of users.
+5. There should be a way of notifying the user once its password is changed by any administrator.
+6. We can add 'created by' column.
+7. User creation and last modified time.
+8. If current user changes its own name/email, main page should reflect new changes.
+9. In-place editing in backgrid.
\ No newline at end of file
diff --git a/requirements_py2.txt b/requirements_py2.txt
index a442e36..cff40b5 100644
--- a/requirements_py2.txt
+++ b/requirements_py2.txt
@@ -44,3 +44,5 @@ unittest2==1.1.0
 Werkzeug==0.9.6
 WTForms==2.0.2
 sqlparse==0.1.19
+flask-marshmallow==0.6.2
+marshmallow-sqlalchemy==0.8.1
diff --git a/requirements_py3.txt b/requirements_py3.txt
index 233b14f..70ab746 100644
--- a/requirements_py3.txt
+++ b/requirements_py3.txt
@@ -38,3 +38,5 @@ Werkzeug==0.9.6
 wheel==0.24.0
 WTForms==2.0.2
 sqlparse==0.1.19
+flask-marshmallow==0.6.2
+marshmallow-sqlalchemy==0.8.1
\ No newline at end of file
diff --git a/web/config.py b/web/config.py
index 36f1632..712ee2b 100644
--- a/web/config.py
+++ b/web/config.py
@@ -150,7 +150,7 @@ MAX_SESSION_IDLE_TIME = 60
 
 # The schema version number for the configuration database
 # DO NOT CHANGE UNLESS YOU ARE A PGADMIN DEVELOPER!!
-SETTINGS_SCHEMA_VERSION = 10
+S

Re: [pgadmin-hackers] User management functionality patch [pgadmin4]

2016-05-31 Thread Harshal Dhumal
Hi,


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Mon, May 30, 2016 at 4:09 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Harshal,
>
> PFA comments as below,
>
> 1) While running setup.py for the first time, We did not handle the case
> to create Standard user.
>
Fixed


> 2) Save button gets enable only clicking on input text box
>
Fixed


> 3) Remove delete button from sub-node
>
Removed button.

4) If current user changes its own name/email, main page should reflect new
> changes.
>
Moved to TODO


>
>
> Can be listed as TODO
> 
> 1) Erros description is missing, for example when have user t...@test.com
> presnt and user try to add user same as t...@test.com we get error as
> "Error during saving user" it should be descriptive like "ERRPR: User {XYZ}
> is already exists.."
>
Fixed. (Added client side validation)


> 2) There should be an option to delete multiple users at one shot.
>
Moved to TODO


> 3) There should be an option to active/deactivate multiple users in one
> shot.
>
Moved to TODO


> 4) In-place editing in backgrid.
>
Moved to TODO


>
>
> Regards,
> Murtuza
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Fri, May 27, 2016 at 7:02 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA initial patch for User management functionality.
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>>
>> --
>> 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] Regarding issue 1241

2016-05-31 Thread Harshal Dhumal
Hi Dave,

Regarding Issue 1241 <https://redmine.postgresql.org/issues/1241>:

We have added header section for parameter tab deliberately so that we can
force user to select parameter name (and therefore parameter's data type)
before adding new row. This is required because behavior of second cell
(Value cell) is dependent on what parameter name user has selected in first
cell (Name cell). See attached screen-shot.

For example:
1. If user selects parameter 'array_nulls' then value for this should be
either true or false (and hence switch cell).
2. If user selects parameter 'cpu_index_tuple_cost' then value for this
should be Integer (and hence Integer cell).

Without the custom header (and forcing user to select parameter) we cannot
decide what type of cell we need in second column.

Let me know your opinion on this.

Apart from this I have fixed column resize issue for Security label tab.
For Privileges tab I have reduced column resizing margin at some extent but
not 100%.



Regards,
-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

-- 
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] User management functionality patch [pgadmin4]

2016-05-27 Thread Harshal Dhumal
Hi,

PFA initial patch for User management functionality.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/requirements_py2.txt b/requirements_py2.txt
index a442e36..f3d8622 100644
--- a/requirements_py2.txt
+++ b/requirements_py2.txt
@@ -44,3 +44,5 @@ unittest2==1.1.0
 Werkzeug==0.9.6
 WTForms==2.0.2
 sqlparse==0.1.19
+flask-marshmallow-0.6.2
+marshmallow-sqlalchemy==0.8.1
diff --git a/requirements_py3.txt b/requirements_py3.txt
index 233b14f..6a6fea4 100644
--- a/requirements_py3.txt
+++ b/requirements_py3.txt
@@ -38,3 +38,5 @@ Werkzeug==0.9.6
 wheel==0.24.0
 WTForms==2.0.2
 sqlparse==0.1.19
+flask-marshmallow-0.6.2
+marshmallow-sqlalchemy==0.8.1
\ No newline at end of file
diff --git a/web/config.py b/web/config.py
index 36f1632..712ee2b 100644
--- a/web/config.py
+++ b/web/config.py
@@ -150,7 +150,7 @@ MAX_SESSION_IDLE_TIME = 60
 
 # The schema version number for the configuration database
 # DO NOT CHANGE UNLESS YOU ARE A PGADMIN DEVELOPER!!
-SETTINGS_SCHEMA_VERSION = 10
+SETTINGS_SCHEMA_VERSION = 11
 
 # The default path to the SQLite database used to store user accounts and
 # settings. This default places the file in the same directory as this
diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py
index f04897e..6d1a9b2 100644
--- a/web/pgadmin/__init__.py
+++ b/web/pgadmin/__init__.py
@@ -16,7 +16,7 @@ from flask.ext.security import Security, SQLAlchemyUserDatastore
 from flask_security.utils import login_user
 from flask_mail import Mail
 from htmlmin.minify import html_minify
-from pgadmin.model import db, Role, User, Version
+from pgadmin.model import db, Role, User, Version, ma
 from importlib import import_module
 from werkzeug.local import LocalProxy
 from pgadmin.utils import PgAdminModule, driver
@@ -189,6 +189,7 @@ def create_app(app_name=config.APP_NAME):
 
 # Create database connection object and mailer
 db.init_app(app)
+ma.init_app(app)
 Mail(app)
 
 import pgadmin.utils.paths as paths
diff --git a/web/pgadmin/model/__init__.py b/web/pgadmin/model/__init__.py
index b8bb256..0aefbf9 100644
--- a/web/pgadmin/model/__init__.py
+++ b/web/pgadmin/model/__init__.py
@@ -20,9 +20,11 @@ things:
 
 from flask.ext.sqlalchemy import SQLAlchemy
 from flask.ext.security import UserMixin, RoleMixin
+from flask_marshmallow import Marshmallow
+from marshmallow import fields
 
 db = SQLAlchemy()
-
+ma = Marshmallow()
 # Define models
 roles_users = db.Table(
 'roles_users',
@@ -46,6 +48,12 @@ class Role(db.Model, RoleMixin):
 description = db.Column(db.String(256), nullable=False)
 
 
+class RoleSchema(ma.ModelSchema):
+"""Define a role schema for serialization"""
+class Meta:
+model = Role
+
+
 class User(db.Model, UserMixin):
 """Define a user object"""
 __tablename__ = 'user'
@@ -58,6 +66,23 @@ class User(db.Model, UserMixin):
 backref=db.backref('users', lazy='dynamic'))
 
 
+class UserSchema(ma.ModelSchema):
+"""Define a user schema for serialization"""
+class Meta:
+model = User
+exclude = ('password', 'roles')
+
+# Convert list of user roles to role.
+# There will be only one role associated with user.
+role = fields.Function(
+  lambda user: str(user.roles[0].id) if len(user.roles) else None
+)
+
+is_admin = fields.Function(
+  lambda user: True if (len(user.roles) and user.roles[0].name == 'Administrators') else False
+)
+
+
 class Setting(db.Model):
 """Define a setting object"""
 __tablename__ = 'setting'
diff --git a/web/pgadmin/static/css/overrides.css b/web/pgadmin/static/css/overrides.css
index 55d83e0..719a989 100755
--- a/web/pgadmin/static/css/overrides.css
+++ b/web/pgadmin/static/css/overrides.css
@@ -1121,7 +1121,7 @@ button.pg-alertify-button {
   margin: 0 0 10px;
   overflow: auto;
   padding: 5px 10px;
-  word-break: break-all;
+  word-break: keep-all;
   word-wrap: break-word;
 }
 
@@ -1129,6 +1129,11 @@ div.backform_control_notes label.control-label {
   min-width: 0px;
 }
 
+.backform_control_notes span{
+  white-space: pre-wrap;
+  word-break: keep-all !important;
+}
+
 form[name="change_password_form"] .help-block {
 color: #A94442 !important;
 }
@@ -1232,3 +1237,15 @@ form[name="change_password_form"] .help-block {
 visibility: hidden;
   }
 }
+
+.subnode-footer {
+  text-align: right;
+  border-color: #a9a9a9;
+  border-style: inset inset inset solid;
+  border-width: 2px 1px 0;
+  margin-top: -10px;
+}
+
+.subnode-footer .ajs-button {
+  margin: 2px 2px 0;
+}
diff --git a/web/pgadmin/tools/user/__init__.py b/web/pgadmin/tools/user/__init__.py
new file mode 100644
index 000..e7cac5a
--- /dev/null
+++ b/web/pgadmin/tools/user/__init__.py
@@ -0,0 +1,307 @@
+##

Re: [pgadmin-hackers] User management functionality patch [pgadmin4]

2016-06-02 Thread Harshal Dhumal
Hi,

This patch requires backgrid password cell for I have sent patch yesterday.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jun 2, 2016 at 7:12 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch for user management functionality.
>
> Major changes in this patch are:
>
> 1. In-place editing of user and saving on server.
> 2. Removed dependency on marshmallow python package.
> 3. UI improvements.
> 4. Search by email.
>
>
>
>
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Tue, May 31, 2016 at 4:24 PM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> On Tue, May 31, 2016 at 2:45 PM, Dave Page <dp...@pgadmin.org> wrote:
>>
>>>
>>>
>>> On Tue, May 31, 2016 at 9:52 AM, Ashesh Vashi <
>>> ashesh.va...@enterprisedb.com> wrote:
>>>
>>>>
>>>>
>>>>
>>>> On Tue, May 31, 2016 at 1:26 PM, Dave Page <dp...@pgadmin.org> wrote:
>>>>
>>>>> Yeah, I was about to reply on this too;
>>>>>
>>>>> - Why do we need Marshmallow?
>>>>>
>>>>> - Why do we need a role system? Perhaps in the future we might have
>>>>> shared servers, and roles that cannot modify them, but not now.
>>>>>
>>>> Hmm..
>>>> He just added one more role - 'Standard'.
>>>> 'Administrator' role was already presents in it.
>>>>
>>>
>>> Oh yes, sorry, misread that. 'pgAdmin User Role' would be a better
>>> description though I think.
>>>
>> Yeah - that can be done. :-)
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> <http://www.enterprisedb.com/>
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> <http://www.linkedin.com/in/asheshvashi>
>>
>>>
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>


Re: [pgadmin-hackers] User management functionality patch [pgadmin4]

2016-06-02 Thread Harshal Dhumal
Hi,

PFA patch for user management functionality.

Major changes in this patch are:

1. In-place editing of user and saving on server.
2. Removed dependency on marshmallow python package.
3. UI improvements.
4. Search by email.





-- 
*Harshal Dhumal*
*Software Engineer*

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

On Tue, May 31, 2016 at 4:24 PM, Ashesh Vashi <ashesh.va...@enterprisedb.com
> wrote:

> On Tue, May 31, 2016 at 2:45 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>>
>>
>> On Tue, May 31, 2016 at 9:52 AM, Ashesh Vashi <
>> ashesh.va...@enterprisedb.com> wrote:
>>
>>>
>>>
>>>
>>> On Tue, May 31, 2016 at 1:26 PM, Dave Page <dp...@pgadmin.org> wrote:
>>>
>>>> Yeah, I was about to reply on this too;
>>>>
>>>> - Why do we need Marshmallow?
>>>>
>>>> - Why do we need a role system? Perhaps in the future we might have
>>>> shared servers, and roles that cannot modify them, but not now.
>>>>
>>> Hmm..
>>> He just added one more role - 'Standard'.
>>> 'Administrator' role was already presents in it.
>>>
>>
>> Oh yes, sorry, misread that. 'pgAdmin User Role' would be a better
>> description though I think.
>>
> Yeah - that can be done. :-)
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com/>
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi>
>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
diff --git a/TODO.txt b/TODO.txt
index 93abba0..1df1305 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -45,3 +45,11 @@ Graphical Explain
 * Explanation on the statistic for the graphical explain plan.
 * Arrow colouring based on the percentage of the cost, and time taken on each
   explain node.
+
+User management
+---
+1. Pagination should be there if there are large number of users.
+2. There should be a way of notifying the user once its password is changed by any administrator.
+3. We can add 'created by' column.
+4. User creation and last modified time.
+5. If current user changes its own name/email, main page should reflect new changes.
\ No newline at end of file
diff --git a/web/config.py b/web/config.py
index 4dd6c76..8f043b2 100644
--- a/web/config.py
+++ b/web/config.py
@@ -150,7 +150,7 @@ MAX_SESSION_IDLE_TIME = 60
 
 # The schema version number for the configuration database
 # DO NOT CHANGE UNLESS YOU ARE A PGADMIN DEVELOPER!!
-SETTINGS_SCHEMA_VERSION = 10
+SETTINGS_SCHEMA_VERSION = 11
 
 # The default path to the SQLite database used to store user accounts and
 # settings. This default places the file in the same directory as this
diff --git a/web/pgadmin/static/css/overrides.css b/web/pgadmin/static/css/overrides.css
index 55d83e0..d746a10 100755
--- a/web/pgadmin/static/css/overrides.css
+++ b/web/pgadmin/static/css/overrides.css
@@ -1232,3 +1232,37 @@ form[name="change_password_form"] .help-block {
 visibility: hidden;
   }
 }
+
+.subnode-footer {
+  text-align: right;
+  border-color: #a9a9a9;
+  border-style: inset inset inset solid;
+  border-width: 2px 1px 0;
+  margin-top: -10px;
+}
+
+.subnode-footer .ajs-button {
+  margin: 2px 2px 0;
+}
+
+.user_management {
+  margin: 0 10px !important;
+  border: 1px solid #ccc;
+  width: calc(100% - 20px);
+  height: 100%;
+  overflow: hidden;
+}
+
+.user_management .search_users form {
+  margin: 0;
+}
+
+.user_management table {
+  display: block;
+  height: 100%;
+  overflow: auto;
+}
+
+.user_management .backform-tab {
+  height: calc(100% - 75px);
+}
\ No newline at end of file
diff --git a/web/pgadmin/tools/user_management/__init__.py b/web/pgadmin/tools/user_management/__init__.py
new file mode 100644
index 000..324ea4d
--- /dev/null
+++ b/web/pgadmin/tools/user_management/__init__.py
@@ -0,0 +1,327 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+
+"""Implements pgAdmin4 User Management Utility"""
+
+import json
+import re
+
+from flask import render_template, request, \
+url_for, Response, abort
+from flask.ext.babel import gettext as _
+from flask.ext.security import login_required, roles_required, current_user
+
+from pgadmin.utils.ajax import make_response 

[pgadmin-hackers] Backgrid passwordCell [pgadmin4]

2016-06-01 Thread Harshal Dhumal
Hi,

PFA patch for backgrid passwordCell


Usage:

schema: [{
  id: 'pass', label: '{{ _('New Password') }}',
  cell: 'password'
}]



-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/static/css/overrides.css b/web/pgadmin/static/css/overrides.css
index 55d83e0..8e5c3f4 100755
--- a/web/pgadmin/static/css/overrides.css
+++ b/web/pgadmin/static/css/overrides.css
@@ -1232,3 +1232,26 @@ form[name="change_password_form"] .help-block {
 visibility: hidden;
   }
 }
+
+.backgrid .string-cell.editor input[type=password] {
+  text-align: left;
+}
+
+.backgrid td.editor input[type=password] {
+  display: block;
+  width: 100%;
+  height: 100%;
+  padding: 0 5px;
+  margin: 0;
+  background-color: transparent;
+  border: 0;
+  outline: 0;
+  -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+  box-shadow: none;
+  -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+  box-sizing: border-box;
+  -webkit-appearance: none;
+ -moz-appearance: none;
+}
\ No newline at end of file
diff --git a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
index 5197f15..6df3aa3 100644
--- a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
+++ b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
@@ -845,6 +845,45 @@
   }
 });
 
+  /**
+   Formatter for PasswordCell.
+
+   @class Backgrid.PasswordFormatter
+   @extends Backgrid.CellFormatter
+   @constructor
+  */
+  var PasswordFormatter = Backgrid.PasswordFormatter = function () {};
+  PasswordFormatter.prototype = new Backgrid.CellFormatter();
+  _.extend(PasswordFormatter.prototype, {
+fromRaw: function (rawValue, model) {
+
+  if (_.isUndefined(rawValue) || _.isNull(rawValue)) return '';
+
+  var pass = '';
+  for(var i = 0; i < rawValue.length; i++) {
+pass += '*';
+  }
+  return pass;
+}
+  });
+
+  var PasswordCell = Backgrid.Extension.PasswordCell  = Backgrid.StringCell.extend({
+
+formatter: PasswordFormatter,
+
+editor: Backgrid.InputCellEditor.extend({
+  attributes: {
+type: "password"
+  },
+
+  render: function () {
+var model = this.model;
+this.$el.val(model.get(this.column.get("name")));
+return this;
+  }
+})
+  });
+
   return Backgrid;
 
 }));

-- 
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] Fix for issue RM1220 and RM 1221 [pgadmin4]

2016-06-21 Thread Harshal Dhumal
Hi,

This patch consist fix for only RM1220
I'll send another patch for RM1221

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Tue, Jun 21, 2016 at 4:08 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch for issues RM1220 and RM1221
>
> Issue fixed: Backup, Restore and Maintenance were causing error with
> database name  with special characters.
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


[pgadmin-hackers] Fix for issue RM1220 and RM 1221 [pgadmin4]

2016-06-21 Thread Harshal Dhumal
Hi,

PFA patch for issues RM1220 and RM1221

Issue fixed: Backup, Restore and Maintenance were causing error with
database name  with special characters.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py
index deb938f..d30db82 100644
--- a/web/pgadmin/misc/bgprocess/processes.py
+++ b/web/pgadmin/misc/bgprocess/processes.py
@@ -156,7 +156,7 @@ class BatchProcess(object):
 # Arguments
 args_csv_io = StringIO()
 csv_writer = csv.writer(
-args_csv_io, delimiter=str(','), quoting=csv.QUOTE_MINIMAL
+args_csv_io, delimiter=str(','), quoting=csv.QUOTE_NONE, quotechar=''
 )
 csv_writer.writerow(_args)
 self.args = args_csv_io.getvalue().strip(str('\r\n'))

-- 
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] Fix for issue RM1220 and RM 1221 [pgadmin4]

2016-06-22 Thread Harshal Dhumal
Hi,

PFA updated patch for issues 1220 and 1221

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Tue, Jun 21, 2016 at 4:41 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Tue, Jun 21, 2016 at 11:38 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA patch for issues RM1220 and RM1221
> >
> > Issue fixed: Backup, Restore and Maintenance were causing error with
> > database name  with special characters.
>
> This patch causes the following error when attempting to run a backup:
>
> "quotechar" must be string, not unicode
>
> If I fix that (by wrapping the '' in str()), it then fails with:
>
> need to escape but no escapechar set.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py
index 5776687..241c43e 100644
--- a/web/pgadmin/misc/bgprocess/processes.py
+++ b/web/pgadmin/misc/bgprocess/processes.py
@@ -154,12 +154,7 @@ class BatchProcess(object):
 self.ecode = None
 
 # Arguments
-args_csv_io = StringIO()
-csv_writer = csv.writer(
-args_csv_io, delimiter=str(','), quoting=csv.QUOTE_MINIMAL
-)
-csv_writer.writerow(_args)
-self.args = args_csv_io.getvalue().strip(str('\r\n'))
+self.args = ",".join(str(arg) for arg in _args)
 
 j = Process(
 pid=int(id), command=_cmd, arguments=self.args, logdir=log_dir,

-- 
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] Fix for issue RM1336 [pgadmin4]

2016-06-16 Thread Harshal Dhumal
Hi,

PAF patch for issue RM1336

Changes: Added keyboard shortcuts (static/non configurable) to some query
tool operations.

Execute  -->   Ctrl + Shift + E
Explain  -->Ctrl + Shift + X
Explain analyze  -->   Ctrl + Shift + A

Note: Keyboard shortcuts do not work if focus is set on any disabled button
inside query tool or out side the query tool.


-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index 43510cd..bde3757 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -61,7 +61,7 @@ body {
 
   
   
-
+
   
 
 
@@ -70,12 +70,12 @@ body {
 
   
 
-  {{ _('Explain') }}
+  {{ _('Explain (Ctrl+Shift+X)') }}
 
   
   
 
-{{ _('Explain analyze') }}
+{{ _('Explain analyze (Ctrl+Shift+A)') }}
 
   
   
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index 60c4ee4..9c9514f 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -175,7 +175,8 @@ define(
 "click #btn-explain-costs": "on_explain_costs",
 "click #btn-explain-buffers": "on_explain_buffers",
 "click #btn-explain-timing": "on_explain_timing",
-"change .limit": "on_limit_change"
+"change .limit": "on_limit_change",
+"keyup": "keyAction"
   },
 
   // This function is used to render the template.
@@ -1010,6 +1011,25 @@ define(
 self,
 self.handler
 );
+  },
+
+  // Callback for keyboard event
+  keyAction: function(ev) {
+if(ev.ctrlKey && ev.shiftKey) {
+  if(ev.keyCode == 69) {
+// char e/E
+// Execute query.
+this.on_flash(ev);
+  } else if(ev.keyCode == 88){
+// char x/X
+// Explain query.
+this.on_explain(ev);
+  } else if(ev.keyCode == 65) {
+// char a/A
+// Explain analyze query.
+this.on_explain_analyze(ev);
+  }
+}
   }
 });
 

-- 
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] Fix for issue RM1336 [pgadmin4]

2016-06-16 Thread Harshal Dhumal
Hi Dave,

Function keys won't work properly with browser as they already have
predefined bindings.

e.g.

F5 for refresh (standard)
F7 for Caret Browsing in firefox


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jun 16, 2016 at 4:10 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi Dave,
>
> Ok, I'll change shortcut keys
>
> New shortcuts would be:
>
> Execute  -->   F5
> Explain  -->F7
> Explain analyze  --> Shift+F7
>
>
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Thu, Jun 16, 2016 at 4:03 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>> Hi,
>>
>> Can we not make them compatible with pgAdmin 3? Ctrl + Shift + E is
>> significantly less convenient than F5.
>>
>> On Thu, Jun 16, 2016 at 11:28 AM, Harshal Dhumal
>> <harshal.dhu...@enterprisedb.com> wrote:
>> > Hi,
>> >
>> > PAF patch for issue RM1336
>> >
>> > Changes: Added keyboard shortcuts (static/non configurable) to some
>> query
>> > tool operations.
>> >
>> > Execute  -->   Ctrl + Shift + E
>> > Explain  -->Ctrl + Shift + X
>> > Explain analyze  -->   Ctrl + Shift + A
>> >
>> > Note: Keyboard shortcuts do not work if focus is set on any disabled
>> button
>> > inside query tool or out side the query tool.
>> >
>> >
>> > --
>> > Harshal Dhumal
>> > Software Engineer
>> >
>> > EnterpriseDB India: 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
>> >
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


Re: [pgadmin-hackers] Fix for issue RM1336 [pgadmin4]

2016-06-16 Thread Harshal Dhumal
Hi,

As per my offline discussion with Ashesh; He is suggesting not to use
Function keys as shortcuts.

And regarding configurable key options, I suspect It is going to be time
consuming task, please let me know if you want me to start working it. Or
can we keep current shortcuts from my last patch?


On Thu, Jun 16, 2016 at 4:19 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> Hmm, I guess that's system dependent. What about Ctrl+F5? Or we bite
> the bullet and make it configurable.
>
On Thu, Jun 16, 2016 at 11:47 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi Dave,
> >
> > Function keys won't work properly with browser as they already have
> > predefined bindings.
> >
> > e.g.
> >
> > F5 for refresh (standard)
> > F7 for Caret Browsing in firefox
> >
> >
> > --
> > Harshal Dhumal
> > Software Engineer
> >
> > EnterpriseDB India: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> >
> > On Thu, Jun 16, 2016 at 4:10 PM, Harshal Dhumal
> > <harshal.dhu...@enterprisedb.com> wrote:
> >>
> >> Hi Dave,
> >>
> >> Ok, I'll change shortcut keys
> >>
> >> New shortcuts would be:
> >>
> >> Execute  -->   F5
> >> Explain  -->F7
> >> Explain analyze  --> Shift+F7
> >>
> >>
> >>
> >> --
> >> Harshal Dhumal
> >> Software Engineer
> >>
> >> EnterpriseDB India: http://www.enterprisedb.com
> >> The Enterprise PostgreSQL Company
> >>
> >> On Thu, Jun 16, 2016 at 4:03 PM, Dave Page <dp...@pgadmin.org> wrote:
> >>>
> >>> Hi,
> >>>
> >>> Can we not make them compatible with pgAdmin 3? Ctrl + Shift + E is
> >>> significantly less convenient than F5.
> >>>
> >>> On Thu, Jun 16, 2016 at 11:28 AM, Harshal Dhumal
> >>> <harshal.dhu...@enterprisedb.com> wrote:
> >>> > Hi,
> >>> >
> >>> > PAF patch for issue RM1336
> >>> >
> >>> > Changes: Added keyboard shortcuts (static/non configurable) to some
> >>> > query
> >>> > tool operations.
> >>> >
> >>> > Execute  -->   Ctrl + Shift + E
> >>> > Explain  -->Ctrl + Shift + X
> >>> > Explain analyze  -->   Ctrl + Shift + A
> >>> >
> >>> > Note: Keyboard shortcuts do not work if focus is set on any disabled
> >>> > button
> >>> > inside query tool or out side the query tool.
> >>> >
> >>> >
> >>> > --
> >>> > Harshal Dhumal
> >>> > Software Engineer
> >>> >
> >>> > EnterpriseDB India: 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
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Dave Page
> >>> Blog: http://pgsnake.blogspot.com
> >>> Twitter: @pgsnake
> >>>
> >>> EnterpriseDB UK: http://www.enterprisedb.com
> >>> The Enterprise PostgreSQL Company
> >>
> >>
> >
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgadmin-hackers] Fix for issue RM1336 [pgadmin4]

2016-06-16 Thread Harshal Dhumal
Hi Dave,

Ok, I'll change shortcut keys

New shortcuts would be:

Execute  -->   F5
Explain  -->F7
Explain analyze  --> Shift+F7



-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jun 16, 2016 at 4:03 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi,
>
> Can we not make them compatible with pgAdmin 3? Ctrl + Shift + E is
> significantly less convenient than F5.
>
> On Thu, Jun 16, 2016 at 11:28 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PAF patch for issue RM1336
> >
> > Changes: Added keyboard shortcuts (static/non configurable) to some query
> > tool operations.
> >
> > Execute  -->   Ctrl + Shift + E
> > Explain  -->Ctrl + Shift + X
> > Explain analyze  -->   Ctrl + Shift + A
> >
> > Note: Keyboard shortcuts do not work if focus is set on any disabled
> button
> > inside query tool or out side the query tool.
> >
> >
> > --
> > Harshal Dhumal
> > Software Engineer
> >
> > EnterpriseDB India: 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
> >
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgadmin-hackers] Fix for issue RM1220 and RM 1221 [pgadmin4]

2016-06-23 Thread Harshal Dhumal
One more thing that this also fails in pgadmin3 as well.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jun 23, 2016 at 6:26 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi Dave,
>
> It seems that pg_dump utility does not handle database name properly with
> equal to (=) sign in it.
>
> Observe above stack trace, we are generating command line command
> properly. However pg_dump only takes database name upto equal to sign reset
> is ignored.
>
> e.g. Database name in command is *"!#$%^&*()_+{}|:\"<>?=-\\][';/**.,"*
> but in pg_dump error it says *failed: invalid connection option
> "!#$%^&*()_+{}|:"<>?"*
>
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Thu, Jun 23, 2016 at 4:19 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>> On Wed, Jun 22, 2016 at 11:09 AM, Harshal Dhumal
>> <harshal.dhu...@enterprisedb.com> wrote:
>> > Hi,
>> >
>> > PFA updated patch for issues 1220 and 1221
>>
>> Hi
>>
>> Still not working I'm afraid:
>>
>> Backing up an object on the server 'PostgreSQL 9.4 (127.0.0.1:5432)'
>> from database '!#$%^&*()_+{}|:"<>?=-\][';/.,'...
>> Running command:
>> /Library/PostgreSQL/9.5/bin/pg_dump --file
>> "/Users/dpage/.pgadmin/storage/dpage/foo.sql" --host "127.0.0.1"
>> --port "5432" --username "postgres" --no-password --verbose --format=c
>> --blobs --section=pre-data --section=data --section=post-data
>> "!#$%^&*()_+{}|:\"<>?=-\\][';/.,"
>>
>> Start time: Thu Jun 23 2016 11:49:06 GMT+0100 (BST)
>>
>> pg_dump: [archiver (db)] connection to database "" failed: invalid
>> connection option "!#$%^&*()_+{}|:"<>?"
>> error: [Errno 9] Bad file descriptor
>> r = self.sock.recv(1024)
>> File "/Applications/PyCharm
>> CE.app/Contents/helpers/pydev/pydevd_comm.py", line 329, in OnRun
>> Traceback (most recent call last):
>>
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


Re: [pgadmin-hackers] Fix for issue RM1220 and RM 1221 [pgadmin4]

2016-06-23 Thread Harshal Dhumal
Hi Dave,

It seems that pg_dump utility does not handle database name properly with
equal to (=) sign in it.

Observe above stack trace, we are generating command line command properly.
However pg_dump only takes database name upto equal to sign reset is
ignored.

e.g. Database name in command is *"!#$%^&*()_+{}|:\"<>?=-\\][';/**.,"* but
in pg_dump error it says *failed: invalid connection option
"!#$%^&*()_+{}|:"<>?"*


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jun 23, 2016 at 4:19 PM, Dave Page <dp...@pgadmin.org> wrote:

> On Wed, Jun 22, 2016 at 11:09 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA updated patch for issues 1220 and 1221
>
> Hi
>
> Still not working I'm afraid:
>
> Backing up an object on the server 'PostgreSQL 9.4 (127.0.0.1:5432)'
> from database '!#$%^&*()_+{}|:"<>?=-\][';/.,'...
> Running command:
> /Library/PostgreSQL/9.5/bin/pg_dump --file
> "/Users/dpage/.pgadmin/storage/dpage/foo.sql" --host "127.0.0.1"
> --port "5432" --username "postgres" --no-password --verbose --format=c
> --blobs --section=pre-data --section=data --section=post-data
> "!#$%^&*()_+{}|:\"<>?=-\\][';/.,"
>
> Start time: Thu Jun 23 2016 11:49:06 GMT+0100 (BST)
>
> pg_dump: [archiver (db)] connection to database "" failed: invalid
> connection option "!#$%^&*()_+{}|:"<>?"
> error: [Errno 9] Bad file descriptor
> r = self.sock.recv(1024)
> File "/Applications/PyCharm
> CE.app/Contents/helpers/pydev/pydevd_comm.py", line 329, in OnRun
> Traceback (most recent call last):
>
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgadmin-hackers] Fix for issue RM1336 [pgadmin4]

2016-06-20 Thread Harshal Dhumal
Hi Dave,

I tried to find unique shortcuts keys combination using function keys on
different platforms (windows, mac, linux ) but no success. Any combination
of function keys with either of (or some of them together) Alt, Ctrl, Shift
conflict with either browser functionality or with window functionality
(like resize, move, minimize, maximize etc).

And regarding Ctrl+F5, it is for hard refresh on some browsers.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jun 16, 2016 at 8:03 PM, Dave Page <dp...@pgadmin.org> wrote:

> On Thu, Jun 16, 2016 at 3:28 PM, Ashesh Vashi
> <ashesh.va...@enterprisedb.com> wrote:
> > On Thu, Jun 16, 2016 at 5:10 PM, Dave Page <dp...@pgadmin.org> wrote:
> >>
> >> On Thu, Jun 16, 2016 at 12:14 PM, Harshal Dhumal
> >> <harshal.dhu...@enterprisedb.com> wrote:
> >> > Hi,
> >> >
> >> > As per my offline discussion with Ashesh; He is suggesting not to use
> >> > Function keys as shortcuts.
> >>
> >> Why? That is primarily what they are on the keyboard for.
> >
> > F5 is always bind to refresh function of the browser on linux & windows.
> > Similarly - many shortcuts of browser are bound to the function keys.
> >
> > Hence - I asked not to use F5.
>
> I suggested Ctrl+F5.
>



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


[pgadmin-hackers] Fix for RM1386 [pgamin4]

2016-06-21 Thread Harshal Dhumal
Hi,

PFA patch for issue RM1386


Issue Fixed: Now User cannot be created with single (or less than 6 )
character password.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js b/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js
index 3fad4f1..ca34b2d 100644
--- a/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js
+++ b/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js
@@ -210,7 +210,7 @@ define([
 
   this.errorModel.set('newPassword', errmsg);
   return errmsg;
-} else if ('newPassword' in changedAttrs && !_.isUndefined(this.get('newPassword')) &&
+} else if (!_.isUndefined(this.get('newPassword')) &&
   !_.isNull(this.get('newPassword')) &&
   this.get('newPassword').length < 6) {
 

-- 
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] Variable js issue [pgAdmin4]

2016-01-17 Thread Harshal Dhumal
Hi,

Here is patch for variable.js

Issues fixed:
1. Parsing variables values of type int and float/real [Ashesh Vashi].
2. variables tab header form control not found issue [Ashesh Vashi].




-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
index bb68951..ed46080 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
@@ -38,7 +38,7 @@
   var VariableModel = pgNode.VariableModel = pgNode.Model.extend({
 defaults: {
   name: undefined,
-  value: '',
+  value: undefined,
   role: undefined,
   database: undefined,
 },
@@ -70,6 +70,7 @@
 },
 validate: function() {
   if (_.isUndefined(this.get('value')) ||
+  _.isNull(this.get('value')) ||
   String(this.get('value')).replace(/^\s+|\s+$/g, '') == '') {
 var msg = 'Please enter some value!';
 
@@ -166,7 +167,7 @@
 
   var formatter = self.formatter;
 
-  formatter.decimals = self.decimals;
+  formatter.decimals = 0;
   formatter.decimalSeparator = self.decimalSeparator;
   formatter.orderSeparator = self.orderSeparator;
 
@@ -291,12 +292,11 @@
   var headerGroups = Backform.generateViewSchema(
   self.field.get('node_info'), self.headerData, 'create',
   node, self.field.get('node_data')
-  );
+  ),
+  fields = [];
 
-  var fields = [];
-
-  _.each(headerGroups, function(val, key) {
-fields = fields.concat(headerGroups[key]);
+  _.each(headerGroups, function(o) {
+fields = fields.concat(o.fields);
   });
 
   self.headerFields = new Backform.Fields(fields);
@@ -312,7 +312,6 @@
   self.listenTo(self.headerData, "select2", self.headerDataChanged);
   self.listenTo(self.collection, "remove", self.onRemoveVariable);
 },
-
 /*
  * Get the variable data for this node.
  */
@@ -476,6 +475,30 @@
   });
   }
 
+  // Change format of each of the data
+  // Because - data coming from the server is in string format
+  self.collection.each(function(model){
+var name = model.get("name");
+
+if (name in self.availVariables) {
+  switch(self.availVariables[name].vartype) {
+case 'real':
+  var v = parseFloat(model.get('value'));
+  model.set('value', (isNaN(v) ? undefined : v), {silent: true});
+
+  break;
+case 'integer':
+  var v = parseInt(model.get('value'));
+  model.set('value', (isNaN(v) ? undefined : v), {silent: true});
+
+  break;
+default:
+  break;
+  }
+}
+  });
+  self.collection.startNewSession();
+
   // Initialize a new Grid instance
   var grid = self.grid = new Backgrid.Grid({
 columns: gridSchema.columns,

-- 
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] New mechanism in backgrid to render different types of cells in same column [pgAdmin4]

2016-01-18 Thread Harshal Dhumal
Hi,

This patch is replacement for our developed DynamicVariablecell.

Now we can pass cellFunction in column schema to get appropriate cell class.
User provided cellFunction must return valid cell class.
cellFunction will be called with context (this) as column and model as
argument.

eg.:

schema: [
  {id: 'name', label:'Name', type:'text', editable: false, cell: 'string'},
  {
id: 'value', label:'Value', type: 'text', editable: true,
cellFunction: function(model){

  if (isNaN(model.get(this.get('name' {
 return "string";
  } else {
  return Backgrid.NumberCell;
 }
  }
  },
  {id: 'database', label:'Database', type: 'text', editable: false},
  .
  .
  .




-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
index 2ead1a0..d0ba646 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
@@ -31,6 +31,46 @@
   }
 } (this, function(root, _, $, Backbone, Backform, Alertify, pgAdmin, pgNode) {
 
+  /*
+   * cellFunction for variable control.
+   * This function returns cell class depending on vartype.
+   */
+  var cellFunction = function(model) {
+var self = this,
+  name = model.get("name"),
+  availVariables = self.get('availVariables'),
+  variable = availVariables[name];
+
+switch(variable && variable.vartype) {
+  case "bool":
+return Backgrid.Extension.SwitchCell;
+  break;
+  case "enum":
+var options = [],
+enumVals = variable.enumvals;
+
+_.each(enumVals, function(enumVal) {
+  options.push([enumVal, enumVal]);
+});
+return Backgrid.Extension.Select2Cell.extend(
+{ optionValues: options }
+);
+  break;
+  case "integer":
+return Backgrid.IntegerCell;
+break;
+  case "real":
+return Backgrid.NumberCell.extend({ decimals: 0 });
+  break;
+  case "string":
+return Backgrid.StringCell;
+  break;
+  default:
+Backgrid.Cell;
+  break;
+}
+  }
+
   /**
*  VariableModel used to represent configuration parameters (variables tab)
*  for database objects.
@@ -46,8 +86,8 @@
 schema: [
   {id: 'name', label:'Name', type:'text', editable: false, cellHeaderClasses: 'width_percent_30'},
   {
-id: 'value', label:'Value', type: 'text', cell: 'dynamic-variable',
-editable: true, cellHeaderClasses: 'width_percent_50'
+id: 'value', label:'Value', type: 'text', editable: true,
+cellFunction: cellFunction, cellHeaderClasses: 'width_percent_50'
   },
   {id: 'database', label:'Database', type: 'text', editable: false},
   {id: 'role', label:'Role', type: 'text', editable: false}
@@ -85,102 +125,6 @@
 }
   });
 
-  /*
-   * Dynamic Variable cell. Used for variable data type column in Variables tab.
-   * Behaviour of cell depends on variable data type.
-   */
-  var DynamicVariableCell = Backgrid.Extension.DynamicVariableCell = Backgrid.Cell.extend({
-/*
- * Mapping of postgres data type to backgrid cell type.
- */
-variableCellMapper: {
-  "bool":Backgrid.Extension.SwitchCell,
-  "enum":Backgrid.Extension.Select2Cell,
-  "string":Backgrid.Cell,
-  "integer":Backgrid.IntegerCell,
-  "real":Backgrid.NumberCell
-},
-initialize: function (opts) {
-
-  var self = this,
-  name = opts.model.get("name");
-  self.availVariables = opts.column.get('availVariables');
-
-  var variable = (self.availVariables[name]),
-  cell = self.variableCellMapper[variable && variable.vartype] || Backgrid.Cell;
-
-  /*
-   * Set properties for dynamic cell.
-   */
-  _.each(cell.prototype, function(v,k) {
-self[k] = v;
-  });
-
-  DynamicVariableCell.__super__.initialize.apply(self, arguments);
-
-  switch(variable && variable.vartype) {
-case "bool":
-  // There are no specific properties for BooleanCell.
-  break;
-
-case "enum":
-  var options = [],
-  name = self.model.get("name"),
-  enumVals = variable.enumvals;
-
-  _.each(enumVals, function(enumVal) {
-options.push([enumVal, enumVal]);
-  });
-
-  self.optionValues = options;
-  self.multiple = cell.prototype.multiple;
-  self.delimiter = cell.prototype.delimiter;
-
-  self.listenTo(
-  self.model, "backgrid:edit",
-  function (model, column,

[pgadmin-hackers] Re: New mechanism in backgrid to render different types of cells in same column [pgAdmin4]

2016-01-18 Thread Harshal Dhumal
+
Also fixed some minor issues related to Unique column functionality in
Variable control in same patch.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Tue, Jan 19, 2016 at 12:37 AM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> This patch is replacement for our developed DynamicVariablecell.
>
> Now we can pass cellFunction in column schema to get appropriate cell
> class.
> User provided cellFunction must return valid cell class.
> cellFunction will be called with context (this) as column and model as
> argument.
>
> eg.:
>
> schema: [
>   {id: 'name', label:'Name', type:'text', editable: false, cell: 'string'},
>   {
> id: 'value', label:'Value', type: 'text', editable: true,
> cellFunction: function(model){
>
>   if (isNaN(model.get(this.get('name' {
>  return "string";
>   } else {
>   return Backgrid.NumberCell;
>  }
>   }
>   },
>   {id: 'database', label:'Database', type: 'text', editable: false},
>   .
>   .
>   .
>
>
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>


[pgadmin-hackers] Privilege control with select2cell for user role section

2016-01-15 Thread Harshal Dhumal
Hi,

Please find the attached path for Privilege control with select2cell for
user role section

TODO:  Need to add current database logged in user in Granter filed in
privilege grid control.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index c38265d..04156ee 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -115,7 +115,8 @@ class ServerModule(sg.ServerGroupPluginModule):
 {
 'name': 'pgadmin.browser.server.privilege',
 'path': url_for('browser.index') + 'server/static/js/privilege',
-'when': self.node_type
+'when': self.node_type,
+'deps': ['pgadmin.browser.node.ui']
 },
 {
 'name': 'pgadmin.browser.server.variable',
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
index 2f6f052..651f837 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
@@ -5,7 +5,7 @@
  function(_, $, Backbone, Backform, Backgrid, Alertify, pgNode) {
   // Export global even in AMD case in case this script is loaded with
   // others that may still expect a global Backform.
-  return factory(root, _, $, Backbone, Backform, Alertify, pgNode);
+  return factory(root, _, $, Backbone, Backform, Backgrid, Alertify, pgNode);
 });
 
   // Next for Node.js or CommonJS. jQuery may not be needed as a module.
@@ -14,15 +14,16 @@
   $ = root.jQuery || root.$ || root.Zepto || root.ender,
   Backbone = require('backbone') || root.Backbone,
   Backform = require('backform') || root.Backform;
+  Backgrid = require('backgrid') || root.Backgrid;
   Alertify = require('alertify') || root.Alertify;
   pgAdmin = require('pgadmin.browser.node') || root.pgAdmin.Browser.Node;
 factory(root, _, $, Backbone, Backform, Alertify, pgNode);
 
   // Finally, as a browser global.
   } else {
-factory(root, root._, (root.jQuery || root.Zepto || root.ender || root.$), root.Backbone, root.Backform, root.pgAdmin.Browser.Node);
+factory(root, root._, (root.jQuery || root.Zepto || root.ender || root.$), root.Backbone, root.Backform, root.Backgrid, root.alertify, root.pgAdmin.Browser.Node);
   }
-} (this, function(root, _, $, Backbone, Backform, Alertify, pgNode) {
+} (this, function(root, _, $, Backbone, Backform, Backgrid, Alertify, pgNode) {
 
   /**
* Each Privilege, supporeted by an database object, will be represented
@@ -66,15 +67,39 @@
 privileges:[],
 
 schema: [{
-  id: 'grantee', label:'Grantee', type:'text', group: null, cell: 'string',
-  disabled: true, cellHeaderClasses: 'width_percent_40'
+  id: 'grantee', label:'Grantee', type:'text', group: null,
+  editable: true, cellHeaderClasses: 'width_percent_40',
+  cell: 'node-list-by-name', node: 'role',
+  disabled : function(column, collection) {
+if (column instanceof Backbone.Collection) {
+  // This has been called during generating the header cell
+  return false;
+}
+return !(this.node_info && this.node_info.server.user.name == column.get('grantor'));
+  },
+  transform: function(data) {
+var res =
+  Backgrid.Extension.NodeListByNameCell.prototype.defaults.transform.apply(
+this, arguments
+);
+res.unshift({label: 'public', value: 'public'});
+return res;
+  }
 }, {
   id: 'privileges', label:'Privileges',
   type: 'collection', model: PrivilegeModel, group: null,
-  disabled: false, cell: 'privilege', control: 'text',
-  cellHeaderClasses: 'width_percent_40'
+  cell: 'privilege', control: 'text', cellHeaderClasses: 'width_percent_40',
+  disabled : function(column, collection) {
+if (column instanceof Backbone.Collection) {
+  // This has been called during generating the header cell
+  return false;
+}
+return !(this.node_info && this.node_info.server.user.name == column.get('grantor') ||
+this.attributes.node_info.server.user.name == column.get('grantor'));
+  }
 },{
-  id: 'grantor', label: 'Granter', type: 'text', disabled: true
+  id: 'grantor', label: 'Granter', type: 'text', disabled: true,
+  cell: 'node-list-by-name', node: 'role'
 }],
 
 /*
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index 7642a47..e38adcb 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -4,7 +4,6 @@ function($, _, pgAdmin, Backbone, Backform, Aler

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

2016-02-10 Thread Harshal Dhumal
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 <http://www.enterprisedb.com>

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 <http://www.enterprisedb.com>
>
> 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.enterprisedb.com/>
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> <http://www.linkedin.com/in/asheshvashi>
>>
>>>
>>>
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer *
>>>
>>>
>>>
>>> EenterpriseDB <http://www.enterprisedb.com>
>>>
>>>
>>> --
>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>
>>>
>>
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros
new file mode 100644
index 000..cec2e53
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros
@@ -0,0 +1,14 @@
+{##}
+{# Macros for schema and its child nodes  #}
+{##}
+{% macro SET(conn, type, role, param, priv, with_grant, schema) -%}
+{% if priv %}
+GRANT {{ priv }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }};
+{% endif %}
+{% if with_grant %}
+GRANT {{ with_grant }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+{% endif %}
+{%- endmacro %}
+{% macro UNSETALL(conn, type, role, param, schema) -%}
+REVOKE ALL ON {{ type }} {{ conn|qtIdent(schema, param) }} FROM {{ conn|qtIdent(role) }};
+{%- endmacro %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/security.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/security.macros
new file mode 100644
index 000..e1126b1
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/security.macros
@@ -0,0 +1,9 @@
+{##}
+{# Macros for schema and its child nodes  #}
+{##}
+{% macro SET(conn, type, name, provider, label, schema) -%}
+SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(schema, name) }} IS {{ label|qtLiteral }};
+{%- endmacro %}
+{% macro UNSET(conn, type, name, provider, schema) -%}
+SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(schema, name) }} IS NULL;
+{%- endmacro %}
\ No newline at end of file

-- 
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 sequence node [pgadmin4]

2016-02-10 Thread Harshal Dhumal
Hi,

PFA updated patch for sequence node.

*Changes:* Updated sql files to refer macros from
schemas/templates/macros/schemas folder instead of servers/templates/macros


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

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

> Hi,
>
> Here is updated patch for sequence node. As macros are changed for
> security and privileges.
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>
> On Tue, Feb 9, 2016 at 4:19 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch for sequence node.
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
new file mode 100644
index 000..65644a7
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
@@ -0,0 +1,536 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+import json
+from flask import render_template, make_response, request, jsonify
+from flask.ext.babel import gettext as _
+from pgadmin.utils.ajax import make_json_response, \
+make_response as ajax_response, internal_server_error
+from pgadmin.browser.utils import NodeView
+from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
+parse_priv_to_db
+from pgadmin.browser.collection import CollectionNodeModule
+import pgadmin.browser.server_groups.servers.databases as database
+from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.driver import get_driver
+from config import PG_DEFAULT_DRIVER
+from functools import wraps
+
+class SequenceModule(CollectionNodeModule):
+NODE_TYPE = 'sequence'
+COLLECTION_LABEL = _("Sequences")
+
+def __init__(self, *args, **kwargs):
+self.min_ver = None
+self.max_ver = None
+super(SequenceModule, self).__init__(*args, **kwargs)
+
+# Before loading this module we need to make sure that scid is catalog and schema object
+# and catalog name is 'sys', 'dbo', 'information_schema' then only we load this module
+def BackendSupported(self, manager, **kwargs):
+"""
+This function will validate schema name & scid against sequence then allow us to
+make decision if we want to load this module or not for that schema
+"""
+if super(SequenceModule, self).BackendSupported(manager, **kwargs):
+conn = manager.connection()
+# If DB is not connected then return error to browser
+if not conn.connected():
+return precondition_required(
+_(
+"Connection to the server has been lost!"
+)
+)
+
+ver = manager.version
+# we will set template path for sql scripts
+if ver >= 90100:
+template_path = 'sequence/sql/9.1_plus'
+else:
+template_path = 'sequence/sql/pre_9.1'
+
+SQL = render_template("/".join([template_path, 'backend_support.sql']), scid=kwargs['scid'])
+status, res = conn.execute_scalar(SQL)
+# check if any errors
+if not status:
+return internal_server_error(errormsg=res)
+# Check scid is catalog and from 'sys', 'dbo', 'information_schema',
+# then False (Do not load this module), othewise True
+if res is True:
+return False
+else:
+return True
+
+def get_nodes(self, gid, sid, did, scid):
+"""
+Generate the sequence node
+"""
+yield self.generate_browser_collection_node(scid)
+
+@property
+def script_load(self):
+"""
+Load the module script for database, when any of the database node is
+initialized.
+"""
+return database.DatabaseModule.NODE_TYPE
+
+blueprint = SequenceModule(__name__)
+
+
+class SequenceView(NodeView):
+node_type = blueprint.node_type
+
+parent_ids = [
+{'type': 'int', 'id': 'gid'},
+{'type': 'int', 'id': 'sid'},
+{'type': 'int', 'id

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

2016-02-10 Thread Harshal Dhumal
+ 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 <http://www.enterprisedb.com>

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 <http://www.enterprisedb.com>
>
> 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 <http://www.enterprisedb.com>
>>
>> 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.enterprisedb.com/>
>>>
>>>
>>> *http://www.linkedin.com/in/asheshvashi*
>>> <http://www.linkedin.com/in/asheshvashi>
>>>
>>>>
>>>>
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Software Engineer *
>>>>
>>>>
>>>>
>>>> EenterpriseDB <http://www.enterprisedb.com>
>>>>
>>>>
>>>> --
>>>> 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] Common utility functions to parse privileges [pgadmin4]

2016-02-04 Thread Harshal Dhumal
Hi,

PFA patch for server utility functions to parse privileges.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/utils.py b/web/pgadmin/browser/server_groups/servers/utils.py
new file mode 100644
index 000..d765d91
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/utils.py
@@ -0,0 +1,94 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+
+"""Server helper utilities"""
+
+
+def parse_priv_from_db(db_privileges):
+"""
+Common utility function to parse privileges retrieved from database.
+"""
+acl = {'grantor':db_privileges['grantor'],
+'grantee':db_privileges['grantee'],
+'privileges':[]
+}
+
+privileges = []
+for idx, priv in enumerate(db_privileges['privileges']):
+if db_privileges['grantable'][idx]:
+privileges.append({"privilege_type": priv,
+"privilege": True,
+"with_grant": True
+})
+else:
+privileges.append({"privilege_type": priv,
+"privilege": True,
+"with_grant": False
+})
+
+acl['privileges'] = privileges
+
+return acl
+
+
+def parse_priv_to_db(str_privileges, object_type = None):
+"""
+Common utility function to parse privileges before sending to database.
+"""
+db_privileges = {
+'c': 'CONNECT',
+'C': 'CREATE',
+'T': 'TEMPORARY',
+'a': 'INSERT',
+'r': 'SELECT',
+'w': 'UPDATE',
+'d': 'DELETE',
+'D': 'TRUNCATE',
+'x': 'REFERENCES',
+'t': 'TRIGGER',
+'U': 'USAGE',
+'X': 'EXECUTE'
+}
+privileges_max_cnt = {
+'DATABASE': 3,
+'TABLESPACE': 2,
+'SCHEMA': 2
+  }
+
+privileges = []
+
+for priv in str_privileges:
+priv_with_grant = []
+priv_without_grant = []
+for privilege in priv['privileges']:
+if privilege['with_grant']:
+priv_with_grant.append(
+db_privileges[privilege['privilege_type']]
+)
+elif privilege['privilege']:
+priv_without_grant.append(
+db_privileges[privilege['privilege_type']]
+)
+
+if object_type in ("DATABASE", "SCHEMA", "TABLESPACE"):
+priv_with_grant = ", ".join(priv_with_grant) if (
+  len(priv_with_grant) < privileges_max_cnt[object_type.upper()]
+  ) else 'ALL'
+priv_without_grant = ", ".join(priv_without_grant) if (
+  len(priv_without_grant) < privileges_max_cnt[object_type.upper()]
+  ) else 'ALL'
+else:
+priv_with_grant = ", ".join(priv_with_grant)
+priv_without_grant = ", ".join(priv_without_grant)
+
+privileges.append({'grantee': priv['grantee'],
+   'with_grant': priv_with_grant,
+   'without_grant': priv_without_grant})
+
+return privileges

-- 
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] Patch sequence node [pgadmin4]

2016-02-09 Thread Harshal Dhumal
Hi,

PFA patch for sequence node.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
new file mode 100644
index 000..b159731
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
@@ -0,0 +1,510 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+import json
+from flask import render_template, make_response, request, jsonify
+from flask.ext.babel import gettext as _
+from pgadmin.utils.ajax import make_json_response, \
+make_response as ajax_response, internal_server_error
+from pgadmin.browser.utils import NodeView
+from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
+parse_priv_to_db
+from pgadmin.browser.collection import CollectionNodeModule
+import pgadmin.browser.server_groups.servers.databases as database
+from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.driver import get_driver
+from config import PG_DEFAULT_DRIVER
+from functools import wraps
+
+class SequenceModule(CollectionNodeModule):
+NODE_TYPE = 'sequence'
+COLLECTION_LABEL = _("Sequences")
+
+def __init__(self, *args, **kwargs):
+self.min_ver = None
+self.max_ver = None
+super(SequenceModule, self).__init__(*args, **kwargs)
+
+# Before loading this module we need to make sure that scid is catalog and schema object
+# and catalog name is 'sys', 'dbo', 'information_schema' then only we load this module
+def BackendSupported(self, manager, **kwargs):
+"""
+This function will validate schema name & scid against sequence then allow us to
+make decision if we want to load this module or not for that schema
+"""
+if super(SequenceModule, self).BackendSupported(manager, **kwargs):
+conn = manager.connection()
+# If DB is not connected then return error to browser
+if not conn.connected():
+return precondition_required(
+_(
+"Connection to the server has been lost!"
+)
+)
+
+ver = manager.version
+# we will set template path for sql scripts
+if ver >= 90100:
+template_path = 'sequence/sql/9.1_plus'
+else:
+template_path = 'sequence/sql/pre_9.1'
+
+SQL = render_template("/".join([template_path, 'backend_support.sql']), scid=kwargs['scid'])
+status, res = conn.execute_scalar(SQL)
+# check if any errors
+if not status:
+return internal_server_error(errormsg=res)
+# Check scid is catalog and from 'sys', 'dbo', 'information_schema',
+# then False (Do not load this module), othewise True
+if res is True:
+return False
+else:
+return True
+
+def get_nodes(self, gid, sid, did, scid):
+"""
+Generate the sequence node
+"""
+yield self.generate_browser_collection_node(scid)
+
+@property
+def script_load(self):
+"""
+Load the module script for database, when any of the database node is
+initialized.
+"""
+return database.DatabaseModule.NODE_TYPE
+
+blueprint = SequenceModule(__name__)
+
+
+class SequenceView(NodeView):
+node_type = blueprint.node_type
+
+parent_ids = [
+{'type': 'int', 'id': 'gid'},
+{'type': 'int', 'id': 'sid'},
+{'type': 'int', 'id': 'did'},
+{'type': 'int', 'id': 'scid'}
+]
+ids = [
+{'type': 'int', 'id': 'seid'}
+]
+
+operations = dict({
+'obj': [
+{'get': 'properties', 'delete': 'delete', 'put': 'update'},
+{'get': 'list', 'post': 'create'}
+],
+'delete': [{'delete': 'delete'}],
+'children': [{'get': 'children'}],
+'nodes': [{'get': 'node'}, {'get': 'nodes'}],
+'sql': [{'get': 'sql'}],
+'msql': [{'get': 'msql'}, {'get': 'msql'}],
+'stats': [{'get': 'statistics'}],
+'dependency': [{'get': 'dependencies'}],
+'dependent': [{'get': 'dependents'}],
+'module.js': [{}, {}, {'get': 'module_js'}]
+})
+
+def module_js(self):
+"""
+This property defines (if javascript) ex

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

2016-02-09 Thread Harshal Dhumal
Hi,

PFA of macros  (privilege, security) for sequence node.

Also fixed minor issue in security macro (removed unwanted qtIdent for
provider)


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros b/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
index 1d6660c..44932c7 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
@@ -1,3 +1,6 @@
+{}
+{# This is generic macro for other objects #}
+{}
 {% macro APPLY(conn, type, role, param, priv, with_grant) -%}
 {% if priv %}
 GRANT {{ priv }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIdent(role) }};
@@ -8,4 +11,18 @@ GRANT {{ with_grant }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIden
 {%- endmacro %}
 {% macro RESETALL(conn, type, role, param) -%}
 REVOKE ALL ON {{ type }} {{ conn|qtIdent(param) }} FROM {{ conn|qtIdent(role) }};
+{%- endmacro %}
+{}
+{# This macro is specific to sequence object#}
+{}
+{% macro SET(conn, type, role, param, priv, with_grant) -%}
+{% if priv %}
+GRANT {{ priv }} ON {{ type }} {{ param }} TO {{ conn|qtIdent(role) }};
+{% endif %}
+{% if with_grant %}
+GRANT {{ with_grant }} ON {{ type }} {{ param }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+{% endif %}
+{%- endmacro %}
+{% macro UNSETALL(conn, type, role, param) -%}
+REVOKE ALL ON {{ type }} {{ param }} FROM {{ conn|qtIdent(role) }};
 {%- endmacro %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/macros/security.macros b/web/pgadmin/browser/server_groups/servers/templates/macros/security.macros
index 83fb9d2..3709a3e 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/macros/security.macros
+++ b/web/pgadmin/browser/server_groups/servers/templates/macros/security.macros
@@ -1,6 +1,18 @@
+{}
+{# This is generic macro for other objects #}
+{}
 {% macro APPLY(conn, type, name, provider, label) -%}
-SECURITY LABEL FOR {{ conn|qtIdent(provider) }} ON {{ type }} {{ conn|qtIdent(name) }} IS {{ label|qtLiteral }};
+SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(name) }} IS {{ label|qtLiteral }};
 {%- endmacro %}
 {% macro DROP(conn, type, name, provider) -%}
-SECURITY LABEL FOR {{ conn|qtIdent(provider) }} ON {{ type }} {{ conn|qtIdent(name) }} IS NULL;
+SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(name) }} IS NULL;
 {%- endmacro %}
+{}
+{# This macro is specific to sequence object#}
+{}
+{% macro SET(conn, type, name, provider, label) -%}
+SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ name }} IS {{ label|qtLiteral }};
+{%- endmacro %}
+{% macro UNSET(conn, type, name, provider) -%}
+SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ name }} IS NULL;
+{%- endmacro %}
\ No newline at end of file

-- 
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] Minor database patch [pgadmin4]

2016-02-09 Thread Harshal Dhumal
Hi,

PFA patch for database node.

Enhancement: We don't need to disconnect and connect to databse for each
single offline query. We can disconnect once then apply queries and then
connect again.

And minor code refactoring (more pythonic way)


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index 5d1d7a5..a015797 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -290,10 +290,7 @@ class DatabaseView(NodeView):
 def formatdbacl(res, dbacl):
 for row in dbacl:
 priv = parse_priv_from_db(row)
-if row['deftype'] in res['rows'][0]:
-res['rows'][0][row['deftype']].append(priv)
-else:
-res['rows'][0][row['deftype']] = [priv]
+res['rows'][0].setdefault(row['deftype'], []).append(priv)
 return res
 
 def module_js(self):
@@ -500,22 +497,21 @@ class DatabaseView(NodeView):
 data['name'] = name
 
 try:
+status = self.manager.release(did=did)
+conn = self.manager.connection()
 for action in ["rename_database", "tablespace"]:
 SQL = self.getOfflineSQL(gid, sid, data, did, action)
 SQL = SQL.strip('\n').strip(' ')
 if SQL and SQL != "":
-status = self.manager.release(did=did)
-
-conn = self.manager.connection()
 status, msg = conn.execute_scalar(SQL)
-
 if not status:
 return internal_server_error(errormsg=msg)
 
-self.conn = self.manager.connection(database=data['name'], auto_reconnect=True)
-status, errmsg = self.conn.connect()
 info = "Database updated."
 
+self.conn = self.manager.connection(database=data['name'], auto_reconnect=True)
+status, errmsg = self.conn.connect()
+
 SQL = self.getOnlineSQL(gid, sid, data, did)
 SQL = SQL.strip('\n').strip(' ')
 if SQL and SQL != "":

-- 
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] Minor issue in variable js [pgadmin4]

2016-02-05 Thread Harshal Dhumal
Hi All,

Now ignore this patch as this issue is covered in this commit.
<http://git.postgresql.org/gitweb/?p=pgadmin4.git;a=commitdiff;h=a0648ed54b9a5079434d8a4ebcd09e30e3f54098>

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Tue, Feb 2, 2016 at 4:55 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA minor patch for variable js.
>
> Issue fixed: Initialize boolean cell with proper data (either true or
> false not undefined).
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>


[pgadmin-hackers] Privilege control: disable with grant ops if grantee is public [pgAdmin4]

2016-02-10 Thread Harshal Dhumal
Hi,

PFA patch for privilege control.

*Issue fixed:* Disable all with grant options if grantee is public.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
index 2b8ceb4..dbc517d 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
@@ -152,9 +152,19 @@
 privileges.add(p, {silent: true});
   });
 
+  this.on("change:grantee", this.granteeChanged)
   return this;
 },
-
+granteeChanged: function() {
+  var privileges = this.get('privileges'),
+grantee = this.get('grantee');
+  // Reset all with grant options if grantee is public.
+  if (grantee == 'public') {
+privileges.each(function(m) {
+  m.set("with_grant", false);
+});
+  }
+},
 toJSON: function(session) {
   if (session) {
 return pgNode.Model.prototype.toJSON.apply(this, arguments);
@@ -231,145 +241,155 @@
 ' ',
 ' ',
 '  ',
-'<%= privilege ? "" : \'disabled\'%>>',
+'<%= enable_with_grant ? "" : \'disabled\'%>>',
 '   WITH GRANT OPTION',
 '  ',
 ' ',
 ''].join(" "), null, {variable: null}),
 
-events: {
-  'change': 'privilegeChanged',
-  'blur': 'lostFocus'
-},
+  events: {
+'change': 'privilegeChanged',
+'blur': 'lostFocus'
+  },
 
-render: function () {
-  this.$el.empty();
-  this.$el.attr('tabindex', '1');
-  this.$el.attr('target', this.elId);
-
-  var collection = this.model.get(this.column.get("name")),
-  tbl = $("").appendTo(this.$el),
-  self = this,
-  privilege = true, with_grant = true;
-
-  // For each privilege generate html template.
-  // List down all the Privilege model.
-  collection.each(function(m) {
-var d = m.toJSON();
-
-privilege = (privilege && d.privilege);
-with_grant = (with_grant && privilege && d.with_grant);
-
-_.extend(
-  d, {
-'target': self.cid,
-'header': false,
-'privilege_label': self.Labels[d.privilege_type]
-});
-privilege = (privilege && d.privilege);
-with_grant = (with_grant && privilege && d.with_grant);
-tbl.append(self.template(d));
-  });
+  render: function () {
+this.$el.empty();
+this.$el.attr('tabindex', '1');
+this.$el.attr('target', this.elId);
+
+var collection = this.model.get(this.column.get("name")),
+tbl = $("").appendTo(this.$el),
+self = this,
+privilege = true, with_grant = true;
 
-  if (collection.length > 1) {
-// Preprend the ALL controls on that table
-tbl.prepend(
-self.template({
+// For each privilege generate html template.
+// List down all the Privilege model.
+collection.each(function(m) {
+  var d = m.toJSON();
+
+  privilege = (privilege && d.privilege);
+  with_grant = (with_grant && privilege && d.with_grant);
+
+  _.extend(
+d, {
   'target': self.cid,
-  'privilege_label': 'ALL',
-  'privilege_type': 'ALL',
-  'privilege': privilege,
-  'with_grant': with_grant,
-  'header': true
-}));
-  }
-  self.$el.find('input[type=checkbox]').first().focus();
-  // Since blur event does not bubble we need to explicitly call parent's blur event.
-  $(self.$el.find('input[type=checkbox]')).on('blur',function() {
-self.$el.blur();
-  });
+  'header': false,
+  'privilege_label': self.Labels[d.privilege_type],
+  'with_grant': (self.model.get('grantee') != 'public' && d.with_grant),
+  'enable_with_grant': (self.model.get('grantee') != 'public' && d.privilege)
+  });
+  privilege = (privilege && d.privilege);
+  with_grant = (with_grant && privilege && d.with_grant);
+  tbl.append(self.template(d));
+});
 
-  // Make row visible in when entering in edit mode.
-  $(self.$el).pgMakeVisible('backform-tab');
+if (collection.length > 1) {
+  // Preprend the ALL controls on that table
+  tbl.prepend(
+  self.template({
+'target': self.cid,
+'privilege_label': 'ALL',
+'privilege_type': 'ALL',
+'

Re: [pgadmin-hackers] [pgAdmin4] [Patch]: Language Module

2016-02-11 Thread Harshal Dhumal
Hi Akshay,

Please find the review comments below for Language node.

- On postgres9.1 language node failed with below error when clicked on
properties or sql tab.


*   function expression in FROM cannot refer to other relations of same
query level LINE 15: aclexplode(lanacl) d ^*
*- *Error when tried to update language name, owner, comment.

File "/home/edb/PRJ/pgadmin4/web/pgadmin/browser/utils.py", line 277, in
dispatch_request
return method(*args, **kwargs)
  File
"/home/edb/PRJ/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py",
line 139, in wrap
return f(*args, **kwargs)
  File
"/home/edb/PRJ/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py",
line 224, in update
sql = self.get_sql(gid, sid, data, did, lid)
TypeError: get_sql() takes from 2 to 3 positional arguments but 6 were given

*- *In pgadmin3 it shows drop down for language name while in pgadmin4 in
edit mode it shows input text
*.*
Need some clarification whether user is allowed to enter any language name
or can only select from predefined language names.

Regards,
~Harshal




-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Mon, Feb 8, 2016 at 6:17 PM, Akshay Joshi <akshay.jo...@enterprisedb.com>
wrote:

> Hi All
>
> Attached is the patch for the Language Module. Please review it and if it
> looks good then please commit it.
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>
>
> --
> 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] Event trigges node patch [pgadmin4]

2016-02-11 Thread Harshal Dhumal
Hi,

PFA patch event triggers node.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>


event_triggers_12_Frb_1.parch
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] [pgAdmin4] [Patch]: Language Module

2016-02-12 Thread Harshal Dhumal
Hi,

New language patch is working fine.
Ashesh - Can you please review it ?
If it looks good then can you please commit ?

Thank you,
Harshal

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Thu, Feb 11, 2016 at 4:01 PM, Akshay Joshi <akshay.jo...@enterprisedb.com
> wrote:

> Hi All
>
> Attached is the modified patch, please review it.
>
> On Thu, Feb 11, 2016 at 2:06 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi Akshay,
>>
>> Please find the review comments below for Language node.
>>
>> - On postgres9.1 language node failed with below error when clicked on
>> properties or sql tab.
>>
>> *   function expression in FROM cannot refer to other relations of same
>> query level LINE 15: aclexplode(lanacl) d ^*
>>
>
>Fixed.
>
>>
>> *- *Error when tried to update language name, owner, comment.
>>
>> File "/home/edb/PRJ/pgadmin4/web/pgadmin/browser/utils.py", line 277, in
>> dispatch_request
>> return method(*args, **kwargs)
>>   File
>> "/home/edb/PRJ/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py",
>> line 139, in wrap
>> return f(*args, **kwargs)
>>   File
>> "/home/edb/PRJ/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py",
>> line 224, in update
>> sql = self.get_sql(gid, sid, data, did, lid)
>> TypeError: get_sql() takes from 2 to 3 positional arguments but 6 were
>> given
>>
>
>Fixed.
>
>>
>>
>> *- *In pgadmin3 it shows drop down for language name while in pgadmin4
>> in edit mode it shows input text
>> *.*
>> Need some clarification whether user is allowed to enter any language
>> name or can only select from predefined language names.
>>
>
>User can give any language name. In pgAdmin3 it shows drop down but in
> disabled state user can't see any predefine value, so its better to have
> input control instead of drop down.
>
>>
>> Regards,
>> ~Harshal
>>
>>
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>> On Mon, Feb 8, 2016 at 6:17 PM, Akshay Joshi <
>> akshay.jo...@enterprisedb.com> wrote:
>>
>>> Hi All
>>>
>>> Attached is the patch for the Language Module. Please review it and if
>>> it looks good then please commit it.
>>>
>>> --
>>> *Akshay Joshi*
>>> *Principal Software Engineer *
>>>
>>>
>>>
>>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>>
>>>
>>> --
>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>
>>>
>>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>


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

2016-02-10 Thread Harshal Dhumal
Hi,

Here is updated patch for macros. I have added required validation in
macros.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

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.enterprisedb.com/>
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi>
>
>>
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>
diff --git a/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros b/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
index 1d6660c..144a7bb 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
@@ -1,3 +1,6 @@
+{}
+{# This is generic macro for other objects #}
+{}
 {% macro APPLY(conn, type, role, param, priv, with_grant) -%}
 {% if priv %}
 GRANT {{ priv }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIdent(role) }};
@@ -8,4 +11,18 @@ GRANT {{ with_grant }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIden
 {%- endmacro %}
 {% macro RESETALL(conn, type, role, param) -%}
 REVOKE ALL ON {{ type }} {{ conn|qtIdent(param) }} FROM {{ conn|qtIdent(role) }};
+{%- endmacro %}
+{}
+{# This macro is specific to sequence object#}
+{}
+{% macro SET(conn, type, role, param, priv, with_grant, schema) -%}
+{% if priv %}
+GRANT {{ priv }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }};
+{% endif %}
+{% if with_grant %}
+GRANT {{ with_grant }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+{% endif %}
+{%- endmacro %}
+{% macro UNSETALL(conn, type, role, param, schema) -%}
+REVOKE ALL ON {{ type }} {{ conn|qtIdent(schema, param) }} FROM {{ conn|qtIdent(role) }};
 {%- endmacro %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/macros/security.macros b/web/pgadmin/browser/server_groups/servers/templates/macros/security.macros
index 83fb9d2..8194bd1 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/macros/security.macros
+++ b/web/pgadmin/browser/server_groups/servers/templates/macros/security.macros
@@ -1,6 +1,18 @@
+{}
+{# This is generic macro for other objects #}
+{}
 {% macro APPLY(conn, type, name, provider, label) -%}
-SECURITY LABEL FOR {{ conn|qtIdent(provider) }} ON {{ type }} {{ conn|qtIdent(name) }} IS {{ label|qtLiteral }};
+SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(name) }} IS {{ label|qtLiteral }};
 {%- endmacro %}
 {% macro DROP(conn, type, name, provider) -%}
-SECURITY LABEL FOR {{ conn|qtIdent(provider) }} ON {{ type }} {{ conn|qtIdent(name) }} IS NULL;
+SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(name) }} IS NULL;
 {%- endmacro %}
+{}
+{# This macro is specific to sequence object#}
+{}
+{% macro SET(conn, type, name, provider, label, schema) -%}
+SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(schema, name) }} IS {{ label|qtLiteral }};
+{%- endmacro %}
+{% macro UNSET(conn, type, name, provider, schema) -%}
+SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(schema, name) }} IS NULL;
+{%- endmacro %}
\ No newline at end of file

-- 
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 sequence node [pgadmin4]

2016-02-10 Thread Harshal Dhumal
Hi,

Here is updated patch for sequence node. As macros are changed for security
and privileges.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Tue, Feb 9, 2016 at 4:19 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch for sequence node.
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
new file mode 100644
index 000..27deb16
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
@@ -0,0 +1,537 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+import json
+from flask import render_template, make_response, request, jsonify
+from flask.ext.babel import gettext as _
+from pgadmin.utils.ajax import make_json_response, \
+make_response as ajax_response, internal_server_error
+from pgadmin.browser.utils import NodeView
+from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
+parse_priv_to_db
+from pgadmin.browser.collection import CollectionNodeModule
+import pgadmin.browser.server_groups.servers.databases as database
+from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.driver import get_driver
+from config import PG_DEFAULT_DRIVER
+from functools import wraps
+
+class SequenceModule(CollectionNodeModule):
+NODE_TYPE = 'sequence'
+COLLECTION_LABEL = _("Sequences")
+
+def __init__(self, *args, **kwargs):
+self.min_ver = None
+self.max_ver = None
+super(SequenceModule, self).__init__(*args, **kwargs)
+
+# Before loading this module we need to make sure that scid is catalog and schema object
+# and catalog name is 'sys', 'dbo', 'information_schema' then only we load this module
+def BackendSupported(self, manager, **kwargs):
+"""
+This function will validate schema name & scid against sequence then allow us to
+make decision if we want to load this module or not for that schema
+"""
+if super(SequenceModule, self).BackendSupported(manager, **kwargs):
+conn = manager.connection()
+# If DB is not connected then return error to browser
+if not conn.connected():
+return precondition_required(
+_(
+"Connection to the server has been lost!"
+)
+)
+
+ver = manager.version
+# we will set template path for sql scripts
+if ver >= 90100:
+template_path = 'sequence/sql/9.1_plus'
+else:
+template_path = 'sequence/sql/pre_9.1'
+
+SQL = render_template("/".join([template_path, 'backend_support.sql']), scid=kwargs['scid'])
+status, res = conn.execute_scalar(SQL)
+# check if any errors
+if not status:
+return internal_server_error(errormsg=res)
+# Check scid is catalog and from 'sys', 'dbo', 'information_schema',
+# then False (Do not load this module), othewise True
+if res is True:
+return False
+else:
+return True
+
+def get_nodes(self, gid, sid, did, scid):
+"""
+Generate the sequence node
+"""
+yield self.generate_browser_collection_node(scid)
+
+@property
+def script_load(self):
+"""
+Load the module script for database, when any of the database node is
+initialized.
+"""
+return database.DatabaseModule.NODE_TYPE
+
+blueprint = SequenceModule(__name__)
+
+
+class SequenceView(NodeView):
+node_type = blueprint.node_type
+
+parent_ids = [
+{'type': 'int', 'id': 'gid'},
+{'type': 'int', 'id': 'sid'},
+{'type': 'int', 'id': 'did'},
+{'type': 'int', 'id': 'scid'}
+]
+ids = [
+{'type': 'int', 'id': 'seid'}
+]
+
+operations = dict({
+'obj': [
+{'get': 'properties', 'delete': 'delete', 'put': 'update'},
+{'get': 'list', 'post': 'create'}
+],
+'delete': [{'delete': 'delete'}],
+'children': [{'get': 'children'}],
+'nodes': [{'get': 'node'}, {'get': 'nodes'}],
+'sql': [{'get': 'sql'}],
+   

Re: [pgadmin-hackers] Updated patches

2016-02-03 Thread Harshal Dhumal
-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

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

> Hi,
>
> PFA updated patch for database node.
>
> I have fixed almost all issues reported by Neel.
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>
> On Tue, Feb 2, 2016 at 4:47 PM, Neel Patel <neel.pa...@enterprisedb.com>
> wrote:
>
>> Adding more comments.
>>
>> - "Delete Database" functionality is not working, we are getting below
>> error.
>> *  The requested URL was not found on the server. If you entered the
>> URL manually please check your spelling and try again.*
>>
>> *Done*

> - "Drop/Delete functionality is not working, we are getting below error."
>>{"success": 0, "data": null, "info": "", "result": null, "errormsg":
>> "Connection to the server has been lost!"}
>>  To drop/delete the database, we need to first disconnect the database
>> connection and Drop the database, If it is unsuccessful then we again need
>> to
>>  make the connection to database.
>>
>> *Done*

> - "Connection Limit" parameter value is not displayed properly. We set the
>> value to "2" then also it shows the wrong value as "-1".
>>
> *Done*

> - When we edit the variables parameters along with name change then query
>> is not taking the new database name.
>>
>> *Done*

> *Wrong SQL:- *
>> ALTER DATABASE test_2 RENAME TO test_2_up;
>>COMMENT ON DATABASE test_2_up
>>IS 'updated comment';
>>ALTER DATABASE test_2 SET wal_compression TO 'off';
>>ALTER ROLE role1 IN DATABASE test_2 SET zero_damaged_pages TO 'off';
>>
>> *Correct SQL:-*
>>  ALTER DATABASE test_2 RENAME TO test_2_up;
>>COMMENT ON DATABASE test_2_up
>>IS 'updated comment';
>>ALTER DATABASE *test_2_up* SET wal_compression TO 'off';
>>ALTER ROLE role1 IN DATABASE *test_2_up* SET zero_damaged_pages TO
>> 'off';
>>
>> *Done*

> - Default Privileges are not getting displayed when we select any database
>> node in Properties panel.
>>
> *We won't be showing default privileges in properties mode.*

> - When the database is already disconnected and when user again perform
>> "Disconnect database" then it gives python error in backend saying "
>> *NameError: **name 'unauthorized' is not defined*".
>>
> *Done*

> - When we update only database name then we are getting error saying "*name
>> 'conn' is not defined*".
>>
>> *Done*

> Thanks,
>> Neel Patel
>>
>> On Tue, Feb 2, 2016 at 1:25 PM, Neel Patel <neel.pa...@enterprisedb.com>
>> wrote:
>>
>>> Hi Harshal,
>>>
>>> Please find below review comments.
>>>
>>> - While applying the patch, we are getting warning regarding "trailing
>>> whitespace.". Please remove the warning.
>>>
>> *Done*

> - We are getting error saying "*IndexError: tuple index out of range*" on
>>> python side while connecting to "template0" database.
>>>
>> *Done (Now user can not connect to template0)*

> - Many properties are not getting displayed in "Properties" window when we
>>> click on any database. Check for pgadmin3 to show all the properties.
>>>
>>   e.g.  Connected, System Database, Allow connections etc..
*Partially done*

> - Do proper formatting while displaying SQL statements in SQL tab. Below
>>> statement semicolon should not be in next line.
>>>
>> *Done*


>e.g.
>>>   CREATE DATABASE postgres
>>>   WITH OWNER = postgres
>>>   ENCODING = 'UTF8'
>>>   TABLESPACE = pg_default
>>> ;
>>>
>>  *Done*

>
>>>
>> - While creating the new database, tablespace drop down values are not
>>> filled correctly. Current it shows the "Template" field value which is
>>> wrong.
>>>
>>  *Done*

> - By default, when user does not specify any "collation" and "character
>>> type" then it should be set as "en_US.UTF8" and accordingly it should
>>> display in
>>>   Properties and SQL window.
>>>
>>  *Done*

> - When we connect to database 9.1 then query is getting failed to execute.
>>> Below ar

[pgadmin-hackers] Minor issue in variable js [pgadmin4]

2016-02-02 Thread Harshal Dhumal
Hi,

PFA minor patch for variable js.

Issue fixed: Initialize boolean cell with proper data (either true or false
not undefined).

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
index fd3a0bb..8308c27 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
@@ -120,7 +120,11 @@
 
   switch(variable && variable.vartype) {
 case "bool":
-  // There are no specific properties for BooleanCell.
+  /*
+   * bool cell and variable can not be stateless (i.e undefined).
+   * It should be either true or false.
+   */
+  opts.model.set("value", Boolean(opts.model.get("value")));
   break;
 
 case "enum":

-- 
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] Updated patches

2016-01-22 Thread Harshal Dhumal
Hi,

PFA updated patches:

I have made changes as per Ashesh's suggestions.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
new file mode 100644
index 000..31fc4fa
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -0,0 +1,712 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+import json
+from flask import render_template, make_response, current_app, request, jsonify
+from flask.ext.babel import gettext
+from pgadmin.utils.ajax import make_json_response, \
+make_response as ajax_response, internal_server_error
+from pgadmin.browser.utils import NodeView, parse_privileges as parse_db_privileges
+from pgadmin.browser.collection import CollectionNodeModule
+import pgadmin.browser.server_groups.servers as servers
+from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.driver import get_driver
+from config import PG_DEFAULT_DRIVER
+from functools import wraps
+
+class DatabaseModule(CollectionNodeModule):
+NODE_TYPE = 'database'
+COLLECTION_LABEL = gettext("Databases")
+
+def __init__(self, *args, **kwargs):
+self.min_ver = None
+self.max_ver = None
+
+super(DatabaseModule, self).__init__(*args, **kwargs)
+
+def get_nodes(self, gid, sid):
+"""
+Generate the collection node
+"""
+yield self.generate_browser_collection_node(sid)
+
+@property
+def script_load(self):
+"""
+Load the module script for server, when any of the server-group node is
+initialized.
+"""
+return servers.ServerModule.NODE_TYPE
+
+@property
+def csssnippets(self):
+"""
+Returns a snippet of css to include in the page
+"""
+snippets = [
+render_template(
+"browser/css/collection.css",
+node_type=self.node_type,
+_=gettext
+),
+render_template(
+"databases/css/database.css",
+node_type=self.node_type,
+_=gettext
+)
+]
+
+for submodule in self.submodules:
+snippets.extend(submodule.csssnippets)
+
+return snippets
+
+
+blueprint = DatabaseModule(__name__)
+
+
+class DatabaseView(NodeView):
+node_type = blueprint.node_type
+
+parent_ids = [
+{'type': 'int', 'id': 'gid'},
+{'type': 'int', 'id': 'sid'}
+]
+ids = [
+{'type': 'int', 'id': 'did'}
+]
+
+operations = dict({
+'obj': [
+{'get': 'properties', 'delete': 'delete', 'put': 'update'},
+{'get': 'list', 'post': 'create'}
+],
+'nodes': [{'get': 'node'}, {'get': 'nodes'}],
+'sql': [{'get': 'sql'}],
+'msql': [{'get': 'msql'}, {'get': 'msql'}],
+'stats': [{'get': 'statistics'}],
+'dependency': [{'get': 'dependencies'}],
+'dependent': [{'get': 'dependents'}],
+'children': [{'get': 'children'}],
+'module.js': [{}, {}, {'get': 'module_js'}],
+'connect': [{
+'get': 'connect_status', 'post': 'connect', 'delete': 'disconnect'
+}],
+'get_encodings': [{'get': 'getEncodings'}, {'get': 'getEncodings'}],
+'get_ctypes': [{'get': 'getCtypes'}, {'get': 'getCtypes'}],
+'vopts': [{}, {'get': 'variable_options'}]
+})
+
+def check_precondition(f):
+"""
+This function will behave as a decorator which will checks
+database connection before running view, it will also attaches
+manager,conn & template_path properties to self
+"""
+@wraps(f)
+def wrap(*args, **kwargs):
+# Here args[0] will hold self & kwargs will hold gid,sid,did
+self = args[0]
+self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
+if 'did' in kwargs:
+self.conn = self.manager.connection(did=kwargs['did'])
+else:
+self.conn = self.manager.connection()
+# If DB not connected then return error to browser
+if not self.conn.connected():
+return precondition_required(
+gettext(
+"Connection to the server 

[pgadmin-hackers] Database patch and other minor patches and control documentation

2016-01-21 Thread Harshal Dhumal
Hi,

Please find the attached patches:

Database node patch (depends on privilege_macro, node_ui_typo, variable_js
patches)

*How to use controls:*

*1] Privilege control:*

   *a]* Data expected from server in following format:
  eg:


* {grantee: public, privileges: Tc* , grantor: postgres} should be
converted to below object*
  (data parsing logic can be found in databases/__init__.py and
browser/utils.py)

"": [{"grantor": "postgres",
  "privileges": [
 {"with_grant": false,
"privilege_type": "T",
"privilege": true
  },
 {"with_grant": true,
   "privilege_type": "c",
   "privilege": true
}],
"grantee": "public"
}]

  *b]* Privilege control field schema:
 When using this control extend PrivilegeRoleModel with actual
privileges you want to show in your control.
See privilege.js for all supported privileges and their mapping.

{
  id: 'datacl', label: '{{ _('Privileges') }}', model:
pgAdmin.Browser.Node.PrivilegeRoleModel.extend(
{privileges: ['C', 'T', 'c']}), uniqueCol : ['grantee', 'grantor'],
  editable: false, type: 'collection', group: '{{ _('Security') }}',
mode: ['properties', 'edit', 'create'],
  canAdd: true, canDelete: true, control: 'unique-col-collection',
}






*2] Variable control:*
*   a]* Data expected from server:

"variables": [{"database": "db", "value": "ser", "name":
"application_name", "role": "postgres"}, {"database": "db"
, "value": "on", "name": "enable_seqscan", "role": "postgres"}]

 *b] Variable control field schema:*
 Note: database and role fields are optional are not included in variable
control unless specified in field schema.
 Use below flag to enable them



* hasDatabase: true and hasRole:true   (both can not be used at same time)*
(In below example you can see hasRole:true as I need role field in variable
control for database node)

{
  id: 'variables', label: '{{ _('Variables') }}', type: 'collection',
  model: pgAdmin.Browser.Node.VariableModel, editable: false,
  group: '{{ _('Security') }}', mode: ['properties', 'edit', 'create'],
  canAdd: true, canEdit: false, canDelete: true, hasRole: true,
  control: Backform.VariableCollectionControl, node: 'role'
}



Let me know if you have any queries regarding how to use above contorls.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
index e1d3b76..b89e676 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
@@ -272,6 +272,9 @@
   $(self.$el.find('input[type=checkbox]')).on('blur',function() {
 self.$el.blur();
   });
+
+  $(self.$el).pgMakeVisible('backform-tab');
+
   self.delegateEvents();
 
   return this;
diff --git a/web/pgadmin/browser/server_groups/servers/templates/macros/default_privilege.macros b/web/pgadmin/browser/server_groups/servers/templates/macros/default_privilege.macros
new file mode 100644
index 000..81fb07d
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/macros/default_privilege.macros
@@ -0,0 +1,14 @@
+{% macro APPLY(conn, type, role, priv, with_grant) -%}
+{% if priv %}
+ALTER DEFAULT PRIVILEGES
+GRANT {{ priv }} ON {{ type }} TO {{ self.conn|qtIdent(role) }};
+{% endif %}
+{% if with_grant %}
+ALTER DEFAULT PRIVILEGES
+GRANT {{ with_grant }} ON {{ type }} TO {{ self.conn|qtIdent(role) }} WITH GRANT OPTION;
+{% endif %}
+{%- endmacro %}
+{% macro RESETALL(conn, type, role) -%}
+ALTER DEFAULT PRIVILEGES
+REVOKE ALL ON {{ type }} FROM {{ self.conn|qtIdent(role) }};
+{%- endmacro %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros b/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
new file mode 100644
index 000..08d53a4
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
@@ -0,0 +1,11 @@
+{% macro APPLY(conn, type, role, param, priv, with_grant) -%}
+{% if priv %}
+GRANT {{ priv }} ON {{ type }} {{ self.conn|qtIdent(param) }} TO {{ self.conn|qtIdent(role) }};
+{% endif %}
+{% if with_grant %}
+GRANT {{ with_grant }} ON {{ t

[pgadmin-hackers] Patch for minor UI issues [pgadmin4]

2016-01-20 Thread Harshal Dhumal
Hi,

PFA patches for minor issues in status bar and border issue in Unique coll
collection.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js
index bdda1ac..67d483e 100644
--- a/web/pgadmin/browser/templates/browser/js/node.js
+++ b/web/pgadmin/browser/templates/browser/js/node.js
@@ -152,7 +152,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
   var onSessionInvalid = function(msg) {
 
 if(!_.isUndefined(that.statusBar)) {
-  that.statusBar.html(msg);
+  that.statusBar.html(msg).css("visibility", "visible");
 }
 callback(true);
 
@@ -162,7 +162,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
   var onSessionValidated =  function(sessHasChanged) {
 
 if(!_.isUndefined(that.statusBar)) {
-  that.statusBar.empty();
+  that.statusBar.empty().css("visibility", "hidden");
 }
 
 callback(false, sessHasChanged);
@@ -579,6 +579,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
 var statusBar = $('').addClass(
   'pg-prop-status-bar'
   ).appendTo(j);
+statusBar.css("visibility", "hidden");
 if (location == "header") {
 statusBar.appendTo(that.header);
 } else {

diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 8d72921..6662a51 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -806,7 +807,7 @@
   '  <%-label%>',
   '  ><%-add_label%>',
   ''].join("\n")),
-gridBody = $('').append(
+gridBody = $('').append(
 gridHeader(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] python 2.6 support [pgAdmin4]

2016-01-27 Thread Harshal Dhumal
Hi,


PFA patch for pgAdmin4 to run in python 2.6 environment.

Changes are mostly related to 1] dictionary comprehension syntax. 2]
Converting query result to dict in execute_dict and execute_2array methods
in psycopg driver 3] Added importlib python package dependency for python
2.6.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/requirements_py2.txt b/requirements_py2.txt
index b7475cd..8dc6caa 100644
--- a/requirements_py2.txt
+++ b/requirements_py2.txt
@@ -27,3 +27,4 @@ speaklater==1.3
 pycrypto==2.6.1
 wsgiref==0.1.2
 simplejson==3.6.5
+importlib==1.0.3
diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py
index 884f7bd..c360e81 100644
--- a/web/pgadmin/__init__.py
+++ b/web/pgadmin/__init__.py
@@ -79,8 +79,8 @@ class PgAdmin(Flask):
 for module in self.submodules:
 for key, value in module.menu_items.items():
 menu_items[key].extend(value)
-menu_items = {key: sorted(values, key=attrgetter('priority'))
-  for key, values in menu_items.items()}
+menu_items = dict((key, sorted(value, key=attrgetter('priority')))
+  for key, value in menu_items.items())
 return menu_items
 
 
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index 9349633..4ed3ccc 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -325,9 +325,9 @@ class ServerNode(PGChildNodeView):
 not_allowed = {}
 
 if conn.connected():
-for arg in {
+for arg in (
 'host', 'port', 'db', 'username', 'sslmode', 'role'
-}:
+):
 if arg in data:
 return forbidden(
 errormsg=gettext(
@@ -660,7 +660,6 @@ class ServerNode(PGChildNodeView):
 
 current_app.logger.info('Connection Established for server: \
 %s - %s' % (server.id, server.name))
-
 return make_json_response(
 success=1,
 info=gettext("Server Connected."),
diff --git a/web/pgadmin/utils/__init__.py b/web/pgadmin/utils/__init__.py
index 95f02b5..cfe8729 100644
--- a/web/pgadmin/utils/__init__.py
+++ b/web/pgadmin/utils/__init__.py
@@ -90,6 +90,6 @@ class PgAdminModule(Blueprint):
 for module in self.submodules:
 for key, value in module.menu_items.items():
 menu_items[key].extend(value)
-menu_items = {key: sorted(values, key=attrgetter('priority'))
-  for key, values in menu_items.items()}
+menu_items = dict((key, sorted(value, key=attrgetter('priority')))
+  for key, value in menu_items.items())
 return menu_items
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py
index d4205d2..211e1fa 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -372,7 +372,7 @@ Attempt to reconnect it failed with the below error:
 import copy
 # Get Resultset Column Name, Type and size
 columns = cur.description and [
-copy.deepcopy(desc.__dict__) for desc in cur.description
+copy.deepcopy(desc._asdict()) for desc in cur.description
 ] or []
 
 rows = []
@@ -414,7 +414,7 @@ Attempt to reconnect it failed with the below error:
 import copy
 # Get Resultset Column Name, Type and size
 columns = cur.description and [
-copy.deepcopy(desc.__dict__) for desc in cur.description
+copy.deepcopy(desc._asdict()) for desc in cur.description
 ] or []
 
 rows = []

-- 
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] work status

2016-02-14 Thread Harshal Dhumal
Hi,

I have started working on Backup Globals feature.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>


Re: [pgadmin-hackers] Patch sequence node [pgadmin4]

2016-03-09 Thread Harshal Dhumal
Hi,

PFA updated patch for sequence node.

Changes: 1] Added changes related to schema child node.
   2] re-based with latest code.
   3] Added dependencies and dependents functionality.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

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

> Hi,
>
> PFA updated patch for sequence node.
>
> *Changes:* Updated sql files to refer macros from
> schemas/templates/macros/schemas folder instead of servers/templates/macros
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>
> On Wed, Feb 10, 2016 at 5:46 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Here is updated patch for sequence node. As macros are changed for
>> security and privileges.
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>> On Tue, Feb 9, 2016 at 4:19 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA patch for sequence node.
>>>
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer *
>>>
>>>
>>>
>>> EenterpriseDB <http://www.enterprisedb.com>
>>>
>>
>>
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
new file mode 100644
index 000..e57ef65
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
@@ -0,0 +1,680 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+
+"""Implements Sequence Node"""
+
+import json
+from flask import render_template, make_response, request, jsonify
+from flask.ext.babel import gettext as _
+from pgadmin.utils.ajax import make_json_response, \
+make_response as ajax_response, internal_server_error
+from pgadmin.browser.utils import PGChildNodeView
+from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
+parse_priv_to_db
+from pgadmin.browser.server_groups.servers.databases.schemas.utils \
+import SchemaChildModule
+import pgadmin.browser.server_groups.servers.databases as database
+from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.driver import get_driver
+from config import PG_DEFAULT_DRIVER
+from functools import wraps
+
+
+class SequenceModule(SchemaChildModule):
+"""
+class SequenceModule(CollectionNodeModule)
+
+A module class for Sequence node derived from CollectionNodeModule.
+
+Methods:
+---
+* __init__(*args, **kwargs)
+  - Method is used to initialize the SequenceModule and it's base module.
+
+* get_nodes(gid, sid, did)
+  - Method is used to generate the browser collection node.
+
+* script_load()
+  - Load the module script for sequence, when any of the database node is
+initialized.
+"""
+
+NODE_TYPE = 'sequence'
+COLLECTION_LABEL = _("Sequences")
+
+def __init__(self, *args, **kwargs):
+super(SequenceModule, self).__init__(*args, **kwargs)
+self.min_ver = None
+self.max_ver = None
+
+def get_nodes(self, gid, sid, did, scid):
+"""
+Generate the sequence node
+"""
+yield self.generate_browser_collection_node(scid)
+
+@property
+def script_load(self):
+"""
+Load the module script for database, when any of the database node is
+initialized.
+"""
+return database.DatabaseModule.NODE_TYPE
+
+blueprint = SequenceModule(__name__)
+
+
+class SequenceView(PGChildNodeView):
+node_type = blueprint.node_type
+
+parent_ids = [
+{'type': 'int', 'id': 'gid'},
+{'type': 'int', 'id': 'sid'},
+{'type': 'int', 'id': 'did'},
+{'type': 'int', 'id': 'scid'}
+]
+ids = [
+{'type': 'int', 'id': 'seid'}
+]
+
+operations = dict({
+'obj': [
+{'get': 'properties', 'delete': 'delete', 'put': 'update'},
+{'get': 'list', 'post': 'create'}
+],
+'delete': [{'delete': 'delete'}],
+'children': [{'get': 'children'}],
+  

Re: [pgadmin-hackers] Patch sequence node [pgadmin4]

2016-03-10 Thread Harshal Dhumal
Hi,

PFA update patch for sequence node.

Changes: Fixed leaf node issue.



-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Thu, Mar 10, 2016 at 12:45 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA updated patch for sequence node.
>
> Changes: 1] Added changes related to schema child node.
>2] re-based with latest code.
>3] Added dependencies and dependents functionality.
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>
> On Wed, Feb 10, 2016 at 7:11 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA updated patch for sequence node.
>>
>> *Changes:* Updated sql files to refer macros from
>> schemas/templates/macros/schemas folder instead of servers/templates/macros
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>> On Wed, Feb 10, 2016 at 5:46 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> Here is updated patch for sequence node. As macros are changed for
>>> security and privileges.
>>>
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer *
>>>
>>>
>>>
>>> EenterpriseDB <http://www.enterprisedb.com>
>>>
>>> On Tue, Feb 9, 2016 at 4:19 PM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> PFA patch for sequence node.
>>>>
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Software Engineer *
>>>>
>>>>
>>>>
>>>> EenterpriseDB <http://www.enterprisedb.com>
>>>>
>>>
>>>
>>
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
new file mode 100644
index 000..cdf36f2
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
@@ -0,0 +1,693 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+
+"""Implements Sequence Node"""
+
+import json
+from flask import render_template, make_response, request, jsonify
+from flask.ext.babel import gettext as _
+from pgadmin.utils.ajax import make_json_response, \
+make_response as ajax_response, internal_server_error
+from pgadmin.browser.utils import PGChildNodeView
+from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
+parse_priv_to_db
+from pgadmin.browser.server_groups.servers.databases.schemas.utils \
+import SchemaChildModule
+import pgadmin.browser.server_groups.servers.databases as database
+from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.driver import get_driver
+from config import PG_DEFAULT_DRIVER
+from functools import wraps
+
+
+class SequenceModule(SchemaChildModule):
+"""
+class SequenceModule(CollectionNodeModule)
+
+A module class for Sequence node derived from CollectionNodeModule.
+
+Methods:
+---
+* __init__(*args, **kwargs)
+  - Method is used to initialize the SequenceModule and it's base module.
+
+* get_nodes(gid, sid, did)
+  - Method is used to generate the browser collection node.
+
+* script_load()
+  - Load the module script for sequence, when any of the database node is
+initialized.
+
+* node_inode()
+  - Method is overridden from its base class to make the node as leaf node.
+
+"""
+
+NODE_TYPE = 'sequence'
+COLLECTION_LABEL = _("Sequences")
+
+def __init__(self, *args, **kwargs):
+super(SequenceModule, self).__init__(*args, **kwargs)
+self.min_ver = None
+self.max_ver = None
+
+def get_nodes(self, gid, sid, did, scid):
+"""
+Generate the sequence node
+"""
+yield self.generate_browser_collection_node(scid)
+
+@property
+def script_load(self):
+"""
+Load the module script for database, when any of the database node is
+initialized.
+"""
+return database.DatabaseModu

Re: [pgadmin-hackers] Control for selecting multiple columns [pgadmin4]

2016-03-18 Thread Harshal Dhumal
Hi Dave,

This seems to be some dependency issue. Can you please send me a screenshot
of debugger console with js error stack.


Regards,
Harshal


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Thu, Mar 17, 2016 at 10:33 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> I tried that, but get the attached error when testing. I'm on a clean
> tree, with the WIP tables patch (which, by the way, doesn't look much like
> Arun's design so is likely to need a lot of layout work). I've restarted,
> refreshed etc.
>
> [image: Inline image 1]
>
>
> On Thu, Mar 17, 2016 at 6:04 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> I have used same control in primary key constraint for selecting multiple
>> columns. So to test this control please extract attached table.zip file
>> under schema node. This zip contains table, column and constraint node with
>> primary key support (as constraint node has dependency on table and column
>> node). Also you will need to apply multiselect control patch separately as
>> this zip does not contain the same.
>>
>>
>> Thank you,
>>
>> Harshal
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>> On Tue, Mar 15, 2016 at 10:13 PM, Dave Page <dp...@pgadmin.org> wrote:
>>
>>> It seems to be missing the test dialogue?
>>>
>>> On Tue, Mar 15, 2016 at 8:47 AM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> PFA generalized updated patch for backform multiSelectControl.
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Software Engineer *
>>>>
>>>>
>>>>
>>>> EenterpriseDB <http://www.enterprisedb.com>
>>>>
>>>> On Tue, Mar 8, 2016 at 1:04 PM, Harshal Dhumal <
>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> PFA backform control for selecting multiple columns.(This control
>>>>> depends on column node.)
>>>>>
>>>>> Usage:
>>>>>
>>>>> {
>>>>>   id: 'columns', label: '{{ _('Columns') }}',
>>>>>   type: 'collection', group: '{{ _('Definition') }}', editable:true,
>>>>>   canDelete: true, canAdd: true, control: 
>>>>> Backform.MultiColumnSelectControl,
>>>>>   deps: ['index'], node: 'column',
>>>>>   model: pgBrowser.Node.Model.extend({
>>>>> keys: ['column'],
>>>>> defaults: {
>>>>>   column: undefined
>>>>> }
>>>>>   })
>>>>> }
>>>>>
>>>>>
>>>>> Note: When using this control model should have *column* attribute.
>>>>> And node property should be *column*.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Harshal Dhumal*
>>>>> *Software Engineer *
>>>>>
>>>>>
>>>>>
>>>>> EenterpriseDB <http://www.enterprisedb.com>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> 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
>>>
>>
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


[pgadmin-hackers] Primary key constraint [pgadmin4]

2016-03-15 Thread Harshal Dhumal
Hi


PFA patch for primary key constraint.

Note: This patch has dependency on Table, Column node and backform
multiselect control.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/__init__.py
new file mode 100644
index 000..64f91e8
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/__init__.py
@@ -0,0 +1,129 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+
+"""Implements Constraint Node"""
+
+from flask.ext.babel import gettext
+from flask import render_template, make_response
+from pgadmin.browser.collection import CollectionNodeModule
+import pgadmin.browser.server_groups.servers.databases.schemas.tables as table
+from pgadmin.utils.ajax import make_json_response, \
+ make_response as ajax_response
+from .type import ConstraintRegistry
+
+
+class ConstraintsModule(CollectionNodeModule):
+"""
+class ConstraintsModule(CollectionNodeModule)
+
+A module class for Constraint node derived from CollectionNodeModule.
+
+Methods:
+---
+* __init__(*args, **kwargs)
+  - Method is used to initialize the ConstraintsModule and it's base module.
+
+* get_nodes(gid, sid, did)
+  - Method is used to generate the browser collection node.
+
+* node_inode()
+  - Method is overridden from its base class to make the node as leaf node.
+
+* script_load()
+  - Load the module script for constraint node, when any of the database node is
+initialized.
+"""
+
+NODE_TYPE = 'constraints'
+COLLECTION_LABEL = gettext("Constraints")
+
+def __init__(self, *args, **kwargs):
+self.min_ver = None
+self.max_ver = None
+super(ConstraintsModule, self).__init__(*args, **kwargs)
+
+def get_nodes(self, gid, sid, did, scid, tid):
+"""
+Generate the collection node
+"""
+yield self.generate_browser_collection_node(tid)
+
+@property
+def script_load(self):
+"""
+Load the module script for constraints, when any of the table node is
+initialized.
+"""
+return table.TableModule.NODE_TYPE
+
+blueprint = ConstraintsModule(__name__)
+
+
+@blueprint.route('/nodes//')
+def nodes(**kwargs):
+"""
+Returns all constraint as a tree node.
+
+Args:
+  **kwargs:
+
+Returns:
+
+"""
+
+cmd = {"cmd": "nodes"}
+res = []
+for name in ConstraintRegistry.registry:
+module = (ConstraintRegistry.registry[name])['nodeview']
+view = module(**cmd)
+res = res + view.get_nodes(**kwargs)
+
+return make_json_response(
+data=res,
+status=200
+)
+
+
+@blueprint.route('/obj//')
+def proplist(**kwargs):
+"""
+Returns all constraint with properties.
+Args:
+  **kwargs:
+
+Returns:
+
+"""
+
+cmd = {"cmd": "obj"}
+res = []
+for name in ConstraintRegistry.registry:
+module = (ConstraintRegistry.registry[name])['nodeview']
+view = module(**cmd)
+res = res + view.get_node_list(**kwargs)
+
+return ajax_response(
+response=res,
+status=200
+)
+
+
+@blueprint.route('/module.js')
+def module_js():
+"""
+  This property defines whether javascript exists for this node.
+
+"""
+return make_response(
+render_template(
+"constraints/js/constraints.js",
+_=gettext
+),
+200, {'Content-Type': 'application/x-javascript'}
+)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/primary_key/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/primary_key/__init__.py
new file mode 100644
index 000..1abbe1d
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/primary_key/__init__.py
@@ -0,0 +1,774 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##

Re: [pgadmin-hackers] Control for selecting multiple columns [pgadmin4]

2016-03-15 Thread Harshal Dhumal
Hi,

PFA generalized updated patch for backform multiSelectControl.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Tue, Mar 8, 2016 at 1:04 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA backform control for selecting multiple columns.(This control depends
> on column node.)
>
> Usage:
>
> {
>   id: 'columns', label: '{{ _('Columns') }}',
>   type: 'collection', group: '{{ _('Definition') }}', editable:true,
>   canDelete: true, canAdd: true, control: Backform.MultiColumnSelectControl,
>   deps: ['index'], node: 'column',
>   model: pgBrowser.Node.Model.extend({
> keys: ['column'],
> defaults: {
>   column: undefined
> }
>   })
> }
>
>
> Note: When using this control model should have *column* attribute. And
> node property should be *column*.
>
>
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index b84b6ee..1202580 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -558,6 +558,46 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
 })
   });
 
+  /*
+   * Control to select multiple columns.
+   */
+  var MultiSelectAjaxControl = Backform.MultiSelectAjaxControl = NodeAjaxOptionsControl.extend({
+formatter: {
+  fromRaw: function (rawData, model) {
+return _.isObject(rawData) ? rawData : JSON.parse(rawData);
+  },
+  toRaw: function (formattedData, model) {
+return formattedData;
+  }
+},
+template: _.template([
+  '<%=label%>',
+  '',
+  '   <%=required ? "required" : ""%>>',
+  '<% for (var i=0; i < options.length; i++) { %>',
+  '  <% var option = options[i]; %>',
+  '   <%=value != null && _.indexOf(value, option.value) != -1 ? "selected" : ""%> <%=option.disabled ? "disabled=\'disabled\'" : ""%>><%-option.label%>',
+  '<% } %>',
+  '  ',
+  ''
+  ].join("\n")),
+getValueFromDOM: function() {
+  var res = [];
+
+  this.$el.find("select").find(':selected').each(function() {
+res.push($(this).attr('value'));
+  });
+
+  return res;
+},
+defaults: _.extend({}, NodeAjaxOptionsControl.prototype.defaults, {
+  select2: {
+multiple: true,
+allowClear: true,
+width: 'style'
+  }
+})
+  });
 
   return Backform;
 });

-- 
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] Event trigges node patch [pgadmin4]

2016-03-09 Thread Harshal Dhumal
Hi,


PFA updated patch for events trigger node.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Fri, Mar 4, 2016 at 7:58 PM, Dave Page <dp...@pgadmin.org> wrote:

>
>
> On Fri, Feb 12, 2016 at 6:32 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch event triggers node.
>>
>>
> Hi
>
> It looks like this has bit-rotted. Please update and re-submit - currently
> it doesn't list triggers in the tree if they're already present, and if you
> try to create a new one it fails to find any trigger functions. I see this
> in the console:
>
> 2016-03-04 14:24:01,759: INFO werkzeug: 127.0.0.1 - - [04/Mar/2016
> 14:24:01] "GET /browser/event_trigger/nodes/1/1/12403/ HTTP/1.1" 500 -
> Traceback (most recent call last):
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1836, in __call__
> return self.wsgi_app(environ, start_response)
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1820, in wsgi_app
> response = self.make_response(self.handle_exception(e))
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1403, in handle_exception
> reraise(exc_type, exc_value, tb)
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1817, in wsgi_app
> response = self.full_dispatch_request()
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1477, in full_dispatch_request
> rv = self.handle_user_exception(e)
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1381, in handle_user_exception
> reraise(exc_type, exc_value, tb)
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1475, in full_dispatch_request
> rv = self.dispatch_request()
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1461, in dispatch_request
> return self.view_functions[rule.endpoint](**req.view_args)
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/views.py",
> line 84, in view
> return self.dispatch_request(*args, **kwargs)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/utils.py", line 248,
> in dispatch_request
> return method(*args, **kwargs)
>   File
> "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py",
> line 118, in wrap
> return f(*args, **kwargs)
>   File
> "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py",
> line 142, in nodes
> res.append(
> AttributeError: 'dict' object has no attribute 'append'
>
> NOTE: Please also check the code conforms to the checklist I added to the
> docs earlier:
> http://git.postgresql.org/gitweb/?p=pgadmin4.git;a=blob;f=docs/en_US/code-review.rst
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
new file mode 100644
index 000..8e71a6e
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
@@ -0,0 +1,658 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+
+import json
+import re
+from flask import render_template, make_response, request, jsonify
+from flask.ext.babel import gettext
+from pgadmin.utils.ajax import make_json_response, \
+make_response as ajax_response, internal_server_error
+from pgadmin.browser.utils import PGChildNodeView
+from pgadmin.browser.collection import CollectionNodeModule
+import pgadmin.browser.server_groups.servers.databases as database
+from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.driver import get_driver
+from config import PG_DEFAULT_DRIVER
+from functools import wraps
+
+
+class EventTriggerModule(CollectionNodeModule):
+"""
+class EventTriggerModule(CollectionNodeModule)
+
+A module class for Even

[pgadmin-hackers] Subnode grid row close issue [pgAdmin4]

2016-03-19 Thread Harshal Dhumal
Hi,

PFA patch for Subnode grid row close issue.

Issue fixed:

1] Close any existing row while adding new row.
2] Close any existing row if we edit new row.



-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 39e3233..e067aff 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1163,6 +1163,30 @@
 });
 self.model.set(data.name, collection, {silent: true});
   }
+
+  var cellEditing = function(args){
+var self = this,
+  cell = args[0];
+// Search for any other rows which are open.
+this.each(function(m){
+  // Check if row which we are about to close is not current row.
+  if (cell.model != m) {
+var idx = self.indexOf(m);
+if (idx > -1) {
+  var row = grid.body.rows[idx],
+  editCell = row.$el.find(".subnode-edit-in-process").parent();
+  // Only close row if it's open.
+  if (editCell.length > 0){
+var event = new Event('click');
+editCell[0].dispatchEvent(event);
+  }
+}
+  }
+});
+  }
+  // Listen for any row which is about to enter in edit mode.
+  collection.on( "enteringEditMode", cellEditing, collection);
+
   // Initialize a new Grid instance
   var grid = self.grid = new Backgrid.Grid({
   columns: gridSchema.columns,
@@ -1184,7 +1208,18 @@
   // Add button callback
   $dialog.find('button.add').click(function(e) {
 e.preventDefault();
+// Close any existing expanded row before adding new one.
+_.each(grid.body.rows, function(row){
+  var editCell = row.$el.find(".subnode-edit-in-process").parent();
+  // Only close row if it's open.
+  if (editCell.length > 0){
+var event = new Event('click');
+editCell[0].dispatchEvent(event);
+  }
+});
+
 grid.insertRow({});
+
 var newRow = $(grid.body.rows[collection.length - 1].$el);
 newRow.attr("class", "new").click(function(e) {
   $(this).attr("class", "editable");
diff --git a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
index 7c7eb0b..4b233d2 100644
--- a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
+++ b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
@@ -190,6 +190,9 @@
   });
 },
 enterEditMode: function () {
+  // Notify that we are about to enter in edit mode for current cell.
+  this.model.trigger("enteringEditMode", [this]);
+
   Backgrid.Cell.prototype.enterEditMode.apply(this, arguments);
   /* Make sure - we listen to the click event */
   this.delegateEvents();

-- 
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] Tree reload & panel close issue after saving new node on server [pgadmin4]

2016-03-31 Thread Harshal Dhumal
Hi,

PFA patch for node.js

Issues fixed:

1] Reload node collection when server doesn't send node data for newly
created node.
2] Close create panel either when collection node matches with newly create
node type  or *collection node type matches with newly created node's
collection type.*





-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js
index 5d6ec86..bb683ee 100644
--- a/web/pgadmin/browser/templates/browser/js/node.js
+++ b/web/pgadmin/browser/templates/browser/js/node.js
@@ -847,7 +847,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
 },
 saveNewNode = function() {
   /* TODO:: Create new tree node for this */
-  if (view.model.tnode) {
+  if (view.model.tnode && '_id' in view.model.tnode) {
 var d = _.extend({}, view.model.tnode),
   func = function(i) {
 setTimeout(function() {
@@ -888,7 +888,8 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
   if (data && data._type && data._type in pgBrowser.Nodes) {
 node = pgBrowser.Nodes[data._type];
 
-if (node && node.node && node.node == that.type) {
+if (node && ((node.node && node.node == that.type) ||
+node.type == that.collection_type)) {
   found = true;
   if (tree.wasLoad(j)) {
 tree.append(j, {
@@ -979,6 +980,48 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
 }
   });
 }
+  } else {
+  /*
+   * Sometime we don't get node in response even though it's saved
+   * on server. In such case just reload the collection to get newly
+   * created nodes.
+   */
+
+   var children = tree.children(item, false, false),
+openNode = function(item, animation){
+  tree.open(item, {
+success: function (item, options){
+  setTimeout(function() {
+closePanel();
+  }, 0);
+},
+fail: function (item, options){
+},
+unanimated: animation
+  });
+};
+
+if (children) {
+  _.each(children, function(child) {
+var $child = $(child);
+var data = tree.itemData($child)
+  if (data._type == that.collection_type){
+// We found collection which need to reload.
+if (tree.wasLoad($child)) {
+  tree.unload($child, {
+success: function (item, options){
+  openNode(item, true);
+},
+fail: function (item, options){
+},
+unanimated: true
+  });
+} else {
+  openNode($child, false);
+}
+  }
+  });
+}
   }
 },
 editInNewPanel = function() {

-- 
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] Patch for index constraint (primary and unique key) [pgadmin4]

2016-04-11 Thread Harshal Dhumal
Hi,

PAF patch for exclusion constraint which takes care both primary and unique
key.

Note: This patch has dependency on Table, Column node and Index constraint.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
new file mode 100644
index 000..54b0bfd
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
@@ -0,0 +1,907 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+
+"""Implements Primary key constraint Node"""
+
+import json
+from flask import render_template, make_response, request, jsonify
+from flask.ext.babel import gettext as _
+from pgadmin.utils.ajax import make_json_response, \
+make_response as ajax_response, internal_server_error
+from pgadmin.browser.utils import PGChildNodeView
+from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.driver import get_driver
+from config import PG_DEFAULT_DRIVER
+import pgadmin.browser.server_groups.servers.databases.schemas.tables as table
+from functools import wraps
+from pgadmin.browser.server_groups.servers.databases.schemas.tables.constraints.type \
+import ConstraintRegistry, ConstraintTypeModule
+
+
+class IndexConstraintModule(ConstraintTypeModule):
+"""
+class IndexConstraintModule(CollectionNodeModule)
+
+A module class for Primary key constraint node derived from ConstraintTypeModule.
+
+Methods:
+---
+* __init__(*args, **kwargs)
+  - Method is used to initialize the PrimaryKeyConstraintModule and it's base module.
+
+* get_nodes(gid, sid, did)
+  - Method is used to generate the browser collection node.
+
+* node_inode()
+  - Method is overridden from its base class to make the node as leaf node.
+
+* script_load()
+  - Load the module script for language, when any of the database node is
+initialized.
+"""
+
+NODE_TYPE = 'Index constraint'
+COLLECTION_LABEL = _('index_constraint')
+
+def __init__(self, *args, **kwargs):
+"""
+Method is used to initialize the PrimaryKeyConstraintModule and it's base module.
+
+Args:
+  *args:
+  **kwargs:
+
+Returns:
+
+"""
+self.min_ver = None
+self.max_ver = None
+super(IndexConstraintModule, self).__init__(*args, **kwargs)
+
+def get_nodes(self, gid, sid, did, scid, tid):
+"""
+Generate the collection node
+"""
+pass
+
+@property
+def node_inode(self):
+"""
+Override this property to make the node a leaf node.
+
+Returns: False as this is the leaf node
+"""
+return False
+
+@property
+def script_load(self):
+"""
+Load the module script for primary_key, when any of the table node is
+initialized.
+
+Returns: node type of the server module.
+"""
+return table.TableModule.NODE_TYPE
+
+
+class PrimaryKeyConstraintModule(IndexConstraintModule):
+"""
+ class PrimaryKeyConstraintModule(IndexConstraintModule)
+
+A module class for the catalog schema node derived from IndexConstraintModule.
+"""
+
+NODE_TYPE = 'primary_key'
+COLLECTION_LABEL = _("Primary key")
+
+
+primary_key_blueprint = PrimaryKeyConstraintModule(__name__)
+
+
+class UniqueConstraintModule(IndexConstraintModule):
+"""
+ class UniqueConstraintModule(IndexConstraintModule)
+
+A module class for the catalog schema node derived from IndexConstraintModule.
+"""
+
+NODE_TYPE = 'unique_constraint'
+COLLECTION_LABEL = _("Unique constraint")
+
+
+unique_constraint_blueprint = UniqueConstraintModule(__name__)
+
+
+class IndexConstraintView(PGChildNodeView):
+"""
+class PrimaryKeyConstraintView(PGChildNodeView)
+
+A view class for Primary key constraint node derived from PGChildNodeView. This class is
+responsible for all the stuff related to view like creating, updating Primary key constraint
+node, showing properties, showing sql in sql pane.
+
+Methods:
+---
+* __init__(**kwargs)
+  - Method is used to initialize the PrimaryKeyConstraintView and it

[pgadmin-hackers] Initial foreign key constraint node patch [pgadmin4]

2016-04-11 Thread Harshal Dhumal
Hi,

PFA initial patch for foreign key constraint.

Note: This patch has dependency on Table, Column node and Index constraint.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
new file mode 100644
index 000..59c6b39
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
@@ -0,0 +1,1032 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+
+"""Implements Foreign key constraint Node"""
+
+import json
+from flask import render_template, make_response, request, jsonify
+from flask.ext.babel import gettext as _
+from pgadmin.utils.ajax import make_json_response, \
+make_response as ajax_response, internal_server_error
+from pgadmin.browser.utils import PGChildNodeView
+from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.driver import get_driver
+from config import PG_DEFAULT_DRIVER
+import pgadmin.browser.server_groups.servers.databases.schemas.tables as table
+from functools import wraps
+from pgadmin.browser.server_groups.servers.databases.schemas.tables.constraints.type \
+import ConstraintRegistry, ConstraintTypeModule
+
+
+class ForeignKeyConstraintModule(ConstraintTypeModule):
+"""
+class ForeignKeyConstraintModule(CollectionNodeModule)
+
+A module class for Foreign key constraint node derived from ConstraintTypeModule.
+
+Methods:
+---
+* __init__(*args, **kwargs)
+  - Method is used to initialize the ForeignKeyConstraintModule and it's base module.
+
+* get_nodes(gid, sid, did)
+  - Method is used to generate the browser collection node.
+
+* node_inode()
+  - Method is overridden from its base class to make the node as leaf node.
+
+* script_load()
+  - Load the module script for language, when any of the database node is
+initialized.
+"""
+
+NODE_TYPE = 'foreign_key'
+COLLECTION_LABEL = _("Foreign Keys")
+
+def __init__(self, *args, **kwargs):
+"""
+Method is used to initialize the ForeignKeyConstraintModule and it's base module.
+
+Args:
+  *args:
+  **kwargs:
+
+Returns:
+
+"""
+self.min_ver = None
+self.max_ver = None
+super(ForeignKeyConstraintModule, self).__init__(*args, **kwargs)
+
+def get_nodes(self, gid, sid, did, scid, tid):
+"""
+Generate the collection node
+"""
+pass
+
+@property
+def node_inode(self):
+"""
+Override this property to make the node a leaf node.
+
+Returns: False as this is the leaf node
+"""
+return False
+
+@property
+def script_load(self):
+"""
+Load the module script for foreign_key, when any of the table node is
+initialized.
+
+Returns: node type of the server module.
+"""
+return table.TableModule.NODE_TYPE
+
+@property
+def csssnippets(self):
+"""
+Returns a snippet of css to include in the page
+"""
+snippets = [
+render_template(
+"browser/css/collection.css",
+node_type=self.node_type,
+_=_
+),
+render_template(
+"foreign_key/css/foreign_key.css",
+node_type=self.node_type,
+_=_
+)
+]
+
+for submodule in self.submodules:
+snippets.extend(submodule.csssnippets)
+
+return snippets
+
+blueprint = ForeignKeyConstraintModule(__name__)
+
+
+class ForeignKeyConstraintView(PGChildNodeView):
+"""
+class ForeignKeyConstraintView(PGChildNodeView)
+
+A view class for Foreign key constraint node derived from PGChildNodeView. This class is
+responsible for all the stuff related to view like creating, updating Foreign key constraint
+node, showing properties, showing sql in sql pane.
+
+Methods:
+---
+* __init__(**kwargs)
+  - Method is used to initialize the ForeignKeyConstraintView and it's base view.
+
+* module_js()
+  - This property defines (if javascript) exi

[pgadmin-hackers] Dialog issue: General category text is shown as undefined [pgadmin4]

2016-04-12 Thread Harshal Dhumal
Hi,

PFA minor patch for message.js

Issue fixed : Dialog issue, General category text is shown as undefined

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/templates/browser/js/messages.js b/web/pgadmin/browser/templates/browser/js/messages.js
index 17e8c6d..400238c 100644
--- a/web/pgadmin/browser/templates/browser/js/messages.js
+++ b/web/pgadmin/browser/templates/browser/js/messages.js
@@ -10,7 +10,7 @@ function(_, S, pgAdmin) {
   pgBrowser.messages = {
 'SERVER_LOST': '{{ _('Connection to the server has been lost!') }}',
 'CLICK_FOR_DETAILED_MSG': '%s' + '{{ _('Click here for details!')|safe }}',
-'GENERAL_CATEOGTY': '{{ _('General')|safe }}',
+'GENERAL_CATEOGTY': '{{ _("General")|safe }}',
 'SQL_TAB': '{{ _('SQL') }}',
 'SQL_NO_CHANGE': '-- ' + '{{ _('Nothing changed')|safe }}',
 'MUST_BE_INT' : "{{ _("'%%s' must be an integer.")|safe }}",

-- 
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] Patch for exclusion constraint [pgadmin4]

2016-04-11 Thread Harshal Dhumal
Hi,

PAF patch for exclusion constraint.

Note: This patch has dependency on Table, Column node and Index constraint
(I'll be sending patch for index constraint immediately after this).

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
new file mode 100644
index 000..d6a174f
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
@@ -0,0 +1,918 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+
+"""Implements Exclusion constraint Node"""
+
+import json
+from flask import render_template, make_response, request, jsonify
+from flask.ext.babel import gettext as _
+from pgadmin.utils.ajax import make_json_response, \
+make_response as ajax_response, internal_server_error
+from pgadmin.browser.utils import PGChildNodeView
+from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.driver import get_driver
+from config import PG_DEFAULT_DRIVER
+import pgadmin.browser.server_groups.servers.databases.schemas.tables as table
+from functools import wraps
+from pgadmin.browser.server_groups.servers.databases.schemas.tables.constraints.type \
+import ConstraintRegistry, ConstraintTypeModule
+
+
+class ExclusionConstraintModule(ConstraintTypeModule):
+"""
+class ForeignKeyConstraintModule(CollectionNodeModule)
+
+A module class for Exclusion constraint node derived from ConstraintTypeModule.
+
+Methods:
+---
+* __init__(*args, **kwargs)
+  - Method is used to initialize the ForeignKeyConstraintModule and it's base module.
+
+* get_nodes(gid, sid, did)
+  - Method is used to generate the browser collection node.
+
+* node_inode()
+  - Method is overridden from its base class to make the node as leaf node.
+
+* script_load()
+  - Load the module script for language, when any of the database node is
+initialized.
+"""
+
+NODE_TYPE = 'exclusion_constraint'
+COLLECTION_LABEL = _("Foreign Keys")
+
+def __init__(self, *args, **kwargs):
+"""
+Method is used to initialize the ForeignKeyConstraintModule and it's base module.
+
+Args:
+  *args:
+  **kwargs:
+
+Returns:
+
+"""
+self.min_ver = None
+self.max_ver = None
+super(ExclusionConstraintModule, self).__init__(*args, **kwargs)
+
+def get_nodes(self, gid, sid, did, scid, tid):
+"""
+Generate the collection node
+"""
+pass
+
+@property
+def node_inode(self):
+"""
+Override this property to make the node a leaf node.
+
+Returns: False as this is the leaf node
+"""
+return False
+
+@property
+def script_load(self):
+"""
+Load the module script for exclusion_constraint, when any of the table node is
+initialized.
+
+Returns: node type of the server module.
+"""
+return table.TableModule.NODE_TYPE
+
+blueprint = ExclusionConstraintModule(__name__)
+
+
+class ExclusionConstraintView(PGChildNodeView):
+"""
+class ExclusionConstraintView(PGChildNodeView)
+
+A view class for Exclusion constraint node derived from PGChildNodeView. This class is
+responsible for all the stuff related to view like creating, updating Exclusion constraint
+node, showing properties, showing sql in sql pane.
+
+Methods:
+---
+* __init__(**kwargs)
+  - Method is used to initialize the ForeignKeyConstraintView and it's base view.
+
+* module_js()
+  - This property defines (if javascript) exists for this node.
+Override this property for your own logic
+
+* check_precondition()
+  - This function will behave as a decorator which will checks
+database connection before running view, it will also attaches
+manager,conn & template_path properties to self
+
+* end_transaction()
+  - To end any existing database transaction.
+
+* list()
+  - This function returns Exclusion constraint nodes within that
+collection as http response.
+
+* get_list()
+  - This function is used to list all the language nodes within that collection
+an

Re: [pgadmin-hackers] Subnode grid row close issue [pgAdmin4]

2016-03-19 Thread Harshal Dhumal
Hi,

Here is updated patch.

In initial patch I fixed this issue in only Subnode control while Type node
uses unique collection control (which is special case of subnode control).
Now I have fixed in both control.



-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Thu, Mar 17, 2016 at 6:41 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Thu, Mar 17, 2016 at 11:14 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch for Subnode grid row close issue.
>>
>> Issue fixed:
>>
>> 1] Close any existing row while adding new row.
>> 2] Close any existing row if we edit new row.
>>
>
> This doesn't appear to make any difference to me. I've confirmed the patch
> is applied, restarted the app, emptied my cache and reloaded, and tested
> with composite types on the Create Type dialogue. I still see multiple row
> forms when I hit the ADD button if one is already open.
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 39e3233..4a0476d 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -975,6 +975,29 @@
 
   var collection = this.model.get(data.name);
 
+  var cellEditing = function(args){
+var self = this,
+  cell = args[0];
+// Search for any other rows which are open.
+this.each(function(m){
+  // Check if row which we are about to close is not current row.
+  if (cell.model != m) {
+var idx = self.indexOf(m);
+if (idx > -1) {
+  var row = grid.body.rows[idx],
+  editCell = row.$el.find(".subnode-edit-in-process").parent();
+  // Only close row if it's open.
+  if (editCell.length > 0){
+var event = new Event('click');
+editCell[0].dispatchEvent(event);
+  }
+}
+  }
+});
+  }
+  // Listen for any row which is about to enter in edit mode.
+  collection.on( "enteringEditMode", cellEditing, collection);
+
   // Initialize a new Grid instance
   var grid = self.grid = new Backgrid.Grid({
 columns: gridSchema.columns,
@@ -997,6 +1020,17 @@
   if (!(data.disabled || data.canAdd == false)) {
 $dialog.find('button.add').first().click(function(e) {
   e.preventDefault();
+
+  // Close any existing expanded row before adding new one.
+  _.each(grid.body.rows, function(row){
+var editCell = row.$el.find(".subnode-edit-in-process").parent();
+// Only close row if it's open.
+if (editCell.length > 0){
+  var event = new Event('click');
+  editCell[0].dispatchEvent(event);
+}
+  });
+
   var allowMultipleEmptyRows = !!self.field.get('allowMultipleEmptyRows');
 
   // If allowMultipleEmptyRows is not set or is false then don't allow second new empty row.
@@ -1163,6 +1197,30 @@
 });
 self.model.set(data.name, collection, {silent: true});
   }
+
+  var cellEditing = function(args){
+var self = this,
+  cell = args[0];
+// Search for any other rows which are open.
+this.each(function(m){
+  // Check if row which we are about to close is not current row.
+  if (cell.model != m) {
+var idx = self.indexOf(m);
+if (idx > -1) {
+  var row = grid.body.rows[idx],
+  editCell = row.$el.find(".subnode-edit-in-process").parent();
+  // Only close row if it's open.
+  if (editCell.length > 0){
+var event = new Event('click');
+editCell[0].dispatchEvent(event);
+  }
+}
+  }
+});
+  }
+  // Listen for any row which is about to enter in edit mode.
+  collection.on( "enteringEditMode", cellEditing, collection);
+
   // Initialize a new Grid instance
   var grid = self.grid = new Backgrid.Grid({
   columns: gridSchema.columns,
@@ -1184,7 +1242,18 @@
   // Add button callback
   $dialog.find('button.add').click(function(e) {
 e.preventDefault();
+// Close any existing expanded row before adding new one.
+_.each(grid.body.rows, function(row){
+  var editCell = row.$el.find(".subnode-edit-in-process").parent();
+  // Only close row if it's open.
+  if (editCell.length > 0){
+var event = new Event('click');
+edit

Re: [pgadmin-hackers] Control for selecting multiple columns [pgadmin4]

2016-03-21 Thread Harshal Dhumal
Hi,

Here is updated patch

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Fri, Mar 18, 2016 at 9:37 PM, Dave Page <dp...@pgadmin.org> wrote:

>
>
> On Fri, Mar 18, 2016 at 11:41 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> The error is at line 84 in primary_key.js (from screenshot).
>>
>> In primary_key.js it requires MultiSelectAjaxControl. I guess patch of
>> MultiSelectControl was not applied correctly.
>>
>> Can you please try again.
>>
>> When testing it check if (in browser script tab) MultiSelectControl is
>> there in node.ui.js at line no 562 (approx).
>>
>
> OK, I got it in the end. Took a lot of repeated cache clear outs though :-(
>
> So... I see two issues:
>
> 1) The control has a black border when it has focus, unlike other controls
> that have gray ones.
>
Fixed.



>
>
2)  The sizing is different from other controls, whether in large screen or
> small screen modes. Please see the attached screenshots. The control should
> be positioned and sized just like a text control (with the exception that
> it expands to multiple rows if needed, as it does).
>
> Fixed.



> Thanks.
>
> [image: Inline image 2][image: Inline image 1]
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index a373972..21a73c0 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -556,6 +556,46 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
 })
   });
 
+  /*
+   * Control to select multiple columns.
+   */
+  var MultiSelectAjaxControl = Backform.MultiSelectAjaxControl = NodeAjaxOptionsControl.extend({
+formatter: {
+  fromRaw: function (rawData, model) {
+return _.isObject(rawData) ? rawData : JSON.parse(rawData);
+  },
+  toRaw: function (formattedData, model) {
+return formattedData;
+  }
+},
+template: _.template([
+  '<%=label%>',
+  '',
+  '   <%=required ? "required" : ""%>>',
+  '<% for (var i=0; i < options.length; i++) { %>',
+  '  <% var option = options[i]; %>',
+  '   <%=value != null && _.indexOf(value, option.value) != -1 ? "selected" : ""%> <%=option.disabled ? "disabled=\'disabled\'" : ""%>><%-option.label%>',
+  '<% } %>',
+  '  ',
+  ''
+  ].join("\n")),
+getValueFromDOM: function() {
+  var res = [];
+
+  this.$el.find("select").find(':selected').each(function() {
+res.push($(this).attr('value'));
+  });
+
+  return res;
+},
+defaults: _.extend({}, NodeAjaxOptionsControl.prototype.defaults, {
+  select2: {
+multiple: true,
+allowClear: true,
+width: 'style'
+  }
+})
+  });
 
   return Backform;
 });
diff --git a/web/pgadmin/static/css/overrides.css b/web/pgadmin/static/css/overrides.css
index 4dcff33..b406e43 100755
--- a/web/pgadmin/static/css/overrides.css
+++ b/web/pgadmin/static/css/overrides.css
@@ -807,4 +807,10 @@ td.edit-cell.editable.sortable.renderable.editor {
 .backgrid .textarea-cell.editor textarea {
 width: 100%;
 height: auto;
+}
+
+.select2-container--default.select2-container--focus
+.select2-selection--multiple {
+border: 1px solid #aaa !important;
+outline: 0 none;
 }
\ No newline at end of file

-- 
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: Added Node Type & Catalog objects [pgAdmin4]

2016-03-19 Thread Harshal Dhumal
Hi Dave,

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Thu, Mar 17, 2016 at 4:13 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Thu, Mar 17, 2016 at 10:08 AM, Murtuza Zabuawala
> <murtuza.zabuaw...@enterprisedb.com> wrote:
> >

> - If I click ADD to add a new member to a composite type whilst the
> > previous row is expanded, the new row is added, but the expanded panel
> > remains linked to the first row.
> >
> > - If I then click on the Edit button on the new row, I see two
> > expanded panels, neither of which is attached to their row (and
> > they're in the wrong order). I would only expect to see one panel at a
> > time.
> >
> > This is general with sub-node collection control.
> > [We will add it in TODO list]
>

I just sent a patch for this issue.


>
>
> --
> 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] Switch control options issue [pgadmin4]

2016-03-22 Thread Harshal Dhumal
Hi,

PFA patch for switch control.

Issue: Configuration options for switch control from different places
should be merged together and not overridden.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 66d8dab..ce5cb1a 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -441,19 +441,21 @@
 },
 events: {'switchChange.bootstrapSwitch': 'onChange'},
 render: function() {
-  var field = _.defaults(this.field.toJSON(), this.defaults, {options: $.fn.bootstrapSwitch.defaults}),
+  var field = _.defaults(this.field.toJSON(), this.defaults),
   attributes = this.model.toJSON(),
   attrArr = field.name.split('.'),
   name = attrArr.shift(),
   path = attrArr.join('.'),
-  rawValue = this.keyPathAccessor(attributes[name], path);
+  rawValue = this.keyPathAccessor(attributes[name], path),
+  options =  _.defaults({}, this.field.get('options'), this.defaults.options,
+$.fn.bootstrapSwitch.defaults);
 
   Backform.InputControl.prototype.render.apply(this, arguments);
   this.$input = this.$el.find("input[type=checkbox]").first();
 
   //Check & set additional properties
   this.$input.bootstrapSwitch(
-  _.extend(field.options, {'state': rawValue})
+  _.extend(options, {'state': rawValue})
   );
 
   return this;

-- 
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] Control for selecting multiple columns [pgadmin4]

2016-03-22 Thread Harshal Dhumal
Hi,

PFA patch for MultiselectControl.

Issue: Fixed issue when parsing undefined data as json.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Mon, Mar 21, 2016 at 11:35 AM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> Here is updated patch
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>
> On Fri, Mar 18, 2016 at 9:37 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>>
>>
>> On Fri, Mar 18, 2016 at 11:41 AM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> The error is at line 84 in primary_key.js (from screenshot).
>>>
>>> In primary_key.js it requires MultiSelectAjaxControl. I guess patch of
>>> MultiSelectControl was not applied correctly.
>>>
>>> Can you please try again.
>>>
>>> When testing it check if (in browser script tab) MultiSelectControl is
>>> there in node.ui.js at line no 562 (approx).
>>>
>>
>> OK, I got it in the end. Took a lot of repeated cache clear outs though
>> :-(
>>
>> So... I see two issues:
>>
>> 1) The control has a black border when it has focus, unlike other
>> controls that have gray ones.
>>
> Fixed.
>
>
>
>>
>>
> 2)  The sizing is different from other controls, whether in large screen
>> or small screen modes. Please see the attached screenshots. The control
>> should be positioned and sized just like a text control (with the exception
>> that it expands to multiple rows if needed, as it does).
>>
>> Fixed.
>
>
>
>> Thanks.
>>
>> [image: Inline image 2][image: Inline image 1]
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index a373972..f127d52 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -556,6 +556,46 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
 })
   });
 
+  /*
+   * Control to select multiple columns.
+   */
+  var MultiSelectAjaxControl = Backform.MultiSelectAjaxControl = NodeAjaxOptionsControl.extend({
+formatter: {
+  fromRaw: function (rawData, model) {
+return (_.isUndefined(rawData) || _.isObject(rawData)) ? rawData : JSON.parse(rawData);
+  },
+  toRaw: function (formattedData, model) {
+return formattedData;
+  }
+},
+template: _.template([
+  '<%=label%>',
+  '',
+  '   <%=required ? "required" : ""%>>',
+  '<% for (var i=0; i < options.length; i++) { %>',
+  '  <% var option = options[i]; %>',
+  '   <%=value != null && _.indexOf(value, option.value) != -1 ? "selected" : ""%> <%=option.disabled ? "disabled=\'disabled\'" : ""%>><%-option.label%>',
+  '<% } %>',
+  '  ',
+  ''
+  ].join("\n")),
+getValueFromDOM: function() {
+  var res = [];
+
+  this.$el.find("select").find(':selected').each(function() {
+res.push($(this).attr('value'));
+  });
+
+  return res;
+},
+defaults: _.extend({}, NodeAjaxOptionsControl.prototype.defaults, {
+  select2: {
+multiple: true,
+allowClear: true,
+width: 'style'
+  }
+})
+  });
 
   return Backform;
 });
diff --git a/web/pgadmin/static/css/overrides.css b/web/pgadmin/static/css/overrides.css
index 4dcff33..b406e43 100755
--- a/web/pgadmin/static/css/overrides.css
+++ b/web/pgadmin/static/css/overrides.css
@@ -807,4 +807,10 @@ td.edit-cell.editable.sortable.renderable.editor {
 .backgrid .textarea-cell.editor textarea {
 width: 100%;
 height: auto;
+}
+
+.select2-container--default.select2-container--focus
+.select2-selection--multiple {
+border: 1px solid #aaa !important;
+outline: 0 none;
 }
\ No newline at end of file

-- 
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] Disabled option to bootstrap switch control [pgadmin4]

2016-03-23 Thread Harshal Dhumal
Hi,

PFA minor patch for switch control.


Change: Added disabled option to bootstrap switch control.


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index b4a1141..fb82161 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -447,8 +447,13 @@
   name = attrArr.shift(),
   path = attrArr.join('.'),
   rawValue = this.keyPathAccessor(attributes[name], path),
-  options =  _.defaults({}, this.field.get('options'), this.defaults.options,
-$.fn.bootstrapSwitch.defaults);
+  evalF = function(f, m) {
+return (_.isFunction(f) ? !!f(m) : !!f);
+},
+  options =  _.defaults({
+  disabled: evalF(field.disabled, this.model)
+}, this.field.get('options'), this.defaults.options,
+$.fn.bootstrapSwitch.defaults);
 
   Backform.InputControl.prototype.render.apply(this, arguments);
   this.$input = this.$el.find("input[type=checkbox]").first();

-- 
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] Control for selecting multiple columns [pgadmin4]

2016-03-08 Thread Harshal Dhumal
Hi Dave,

Currently there is no test dialogue to test this control.
Also Ashesh has suggested some changes. Once I complete those changes; I'll
resubmit the patch along with test dialogue to test it.



-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Tue, Mar 8, 2016 at 4:16 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi,
>
> Do you have a test dialogue or similar in which I can test this code?
> Ideally an addition to the test module would be good.
>
> Thanks.
>
> On Tue, Mar 8, 2016 at 7:34 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA backform control for selecting multiple columns.(This control depends
>> on column node.)
>>
>> Usage:
>>
>> {
>>   id: 'columns', label: '{{ _('Columns') }}',
>>   type: 'collection', group: '{{ _('Definition') }}', editable:true,
>>   canDelete: true, canAdd: true, control: Backform.MultiColumnSelectControl,
>>   deps: ['index'], node: 'column',
>>   model: pgBrowser.Node.Model.extend({
>> keys: ['column'],
>> defaults: {
>>   column: undefined
>> }
>>   })
>> }
>>
>>
>> Note: When using this control model should have *column* attribute. And
>> node property should be *column*.
>>
>>
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>>
>> --
>> 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
>


[pgadmin-hackers] Control for selecting multiple columns [pgadmin4]

2016-03-07 Thread Harshal Dhumal
Hi,

PFA backform control for selecting multiple columns.(This control depends
on column node.)

Usage:

{
  id: 'columns', label: '{{ _('Columns') }}',
  type: 'collection', group: '{{ _('Definition') }}', editable:true,
  canDelete: true, canAdd: true, control: Backform.MultiColumnSelectControl,
  deps: ['index'], node: 'column',
  model: pgBrowser.Node.Model.extend({
keys: ['column'],
defaults: {
  column: undefined
}
  })
}


Note: When using this control model should have *column* attribute. And
node property should be *column*.




-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index b84b6ee..500d49b 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -558,6 +558,145 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
 })
   });
 
+  /*
+   * Control to select multiple columns.
+   */
+  var MultiColumnSelectControl = Backform.MultiColumnSelectControl = Backform.NodeListByNameControl.extend({
+formatter: {
+  fromRaw: function (rawData, model) {
+var res = _.isObject(rawData) ? rawData : JSON.parse(rawData);
+
+return _.pluck(res, 'column');
+  },
+  toRaw: function (formattedData, model) {
+return formattedData;
+  }
+},
+template: _.template([
+  '<%=label%>',
+  '',
+  '   <%=required ? "required" : ""%>>',
+  '<% for (var i=0; i < options.length; i++) { %>',
+  '  <% var option = options[i]; %>',
+  '   <%=value != null && _.indexOf(value, option.value) != -1 ? "selected" : ""%> <%=option.disabled ? "disabled=\'disabled\'" : ""%>><%-option.label%>',
+  '<% } %>',
+  '  ',
+  ''
+  ].join("\n")),
+events: {"change select": "onChange"},
+getValueFromDOM: function() {
+  var res = [];
+
+  this.$el.find("select").find(':selected').each(function() {
+res.push($(this).attr('value'));
+  });
+
+  return res;
+},
+render: function() {
+  var field = _.defaults(this.field.toJSON(), this.defaults),
+  attrArr = field.name.split('.'),
+  name = attrArr.shift(),
+  path = attrArr.join('.'),
+  data = _.extend(field),
+  evalF = function(f, d, m) {
+return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f);
+  };
+
+  // Evaluate the disabled, visible, and required option
+  _.extend(data, {
+disabled: evalF(data.disabled, data, this.model),
+visible:  evalF(data.visible, data, this.model),
+required: evalF(data.required, data, this.model)
+  });
+
+  var attributes = this.model.toJSON(),
+rawValue = this.keyPathAccessor(attributes[name], path);
+
+  data = _.extend(data, {
+rawValue: rawValue,
+value: this.formatter.fromRaw(rawValue, this.model),
+attributes: attributes,
+formatter: this.formatter
+  })
+  // Evaluation the options
+  if (_.isFunction(data.options)) {
+try {
+  data.options = data.options.apply(this)
+} catch(e) {
+  // Do nothing
+  data.options = []
+  this.model.trigger('pgadmin-view:transform:error', m, self.field, e);
+}
+  }
+
+  // Clean up first
+  this.$el.removeClass(Backform.hiddenClassname);
+
+  if (!data.visible)
+this.$el.addClass(Backform.hiddenClassname);
+
+  this.$el.html(this.template(data)).addClass(field.name);
+  this.updateInvalid();
+
+  var self = this,
+  collection = this.model.get(this.field.get('name'));
+
+  this.$el.find('select').select2({
+multiple: true,
+allowClear: true,
+placeholder: "Select column/s",
+width: 'style'
+  }).on("change", function(e) {
+$(e.target).find(':selected').each(function() {
+});
+  });
+  return this;
+},
+onChange: function(e) {
+  var model = this.model,
+  $el = $(e.target),
+  attrArr = this.field.get("name").split('.'),
+  name = attrArr.shift(),
+  path = attrArr.join('.'),
+  vals = this.getValueFromDOM(),
+  collection = model.get(name),
+  removed = [];
+
+  this.stopListening(this.model, "change:" + name, this.render);
+
+  /*
+   * Iterate through all the values, and find out how many are already
+   * present in the collection.
+   */
+  collection.each(function(m) {
+var column = m.get('column'),
+idx = _.indexOf(vals, column);
+
+if (idx > -1) {
+ 

[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 <http://www.enterprisedb.com>
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 <http://www.enterprisedb.com>

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 <http://www.enterprisedb.com>
>
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),
   attrAr

[pgadmin-hackers] [pgadmin3] [postgresSQL] [bug] Two or more different types of constraints with same name creates ambiguity while drooping.

2016-03-29 Thread Harshal Dhumal
Hi,

If we create two different type of constrains (lets say primary key and
foreign key) with same name (lets say 'key' ) then its shows same drop
query for both constrains.
e.g.

ALTER TABLE public."Test_tbl" DROP CONSTRAINT key;


If we execute above query for first time then it drops primary key first
and if execute same query for second time then it drops foreign key.

Also in pgadmin3 if we right click on foreign key and try to drop it, it
drops primary key and not the foreign key. We have to drop foreign key
twice to actually drop the foreign key if primary key with same was there.


*Note: Create foreign key first with some name and then primary key with
same name.*


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>


Re: [pgadmin-hackers] Minor issues

2016-04-29 Thread Harshal Dhumal
-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Fri, Apr 29, 2016 at 11:52 AM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch for minor issues.
>
> Issues fixed:
>
> 1] Removed unwanted "{% if  %}" from database 9.1 nodes.sql
> 2] Fixed issue while removing select2cell fro backgrid.
>

Regarding select2 cell; Even though we have created select2 cell sometimes
we do not get select2 instance when we retrieve it from dom. So we have to
manually check it's data attribute before calling it's destroy method.


>
>
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>


[pgadmin-hackers] Minor issues

2016-04-29 Thread Harshal Dhumal
Hi,

PFA patch for minor issues.

Issues fixed:

1] Removed unwanted "{% if  %}" from database 9.1 nodes.sql
2] Fixed issue while removing select2cell fro backgrid.




-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/nodes.sql
index 3ce9645..b05880c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/nodes.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/nodes.sql
@@ -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
diff --git a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
index 999ac7c..5311a01 100644
--- a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
+++ b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js
@@ -530,7 +530,9 @@
 
 remove: function() {
   this.$select.off('change', this.onSave);
-  this.$select.select2('destroy');
+  if (this.$select.data('select2')) {
+this.$select.select2('destroy');
+  }
   this.$el.empty();
   Backgrid.SelectCell.prototype.remove.apply(this, arguments);
  }

-- 
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] Tables node (pgAdmin4)

2016-04-28 Thread Harshal Dhumal
-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Thu, Apr 28, 2016 at 2:22 PM, Dave Page <dp...@pgadmin.org> wrote:

>
>
> > On 27 Apr 2016, at 13:43, Thom Brown <t...@linux.com> wrote:
> >
> > On 27 April 2016 at 10:22, Harshal Dhumal
> > <harshal.dhu...@enterprisedb.com> wrote:
> >>
> >> Hi,
> >>
> >> PFA attached patches for table node and all table child nodes.
> >>
> >> This patch includes below nodes,
> >>
> >> 1) Table node  -- Initial patch by Murtuza,
> constraints compatibility by Harshal.
> >> 2) Column node   -- by Murtuza.
> >> 3) Index node  -- by Murtuza.
> >> 4) Trigger node-- by Murtuzz.
> >> 6) Rules node  -- by Surinder.
> >> 7) Constraints nodes:
> >>  i]  Index Constraint -- Initial patch by Harshal,
> Integration with table node by Murtuza.
> >>  ii] Foreign key-- Initial patch and
> Integration with table node by Harshal.
> >>  iii] Check constraint-- Initial patch and
> Integration with table node by Harshal.
> >>  iv] Exclusion constraint   -- Initial patch and
> Integration with table node by Harshal.
> >>
> >> Please apply patches in following order as all of them depends on each
> other.
> >>
> >> Order:  Table Node > Index constraint ---> remaining patches in any
> order.
> >
> > Nice work.  Here's some initial feedback from a very quick play around.
> >
> > On the Create table editor, in the Advance tab (which should probably
> > be labelled "Advanced"), the Like section should grey out the "With *"
> > values if no relation is selected in the drop-down box.
> >
> > The way primary keys are defined are kinda awkward.  It might be
> > useful to provide some kind of checkbox on the initial column list
> > that tells it which columns are involved in the primary key, then the
> > user could just select which ones they want.  If they want to refine
> > it, they could edit it in the Constraints > Primary Key section.
>
> If the design we did has been properly followed (I can't check right now),
> then that's exactly how it should be working. Harshal?
>

I can't comment on entire table node ui design as I haven't worked on it
except the constraints nodes.

In constraints nodes I can see that order of some properties in tabs is not
same as that of design (this can be easily changed by reordering schema
properties of constraints node).

And also currently there is no support to show two or more controls inline
in dialog and where in design for e.g In Unique key constraint under
columns tab the "Order" and "Null's order" are shown inline (there are many
of like this). So all controls are rendered on separate row which is not as
per design.


> Arun Kollan and I spent a lot of time redesigning the table dialogue to
> make it as quick and efficient to use as possible. There will likely be
> minor deviations from that design to ensure consistency with the way other
> parts of the app have turned out, but the basic principles should be there.
>
> >
> > I'm getting weird spacing in the SQL output.  Here's an example:
> >
> > CREATE UNLOGGED TABLE public.test
> > (
> >id integer COLLATE pg_catalog."de_DE.utf8" NOT NULL DEFAULT -1,
> >stuff text COLLATE pg_catalog."C.UTF-8" DEFAULT "hello",
> >CONSTRAINT pk PRIMARY KEY (id, stuff) WITH (FILLFACTOR=33) DEFERRABLE
> > )
> > WITH (
> >OIDS = TRUE,
> >FILLFACTOR = 88,
> >autovacuum_enabled = TRUE,
> >autovacuum_analyze_scale_factor = 0.33,
> >autovacuum_analyze_threshold = 30,
> >autovacuum_freeze_max_age = 333,
> >autovacuum_vacuum_cost_delay = 30,
> >autovacuum_vacuum_cost_limit = 3,
> >autovacuum_vacuum_scale_factor = 0.33,
> >autovacuum_vacuum_threshold = 33,
> >autovacuum_freeze_min_age = 330,
> >autovacuum_freeze_table_age = 33300
> > )
> > TABLESPACE pg_default;
> >
> > ALTER TABLE public.test
> >OWNER to thom;
> > GRANT ALL ON TABLE public.test TO thom;
> >
> >
> > COMMENT ON TABLE public.test
> >IS 'This is just a test table';
> >
> > COMMENT ON COLUMN public.test.id
> >IS 'the main ID';
> >
> > ALTER TABLE public.test
> >ALTER COLUM

Re: [pgadmin-hackers] [PATCH] Tables node (pgAdmin4)

2016-04-27 Thread Harshal Dhumal
Hi,

The exclusion constraint has minor validation issue (this won't block
testing of patch). I'm closely working with Ashesh to fix this.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Wed, Apr 27, 2016 at 2:52 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA attached patches for table node and all table child nodes.
>
> This patch includes below nodes,
>
> 1) Table node  *-- Initial patch by Murtuza,
> constraints compatibility by Harshal. *
> 2) Column node   *-- by Murtuza. *
> 3) Index node  *-- by Murtuza. *
> 4) Trigger node*-- by Murtuzz. *
> 6) Rules node
> *-- by Surinder.*
> 7) Constraints nodes:
>   i]  Index Constraint *-- Initial patch by Harshal,
> Integration with table node by **Murtuza.*
>   ii] Foreign key*-- Initial patch and
> Integration with table node by Harshal**.*
>   iii] Check constraint*-- Initial patch and
> Integration with table node by Harshal**.*
>   iv] Exclusion constraint   *-- Initial patch and
> Integration with table node by Harshal**.*
>
> Please apply patches in following order as all of them depends on each
> other.
>
>
>
> *Order:  Table Node > Index constraint ---> remaining patches in any
> order.*
>
>
>
>
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>
> On Mon, Apr 18, 2016 at 7:04 PM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find initial patch for tables node.
>>
>> This patch includes below nodes,
>>
>> 1) Tables node
>> 2) Columns node
>> 3) Index node
>> 4) Trigger node
>> 5) Constraints node (Primary key & Unique constraints only)*-- From:
>> Harshal*
>> 6) Roles node
>>*-- From: Surinder*
>>
>> This patch also includes "VacuumSettings control" required by table node.
>>
>> Please apply Fieldset Control UI patch sent earlier.
>>
>>
>> *Please note that constraint node is still partial, It has Primary Key &
>> Unique constraint working & integrated in tables node.*
>>
>> 1)  I have used initial patch of index constraints node from Harshal &
>> further extend it it to work with table node.
>> [ Harshal will integrate rest of constraints in tables node, he is
>> working on it.]
>>
>> 2) I have also used initial patches of rules node and VacuumSettings
>> control from Surinder & further extend them it to work with table node.
>>
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: 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] server and database node type check in is_connected check [pgadmin4]

2016-05-24 Thread Harshal Dhumal
Hi,


PFA patch for server and database node:

Issue fixed: Added node type check in is_connected check.
-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
index 5d55170..5d7f1a0 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
@@ -103,10 +103,12 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
 return server.connected && server.user.can_create_db;
   },
   is_not_connected: function(node) {
-return (node && node.connected != true);
+return (node && node._type == "database" &&
+node.connected != true);
   },
   is_connected: function(node) {
-return (node && node.connected == true && node.canDisconn == true);
+return (node && node._type == "database" &&
+  node.connected == true && node.canDisconn == true);
   },
   callbacks: {
 /* Connect the database */
diff --git a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
index 33deafb..78bf67b 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
+++ b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
@@ -72,10 +72,12 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
   '{{ _('At least one privilege should be selected.') }}';
   },
   is_not_connected: function(node) {
-return (node && node.connected != true);
+return (node && node._type == "server" &&
+node.connected != true);
   },
   is_connected: function(node) {
-return (node && node.connected == true);
+return (node && node._type == "server" &&
+  node.connected == true);
   },
   enable_reload_config: function(node) {
 // Must be connected & is Super user

-- 
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] server and database node type check in is_connected check [pgadmin4]

2016-05-24 Thread Harshal Dhumal
Hi Ashesh,

For change server password we have added check is_connected() in server.js.
Also same function is also available in database.js. So it was causing
change server password menu to enable on database node as well if database
is connected.

This issue will appear for any other menu if that menu has check on
is_connected function.




-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Tue, May 24, 2016 at 12:13 PM, Ashesh Vashi <
ashesh.va...@enterprisedb.com> wrote:

>
> On Tue, May 24, 2016 at 12:06 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>>
>> PFA patch for server and database node:
>>
>> Issue fixed: Added node type check in is_connected check.
>>
>
> Can you please describe the situation, when these functions are being
> executed outside the respective node instance?
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com/>
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi>
>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>>
>> --
>> 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] variable scope issue in server js [pgadmin4]

2016-05-12 Thread Harshal Dhumal
Hi Akshay,

Murtuza hasn't fixed it in all places. He missed in following tow functions

connect_server and disconnect_server




-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Thu, May 12, 2016 at 7:38 PM, Akshay Joshi <akshay.jo...@enterprisedb.com
> wrote:

> Hi
>
> On Thu, May 12, 2016 at 5:05 PM, Harshal Dhumal <harshal.dhumal@
> enterprisedb.com> wrote:
>
>> Hi,
>>
>>
>> PFA patch for server.js. Replaced ";" (semicolon) with ","  (coma) in
>> variable declaration.
>>
>> Issue: This was changing scope of all the variables declared after ";"
>> (semicolon) from *local* to *global* and therefore affecting all other *local
>> variables *with same name at different place in same file.
>>
>
>Thanks- it is already being committed with the patch for "Named Restore
> Point" send by Murtuza.
>
>>
>>
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>


Re: [pgadmin-hackers] [PATCH] Tables node (pgAdmin4)

2016-05-12 Thread Harshal Dhumal
Hi,


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Tue, May 10, 2016 at 6:37 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Harshal,
>
> Pending issues to be fixed which I tried but not able to fix in
> Constraints node,
>
*1)* Adding Primary key in create table mode causes "too much recursion"
> error & Column collection validation error.
>
Fixed.


> *2)* MultiSelect2 rendering issue causing window to hang.
>
Fixed.


>
>
>
>
> PFA updated patch for table node,
> - Added help file names in js.
> - Added Deps for primary key cell in create table node
> - Corrected validation error messages
> - Formatted SQL templates properly
> - Added support for View in triggers node
>
>
> Regards,
> Murtuza
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Mon, May 9, 2016 at 5:51 PM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi Harshal,
>>
>> Please find comments as below for constraints node,
>>
>> 1) Not able to create Primary key due to 'Please provide primary key'
>> validation error
>> 2) Primary key dialog do not close after save.
>> 3) Error "too much recursion" when creating Forgien key from New table.
>> 4) Error "too much recursion" when creating Check constraint from New
>> table.
>> 5) Remove console.log from JS (Unique constraint)
>> 6) Unique & Exclude constraint are also not working in create mode, No
>> SQL is generated in create mode
>> 7) If there are no columns on table select2 shows columns of previously
>> fetched objects columns.
>>
>>
>>
>> Also attaching new updated patch, which will fixes below issues,
>> Fixed:
>> =
>> 1) Do not show Foreign tables under tables node
>> 2) In trigger node changed select2 control options as per new format.
>> 3) Removed unwanted templates from trigger node
>> 4) clean up some unwanted code from trigger node
>> 5) Fixed Create sql template in index node
>>
>>
>> Regards,
>> Murtuza
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Sat, May 7, 2016 at 7:45 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> Please find below responses.
>>>
>>>>
>>>> Please find the review comments so far:
>>>>
>>>> 1. On the Table Collection node, The fields in the grid should be Name,
>>>> Owner and Comments. OID is not required. Please follow same for the other
>>>> Nodes like Index, Constraints etc.
>>>>
>>>
>>> Fixed
>>>
>>>> 2. While Updating the Table, Add any column as well as Inherits any
>>>> table, then the check the SQL tab.
>>>> ALTER TABLE SQL should be come in the new line
>>>>
>>>> *Current SQL Tab:*
>>>>
>>>> ALTER TABLE pem.agent_heartbeat
>>>> INHERIT pem.alert_history;ALTER TABLE pem.agent_heartbeat
>>>> ADD COLUMN test bigint;
>>>>
>>> Fixed
>>>
>>>
>>>> 3. While Creating/updating table, if the Schema is other than selected
>>>> one, then after saving the table, it is not falling under the same schema.
>>>> And also in update mode it gives an error.
>>>>
>>> TODO
>>>
>>>
>>>> 4. Unlogged setting does not honor the change of value.
>>>>
>>> Not reproducible.
>>>
>>>
>>>> 5. Please Check SQL tab for all the Nodes as most of them having
>>>> problem of No blank lines/More than one Blank Lines/Blank Lines at the end
>>>> etc.
>>>>
>>> Fixed
>>>
>>>
>>>> 6. Creating Table with  auto_vacuum and updating only one field then
>>>> wrong SQL is generated.
>>>> WITH (
>>>> OIDS = TRUE,
>>>> FILLFACTOR = 12,
>>>> autovacuum_enabled = TRUE,
>>>> ,
>>>> autovacuum_vacuum_cost_delay = 21
>>>> )
>>>>
>>>> Fixed.
>>>
>>>
>>>> 7. Same as toast
>>>> WITH (
>>>> OIDS = TRUE,
>>>> FILLFACTOR = 12,
>>>> autovacuum_enabled = TRUE,
>>>> toast.autovacuum_en

Re: [pgadmin-hackers] Change server password [pgadmin4]

2016-05-12 Thread Harshal Dhumal
Hi,

PFA updated patch.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Thu, May 12, 2016 at 4:14 PM, Akshay Joshi <akshay.jo...@enterprisedb.com
> wrote:

> Hi Harshal
>
> Below are my review comments :
>
>- Facing error unexpected identifier 'change_password: function(args)'
>in js file
>
> Fixed

>
>-
>- Please correct the spelling of password in the menu item.
>
> Fixed

>
>-
>- Title for alertify dialog showing "Change password for servers" it
>should be only "Change Password" or "Change Password for ".
>
> Fixed

>
>-
>- Facing error "name 'decrypt' is not defined."
>
> Fixed

>
>    -
>- Not able to change the password facing error.
>
> Fixed

>
>-
>
>
> On Thu, May 12, 2016 at 1:43 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA updated patch.
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>> On Thu, May 12, 2016 at 1:27 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>> This patch needs a rebase. (as "Named restore point" patch is committed.)
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer *
>>>
>>>
>>>
>>> EenterpriseDB <http://www.enterprisedb.com>
>>>
>>> On Wed, May 11, 2016 at 12:35 PM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> PFA patch for changing server password.
>>>>
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Software Engineer *
>>>>
>>>>
>>>>
>>>> EenterpriseDB <http://www.enterprisedb.com>
>>>>
>>>
>>>
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index a79f1d4..130bc16 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -19,7 +19,7 @@ from pgadmin.browser.utils import PGChildNodeView
 import traceback
 from flask.ext.babel import gettext
 import pgadmin.browser.server_groups as sg
-from pgadmin.utils.crypto import encrypt
+from pgadmin.utils.crypto import encrypt, decrypt, pqencryptpassword
 from config import PG_DEFAULT_DRIVER
 from pgadmin.browser.server_groups.servers.types import ServerType
 import config
@@ -195,7 +195,9 @@ class ServerNode(PGChildNodeView):
 [{'post': 'create_restore_point'}],
 'connect': [{
 'get': 'connect_status', 'post': 'connect', 'delete': 'disconnect'
-}]
+}],
+'change_password': [{
+'post': 'change_password'}]
 })
 
 def nodes(self, gid):
@@ -838,4 +840,93 @@ class ServerNode(PGChildNodeView):
 )
 return internal_server_error(errormsg=str(e))
 
+def change_password(self, gid, sid):
+try:
+data = json.loads(request.form['data'])
+if data and ('password' not in data or
+ data['password'] == '' or
+ 'newPassword' not in data or
+ data['newPassword'] == '' or
+ 'confirmPassword' not in data or
+ data['confirmPassword'] == ''):
+return make_json_response(
+status=400,
+success=0,
+errormsg=gettext(
+"Couldn't find the required parameter(s)."
+)
+)
+
+if data['newPassword'] != data['confirmPassword']:
+return make_json_response(
+status=200,
+success=0,
+errormsg=gettext(
+"Passwords do not match."
+)
+)
+
+# Fetch Server Details
+server = Server.query.filter_by(id=sid).first()
+if server is None:
+return bad_request(gettext("Server not found."))
+
+   

Re: [pgadmin-hackers] Change server password [pgadmin4]

2016-05-12 Thread Harshal Dhumal
Hi,


-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Thu, May 12, 2016 at 4:16 PM, Ashesh Vashi <ashesh.va...@enterprisedb.com
> wrote:

> On Thu, May 12, 2016 at 4:14 PM, Akshay Joshi <
> akshay.jo...@enterprisedb.com> wrote:
>
>> Hi Harshal
>>
>> Below are my review comments :
>>
>>- Facing error unexpected identifier 'change_password:
>>function(args)' in js file.
>>- Please correct the spelling of password in the menu item.
>>- Title for alertify dialog showing "Change password for servers" it
>>should be only "Change Password" or "Change Password for ".
>>
>> It should be "Change password for the user on the server - ' name>'".
>

Fixed in latest patch. Also added user name whose password we are changing.


>
>>-
>>    - Facing error "name 'decrypt' is not defined."
>>- Not able to change the password facing error.
>>
>>
>> On Thu, May 12, 2016 at 1:43 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA updated patch.
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer *
>>>
>>>
>>>
>>> EenterpriseDB <http://www.enterprisedb.com>
>>>
>>> On Thu, May 12, 2016 at 1:27 PM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>> This patch needs a rebase. (as "Named restore point" patch is
>>>> committed.)
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Software Engineer *
>>>>
>>>>
>>>>
>>>> EenterpriseDB <http://www.enterprisedb.com>
>>>>
>>>> On Wed, May 11, 2016 at 12:35 PM, Harshal Dhumal <
>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> PFA patch for changing server password.
>>>>>
>>>>>
>>>>> --
>>>>> *Harshal Dhumal*
>>>>> *Software Engineer *
>>>>>
>>>>>
>>>>>
>>>>> EenterpriseDB <http://www.enterprisedb.com>
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>
>>>
>>
>>
>> --
>> *Akshay Joshi*
>> *Principal Software Engineer *
>>
>>
>>
>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>
>
>


Re: [pgadmin-hackers] Change server password [pgadmin4]

2016-05-12 Thread Harshal Dhumal
Hi,

PFA updated patch.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Thu, May 12, 2016 at 1:27 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
> This patch needs a rebase. (as "Named restore point" patch is committed.)
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>
> On Wed, May 11, 2016 at 12:35 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch for changing server password.
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com>
>>
>
>
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index a79f1d4..ad82a8c 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -195,7 +195,9 @@ class ServerNode(PGChildNodeView):
 [{'post': 'create_restore_point'}],
 'connect': [{
 'get': 'connect_status', 'post': 'connect', 'delete': 'disconnect'
-}]
+}],
+'change_password': [{
+'post': 'change_password'}]
 })
 
 def nodes(self, gid):
@@ -838,4 +840,93 @@ class ServerNode(PGChildNodeView):
 )
 return internal_server_error(errormsg=str(e))
 
+def change_password(self, gid, sid):
+try:
+data = json.loads(request.form['data'])
+if data and ('password' not in data or
+ data['password'] == '' or
+ 'newPassword' not in data or
+ data['newPassword'] == '' or
+ 'confirmPassword' not in data or
+ data['confirmPassword'] == ''):
+return make_json_response(
+status=400,
+success=0,
+errormsg=gettext(
+"Couldn't find the required parameter(s)."
+)
+)
+
+if data['newPassword'] != data['confirmPassword']:
+return make_json_response(
+status=200,
+success=0,
+errormsg=gettext(
+"Passwords do not match."
+)
+)
+
+# Fetch Server Details
+server = Server.query.filter_by(id=sid).first()
+if server is None:
+return bad_request(gettext("Server not found."))
+
+# Fetch User Details.
+user = User.query.filter_by(id=current_user.id).first()
+if user is None:
+return unauthorized(gettext("Unauthorized request."))
+
+from pgadmin.utils.driver import get_driver
+manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
+conn = manager.connection()
+
+decrypted_password = decrypt(manager.password, user.password)
+
+if isinstance(decrypted_password, bytes):
+decrypted_password = decrypted_password.decode()
+
+password = data['password']
+
+# Validate old password before setting new.
+if password != decrypted_password:
+return unauthorized(gettext("Incorrect password."))
+
+# Hash new password before saving it.
+password = pqencryptpassword(data['newPassword'], manager.user)
+
+SQL = render_template("/".join([
+'servers/sql',
+'9.2_plus' if manager.version >= 90200 else '9.1_plus',
+'alter_with_encrypted_password.sql'
+]),
+conn=conn, _=gettext,
+user=manager.user, encrypted_password=password)
+
+status, res = conn.execute_scalar(SQL)
+
+if not status:
+return internal_server_error(errormsg=res)
+
+password = encrypt(data['newPassword'], user.password)
+# Check if old password was stored in pgadmin4 sqlite database.
+# If yes then update that password.
+if server.password is not None:
+setattr(server, 'password', password)
+db.session.commit()
+# Also update password in connection manager.
+manager.password = password
+manager.update_session()
+
+return make_json_response(
+status=200,
+success=1,
+info=gettext(
+"Password changed successfully."
+)
+   

Re: [pgadmin-hackers] Change server password [pgadmin4]

2016-05-12 Thread Harshal Dhumal
Hi,
This patch needs a rebase. (as "Named restore point" patch is committed.)

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Wed, May 11, 2016 at 12:35 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch for changing server password.
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com>
>


Re: [pgadmin-hackers] PATCH: FTS configuration node

2016-05-17 Thread Harshal Dhumal
Hi Sanket,

Please find my review comments below:

1. In create mode it generates wrong sql.

CREATE TEXT SEARCH CONFIGURATION test.asdf (
COPY=
);

steps to reproduce:
a] Fill up any necessary fields in general tab.
b] On definition tab set Copy config filed and navigate to SQL tab.
c] Come back again to definition tab clear Copy config field and set
Parser field and again navigate to SQL tab

2. Create new FTS configuration with parser throws below error.

provide atleast copy config or parser.

(this is because you have used key name for parser in js as "prsname" and
in python you have applied validations on key "parser")

3. When we clear dictionary for any token using cross (x) button in
select2; JavaScript code for selecct2 fails. (see attached screenshot)






-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>

On Mon, May 16, 2016 at 7:37 PM, Sanket Mehta <sanket.me...@enterprisedb.com
> wrote:

> Hi,
>
> Revised patch is attached with this mail.
> My response is inline.
>
>
> Regards,
> Sanket Mehta
> Sr Software engineer
> Enterprisedb
>
> On Fri, May 13, 2016 at 6:20 PM, Akshay Joshi <
> akshay.jo...@enterprisedb.com> wrote:
>
>> Hi Sanket
>>
>> Below are my review comments:
>>
>>
>>- Add button should be disabled in Tokens tab while creating.
>>
>> Done
>
>>
>>- Unable to click on down arrow for token select control.
>>
>> Done
>
>>
>>- Title should be change from "Create FTS-dictionaries" to "Create FTS
>>-Configuration".
>>
>> Done
>
>>
>>- Tree node is not getting refreshed on name change.
>>
>> Done
>
>>
>>- Unable to rename FTS Configuration when name contains any capital
>>letter.
>>
>> Done
>
>>
>>- If user tries to add already existing token then respective row in
>>the backgrid should be highlighted.
>>
>> Done
>
>>
>>- "URL not found" when click on SQL help icon from the properties
>>dialog.
>>
>> Done
>
>>
>>- SQL should not be generated when remove and add the same token
>>again. Currently it is creating two sql's one for remove and another
>>is for add.
>>   - *Fix for the above issue is*: - Add "keys: ['token']," to
>>   TokenModel in your js file.
>>
>> Done
>
>
>>
>> On Fri, May 13, 2016 at 2:58 PM, Sanket Mehta <
>> sanket.me...@enterprisedb.com> wrote:
>>
>>> Hi All,
>>>
>>> Last patch for FTS configuration does not contain node.ui.js file
>>> Kindly ignore it.
>>>
>>> Here is the new revised patch attached with this mail.
>>> Please do review it and let me know if any changes required
>>>
>>> Regards,
>>> Sanket Mehta
>>> Sr Software engineer
>>> Enterprisedb
>>>
>>> On Thu, May 12, 2016 at 4:38 PM, Sanket Mehta <
>>> sanket.me...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> PFA the revised patch.
>>>> Please do review it and let me know if anything is not proper.
>>>>
>>>> Regards,
>>>> Sanket Mehta
>>>> Sr Software engineer
>>>> Enterprisedb
>>>>
>>>> On Thu, May 5, 2016 at 8:19 PM, Harshal Dhumal <
>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>
>>>>> + patch link
>>>>>
>>>>>
>>>>> http://www.postgresql.org/message-id/CAFiP3vwkka+=1foj7kr2zbc4azecoca9eo9dz34-oyy_9ge...@mail.gmail.com
>>>>>
>>>>> --
>>>>> *Harshal Dhumal*
>>>>> *Software Engineer *
>>>>>
>>>>>
>>>>>
>>>>> EenterpriseDB <http://www.enterprisedb.com>
>>>>>
>>>>> On Thu, May 5, 2016 at 8:18 PM, Sanket Mehta <
>>>>> sanket.me...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> PFA first patch for FTS configuration node.
>>>>>>
>>>>>> It depends upon backgrid select2cell multi select control, for which
>>>>>> Harshal has sent the patch recently.
>>>>>> Please do apply his patch first and then apply this patch.
>>>>>>
>>>>>> Please do review it and let me know if any changes are required.
>>>>>>
>>>>>>
>>>>>> Regards,
>>>>>> Sanket Mehta
>>>>>> Sr Software engineer
>>>>>> Enterprisedb
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org
>>>>>> )
>>>>>> To make changes to your subscription:
>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>
>>>
>>
>>
>> --
>> *Akshay Joshi*
>> *Principal Software Engineer *
>>
>>
>>
>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>
>
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
>

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


  1   2   3   >