[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' 

[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


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
>>
>
>


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] update the alert style in the sub-navigation

2017-08-16 Thread Violet Cheng
Thanks Surinder! Hope it could be committed soon :)

On Wed, Aug 16, 2017 at 1:34 PM, Surinder Kumar <
surinder.ku...@enterprisedb.com> wrote:

> Hi Violet,
>
> I have already reviewed this patch. Here is the link
> 
> .
>
> Thanks,
> Surinder
>
> On Wed, Aug 16, 2017 at 8:57 AM, Violet Cheng  wrote:
>
>> Hi,
>>
>> Any update on this patch? Could it be committed soon?
>>
>> Thanks,
>> Violet
>>
>> On Fri, Aug 11, 2017 at 1:40 PM, Sarah McAlear 
>> wrote:
>>
>>> Hi!
>>>
>>> We fixed that issue and created a new patch
>>> 
>>> .
>>>
>>> Thanks!
>>>
>>> On Thu, Aug 10, 2017 at 4:10 PM, Violet Cheng  wrote:
>>>
 Here's the Redmine link

 https://redmine.postgresql.org/issues/2644

 On Thu, Aug 10, 2017 at 4:03 PM, Violet Cheng 
 wrote:

> Hi Surinder!
>
> Are you referring to the green message popup? If so, it also appears
> to be happening on master. We'll log a bug in our backlog and Redmine and
> prioritize it. We agree that it needs to be fixed, but don't think it's
> unrelated to this patch.
>
> Thanks!
> Violet & Sarah
>
> On Thu, Aug 10, 2017 at 2:32 PM, Surinder Kumar <
> surinder.ku...@enterprisedb.com> wrote:
>
>> Please find attached screenshot.
>>
>> On Thu, Aug 10, 2017 at 11:30 AM, Surinder Kumar <
>> surinder.ku...@enterprisedb.com> wrote:
>>
>>> Hi Sarah,
>>>
>>> We noticed that due to this patch, the alert style of "Database
>>> connected" message is changed.
>>> Can you please look into this?
>>>
>>> Thanks,
>>> Surinder
>>>
>>> On Wed, Aug 9, 2017 at 4:43 PM, Surinder Kumar <
>>> surinder.ku...@enterprisedb.com> wrote:
>>>
 ​Hi,

 ​The updated patch looks good to me.

 On Wed, Aug 9, 2017 at 4:15 PM, Sarah McAlear 
 wrote:

> As discussed with Surinder, we have created a Redmine ticket for
> his 4th comment regarding the error message not showing up when the 
> app
> can't be reached. This issue existed prior to this patch and should be
> prioritized.
>
> https://redmine.postgresql.org/issues/2640
>
> Thanks!
> Matt & Sarah
>
> On Wed, Aug 9, 2017 at 4:06 PM, Sarah McAlear  > wrote:
>
>> Hi Surinder!
>>
>> I am not able to see anything different from what I see on Master
>> with or without the patch applied. I tried adjusting the 
>> preferences. I did
>> update the dashboard.js to instantiate a new object, great idea!
>>
>> Thanks,
>> Sarah
>>
>>
>>
>> On Wed, Aug 9, 2017 at 1:42 PM, Surinder Kumar <
>> surinder.ku...@enterprisedb.com> wrote:
>>
>>> Hi Wenlin,
>>>
>>> On Tue, Aug 8, 2017 at 3:15 PM, Wenlin Zhang 
>>> wrote:
>>>
 Hi Surinder,

Thanks for your review.

We have changed the indentation for _dashboard.scss file
 and also removed the style about icon-postgres:before, like
 margin-top,etc, but we are not sure if it is perfectly aligned 
 now, you can
 add further change to it.

 As the second comment, I'm sorry I'm not sure what's the
 problem, could you please clarify it? Because we replace css with 
 scss
 right now, dashboard.css doesn't exist. So maybe you are looking 
 at the css
 file that are complied by the scss?

>>> ​Sorry I​ typed 'dashboard.css' instead of 'dashboard.js'.
>>> ​In dashboard.js can we change `return DashboardAlert;` to
>>> `return new DashboardAlert();`
>>> and then we can remove the instances being created(var
>>> alertDashboard = new AlertDashboard();) from dashboard.js, and 
>>> simply
>>> use `AlertDashboard.info('message')`.
>>>
>>>
 For the fourth comment, we tried the steps you suggested on
 master branch, the error is not shown either. So it should be an 
 existing
 issue. But if you want to see the error message, navigate to 
 "Servers" at
 the top of browser, then navigate back to postgresql server, then 
 you will
 see the error message.

>>> ​The error in console will appear when you selected a database
>>>