[PATCH] Persist opened nodes in tree

2017-07-18 Thread Versus Void
This will restore tree structure on load like in good old pgadmin3.



[PATCH] Persist opened nodes in tree

2017-07-18 Thread Versus Void
---
 web/pgadmin/browser/__init__.py|  13 +-
 .../browser/static/vendor/jStorage/jstorage.js | 996 +
 .../browser/static/vendor/jStorage/jstorage.min.js |  16 +
 .../browser/templates/browser/js/browser.js|   6 +-
 4 files changed, 1029 insertions(+), 2 deletions(-)
 create mode 100644 web/pgadmin/browser/static/vendor/jStorage/jstorage.js
 create mode 100644 web/pgadmin/browser/static/vendor/jStorage/jstorage.min.js

diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py
index 77e052f0..ecf3afba 100644
--- a/web/pgadmin/browser/__init__.py
+++ b/web/pgadmin/browser/__init__.py
@@ -100,13 +100,24 @@ class BrowserModule(PgAdminModule):
 'preloaded': True
 })
 scripts.append({
+'name': 'jStorage',
+'path': url_for(
+'browser.static',
+filename='vendor/jStorage/jstorage' if
+current_app.debug else 'vendor/jStorage/jstorage.min'
+),
+'deps': ['jquery'],
+'exports': 'jStorage',
+'preloaded': True
+})
+scripts.append({
 'name': 'jquery.acitree',
 'path': url_for(
 'browser.static',
 filename='vendor/aciTree/jquery.aciTree' if
 current_app.debug else 'vendor/aciTree/jquery.aciTree.min'
 ),
-'deps': ['jquery', 'jquery.aciplugin'],
+'deps': ['jquery', 'jquery.aciplugin', 'jStorage'],
 'exports': 'aciPluginClass.plugins.aciTree',
 'preloaded': True
 })
diff --git a/web/pgadmin/browser/static/vendor/jStorage/jstorage.js 
b/web/pgadmin/browser/static/vendor/jStorage/jstorage.js
new file mode 100644
index ..1ac8fccc
--- /dev/null
+++ b/web/pgadmin/browser/static/vendor/jStorage/jstorage.js
@@ -0,0 +1,996 @@
+/*
+ * - JSTORAGE -
+ * Simple local storage wrapper to save data on the browser side, supporting
+ * all major browsers - IE6+, Firefox2+, Safari4+, Chrome4+ and Opera 10.5+
+ *
+ * Author: Andris Reinman, andris.rein...@gmail.com
+ * Project homepage: www.jstorage.info
+ *
+ * Licensed under Unlicense:
+ *
+ * This is free and unencumbered software released into the public domain.
+ *
+ * Anyone is free to copy, modify, publish, use, compile, sell, or
+ * distribute this software, either in source code form or as a compiled
+ * binary, for any purpose, commercial or non-commercial, and by any
+ * means.
+ *
+ * In jurisdictions that recognize copyright laws, the author or authors
+ * of this software dedicate any and all copyright interest in the
+ * software to the public domain. We make this dedication for the benefit
+ * of the public at large and to the detriment of our heirs and
+ * successors. We intend this dedication to be an overt act of
+ * relinquishment in perpetuity of all present and future rights to this
+ * software under copyright law.
+ *
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For more information, please refer to 
+ */
+
+/* global ActiveXObject: false */
+/* jshint browser: true */
+
+(function() {
+'use strict';
+
+var
+/* jStorage version */
+JSTORAGE_VERSION = '0.4.12',
+
+/* detect a dollar object or create one if not found */
+$ = window.jQuery || window.$ || (window.$ = {}),
+
+/* check for a JSON handling support */
+JSON = {
+parse: window.JSON && (window.JSON.parse || window.JSON.decode) ||
+String.prototype.evalJSON && function(str) {
+return String(str).evalJSON();
+} ||
+$.parseJSON ||
+$.evalJSON,
+stringify: Object.toJSON ||
+window.JSON && (window.JSON.stringify || window.JSON.encode) ||
+$.toJSON
+};
+
+// Break if no JSON support was found
+if (typeof JSON.parse !== 'function' || typeof JSON.stringify !== 
'function') {
+throw new Error('No JSON support found, include 
//cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js to page');
+}
+
+var
+/* This is the object, that holds the cached values */
+_storage = {
+__jstorage_meta: {
+CRC32: {}
+}
+},
+
+/* Actual browser storage (localStorage or globalStorage['domain']) */
+_storage_service = {
+jStorage: '{}'
+},
+
+