public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button
4+ messages / 2 participants
[nested] [flat]

* [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button
@ 2016-09-19 15:23 Surinder Kumar <[email protected]>
  2016-09-19 16:19 ` Re: [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button Dave Page <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Surinder Kumar @ 2016-09-19 15:23 UTC (permalink / raw)
  To: pgadmin-hackers; +Cc: Ashesh Vashi <[email protected]>

Hi

Please find patch with following fixes:

1) Newly added server-group not listing in tree view.

2) On creating a first node for collection node with no child. the created
node doesn't show up under its respective parent node.
- to add a node to child under its parent node. its parent node attribute
must be set 'inode: true' but it always gets false for inode that doesn't
add the node.

Ashesh - Can you please review it?

Thanks
Surinder Kumar


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


Attachments:

  [application/octet-stream] RM1627.patch (4.6K, 3-RM1627.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index 151d05b..0ac4616 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -820,6 +820,11 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
               ctx.b._findTreeChildNode(
                 ctx.i, d, ctx
               );
+
+              // Only server-group node will not have any parent
+              if (!_data._pid) {
+                addNodeWithNoParent.apply(ctx, arguments);
+              }
             }
             return true;
           }.bind(ctx),
@@ -958,7 +963,7 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
                           });
                         }.bind(ctx);

-                    if (!ctx.t.isInode(ctx.i) && ctx.d.inode) {
+                    if (!ctx.t.isInode(ctx.i) && _data && _data.inode) {
                         ctx.t.setInode(ctx.i, {success: _append});
                     } else {
                         _append();
@@ -997,6 +1002,94 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
             // We can find the collection node using _findTreeChildNode
             // indirectly.
             findChildNode(selectNode, addNode);
+          }.bind(ctx),
+          addNodeWithNoParent = function() {
+            // Append the new data in the tree at appropriate postition.
+            var ctx = this,
+                items = ctx.t.children(),
+                s = 0, e = items.length - 1, i,
+                linearSearch = function() {
+                  while (e >= s) {
+                    i = items.eq(s);
+                    d = ctx.t.itemData(i);
+                    if (d.label > _data.label)
+                      return true;
+                    s++;
+                  }
+                  if (e != items.length - 1) {
+                    i = items.eq(e);
+                    return true;
+                  }
+                  i = null;
+                  return false;
+                },
+                binarySearch = function() {
+                  var d, m;
+                  // Binary search only outperforms Linear search for n > 44.
+                  // Reference:
+                  // https://en.wikipedia.org/wiki/Binary_search_algorithm#cite_note-30
+                  //
+                  // We will try until it's half.
+                  while (e - s > 22) {
+                    i = items.eq(s);
+                    d = ctx.t.itemData(i);
+                    if (d.label > _data.label)
+                      return true;
+                    i = items.eq(e);
+                    d = ctx.t.itemData(i);
+                    if (d.label < _data.label)
+                      return true;
+                    m = Math.round((e - s) / 2);
+                    i = items.eq(e);
+                    d = ctx.t.itemData(i);
+                    if (d.label < _data.label) {
+                      s = m + 1;
+                      e--;
+                    } else {
+                      s++;
+                      e = m - 1;
+                    }
+                  }
+                  return linearSearch();
+                };
+
+            if (binarySearch()) {
+              ctx.t.before(i, {
+                itemData: _data,
+                success: function() {
+                  if (
+                    ctx.o && ctx.o.success && typeof(ctx.o.success) == 'function'
+                  ) {
+                    ctx.o.success.apply(ctx.t, [i, _data]);
+                  }
+                },
+                fail: function() {
+                  if (
+                    ctx.o && ctx.o.fail && typeof(ctx.o.fail) == 'function'
+                  ) {
+                    ctx.o.fail.apply(ctx.t, [i, _data]);
+                  }
+                }
+              });
+            } else {
+              ctx.t.append(ctx.i, {
+                itemData: _data,
+                success: function() {
+                  if (
+                    ctx.o && ctx.o.success && typeof(ctx.o.success) == 'function'
+                  ) {
+                    ctx.o.success.apply(ctx.t, [ctx.i, _old, _new]);
+                  }
+                },
+                fail: function() {
+                  if (
+                    ctx.o && ctx.o.fail && typeof(ctx.o.fail) == 'function'
+                  ) {
+                    ctx.o.fail.apply(ctx.t, [ctx.i, _old, _new]);
+                  }
+                }
+              });
+            }
           }.bind(ctx);

       if (!ctx.t.wasInit() || !_data) {


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button
  2016-09-19 15:23 [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button Surinder Kumar <[email protected]>
@ 2016-09-19 16:19 ` Dave Page <[email protected]>
  2016-09-20 09:22   ` Re: [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button Surinder Kumar <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Dave Page @ 2016-09-19 16:19 UTC (permalink / raw)
  To: Surinder Kumar <[email protected]>; +Cc: pgadmin-hackers; Ashesh Vashi <[email protected]>

Hi


On Mon, Sep 19, 2016 at 4:23 PM, Surinder Kumar
<[email protected]> wrote:
> Hi
>
> Please find patch with following fixes:
>
> 1) Newly added server-group not listing in tree view.
>
> 2) On creating a first node for collection node with no child. the created
> node doesn't show up under its respective parent node.
> - to add a node to child under its parent node. its parent node attribute
> must be set 'inode: true' but it always gets false for inode that doesn't
> add the node.
>
> Ashesh - Can you please review it?

I tested this by adding a sequence to a database and schema that
didn't previously contain any. The node was not added, and in the
Javascript console I get:

browser.js:1108 Failed to append

-- 
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 ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button
  2016-09-19 15:23 [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button Surinder Kumar <[email protected]>
  2016-09-19 16:19 ` Re: [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button Dave Page <[email protected]>
@ 2016-09-20 09:22   ` Surinder Kumar <[email protected]>
  2016-09-20 10:18     ` Re: [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button Dave Page <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Surinder Kumar @ 2016-09-20 09:22 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgadmin-hackers; Ashesh Vashi <[email protected]>

On Mon, Sep 19, 2016 at 9:49 PM, Dave Page <[email protected]> wrote:

> Hi
>
>
> On Mon, Sep 19, 2016 at 4:23 PM, Surinder Kumar
> <[email protected]> wrote:
> > Hi
> >
> > Please find patch with following fixes:
> >
> > 1) Newly added server-group not listing in tree view.
> >
> > 2) On creating a first node for collection node with no child. the
> created
> > node doesn't show up under its respective parent node.
> > - to add a node to child under its parent node. its parent node attribute
> > must be set 'inode: true' but it always gets false for inode that doesn't
> > add the node.
> >
> > Ashesh - Can you please review it?
>
> I tested this by adding a sequence to a database and schema that
> didn't previously contain any. The node was not added, and in the
> Javascript console I get:
>
> browser.js:1108 Failed to append

​This issue is taken care in updated patch, Also properly handled the case
for 'server-group' not listing in tree view, thus removing
'addNodeWithNoParent' method from previous patch.
I have tested it for most of the nodes, it works.
Please find updated patch and review.

> --
> 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 ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] RM1627_v1.patch (1.2K, 3-RM1627_v1.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index 151d05b..46c49cf 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -820,6 +820,10 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
               ctx.b._findTreeChildNode(
                 ctx.i, d, ctx
               );
+              // if parent node is null
+              if (!_data._pid) {
+                addItemNode.apply(ctx, arguments);
+              }
             }
             return true;
           }.bind(ctx),
