public inbox for [email protected]
help / color / mirror / Atom feedFrom: Surinder Kumar <[email protected]>
To: pgadmin-hackers <[email protected]>
Cc: Ashesh Vashi <[email protected]>
Subject: [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button
Date: Mon, 19 Sep 2016 20:53:52 +0530
Message-ID: <CAM5-9D-5Vf2XvBm-U7DQLQY2ZKepyaLHVTOHcAsGiW84=V5cSA@mail.gmail.com> (raw)
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
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) {
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [pgAdmin4][Patch]: RM1627 - Objects are not visible after creation until press refresh button
In-Reply-To: <CAM5-9D-5Vf2XvBm-U7DQLQY2ZKepyaLHVTOHcAsGiW84=V5cSA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox