Re: [pgAdmin4][Patch]: RM_2596 - Query tool not working in Desktop Runtime on Mac OS X

2017-08-16 Thread Surinder Kumar
Hi,

Updated patch contains changes:

   - Enable definePlugin for development environment as well. Just adding
   definePlugin in plugins array.
   The variable process.env.NODE_ENV is useful to write conditional code in
   pgAdmin4 JS modules.

For example:

if (process.env.NODE_ENV !== 'production') {
  // Write development environment specific code
} else {
  // Write production only code.
}

Please review this patch and let me know for changes.

Thanks,
Surinder
​

On Tue, Aug 1, 2017 at 11:32 AM, Surinder Kumar <
surinder.ku...@enterprisedb.com> wrote:

> Hi Ashesh,
>
> 1. Now we are using `envType` variable in definePlugin which sets
> environment variable NODE_ENV globally which is used by React to create
> development or production build.
> where:
>  envType - determine build type is either `production` or
> `development`​ depending on the environment set in package.json > scripts.
>
> 2. In `UglifyJSPlugin`, i am setting compress > `warnings to false`,
> because here warning flag is meant to display warnings on terminal while
> creating build in production mode. so it is set to false.
>
> I didn't created an RM for #2 as it is minor change, if needed, i will
> create.
>
> ​Reference to webpack definePlugin:
> https://webpack.js.org/guides/production/#node-environment-variable​
>
> Please find updated patch with fixed review comments and review.
>
> Thanks,
> Surinder
>
> On Mon, Jul 31, 2017 at 3:31 PM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> On Fri, Jul 28, 2017 at 12:42 PM, Surinder Kumar <
>> surinder.ku...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> I inspect the react code and in call stacks, found
>>> `process.env.NODE_ENV` is undefined due to which 'SyntheticEvent.call' is
>>> not callable.
>>>
>>> So, to fix this, i add 'definePlugin' to plugins for `dev` environment
>>> in `webpack.config.js`. Initially it was added only for `production`
>>> environment. but it is needed for both, because React code is conditional
>>> based on environment variables set.
>>>
>>
>>> Please find attached patch and review.
>>>
>> As discussed, you're setting 'production', even in the 'development' mode.
>>
>> Please understand the code, and share the updated patch.
>> Also - share the references next time, so that - committer can understand
>> the reason for these changes.
>>
>> -- Thanks, Ashesh
>>
>>>
>>> Thanks,
>>> Surinder
>>>
>>
>>
>


RM_2596_v2.patch
Description: Binary data


Re: [pgAdmin4][patch] extract generate_url function from node.js and collection.js

2017-08-16 Thread Khushboo Vashi
Hi,

The patch looks good to me.

> Thanks,
Khushboo

On Fri, Aug 11, 2017 at 12:08 PM, Ashesh Vashi <
ashesh.va...@enterprisedb.com> wrote:

> On Thu, Aug 10, 2017 at 1:15 PM, Violet Cheng  wrote:
>
>> Hi hackers,
>>
>> We tried to extract and refactor generate_url function in node.js and
>> collection.js. Please see the patch attached.
>>
> Khushboo,
>
> Please review this one.
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> 
>
>
> *http://www.linkedin.com/in/asheshvashi*
> 
>
>>
>> Thanks,
>> Violet & Sarah
>>
>
>


[pgAdmin4][Patch]: RM_ 2582 - Backup : Fix compression value

2017-08-16 Thread Surinder Kumar
Hi

*Issue:*
In Backup, compression field can only accept values between 0 to 9. But if
the field is clicked, an empty value is set into the model, So, added a
check to remove the model attribute if the field is an empty string before
data is sent to the server.

Please find attached patch.

Thanks,
Surinder


RM_2582.patch
Description: Binary data


[pgAdmin4][PATCH] To fix pgAgent job step issues

2017-08-16 Thread Murtuza Zabuawala
Hi,

Please find attached patch to fix below given issues from pgAgent Jobs
Steps module.
1) 'Connection Type' cell was not honouring to 'Kind' option in Subnode
control.
2) Kind option was not saved properly
3) User was not be able to update Kind option in edit mode.
RM#2633

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]

diff --git 
a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
 