@@ -958,9 +962,11 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
                           });
                         }.bind(ctx);

-                    if (!ctx.t.isInode(ctx.i) && ctx.d.inode) {
+                    if (ctx.i && !ctx.t.isInode(ctx.i)) {
                         ctx.t.setInode(ctx.i, {success: _append});
                     } else {
+                        // Handle case for node without parent i.e. server-group
+                        // or if parent node's inode is true.
                         _append();
                     }
                   }


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button
  2016-09-19 15:23 [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button Surinder Kumar <[email protected]>
  2016-09-19 16:19 ` Re: [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button Dave Page <[email protected]>
  2016-09-20 09:22   ` Re: [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button Surinder Kumar <[email protected]>
@ 2016-09-20 10:18     ` Dave Page <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Dave Page @ 2016-09-20 10:18 UTC (permalink / raw)
  To: Surinder Kumar <[email protected]>; +Cc: pgadmin-hackers; Ashesh Vashi <[email protected]>

On Tue, Sep 20, 2016 at 10:22 AM, Surinder Kumar
<[email protected]> wrote:
> On Mon, Sep 19, 2016 at 9:49 PM, Dave Page <[email protected]> wrote:
>>
>> Hi
>>
>>
>> On Mon, Sep 19, 2016 at 4:23 PM, Surinder Kumar
>> <[email protected]> wrote:
>> > Hi
>> >
>> > Please find patch with following fixes:
>> >
>> > 1) Newly added server-group not listing in tree view.
>> >
>> > 2) On creating a first node for collection node with no child. the
>> > created
>> > node doesn't show up under its respective parent node.
>> > - to add a node to child under its parent node. its parent node
>> > attribute
>> > must be set 'inode: true' but it always gets false for inode that
>> > doesn't
>> > add the node.
>> >
>> > Ashesh - Can you please review it?
>>
>> I tested this by adding a sequence to a database and schema that
>> didn't previously contain any. The node was not added, and in the
>> Javascript console I get:
>>
>> browser.js:1108 Failed to append
>
> This issue is taken care in updated patch, Also properly handled the case
> for 'server-group' not listing in tree view, thus removing
> 'addNodeWithNoParent' method from previous patch.
> I have tested it for most of the nodes, it works.
> Please find updated patch and review.

Works nicely - applied, thanks.

-- 
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 ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2016-09-20 10:18 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19 15:23 [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button Surinder Kumar <[email protected]>
2016-09-19 16:19 ` Dave Page <[email protected]>
2016-09-20 09:22   ` Surinder Kumar <[email protected]>
2016-09-20 10:18     ` Dave Page <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox