public inbox for [email protected]
help / color / mirror / Atom feed[pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query
8+ messages / 2 participants
[nested] [flat]
* [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query
@ 2018-06-20 14:13 Akshay Joshi <[email protected]>
2018-06-21 00:50 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Akshay Joshi @ 2018-06-20 14:13 UTC (permalink / raw)
To: pgadmin-hackers
Hi Hackers,
Attached is the patch for Feature #3273 Add ability to sort in the Select
File window when opening a saved query.
I haven't seen any refactoring possibility, patch contains feature test
with *time.sleep(0.05). *I have spend lot of time to not introduce
"time.sleep()" and tried couple of different ways of WebDriveWait, but
didn't get success.
Please review it.
--
*Akshay Joshi*
*Sr. Software Architect *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
Attachments:
[application/octet-stream] RM_3273.patch (8.2K, 3-RM_3273.patch)
download | inline diff:
diff --git a/web/package.json b/web/package.json
index b64bbe1..a551af1 100644
--- a/web/package.json
+++ b/web/package.json
@@ -87,6 +87,7 @@
"snapsvg": "^0.5.1",
"spectrum-colorpicker": "^1.8.0",
"sprintf-js": "^1.1.1",
+ "tablesorter": "^2.30.6",
"underscore": "^1.8.3",
"underscore.string": "^3.3.4",
"watchify": "~3.9.0",
diff --git a/web/pgadmin/feature_tests/xss_checks_file_manager_test.py b/web/pgadmin/feature_tests/xss_checks_file_manager_test.py
index 60d7e91..68d702b 100644
--- a/web/pgadmin/feature_tests/xss_checks_file_manager_test.py
+++ b/web/pgadmin/feature_tests/xss_checks_file_manager_test.py
@@ -9,6 +9,7 @@
import os
import time
+import sys
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
@@ -21,7 +22,7 @@ class CheckFileManagerFeatureTest(BaseFeatureTest):
"""Tests to check file manager for XSS."""
scenarios = [
- ("Tests to check if File manager is vulnerable to XSS",
+ ("File manager feature test",
dict())
]
@@ -55,10 +56,17 @@ class CheckFileManagerFeatureTest(BaseFeatureTest):
test_utils.drop_database(connection, "acceptance_test_db")
def runTest(self):
+ print("Tests to check if File manager is vulnerable to XSS... ",
+ file=sys.stderr, end="")
self._navigate_to_query_tool()
self.page.fill_codemirror_area_with("SELECT 1;")
self._create_new_file()
self._open_file_manager_and_check_xss_file()
+ print("OK.", file=sys.stderr)
+
+ print("File manager sorting of data", file=sys.stderr)
+ self._check_file_sorting()
+ print("OK.", file=sys.stderr)
def _navigate_to_query_tool(self):
self.page.toggle_open_tree_item(self.server['name'])
@@ -124,3 +132,32 @@ class CheckFileManagerFeatureTest(BaseFeatureTest):
assert source_code.find(
string_to_find
) != -1, "{0} might be vulnerable to XSS ".format(source)
+
+ def _check_file_sorting(self):
+ self.page.find_by_id("btn-load-file").click()
+ self.wait.until(
+ EC.element_to_be_clickable((
+ By.CSS_SELECTOR,
+ "#contents th[data-column='0']")
+ )
+ )
+
+ # Added time.sleep so that the element to be clicked.
+ time.sleep(0.05)
+ self.page.find_by_css_selector("#contents th[data-column='0']").click()
+ # Check for sort Ascending
+ self.wait.until(
+ EC.presence_of_element_located((
+ By.CSS_SELECTOR,
+ "#contents th[data-column='0'].tablesorter-headerAsc")
+ )
+ )
+
+ # Click and Check for sort Descending
+ self.page.find_by_css_selector("#contents th[data-column='0']").click()
+ self.wait.until(
+ EC.presence_of_element_located((
+ By.CSS_SELECTOR,
+ "#contents th[data-column='0'].tablesorter-headerDesc")
+ )
+ )
diff --git a/web/pgadmin/misc/file_manager/static/css/file_manager.css b/web/pgadmin/misc/file_manager/static/css/file_manager.css
index 6e4ee9e..6e76795 100644
--- a/web/pgadmin/misc/file_manager/static/css/file_manager.css
+++ b/web/pgadmin/misc/file_manager/static/css/file_manager.css
@@ -233,17 +233,6 @@ div.clip {
color: #fff;
}
-.file_listing #contents.list th.tablesorter-headerAsc,
-.file_listing #contents.list th.tablesorter-headerDesc {
- background: rgb(214,212,209); /* Old browsers */
- background: -moz-linear-gradient(top, rgba(214,212,209,1) 0%, rgba(244,241,237,1) 100%); /* FF3.6+ */
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(214,212,209,1)), color-stop(100%,rgba(244,241,237,1))); /* Chrome,Safari4+ */
- background: -webkit-linear-gradient(top, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* Chrome10+,Safari5.1+ */
- background: -o-linear-gradient(top, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* Opera 11.10+ */
- background: -ms-linear-gradient(top, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* IE10+ */
- background: linear-gradient(to bottom, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* W3C */
-}
-
.file_listing #contents.list td:first-child {
display: table-cell;
padding-left: 0;
@@ -729,3 +718,43 @@ a.dz-remove {
div.change_file_types span {
padding-left:10px;
}
+
+/* overall */
+.tablesorter .header,
+.tablesorter .tablesorter-header {
+ /* black (unsorted) double arrow */
+ background-image: url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);
+ background-repeat: no-repeat;
+ background-position: center right;
+ padding: 4px 18px 4px 4px;
+ white-space: normal;
+ cursor: pointer;
+}
+
+.tablesorter .headerSortUp,
+.tablesorter .tablesorter-headerSortUp,
+.tablesorter .tablesorter-headerAsc {
+ /* black asc arrow */
+ background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);
+}
+
+.tablesorter .headerSortDown,
+.tablesorter .tablesorter-headerSortDown,
+.tablesorter .tablesorter-headerDesc {
+ /* black desc arrow */
+ background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7);
+}
+
+.tablesorter thead .sorter-false {
+ background-image: none;
+ cursor: default;
+ padding: 4px;
+}
+
+/* table processing indicator */
+.tablesorter .tablesorter-processing {
+ background-position: center center !important;
+ background-repeat: no-repeat !important;
+ background-image: url('data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=') !important;
+}
+
diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js
index ce3cd17..ef62aba 100644
--- a/web/pgadmin/misc/file_manager/static/js/utility.js
+++ b/web/pgadmin/misc/file_manager/static/js/utility.js
@@ -13,6 +13,7 @@ import loading_icon from 'acitree/image/load-root.gif';
define([
'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
'sources/gettext', 'sources/url_for', 'dropzone', 'sources/pgadmin',
+ 'tablesorter',
], function($, _, S, Alertify, gettext, url_for, Dropzone, pgAdmin) {
/*---------------------------------------------------------
@@ -574,8 +575,8 @@ define([
result += '</ul>';
} else {
- result += '<table id="contents" class="list">';
- result += '<thead><tr><th class="headerSortDown">';
+ result += '<table id="contents" class="list tablesorter">';
+ result += '<thead><tr><th>';
result += '<span>' + lg.name + '</span></th>';
result += '<th><span>' + lg.size + '</span></th><th>';
result += '<span>' + lg.modified + '</span></th></tr></thead>';
@@ -649,8 +650,8 @@ define([
if ($('.fileinfo').data('view') == 'grid') {
result += '<ul id="contents" class="grid"></ul>';
} else {
- result += '<table id="contents" class="list">';
- result += '<thead><tr><th class="headerSortDown"><span>' +
+ result += '<table id="contents" class="list tablesorter">';
+ result += '<thead><tr><th><span>' +
lg.name + '</span></th><th><span>' + lg.size +
'</span></th><th><span>' + lg.modified +
'</span></th></tr></thead>';
@@ -667,6 +668,7 @@ define([
// Add the new markup to the DOM.
$('.fileinfo .file_listing').html(result);
+ $('.fileinfo .file_listing #contents').tablesorter();
// rename file/folder
$('.file_manager button.rename').off().on('click', function(e) {
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query
2018-06-20 14:13 [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
@ 2018-06-21 00:50 ` Dave Page <[email protected]>
2018-06-21 05:27 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Dave Page @ 2018-06-21 00:50 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers
Hi
On Wed, Jun 20, 2018 at 3:13 PM, Akshay Joshi <[email protected]
> wrote:
> Hi Hackers,
>
> Attached is the patch for Feature #3273 Add ability to sort in the Select
> File window when opening a saved query.
>
> I haven't seen any refactoring possibility, patch contains feature test
> with *time.sleep(0.05). *I have spend lot of time to not introduce
> "time.sleep()" and tried couple of different ways of WebDriveWait, but
> didn't get success.
>
> Please review it.
>
I get the following running the feature tests:
invalid syntax (xss_checks_file_manager_test.py, line 60)
make: *** [check-feature] Error 1
Also; should that file be renamed now, to reflect that it tests more than
just XSS?
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query
2018-06-20 14:13 [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-21 00:50 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
@ 2018-06-21 05:27 ` Akshay Joshi <[email protected]>
2018-06-21 18:27 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Akshay Joshi @ 2018-06-21 05:27 UTC (permalink / raw)
To: Dave Page <[email protected]>; +Cc: pgadmin-hackers
On Thu, Jun 21, 2018 at 6:20 AM, Dave Page <[email protected]> wrote:
> Hi
>
> On Wed, Jun 20, 2018 at 3:13 PM, Akshay Joshi <
> [email protected]> wrote:
>
>> Hi Hackers,
>>
>> Attached is the patch for Feature #3273 Add ability to sort in the Select
>> File window when opening a saved query.
>>
>> I haven't seen any refactoring possibility, patch contains feature test
>> with *time.sleep(0.05). *I have spend lot of time to not introduce
>> "time.sleep()" and tried couple of different ways of WebDriveWait, but
>> didn't get success.
>>
>> Please review it.
>>
>
> I get the following running the feature tests:
>
> invalid syntax (xss_checks_file_manager_test.py, line 60)
>
> make: *** [check-feature] Error 1
>
> Fixed.
> Also; should that file be renamed now, to reflect that it tests more than
> just XSS?
>
Done. Attached is the modified patch.
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
--
*Akshay Joshi*
*Sr. Software Architect *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
Attachments:
[application/octet-stream] RM_3273_v2.patch (16.5K, 3-RM_3273_v2.patch)
download | inline diff:
diff --git a/web/package.json b/web/package.json
index b64bbe1..a551af1 100644
--- a/web/package.json
+++ b/web/package.json
@@ -87,6 +87,7 @@
"snapsvg": "^0.5.1",
"spectrum-colorpicker": "^1.8.0",
"sprintf-js": "^1.1.1",
+ "tablesorter": "^2.30.6",
"underscore": "^1.8.3",
"underscore.string": "^3.3.4",
"watchify": "~3.9.0",
diff --git a/web/pgadmin/feature_tests/file_manager_test.py b/web/pgadmin/feature_tests/file_manager_test.py
new file mode 100644
index 0000000..9cdce65
--- /dev/null
+++ b/web/pgadmin/feature_tests/file_manager_test.py
@@ -0,0 +1,164 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2018, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+from __future__ import print_function
+import os
+import time
+import sys
+from selenium.webdriver.common.keys import Keys
+from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions as EC
+from regression.python_test_utils import test_utils
+from regression.feature_utils.base_feature_test import BaseFeatureTest
+
+
+class CheckFileManagerFeatureTest(BaseFeatureTest):
+ """Tests to check file manager for XSS."""
+
+ scenarios = [
+ ("File manager feature test",
+ dict())
+ ]
+
+ def before(self):
+ connection = test_utils.get_db_connection(
+ self.server['db'],
+ self.server['username'],
+ self.server['db_password'],
+ self.server['host'],
+ self.server['port']
+ )
+ test_utils.drop_database(connection, "acceptance_test_db")
+ test_utils.create_database(self.server, "acceptance_test_db")
+ self.page.add_server(self.server)
+ self.wait = WebDriverWait(self.page.driver, 10)
+ self.XSS_FILE = '/tmp/<img src=x onmouseover=alert("1")>.sql'
+ # Remove any previous file
+ if os.path.isfile(self.XSS_FILE):
+ os.remove(self.XSS_FILE)
+
+ def after(self):
+ self.page.close_query_tool('sql', False)
+ self.page.remove_server(self.server)
+ connection = test_utils.get_db_connection(
+ self.server['db'],
+ self.server['username'],
+ self.server['db_password'],
+ self.server['host'],
+ self.server['port']
+ )
+ test_utils.drop_database(connection, "acceptance_test_db")
+
+ def runTest(self):
+ print("Tests to check if File manager is vulnerable to XSS... ",
+ file=sys.stderr, end="")
+ self._navigate_to_query_tool()
+ self.page.fill_codemirror_area_with("SELECT 1;")
+ self._create_new_file()
+ self._open_file_manager_and_check_xss_file()
+ print("OK.", file=sys.stderr)
+
+ print("File manager sorting of data", file=sys.stderr)
+ self._check_file_sorting()
+ print("OK.", file=sys.stderr)
+
+ def _navigate_to_query_tool(self):
+ self.page.toggle_open_tree_item(self.server['name'])
+ self.page.toggle_open_tree_item('Databases')
+ self.page.toggle_open_tree_item('acceptance_test_db')
+ self.page.open_query_tool()
+
+ def _create_new_file(self):
+ self.page.find_by_id("btn-save").click()
+ self.page.wait_for_query_tool_loading_indicator_to_disappear()
+ self.wait.until(EC.presence_of_element_located(
+ (
+ By.XPATH,
+ "//*[contains(string(), 'Show hidden files and folders? ')]"
+ )
+ ))
+ # Set the XSS value in input
+ self.page.find_by_id("file-input-path").clear()
+ self.page.find_by_id("file-input-path").send_keys(
+ self.XSS_FILE
+ )
+ # Save the file
+ self.page.click_modal('Save')
+ self.page.wait_for_query_tool_loading_indicator_to_disappear()
+
+ def _open_file_manager_and_check_xss_file(self):
+ self.page.find_by_id("btn-load-file").click()
+ self.wait.until(EC.presence_of_element_located(
+ (
+ By.XPATH,
+ "//*[contains(string(), 'Show hidden files and folders? ')]"
+ )
+ ))
+ self.page.find_by_id("file-input-path").clear()
+ self.page.find_by_id("file-input-path").send_keys(
+ '/tmp/'
+ )
+ self.page.find_by_id("file-input-path").send_keys(
+ Keys.RETURN
+ )
+
+ if self.page.driver.capabilities['browserName'] == 'firefox':
+ table = self.page.wait_for_element_to_reload(
+ lambda driver:
+ driver.find_element_by_css_selector("table#contents")
+ )
+ else:
+ table = self.page.driver \
+ .find_element_by_css_selector("table#contents")
+
+ contents = table.get_attribute('innerHTML')
+
+ self.page.click_modal('Cancel')
+ self.page.wait_for_query_tool_loading_indicator_to_disappear()
+ self._check_escaped_characters(
+ contents,
+ '<img src=x onmouseover=alert("1")>.sql',
+ 'File manager'
+ )
+
+ def _check_escaped_characters(self, source_code, string_to_find, source):
+ # For XSS we need to search against element's html code
+ assert source_code.find(
+ string_to_find
+ ) != -1, "{0} might be vulnerable to XSS ".format(source)
+
+ def _check_file_sorting(self):
+ self.page.find_by_id("btn-load-file").click()
+ self.wait.until(
+ EC.element_to_be_clickable((
+ By.CSS_SELECTOR,
+ "#contents th[data-column='0']")
+ )
+ )
+
+ # Added time.sleep so that the element to be clicked.
+ time.sleep(0.05)
+ self.page.find_by_css_selector("#contents th[data-column='0']").click()
+ # Check for sort Ascending
+ self.wait.until(
+ EC.presence_of_element_located((
+ By.CSS_SELECTOR,
+ "#contents th[data-column='0'].tablesorter-headerAsc")
+ )
+ )
+
+ # Click and Check for sort Descending
+ self.page.find_by_css_selector("#contents th[data-column='0']").click()
+ self.wait.until(
+ EC.presence_of_element_located((
+ By.CSS_SELECTOR,
+ "#contents th[data-column='0'].tablesorter-headerDesc")
+ )
+ )
diff --git a/web/pgadmin/feature_tests/xss_checks_file_manager_test.py b/web/pgadmin/feature_tests/xss_checks_file_manager_test.py
deleted file mode 100644
index 60d7e91..0000000
--- a/web/pgadmin/feature_tests/xss_checks_file_manager_test.py
+++ /dev/null
@@ -1,126 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2018, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import time
-from selenium.webdriver.common.keys import Keys
-from selenium.webdriver.support.ui import WebDriverWait
-from selenium.webdriver.common.by import By
-from selenium.webdriver.support import expected_conditions as EC
-from regression.python_test_utils import test_utils
-from regression.feature_utils.base_feature_test import BaseFeatureTest
-
-
-class CheckFileManagerFeatureTest(BaseFeatureTest):
- """Tests to check file manager for XSS."""
-
- scenarios = [
- ("Tests to check if File manager is vulnerable to XSS",
- dict())
- ]
-
- def before(self):
- connection = test_utils.get_db_connection(
- self.server['db'],
- self.server['username'],
- self.server['db_password'],
- self.server['host'],
- self.server['port']
- )
- test_utils.drop_database(connection, "acceptance_test_db")
- test_utils.create_database(self.server, "acceptance_test_db")
- self.page.add_server(self.server)
- self.wait = WebDriverWait(self.page.driver, 10)
- self.XSS_FILE = '/tmp/<img src=x onmouseover=alert("1")>.sql'
- # Remove any previous file
- if os.path.isfile(self.XSS_FILE):
- os.remove(self.XSS_FILE)
-
- def after(self):
- self.page.close_query_tool('sql', False)
- self.page.remove_server(self.server)
- connection = test_utils.get_db_connection(
- self.server['db'],
- self.server['username'],
- self.server['db_password'],
- self.server['host'],
- self.server['port']
- )
- test_utils.drop_database(connection, "acceptance_test_db")
-
- def runTest(self):
- self._navigate_to_query_tool()
- self.page.fill_codemirror_area_with("SELECT 1;")
- self._create_new_file()
- self._open_file_manager_and_check_xss_file()
-
- def _navigate_to_query_tool(self):
- self.page.toggle_open_tree_item(self.server['name'])
- self.page.toggle_open_tree_item('Databases')
- self.page.toggle_open_tree_item('acceptance_test_db')
- self.page.open_query_tool()
-
- def _create_new_file(self):
- self.page.find_by_id("btn-save").click()
- self.page.wait_for_query_tool_loading_indicator_to_disappear()
- self.wait.until(EC.presence_of_element_located(
- (
- By.XPATH,
- "//*[contains(string(), 'Show hidden files and folders? ')]"
- )
- ))
- # Set the XSS value in input
- self.page.find_by_id("file-input-path").clear()
- self.page.find_by_id("file-input-path").send_keys(
- self.XSS_FILE
- )
- # Save the file
- self.page.click_modal('Save')
- self.page.wait_for_query_tool_loading_indicator_to_disappear()
-
- def _open_file_manager_and_check_xss_file(self):
- self.page.find_by_id("btn-load-file").click()
- self.wait.until(EC.presence_of_element_located(
- (
- By.XPATH,
- "//*[contains(string(), 'Show hidden files and folders? ')]"
- )
- ))
- self.page.find_by_id("file-input-path").clear()
- self.page.find_by_id("file-input-path").send_keys(
- '/tmp/'
- )
- self.page.find_by_id("file-input-path").send_keys(
- Keys.RETURN
- )
-
- if self.page.driver.capabilities['browserName'] == 'firefox':
- table = self.page.wait_for_element_to_reload(
- lambda driver:
- driver.find_element_by_css_selector("table#contents")
- )
- else:
- table = self.page.driver \
- .find_element_by_css_selector("table#contents")
-
- contents = table.get_attribute('innerHTML')
-
- self.page.click_modal('Cancel')
- self.page.wait_for_query_tool_loading_indicator_to_disappear()
- self._check_escaped_characters(
- contents,
- '<img src=x onmouseover=alert("1")>.sql',
- 'File manager'
- )
-
- def _check_escaped_characters(self, source_code, string_to_find, source):
- # For XSS we need to search against element's html code
- assert source_code.find(
- string_to_find
- ) != -1, "{0} might be vulnerable to XSS ".format(source)
diff --git a/web/pgadmin/misc/file_manager/static/css/file_manager.css b/web/pgadmin/misc/file_manager/static/css/file_manager.css
index 6e4ee9e..6e76795 100644
--- a/web/pgadmin/misc/file_manager/static/css/file_manager.css
+++ b/web/pgadmin/misc/file_manager/static/css/file_manager.css
@@ -233,17 +233,6 @@ div.clip {
color: #fff;
}
-.file_listing #contents.list th.tablesorter-headerAsc,
-.file_listing #contents.list th.tablesorter-headerDesc {
- background: rgb(214,212,209); /* Old browsers */
- background: -moz-linear-gradient(top, rgba(214,212,209,1) 0%, rgba(244,241,237,1) 100%); /* FF3.6+ */
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(214,212,209,1)), color-stop(100%,rgba(244,241,237,1))); /* Chrome,Safari4+ */
- background: -webkit-linear-gradient(top, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* Chrome10+,Safari5.1+ */
- background: -o-linear-gradient(top, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* Opera 11.10+ */
- background: -ms-linear-gradient(top, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* IE10+ */
- background: linear-gradient(to bottom, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* W3C */
-}
-
.file_listing #contents.list td:first-child {
display: table-cell;
padding-left: 0;
@@ -729,3 +718,43 @@ a.dz-remove {
div.change_file_types span {
padding-left:10px;
}
+
+/* overall */
+.tablesorter .header,
+.tablesorter .tablesorter-header {
+ /* black (unsorted) double arrow */
+ background-image: url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);
+ background-repeat: no-repeat;
+ background-position: center right;
+ padding: 4px 18px 4px 4px;
+ white-space: normal;
+ cursor: pointer;
+}
+
+.tablesorter .headerSortUp,
+.tablesorter .tablesorter-headerSortUp,
+.tablesorter .tablesorter-headerAsc {
+ /* black asc arrow */
+ background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);
+}
+
+.tablesorter .headerSortDown,
+.tablesorter .tablesorter-headerSortDown,
+.tablesorter .tablesorter-headerDesc {
+ /* black desc arrow */
+ background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7);
+}
+
+.tablesorter thead .sorter-false {
+ background-image: none;
+ cursor: default;
+ padding: 4px;
+}
+
+/* table processing indicator */
+.tablesorter .tablesorter-processing {
+ background-position: center center !important;
+ background-repeat: no-repeat !important;
+ background-image: url('data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=') !important;
+}
+
diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js
index ce3cd17..ef62aba 100644
--- a/web/pgadmin/misc/file_manager/static/js/utility.js
+++ b/web/pgadmin/misc/file_manager/static/js/utility.js
@@ -13,6 +13,7 @@ import loading_icon from 'acitree/image/load-root.gif';
define([
'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
'sources/gettext', 'sources/url_for', 'dropzone', 'sources/pgadmin',
+ 'tablesorter',
], function($, _, S, Alertify, gettext, url_for, Dropzone, pgAdmin) {
/*---------------------------------------------------------
@@ -574,8 +575,8 @@ define([
result += '</ul>';
} else {
- result += '<table id="contents" class="list">';
- result += '<thead><tr><th class="headerSortDown">';
+ result += '<table id="contents" class="list tablesorter">';
+ result += '<thead><tr><th>';
result += '<span>' + lg.name + '</span></th>';
result += '<th><span>' + lg.size + '</span></th><th>';
result += '<span>' + lg.modified + '</span></th></tr></thead>';
@@ -649,8 +650,8 @@ define([
if ($('.fileinfo').data('view') == 'grid') {
result += '<ul id="contents" class="grid"></ul>';
} else {
- result += '<table id="contents" class="list">';
- result += '<thead><tr><th class="headerSortDown"><span>' +
+ result += '<table id="contents" class="list tablesorter">';
+ result += '<thead><tr><th><span>' +
lg.name + '</span></th><th><span>' + lg.size +
'</span></th><th><span>' + lg.modified +
'</span></th></tr></thead>';
@@ -667,6 +668,7 @@ define([
// Add the new markup to the DOM.
$('.fileinfo .file_listing').html(result);
+ $('.fileinfo .file_listing #contents').tablesorter();
// rename file/folder
$('.file_manager button.rename').off().on('click', function(e) {
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query
2018-06-20 14:13 [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-21 00:50 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
2018-06-21 05:27 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
@ 2018-06-21 18:27 ` Dave Page <[email protected]>
2018-06-22 05:39 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Dave Page @ 2018-06-21 18:27 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers
Hi
On Thu, Jun 21, 2018 at 6:27 AM, Akshay Joshi <[email protected]
> wrote:
>
>
> On Thu, Jun 21, 2018 at 6:20 AM, Dave Page <[email protected]> wrote:
>
>> Hi
>>
>> On Wed, Jun 20, 2018 at 3:13 PM, Akshay Joshi <
>> [email protected]> wrote:
>>
>>> Hi Hackers,
>>>
>>> Attached is the patch for Feature #3273 Add ability to sort in the
>>> Select File window when opening a saved query.
>>>
>>> I haven't seen any refactoring possibility, patch contains feature test
>>> with *time.sleep(0.05). *I have spend lot of time to not introduce
>>> "time.sleep()" and tried couple of different ways of WebDriveWait, but
>>> didn't get success.
>>>
>>> Please review it.
>>>
>>
>> I get the following running the feature tests:
>>
>> invalid syntax (xss_checks_file_manager_test.py, line 60)
>>
>> make: *** [check-feature] Error 1
>>
>> Fixed.
>
>
>> Also; should that file be renamed now, to reflect that it tests more than
>> just XSS?
>>
>
> Done. Attached is the modified patch.
>
This seems to work for the most part, however, when sorting on the Modified
column, it is sorting alphabetically, not by date. This doesn't seem like
it's what users would expect.
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query
2018-06-20 14:13 [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-21 00:50 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
2018-06-21 05:27 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-21 18:27 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
@ 2018-06-22 05:39 ` Akshay Joshi <[email protected]>
2018-06-25 11:13 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Akshay Joshi @ 2018-06-22 05:39 UTC (permalink / raw)
To: Dave Page <[email protected]>; +Cc: pgadmin-hackers
On Thu, Jun 21, 2018 at 11:57 PM, Dave Page <[email protected]> wrote:
> Hi
>
> On Thu, Jun 21, 2018 at 6:27 AM, Akshay Joshi <
> [email protected]> wrote:
>
>>
>>
>> On Thu, Jun 21, 2018 at 6:20 AM, Dave Page <[email protected]> wrote:
>>
>>> Hi
>>>
>>> On Wed, Jun 20, 2018 at 3:13 PM, Akshay Joshi <
>>> [email protected]> wrote:
>>>
>>>> Hi Hackers,
>>>>
>>>> Attached is the patch for Feature #3273 Add ability to sort in the
>>>> Select File window when opening a saved query.
>>>>
>>>> I haven't seen any refactoring possibility, patch contains feature test
>>>> with *time.sleep(0.05). *I have spend lot of time to not introduce
>>>> "time.sleep()" and tried couple of different ways of WebDriveWait, but
>>>> didn't get success.
>>>>
>>>> Please review it.
>>>>
>>>
>>> I get the following running the feature tests:
>>>
>>> invalid syntax (xss_checks_file_manager_test.py, line 60)
>>>
>>> make: *** [check-feature] Error 1
>>>
>>> Fixed.
>>
>>
>>> Also; should that file be renamed now, to reflect that it tests more
>>> than just XSS?
>>>
>>
>> Done. Attached is the modified patch.
>>
>
> This seems to work for the most part, however, when sorting on the
> Modified column, it is sorting alphabetically, not by date. This doesn't
> seem like it's what users would expect.
>
Attached is the modified patch with the above fix.
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
--
*Akshay Joshi*
*Sr. Software Architect *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
Attachments:
[application/octet-stream] RM_3273_v3.patch (16.6K, 3-RM_3273_v3.patch)
download | inline diff:
diff --git a/web/package.json b/web/package.json
index b64bbe1..a551af1 100644
--- a/web/package.json
+++ b/web/package.json
@@ -87,6 +87,7 @@
"snapsvg": "^0.5.1",
"spectrum-colorpicker": "^1.8.0",
"sprintf-js": "^1.1.1",
+ "tablesorter": "^2.30.6",
"underscore": "^1.8.3",
"underscore.string": "^3.3.4",
"watchify": "~3.9.0",
diff --git a/web/pgadmin/feature_tests/file_manager_test.py b/web/pgadmin/feature_tests/file_manager_test.py
new file mode 100644
index 0000000..9cdce65
--- /dev/null
+++ b/web/pgadmin/feature_tests/file_manager_test.py
@@ -0,0 +1,164 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2018, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+from __future__ import print_function
+import os
+import time
+import sys
+from selenium.webdriver.common.keys import Keys
+from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions as EC
+from regression.python_test_utils import test_utils
+from regression.feature_utils.base_feature_test import BaseFeatureTest
+
+
+class CheckFileManagerFeatureTest(BaseFeatureTest):
+ """Tests to check file manager for XSS."""
+
+ scenarios = [
+ ("File manager feature test",
+ dict())
+ ]
+
+ def before(self):
+ connection = test_utils.get_db_connection(
+ self.server['db'],
+ self.server['username'],
+ self.server['db_password'],
+ self.server['host'],
+ self.server['port']
+ )
+ test_utils.drop_database(connection, "acceptance_test_db")
+ test_utils.create_database(self.server, "acceptance_test_db")
+ self.page.add_server(self.server)
+ self.wait = WebDriverWait(self.page.driver, 10)
+ self.XSS_FILE = '/tmp/<img src=x onmouseover=alert("1")>.sql'
+ # Remove any previous file
+ if os.path.isfile(self.XSS_FILE):
+ os.remove(self.XSS_FILE)
+
+ def after(self):
+ self.page.close_query_tool('sql', False)
+ self.page.remove_server(self.server)
+ connection = test_utils.get_db_connection(
+ self.server['db'],
+ self.server['username'],
+ self.server['db_password'],
+ self.server['host'],
+ self.server['port']
+ )
+ test_utils.drop_database(connection, "acceptance_test_db")
+
+ def runTest(self):
+ print("Tests to check if File manager is vulnerable to XSS... ",
+ file=sys.stderr, end="")
+ self._navigate_to_query_tool()
+ self.page.fill_codemirror_area_with("SELECT 1;")
+ self._create_new_file()
+ self._open_file_manager_and_check_xss_file()
+ print("OK.", file=sys.stderr)
+
+ print("File manager sorting of data", file=sys.stderr)
+ self._check_file_sorting()
+ print("OK.", file=sys.stderr)
+
+ def _navigate_to_query_tool(self):
+ self.page.toggle_open_tree_item(self.server['name'])
+ self.page.toggle_open_tree_item('Databases')
+ self.page.toggle_open_tree_item('acceptance_test_db')
+ self.page.open_query_tool()
+
+ def _create_new_file(self):
+ self.page.find_by_id("btn-save").click()
+ self.page.wait_for_query_tool_loading_indicator_to_disappear()
+ self.wait.until(EC.presence_of_element_located(
+ (
+ By.XPATH,
+ "//*[contains(string(), 'Show hidden files and folders? ')]"
+ )
+ ))
+ # Set the XSS value in input
+ self.page.find_by_id("file-input-path").clear()
+ self.page.find_by_id("file-input-path").send_keys(
+ self.XSS_FILE
+ )
+ # Save the file
+ self.page.click_modal('Save')
+ self.page.wait_for_query_tool_loading_indicator_to_disappear()
+
+ def _open_file_manager_and_check_xss_file(self):
+ self.page.find_by_id("btn-load-file").click()
+ self.wait.until(EC.presence_of_element_located(
+ (
+ By.XPATH,
+ "//*[contains(string(), 'Show hidden files and folders? ')]"
+ )
+ ))
+ self.page.find_by_id("file-input-path").clear()
+ self.page.find_by_id("file-input-path").send_keys(
+ '/tmp/'
+ )
+ self.page.find_by_id("file-input-path").send_keys(
+ Keys.RETURN
+ )
+
+ if self.page.driver.capabilities['browserName'] == 'firefox':
+ table = self.page.wait_for_element_to_reload(
+ lambda driver:
+ driver.find_element_by_css_selector("table#contents")
+ )
+ else:
+ table = self.page.driver \
+ .find_element_by_css_selector("table#contents")
+
+ contents = table.get_attribute('innerHTML')
+
+ self.page.click_modal('Cancel')
+ self.page.wait_for_query_tool_loading_indicator_to_disappear()
+ self._check_escaped_characters(
+ contents,
+ '<img src=x onmouseover=alert("1")>.sql',
+ 'File manager'
+ )
+
+ def _check_escaped_characters(self, source_code, string_to_find, source):
+ # For XSS we need to search against element's html code
+ assert source_code.find(
+ string_to_find
+ ) != -1, "{0} might be vulnerable to XSS ".format(source)
+
+ def _check_file_sorting(self):
+ self.page.find_by_id("btn-load-file").click()
+ self.wait.until(
+ EC.element_to_be_clickable((
+ By.CSS_SELECTOR,
+ "#contents th[data-column='0']")
+ )
+ )
+
+ # Added time.sleep so that the element to be clicked.
+ time.sleep(0.05)
+ self.page.find_by_css_selector("#contents th[data-column='0']").click()
+ # Check for sort Ascending
+ self.wait.until(
+ EC.presence_of_element_located((
+ By.CSS_SELECTOR,
+ "#contents th[data-column='0'].tablesorter-headerAsc")
+ )
+ )
+
+ # Click and Check for sort Descending
+ self.page.find_by_css_selector("#contents th[data-column='0']").click()
+ self.wait.until(
+ EC.presence_of_element_located((
+ By.CSS_SELECTOR,
+ "#contents th[data-column='0'].tablesorter-headerDesc")
+ )
+ )
diff --git a/web/pgadmin/feature_tests/xss_checks_file_manager_test.py b/web/pgadmin/feature_tests/xss_checks_file_manager_test.py
deleted file mode 100644
index 60d7e91..0000000
--- a/web/pgadmin/feature_tests/xss_checks_file_manager_test.py
+++ /dev/null
@@ -1,126 +0,0 @@
-##########################################################################
-#
-# pgAdmin 4 - PostgreSQL Tools
-#
-# Copyright (C) 2013 - 2018, The pgAdmin Development Team
-# This software is released under the PostgreSQL Licence
-#
-##########################################################################
-
-import os
-import time
-from selenium.webdriver.common.keys import Keys
-from selenium.webdriver.support.ui import WebDriverWait
-from selenium.webdriver.common.by import By
-from selenium.webdriver.support import expected_conditions as EC
-from regression.python_test_utils import test_utils
-from regression.feature_utils.base_feature_test import BaseFeatureTest
-
-
-class CheckFileManagerFeatureTest(BaseFeatureTest):
- """Tests to check file manager for XSS."""
-
- scenarios = [
- ("Tests to check if File manager is vulnerable to XSS",
- dict())
- ]
-
- def before(self):
- connection = test_utils.get_db_connection(
- self.server['db'],
- self.server['username'],
- self.server['db_password'],
- self.server['host'],
- self.server['port']
- )
- test_utils.drop_database(connection, "acceptance_test_db")
- test_utils.create_database(self.server, "acceptance_test_db")
- self.page.add_server(self.server)
- self.wait = WebDriverWait(self.page.driver, 10)
- self.XSS_FILE = '/tmp/<img src=x onmouseover=alert("1")>.sql'
- # Remove any previous file
- if os.path.isfile(self.XSS_FILE):
- os.remove(self.XSS_FILE)
-
- def after(self):
- self.page.close_query_tool('sql', False)
- self.page.remove_server(self.server)
- connection = test_utils.get_db_connection(
- self.server['db'],
- self.server['username'],
- self.server['db_password'],
- self.server['host'],
- self.server['port']
- )
- test_utils.drop_database(connection, "acceptance_test_db")
-
- def runTest(self):
- self._navigate_to_query_tool()
- self.page.fill_codemirror_area_with("SELECT 1;")
- self._create_new_file()
- self._open_file_manager_and_check_xss_file()
-
- def _navigate_to_query_tool(self):
- self.page.toggle_open_tree_item(self.server['name'])
- self.page.toggle_open_tree_item('Databases')
- self.page.toggle_open_tree_item('acceptance_test_db')
- self.page.open_query_tool()
-
- def _create_new_file(self):
- self.page.find_by_id("btn-save").click()
- self.page.wait_for_query_tool_loading_indicator_to_disappear()
- self.wait.until(EC.presence_of_element_located(
- (
- By.XPATH,
- "//*[contains(string(), 'Show hidden files and folders? ')]"
- )
- ))
- # Set the XSS value in input
- self.page.find_by_id("file-input-path").clear()
- self.page.find_by_id("file-input-path").send_keys(
- self.XSS_FILE
- )
- # Save the file
- self.page.click_modal('Save')
- self.page.wait_for_query_tool_loading_indicator_to_disappear()
-
- def _open_file_manager_and_check_xss_file(self):
- self.page.find_by_id("btn-load-file").click()
- self.wait.until(EC.presence_of_element_located(
- (
- By.XPATH,
- "//*[contains(string(), 'Show hidden files and folders? ')]"
- )
- ))
- self.page.find_by_id("file-input-path").clear()
- self.page.find_by_id("file-input-path").send_keys(
- '/tmp/'
- )
- self.page.find_by_id("file-input-path").send_keys(
- Keys.RETURN
- )
-
- if self.page.driver.capabilities['browserName'] == 'firefox':
- table = self.page.wait_for_element_to_reload(
- lambda driver:
- driver.find_element_by_css_selector("table#contents")
- )
- else:
- table = self.page.driver \
- .find_element_by_css_selector("table#contents")
-
- contents = table.get_attribute('innerHTML')
-
- self.page.click_modal('Cancel')
- self.page.wait_for_query_tool_loading_indicator_to_disappear()
- self._check_escaped_characters(
- contents,
- '<img src=x onmouseover=alert("1")>.sql',
- 'File manager'
- )
-
- def _check_escaped_characters(self, source_code, string_to_find, source):
- # For XSS we need to search against element's html code
- assert source_code.find(
- string_to_find
- ) != -1, "{0} might be vulnerable to XSS ".format(source)
diff --git a/web/pgadmin/misc/file_manager/static/css/file_manager.css b/web/pgadmin/misc/file_manager/static/css/file_manager.css
index 6e4ee9e..6e76795 100644
--- a/web/pgadmin/misc/file_manager/static/css/file_manager.css
+++ b/web/pgadmin/misc/file_manager/static/css/file_manager.css
@@ -233,17 +233,6 @@ div.clip {
color: #fff;
}
-.file_listing #contents.list th.tablesorter-headerAsc,
-.file_listing #contents.list th.tablesorter-headerDesc {
- background: rgb(214,212,209); /* Old browsers */
- background: -moz-linear-gradient(top, rgba(214,212,209,1) 0%, rgba(244,241,237,1) 100%); /* FF3.6+ */
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(214,212,209,1)), color-stop(100%,rgba(244,241,237,1))); /* Chrome,Safari4+ */
- background: -webkit-linear-gradient(top, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* Chrome10+,Safari5.1+ */
- background: -o-linear-gradient(top, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* Opera 11.10+ */
- background: -ms-linear-gradient(top, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* IE10+ */
- background: linear-gradient(to bottom, rgba(214,212,209,1) 0%,rgba(244,241,237,1) 100%); /* W3C */
-}
-
.file_listing #contents.list td:first-child {
display: table-cell;
padding-left: 0;
@@ -729,3 +718,43 @@ a.dz-remove {
div.change_file_types span {
padding-left:10px;
}
+
+/* overall */
+.tablesorter .header,
+.tablesorter .tablesorter-header {
+ /* black (unsorted) double arrow */
+ background-image: url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);
+ background-repeat: no-repeat;
+ background-position: center right;
+ padding: 4px 18px 4px 4px;
+ white-space: normal;
+ cursor: pointer;
+}
+
+.tablesorter .headerSortUp,
+.tablesorter .tablesorter-headerSortUp,
+.tablesorter .tablesorter-headerAsc {
+ /* black asc arrow */
+ background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);
+}
+
+.tablesorter .headerSortDown,
+.tablesorter .tablesorter-headerSortDown,
+.tablesorter .tablesorter-headerDesc {
+ /* black desc arrow */
+ background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7);
+}
+
+.tablesorter thead .sorter-false {
+ background-image: none;
+ cursor: default;
+ padding: 4px;
+}
+
+/* table processing indicator */
+.tablesorter .tablesorter-processing {
+ background-position: center center !important;
+ background-repeat: no-repeat !important;
+ background-image: url('data:image/gif;base64,R0lGODlhFAAUAKEAAO7u7lpaWgAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQBCgACACwAAAAAFAAUAAACQZRvoIDtu1wLQUAlqKTVxqwhXIiBnDg6Y4eyx4lKW5XK7wrLeK3vbq8J2W4T4e1nMhpWrZCTt3xKZ8kgsggdJmUFACH5BAEKAAIALAcAAAALAAcAAAIUVB6ii7jajgCAuUmtovxtXnmdUAAAIfkEAQoAAgAsDQACAAcACwAAAhRUIpmHy/3gUVQAQO9NetuugCFWAAAh+QQBCgACACwNAAcABwALAAACE5QVcZjKbVo6ck2AF95m5/6BSwEAIfkEAQoAAgAsBwANAAsABwAAAhOUH3kr6QaAcSrGWe1VQl+mMUIBACH5BAEKAAIALAIADQALAAcAAAIUlICmh7ncTAgqijkruDiv7n2YUAAAIfkEAQoAAgAsAAAHAAcACwAAAhQUIGmHyedehIoqFXLKfPOAaZdWAAAh+QQFCgACACwAAAIABwALAAACFJQFcJiXb15zLYRl7cla8OtlGGgUADs=') !important;
+}
+
diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js
index ce3cd17..e5dac84 100644
--- a/web/pgadmin/misc/file_manager/static/js/utility.js
+++ b/web/pgadmin/misc/file_manager/static/js/utility.js
@@ -13,6 +13,7 @@ import loading_icon from 'acitree/image/load-root.gif';
define([
'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
'sources/gettext', 'sources/url_for', 'dropzone', 'sources/pgadmin',
+ 'tablesorter',
], function($, _, S, Alertify, gettext, url_for, Dropzone, pgAdmin) {
/*---------------------------------------------------------
@@ -574,8 +575,8 @@ define([
result += '</ul>';
} else {
- result += '<table id="contents" class="list">';
- result += '<thead><tr><th class="headerSortDown">';
+ result += '<table id="contents" class="list tablesorter">';
+ result += '<thead><tr><th>';
result += '<span>' + lg.name + '</span></th>';
result += '<th><span>' + lg.size + '</span></th><th>';
result += '<span>' + lg.modified + '</span></th></tr></thead>';
@@ -649,8 +650,8 @@ define([
if ($('.fileinfo').data('view') == 'grid') {
result += '<ul id="contents" class="grid"></ul>';
} else {
- result += '<table id="contents" class="list">';
- result += '<thead><tr><th class="headerSortDown"><span>' +
+ result += '<table id="contents" class="list tablesorter">';
+ result += '<thead><tr><th><span>' +
lg.name + '</span></th><th><span>' + lg.size +
'</span></th><th><span>' + lg.modified +
'</span></th></tr></thead>';
@@ -667,6 +668,13 @@ define([
// Add the new markup to the DOM.
$('.fileinfo .file_listing').html(result);
+ $('.fileinfo .file_listing #contents').tablesorter({
+ headers: {
+ 2: {
+ sorter: 'shortDate',
+ },
+ },
+ });
// rename file/folder
$('.file_manager button.rename').off().on('click', function(e) {
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query
2018-06-20 14:13 [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-21 00:50 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
2018-06-21 05:27 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-21 18:27 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
2018-06-22 05:39 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
@ 2018-06-25 11:13 ` Dave Page <[email protected]>
2018-06-25 11:23 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Dave Page @ 2018-06-25 11:13 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers
Hi
On Fri, Jun 22, 2018 at 6:39 AM, Akshay Joshi <[email protected]
> wrote:
>
>
> On Thu, Jun 21, 2018 at 11:57 PM, Dave Page <[email protected]> wrote:
>
>> Hi
>>
>> On Thu, Jun 21, 2018 at 6:27 AM, Akshay Joshi <
>> [email protected]> wrote:
>>
>>>
>>>
>>> On Thu, Jun 21, 2018 at 6:20 AM, Dave Page <[email protected]> wrote:
>>>
>>>> Hi
>>>>
>>>> On Wed, Jun 20, 2018 at 3:13 PM, Akshay Joshi <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi Hackers,
>>>>>
>>>>> Attached is the patch for Feature #3273 Add ability to sort in the
>>>>> Select File window when opening a saved query.
>>>>>
>>>>> I haven't seen any refactoring possibility, patch contains feature
>>>>> test with *time.sleep(0.05). *I have spend lot of time to not
>>>>> introduce "time.sleep()" and tried couple of different ways of
>>>>> WebDriveWait, but didn't get success.
>>>>>
>>>>> Please review it.
>>>>>
>>>>
>>>> I get the following running the feature tests:
>>>>
>>>> invalid syntax (xss_checks_file_manager_test.py, line 60)
>>>>
>>>> make: *** [check-feature] Error 1
>>>>
>>>> Fixed.
>>>
>>>
>>>> Also; should that file be renamed now, to reflect that it tests more
>>>> than just XSS?
>>>>
>>>
>>> Done. Attached is the modified patch.
>>>
>>
>> This seems to work for the most part, however, when sorting on the
>> Modified column, it is sorting alphabetically, not by date. This doesn't
>> seem like it's what users would expect.
>>
>
> Attached is the modified patch with the above fix.
>
>>
I'm seeing the following failure pretty consistently:
======================================================================
ERROR: runTest
(pgadmin.feature_tests.file_manager_test.CheckFileManagerFeatureTest)
File manager feature test
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/dpage/git/pgadmin4/web/regression/feature_utils/base_feature_test.py",
line 66, in tearDown
self.after()
File
"/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/file_manager_test.py",
line 48, in after
self.page.close_query_tool('sql', False)
File
"/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
line 104, in close_query_tool
"//li[contains(@class, 'context-menu-item')]/span[contains(text(),"
File
"/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
line 171, in find_by_xpath
lambda driver: driver.find_element_by_xpath(xpath)
File
"/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
line 263, in wait_for_element
return self._wait_for("element to exist", element_if_it_exists)
File
"/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
line 337, in _wait_for
"Timed out waiting for " + waiting_for_message
File
"/Users/dpage/.virtualenvs/pgadmin4/lib/python3.6/site-packages/selenium/webdriver/support/wait.py",
line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: Timed out waiting for
element to exist
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query
2018-06-20 14:13 [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-21 00:50 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
2018-06-21 05:27 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-21 18:27 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
2018-06-22 05:39 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-25 11:13 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
@ 2018-06-25 11:23 ` Akshay Joshi <[email protected]>
2018-06-25 13:41 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Akshay Joshi @ 2018-06-25 11:23 UTC (permalink / raw)
To: Dave Page <[email protected]>; +Cc: pgadmin-hackers
On Mon, Jun 25, 2018 at 4:43 PM, Dave Page <[email protected]> wrote:
> Hi
>
> On Fri, Jun 22, 2018 at 6:39 AM, Akshay Joshi <
> [email protected]> wrote:
>
>>
>>
>> On Thu, Jun 21, 2018 at 11:57 PM, Dave Page <[email protected]> wrote:
>>
>>> Hi
>>>
>>> On Thu, Jun 21, 2018 at 6:27 AM, Akshay Joshi <
>>> [email protected]> wrote:
>>>
>>>>
>>>>
>>>> On Thu, Jun 21, 2018 at 6:20 AM, Dave Page <[email protected]> wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> On Wed, Jun 20, 2018 at 3:13 PM, Akshay Joshi <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hi Hackers,
>>>>>>
>>>>>> Attached is the patch for Feature #3273 Add ability to sort in the
>>>>>> Select File window when opening a saved query.
>>>>>>
>>>>>> I haven't seen any refactoring possibility, patch contains feature
>>>>>> test with *time.sleep(0.05). *I have spend lot of time to not
>>>>>> introduce "time.sleep()" and tried couple of different ways of
>>>>>> WebDriveWait, but didn't get success.
>>>>>>
>>>>>> Please review it.
>>>>>>
>>>>>
>>>>> I get the following running the feature tests:
>>>>>
>>>>> invalid syntax (xss_checks_file_manager_test.py, line 60)
>>>>>
>>>>> make: *** [check-feature] Error 1
>>>>>
>>>>> Fixed.
>>>>
>>>>
>>>>> Also; should that file be renamed now, to reflect that it tests more
>>>>> than just XSS?
>>>>>
>>>>
>>>> Done. Attached is the modified patch.
>>>>
>>>
>>> This seems to work for the most part, however, when sorting on the
>>> Modified column, it is sorting alphabetically, not by date. This doesn't
>>> seem like it's what users would expect.
>>>
>>
>> Attached is the modified patch with the above fix.
>>
>>>
> I'm seeing the following failure pretty consistently:
>
> ======================================================================
>
> ERROR: runTest (pgadmin.feature_tests.file_manager_test.
> CheckFileManagerFeatureTest)
>
> File manager feature test
>
> ----------------------------------------------------------------------
>
> Traceback (most recent call last):
>
> File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/base_feature_test.py",
> line 66, in tearDown
>
> self.after()
>
> File "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/file_manager_test.py",
> line 48, in after
>
> self.page.close_query_tool('sql', False)
>
> File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
> line 104, in close_query_tool
>
> "//li[contains(@class, 'context-menu-item')]/span[contains(text(),"
>
> File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
> line 171, in find_by_xpath
>
> lambda driver: driver.find_element_by_xpath(xpath)
>
> File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
> line 263, in wait_for_element
>
> return self._wait_for("element to exist", element_if_it_exists)
>
> File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
> line 337, in _wait_for
>
> "Timed out waiting for " + waiting_for_message
>
> File "/Users/dpage/.virtualenvs/pgadmin4/lib/python3.6/site-
> packages/selenium/webdriver/support/wait.py", line 80, in until
>
> raise TimeoutException(message, screen, stacktrace)
>
> selenium.common.exceptions.TimeoutException: Message: Timed out waiting
> for element to exist
>
>
It's a Timed out issue and I haven't faced this on my machine. As per
above traceback it is failing on "self.page.close_query_tool()" which is
not the part of this patch and not reproducible either on my machine.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
--
*Akshay Joshi*
*Sr. Software Architect *
*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query
2018-06-20 14:13 [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-21 00:50 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
2018-06-21 05:27 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-21 18:27 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
2018-06-22 05:39 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-25 11:13 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Dave Page <[email protected]>
2018-06-25 11:23 ` Re: [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
@ 2018-06-25 13:41 ` Dave Page <[email protected]>
0 siblings, 0 replies; 8+ messages in thread
From: Dave Page @ 2018-06-25 13:41 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers
On Mon, Jun 25, 2018 at 12:23 PM, Akshay Joshi <
[email protected]> wrote:
>
>
> On Mon, Jun 25, 2018 at 4:43 PM, Dave Page <[email protected]> wrote:
>
>> Hi
>>
>> On Fri, Jun 22, 2018 at 6:39 AM, Akshay Joshi <
>> [email protected]> wrote:
>>
>>>
>>>
>>> On Thu, Jun 21, 2018 at 11:57 PM, Dave Page <[email protected]> wrote:
>>>
>>>> Hi
>>>>
>>>> On Thu, Jun 21, 2018 at 6:27 AM, Akshay Joshi <
>>>> [email protected]> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Thu, Jun 21, 2018 at 6:20 AM, Dave Page <[email protected]> wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> On Wed, Jun 20, 2018 at 3:13 PM, Akshay Joshi <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Hi Hackers,
>>>>>>>
>>>>>>> Attached is the patch for Feature #3273 Add ability to sort in the
>>>>>>> Select File window when opening a saved query.
>>>>>>>
>>>>>>> I haven't seen any refactoring possibility, patch contains feature
>>>>>>> test with *time.sleep(0.05). *I have spend lot of time to not
>>>>>>> introduce "time.sleep()" and tried couple of different ways of
>>>>>>> WebDriveWait, but didn't get success.
>>>>>>>
>>>>>>> Please review it.
>>>>>>>
>>>>>>
>>>>>> I get the following running the feature tests:
>>>>>>
>>>>>> invalid syntax (xss_checks_file_manager_test.py, line 60)
>>>>>>
>>>>>> make: *** [check-feature] Error 1
>>>>>>
>>>>>> Fixed.
>>>>>
>>>>>
>>>>>> Also; should that file be renamed now, to reflect that it tests more
>>>>>> than just XSS?
>>>>>>
>>>>>
>>>>> Done. Attached is the modified patch.
>>>>>
>>>>
>>>> This seems to work for the most part, however, when sorting on the
>>>> Modified column, it is sorting alphabetically, not by date. This doesn't
>>>> seem like it's what users would expect.
>>>>
>>>
>>> Attached is the modified patch with the above fix.
>>>
>>>>
>> I'm seeing the following failure pretty consistently:
>>
>> ======================================================================
>>
>> ERROR: runTest (pgadmin.feature_tests.file_ma
>> nager_test.CheckFileManagerFeatureTest)
>>
>> File manager feature test
>>
>> ----------------------------------------------------------------------
>>
>> Traceback (most recent call last):
>>
>> File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/base_feature_test.py",
>> line 66, in tearDown
>>
>> self.after()
>>
>> File "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/file_manager_test.py",
>> line 48, in after
>>
>> self.page.close_query_tool('sql', False)
>>
>> File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>> line 104, in close_query_tool
>>
>> "//li[contains(@class, 'context-menu-item')]/span[contains(text(),"
>>
>> File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>> line 171, in find_by_xpath
>>
>> lambda driver: driver.find_element_by_xpath(xpath)
>>
>> File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>> line 263, in wait_for_element
>>
>> return self._wait_for("element to exist", element_if_it_exists)
>>
>> File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>> line 337, in _wait_for
>>
>> "Timed out waiting for " + waiting_for_message
>>
>> File "/Users/dpage/.virtualenvs/pgadmin4/lib/python3.6/site-packa
>> ges/selenium/webdriver/support/wait.py", line 80, in until
>>
>> raise TimeoutException(message, screen, stacktrace)
>>
>> selenium.common.exceptions.TimeoutException: Message: Timed out waiting
>> for element to exist
>>
>>
> It's a Timed out issue and I haven't faced this on my machine. As per
> above traceback it is failing on "self.page.close_query_tool()" which is
> not the part of this patch and not reproducible either on my machine.
>
True. I've pushed the patch, and will setup a call to figure out how to
resolve these issues as they are becoming a real pain.
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2018-06-25 13:41 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-06-20 14:13 [pgadmin4][Patch]: Feature #3273 Add ability to sort in the Select File window when opening a saved query Akshay Joshi <[email protected]>
2018-06-21 00:50 ` Dave Page <[email protected]>
2018-06-21 05:27 ` Akshay Joshi <[email protected]>
2018-06-21 18:27 ` Dave Page <[email protected]>
2018-06-22 05:39 ` Akshay Joshi <[email protected]>
2018-06-25 11:13 ` Dave Page <[email protected]>
2018-06-25 11:23 ` Akshay Joshi <[email protected]>
2018-06-25 13:41 ` 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