b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
index 1a9653d..0c5a523 100644
--- 
a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
+++ 
b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
@@ -1,8 +1,8 @@
 define('pgadmin.node.pga_jobstep', [
   'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
   'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'alertify', 
'backform',
-  'pgadmin.backform'
-], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform) 
{
+  'backgrid', 'pgadmin.backform', 'pgadmin.backgrid'
+], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform, 
Backgrid) {
 
   if (!pgBrowser.Nodes['coll-pga_jobstep']) {
 pgBrowser.Nodes['coll-pga_jobstep'] =
@@ -18,6 +18,40 @@ define('pgadmin.node.pga_jobstep', [
   });
   }
 
+  // Switch Cell with Deps, Needed for SubNode control
+  var SwitchDepsCell = Backgrid.Extension.SwitchCell.extend({
+initialize: function initialize() {
+  Backgrid.Extension.SwitchCell.prototype.initialize.apply(this, 
arguments);
+  Backgrid.Extension.DependentCell.prototype.initialize.apply(this, 
arguments);
+},
+dependentChanged: function dependentChanged() {
+  var model = this.model,
+  column = this.column,
+  editable = this.column.get("editable"),
+  input = this.$el.find('input[type=checkbox]').first(),
+  self_name = column.get('name'),
+  is_editable;
+
+  is_editable = _.isFunction(editable) ? !!editable.apply(column, [model]) 
: !!editable;
+  if (is_editable) {
+this.$el.addClass("editable");
+input.bootstrapSwitch('disabled', false);
+  } else {
+this.$el.removeClass("editable");
+input.bootstrapSwitch('disabled', true);
+// Set self value into model
+setTimeout(function () {
+  model.set(self_name, true);
+}, 10);
+
+  }
+
+  this.delegateEvents();
+  return this;
+},
+remove: Backgrid.Extension.DependentCell.prototype.remove
+  });
+
   if (!pgBrowser.Nodes['pga_jobstep']) {
 pgBrowser.Nodes['pga_jobstep'] = pgBrowser.Node.extend({
   parent_type: 'pga_job',
@@ -118,6 +152,11 @@ define('pgadmin.node.pga_jobstep', [
   id: 'jstconntype', label: gettext('Connection type'),
   type: 'switch', deps: ['jstkind'], mode: ['create', 'edit'],
   disabled: function(m) { return !m.get('jstkind'); },
+  cell: SwitchDepsCell,
+  editable: function(m) {
+// If jstkind is Batch then disable it
+return m.get('jstkind');
+  },
   options: {
 'onText': gettext('Local'), 'offText': gettext('Remote'),
 'onColor': 'primary', 'offColor': 'primary'
diff --git 
a/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_jobstep.macros
 
b/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_jobstep.macros
index 520d89f..45753af 100644
--- 
a/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_jobstep.macros
+++ 
b/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_jobstep.macros
@@ -14,10 +14,15 @@ INSERT INTO pgagent.pga_jobstep (
 ) {% if jid %}RETURNING jstid{% endif %};
 {%- endmacro %}
 {% macro UPDATE(has_connstr, jid, jstid, data) -%}
+{% if 'jstname' in data or 'jstenabled' in data or 'jstdesc' in data or 
'jstonerror' in data or 'jstcode' in data %}
+{% set is_colon_required = True %}
+{% else %}
+{% set is_colon_required = False %}
+{% endif %}
 -- Updating the existing step (id: {{ jstid|qtLiteral }} jobid: {{ 
jid|qtLiteral }})
 UPDATE pgagent.pga_jobstep
 SET
-{% if has_connstr %}{% if 'jstconntype' in data %}{% if data.jstconntype 
%}jstdbname={{ data.jstdbname|qtLiteral }}, jstconnstr=''{% else 
%}jstdbname='', jstconnstr={{ data.jstconnstr|qtLiteral }}{% endif %}{% if 
'jstname' in data or 'jstenabled' in data or 'jstdesc' in data or 'jstonerror' 
in data or 'jstcode' in data %},{% endif %}{% endif %}{% else %}{% if 
'jstdbname' in data %}jstdbname={{ data.jstdbname|qtLiteral }}::name{% endif 
%}{% if 'jstname' in data or 'jstenabled' in data or 'jstdesc' in data or 
'jstonerror' in data or 'jstcode' in data %},{% endif %}{% endif %}{% if 
'jstname' in data  %}
+{% if has_connstr %}{% if 'jstkind'