[pgAdmin4][Patch]: Prevent adding same server multiple times if connection is slow

2017-12-25 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue where user was able to click on save button
multiple times if the connection is slow, this may result user adding the
same server multiple times unknowingly if user clicks save button multiple
times.
RM#2928


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/static/js/node.js 
b/web/pgadmin/browser/static/js/node.js
index 78a0079..83a5541 100644
--- a/web/pgadmin/browser/static/js/node.js
+++ b/web/pgadmin/browser/static/js/node.js
@@ -937,7 +937,10 @@ define(
   // Return if event is fired from child element
   if (event.target !== context) return;
   if (view && view.model && view.model.sessChanged()) {
-onSave.call(this, view);
+var btn = $(event.target).closest('.obj_properties')
+ .find('.pg-prop-btn-group')
+ .find('button.btn-primary');
+onSave.call(this, view, btn);
   }
   break;
 case keyCode.F1:
@@ -1161,20 +1164,25 @@ define(
   iframe.openURL(that.dialogHelp);
 }.bind(panel),
 
-onSave = function(view) {
+onSave = function(view, saveBtn) {
   var m = view.model,
 d = m.toJSON(true),
-
 // Generate a timer for the request
 timer = setTimeout(function(){
   $('.obj_properties').addClass('show_progress');
-}, 1000);
+}, 1000),
+saveBtn = saveBtn;
+
+  // Prevent subsequent save operation by disabling Save button
+  if(saveBtn)
+$(saveBtn).prop('disabled', true);
 
   if (d && !_.isEmpty(d)) {
 m.save({}, {
   attrs: d,
   validate: false,
   cache: false,
+  wait: true,
   success: function() {
 onSaveFunc.call();
 // Hide progress cursor
@@ -1209,6 +1217,8 @@ define(
 // Hide progress cursor
 $('.obj_properties').removeClass('show_progress');
 clearTimeout(timer);
+if(saveBtn)
+  $(saveBtn).prop('disabled', false);
   }
 });
   }
@@ -1307,7 +1317,7 @@ define(
   register: function(btn) {
 // Save the changes
 btn.click(function() {
-  onSave.call(this, view);
+  onSave.call(this, view, btn);
 });
   }
 },{


[pgAdmin4][Patch]: RM #2963 - Backup database, Restore database and Maintenance Database failed for é object.

2017-12-25 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #2963: Backup database, Restore
database and Maintenance Database failed for é object.

Thanks,
Khushboo
diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py
index 209c2a1..a5d2655 100644
--- a/web/pgadmin/misc/bgprocess/processes.py
+++ b/web/pgadmin/misc/bgprocess/processes.py
@@ -164,12 +164,13 @@ class BatchProcess(object):
 csv_writer.writerow(_args)
 
 args_val = args_csv_io.getvalue().strip(str('\r\n'))
+desc_str = dumps(self.desc)
 
 j = Process(
 pid=int(id), command=_cmd,
-arguments=args_val.decode('utf-8', 'replace') if IS_PY2 and hasattr(args_val, 'decode') \
-else args_val,
-logdir=log_dir, desc=dumps(self.desc), user_id=current_user.id
+arguments=args_val.decode('utf-8', 'replace') if IS_PY2 and hasattr(args_val, 'decode') else args_val,
+logdir=log_dir, desc=desc_str.decode('utf-8', 'replace') if IS_PY2 and hasattr(desc_str, 'decode')
+else desc_str, user_id=current_user.id
 )
 db.session.add(j)
 db.session.commit()