diff --git a/requirements.txt b/requirements.txt index 5bd5d726..012a2555 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,6 +23,7 @@ Flask-Migrate==2.4.0 Flask-Principal==0.4.0 Flask-SQLAlchemy==2.3.2 Flask-WTF==0.14.2 +Flask-Compress==1.4.0 passlib==1.7.1 pytz==2018.9 simplejson==3.16.0 @@ -34,10 +35,6 @@ Flask-Paranoid==0.2.0 psutil==5.5.1 psycopg2>=2.8 python-dateutil>=2.8.0 -htmlmin==0.1.12 -Flask-HTMLmin==1.5.0 SQLAlchemy>=1.2.18 Flask-Security>=3.0.0 sshtunnel>=0.1.4 - - diff --git a/web/.eslintrc.js b/web/.eslintrc.js index a9d7437f..dd24f02b 100644 --- a/web/.eslintrc.js +++ b/web/.eslintrc.js @@ -17,9 +17,11 @@ module.exports = { 'extends': [ 'eslint:recommended', ], + 'parser': 'babel-eslint', 'parserOptions': { 'ecmaVersion': 2018, 'sourceType': 'module', + 'allowImportExportEverywhere': true }, 'plugins': [ ], diff --git a/web/config.py b/web/config.py index e8c20010..f6d95caa 100644 --- a/web/config.py +++ b/web/config.py @@ -180,10 +180,13 @@ PROXY_X_PREFIX_COUNT = 0 # longer part of the main configuration, but are stored in the # configuration databases 'keys' table and are auto-generated. -# Should HTML be minified on the fly when not in debug mode? -# NOTE: The HTMLMIN module doesn't work with Python 2.6, so this option -# has no effect on <= Python 2.7. -MINIFY_PAGE = True +# COMPRESSION +COMPRESS_MIMETYPES = [ + 'text/html', 'text/css', 'text/xml', 'application/json', + 'application/javascript' +] +COMPRESS_LEVEL = 9 +COMPRESS_MIN_SIZE = 500 # Set the cache control max age for static files in flask to 1 year SEND_FILE_MAX_AGE_DEFAULT = 31556952 diff --git a/web/package.json b/web/package.json index 27954a44..a1a023ed 100644 --- a/web/package.json +++ b/web/package.json @@ -7,11 +7,13 @@ ], "license": "PostgreSQL", "devDependencies": { - "@babel/core": "~7.3.4", - "@babel/preset-env": "~7.3.4", + "@babel/core": "~7.6.0", + "@babel/preset-env": "~7.6.0", "axios-mock-adapter": "^1.16.0", + "babel-eslint": "^10.0.3", "babel-loader": "~8.0.5", "babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3", + "core-js": "^3.2.1", "cross-env": "^5.2.0", "eclint": "^2.8.1", "eslint": "5.15.1", @@ -40,11 +42,12 @@ "uglifyjs-webpack-plugin": "^2.1.2", "url-loader": "^1.1.2", "webpack": "^4.29.6", + "webpack-bundle-analyzer": "^3.5.1", "webpack-cli": "^3.2.3", + "webpack-require-from": "^1.8.0", "yarn-audit-html": "^1.1.0" }, "dependencies": { - "@babel/polyfill": "^7.2.5", "acitree": "git+https://github.com/imsurinder90/jquery-aciTree.git#rc.7", "alertifyjs": "1.7.1", "axios": "^0.18.1", @@ -53,7 +56,6 @@ "babelify": "~10.0.0", "backbone": "1.4.0", "backform": "^0.2.0", - "backgrid": "^0.3.8", "backgrid-filter": "^0.3.7", "backgrid-select-all": "^0.3.5", "backgrid-sizeable-columns": "^0.1.1", @@ -88,12 +90,10 @@ "snapsvg": "^0.5.1", "spectrum-colorpicker": "^1.8.0", "split.js": "^1.5.10", - "sprintf-js": "^1.1.2", "tablesorter": "^2.31.1", "tempusdominus-bootstrap-4": "^5.1.2", "tempusdominus-core": "^5.0.3", "underscore": "^1.9.1", - "underscore.string": "^3.3.5", "watchify": "~3.11.1", "webcabin-docker": "git+https://github.com/EnterpriseDB/wcDocker/#c95d295382ac61159e571af9c3b8f4f8ae81746d", "wkx": "^0.4.6" @@ -104,6 +104,7 @@ "webpacker:watch": "yarn run webpack --config webpack.config.js --progress --watch", "bundle:watch": "yarn run linter && yarn run webpacker:watch", "bundle:dev": "yarn run linter && yarn run webpacker", + "bundle:analyze": "cross-env NODE_ENV=production ANALYZE=true yarn run bundle:dev", "bundle": "cross-env NODE_ENV=production yarn run bundle:dev", "test:karma-once": "yarn run linter && yarn run karma start --single-run", "test:karma": "yarn run linter && yarn run karma start", diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py index 28bb51c7..7fd0ad36 100644 --- a/web/pgadmin/__init__.py +++ b/web/pgadmin/__init__.py @@ -705,11 +705,11 @@ def create_app(app_name=None): values.pop(config.APP_VERSION_PARAM) ########################################################################## - # Minify output + # Minify output. Not required in desktop mode ########################################################################## - if not config.DEBUG: - from flask_htmlmin import HTMLMIN - HTMLMIN(app) + if not config.DEBUG and config.SERVER_MODE: + from flask_compress import Compress + Compress(app) @app.context_processor def inject_blueprint(): diff --git a/web/pgadmin/about/static/js/about.js b/web/pgadmin/about/static/js/about.js index 64bc356d..9186f65c 100644 --- a/web/pgadmin/about/static/js/about.js +++ b/web/pgadmin/about/static/js/about.js @@ -8,10 +8,10 @@ ////////////////////////////////////////////////////////////// define( - ['jquery', 'alertify', 'sources/pgadmin', 'underscore.string', 'sources/gettext', + ['jquery', 'alertify', 'sources/pgadmin', 'sources/gettext', 'sources/url_for', ], - function($, alertify, pgAdmin, S, gettext, url_for) { + function($, alertify, pgAdmin, gettext, url_for) { pgAdmin = pgAdmin || window.pgAdmin || {}; /* Return back, this has been called more than once */ @@ -53,7 +53,7 @@ define( $.get(url_for('about.index'), function(data) { alertify.aboutDialog( - S(gettext('About %s')).sprintf(pgAdmin.Browser.utils.app_name).value(), data + gettext('About %s', pgAdmin.Browser.utils.app_name), data ).resizeTo(pgAdmin.Browser.stdW.md, pgAdmin.Browser.stdH.md); }); }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js b/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js index c3b8e080..711d3ad3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js +++ b/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js @@ -9,9 +9,9 @@ define('pgadmin.node.cast', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.backform', 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, Backform) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, alertify, Backform) { // Extend the collection class for cast if (!pgBrowser.Nodes['coll-cast']) { pgAdmin.Browser.Nodes['coll-cast'] = diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/static/js/event_trigger.js b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/static/js/event_trigger.js index fc78e602..8f8c2ad8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/static/js/event_trigger.js +++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/static/js/event_trigger.js @@ -9,9 +9,9 @@ define('pgadmin.node.event_trigger', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform) { // Extend the browser's collection class for event trigger collection if (!pgBrowser.Nodes['coll-event_trigger']) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.js b/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.js index 64ab3e4e..8fcb442f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.js +++ b/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.js @@ -9,9 +9,9 @@ define('pgadmin.node.extension', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform) { /* * Create and Add an Extension Collection into nodes diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/static/js/foreign_server.js b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/static/js/foreign_server.js index 1c82513f..e392cc41 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/static/js/foreign_server.js +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/static/js/foreign_server.js @@ -8,10 +8,10 @@ ////////////////////////////////////////////////////////////// define('pgadmin.node.foreign_server', [ - 'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin', + 'sources/gettext', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.browser.collection', 'pgadmin.browser.server.privilege', -], function(gettext, $, _, S, pgAdmin, pgBrowser, Backform) { +], function(gettext, $, _, pgAdmin, pgBrowser, Backform) { // Extend the browser's node model class to create a Options model var OptionsModel = pgAdmin.Browser.Node.Model.extend({ diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/static/js/user_mapping.js b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/static/js/user_mapping.js index 3d75f673..b3b66f71 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/static/js/user_mapping.js +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/static/js/user_mapping.js @@ -9,9 +9,9 @@ define('pgadmin.node.user_mapping', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform) { // Extend the browser's node model class to create a Options model var OptionsModel = pgAdmin.Browser.Node.Model.extend({ diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/static/js/foreign_data_wrapper.js b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/static/js/foreign_data_wrapper.js index c5ee0b3c..2fd5c915 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/static/js/foreign_data_wrapper.js +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/static/js/foreign_data_wrapper.js @@ -9,9 +9,9 @@ define('pgadmin.node.foreign_data_wrapper', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.browser.collection', 'pgadmin.browser.server.privilege', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform) { // Extend the browser's node model class to create a Options model var OptionsModel = pgBrowser.Node.Model.extend({ diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js b/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js index 8c2ec0b7..0d7cea19 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js +++ b/web/pgadmin/browser/server_groups/servers/databases/languages/static/js/language.js @@ -9,9 +9,9 @@ define('pgadmin.node.language', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.browser.collection', 'pgadmin.browser.server.privilege', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform) { // Extend the browser's collection class for languages collection if (!pgBrowser.Nodes['coll-language']) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/static/js/catalog_object_column.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/static/js/catalog_object_column.js index d01e9a2d..1682b04d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/static/js/catalog_object_column.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/static/js/catalog_object_column.js @@ -8,9 +8,9 @@ ////////////////////////////////////////////////////////////// define('pgadmin.node.catalog_object_column', [ - 'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin', + 'sources/gettext', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.browser.collection', -], function(gettext, $, _, S, pgAdmin, pgBrowser) { +], function(gettext, $, _, pgAdmin, pgBrowser) { if (!pgBrowser.Nodes['coll-catalog_object_column']) { pgAdmin.Browser.Nodes['coll-catalog_object_column'] = diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/static/js/catalog_object.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/static/js/catalog_object.js index a21e2064..efdafbb9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/static/js/catalog_object.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/static/js/catalog_object.js @@ -8,9 +8,9 @@ ////////////////////////////////////////////////////////////// define('pgadmin.node.catalog_object', [ - 'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin', + 'sources/gettext', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.browser.collection', -], function(gettext, $, _, S, pgAdmin, pgBrowser) { +], function(gettext, $, _, pgAdmin, pgBrowser) { if (!pgBrowser.Nodes['coll-catalog_object']) { pgAdmin.Browser.Nodes['coll-catalog_object'] = diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js index e3b60303..407f82f0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js @@ -9,10 +9,10 @@ define('pgadmin.node.collation', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, schemaChild, +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, schemaChild, schemaChildTreeNode) { if (!pgBrowser.Nodes['coll-collation']) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.js index f916ae54..a7f0a91d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.js @@ -10,9 +10,9 @@ // Domain Constraint Module: Collection and Node define('pgadmin.node.domain_constraints', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, schemaChildTreeNode) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, schemaChildTreeNode) { // Define Domain Constraint Collection Node if (!pgBrowser.Nodes['coll-domain_constraints']) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary.js index c7b2a56b..1fbdf8e2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary.js @@ -9,11 +9,11 @@ define('pgadmin.node.fts_dictionary', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', ], function( - gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, schemaChild, + gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, schemaChild, schemaChildTreeNode ) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/procedure.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/procedure.js index 7b26b238..1dc8988f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/procedure.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/procedure.js @@ -10,11 +10,11 @@ /* Create and Register Procedure Collection and Node. */ define('pgadmin.node.procedure', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'alertify', + 'sources/pgadmin', 'pgadmin.browser', 'alertify', 'pgadmin.node.function', 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', 'pgadmin.browser.server.privilege', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, Function, +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, alertify, Function, schemaChild, schemaChildTreeNode) { if (!pgBrowser.Nodes['coll-procedure']) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js index 170ba982..abe88aaa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js @@ -9,11 +9,11 @@ define('pgadmin.node.sequence', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', ], function( - gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, schemaChild, + gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, schemaChild, schemaChildTreeNode ) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js index e42eca4c..0104ce75 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js @@ -9,10 +9,10 @@ define('pgadmin.node.synonym', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, alertify, schemaChild, schemaChildTreeNode) { if (!pgBrowser.Nodes['coll-synonym']) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/static/js/compound_trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/static/js/compound_trigger.js index 2c30d1bc..592f08a8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/static/js/compound_trigger.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/static/js/compound_trigger.js @@ -9,12 +9,12 @@ define('pgadmin.node.compound_trigger', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.alertifyjs', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', ], function( - gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, + gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, alertify, SchemaChildTreeNode ) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js index 8258b3cb..65a002e1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js @@ -10,9 +10,9 @@ // Check Constraint Module: Node define('pgadmin.node.check_constraint', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, schemaChildTreeNode) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, alertify, schemaChildTreeNode) { // Check Constraint Node if (!pgBrowser.Nodes['check_constraint']) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js index 29211865..8ecd1dae 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js @@ -640,7 +640,7 @@ define('pgadmin.node.primary_key', [ if ((_.isUndefined(index) || String(index).replace(/^\s+|\s+$/g, '') == '') && (_.isUndefined(columns) || _.isNull(columns) || columns.length < 1)) { - var msg = gettext('Please specify columns for %(node)s', {node: gettext('Primary key')}); + var msg = gettext('Please specify columns for %s', gettext('Primary key')); this.errorModel.set('columns', msg); return msg; } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js index 41a524b1..9dac2202 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.js @@ -629,7 +629,7 @@ define('pgadmin.node.unique_constraint', [ if ((_.isUndefined(index) || String(index).replace(/^\s+|\s+$/g, '') == '') && (_.isUndefined(columns) || _.isNull(columns) || columns.length < 1)) { - var msg = gettext('Please specify columns for %(node)s', {node: gettext('Unique constraint')}); + var msg = gettext('Please specify columns for %s', gettext('Unique constraint')); this.errorModel.set('columns', msg); return msg; } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js index 493deae0..a10b3976 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js @@ -9,14 +9,14 @@ define([ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.backform', 'pgadmin.backgrid', - 'pgadmin.node.schema.dir/schema_child_tree_node', + 'pgadmin.node.schema.dir/schema_child_tree_node', 'sources/utils', 'pgadmin.browser.collection', 'pgadmin.browser.table.partition.utils', ], function( - gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform, Backgrid, - SchemaChildTreeNode + gettext, url_for, $, _, pgAdmin, pgBrowser, Alertify, Backform, Backgrid, + SchemaChildTreeNode, pgadminUtils ) { if (!pgBrowser.Nodes['coll-partition']) { @@ -107,13 +107,13 @@ function( info = (_.isUndefined(item) || _.isNull(item)) ? info || {} : this.getTreeNodeHierarchy(item); - return S('table/%s/%s/%s/%s/%s/%s').sprintf( + return pgadminUtils.sprintf('table/%s/%s/%s/%s/%s/%s', encodeURIComponent(type), encodeURIComponent(info['server_group']._id), encodeURIComponent(info['server']._id), encodeURIComponent(info['database']._id), encodeURIComponent(info['partition'].schema_id), encodeURIComponent(info['partition']._id) - ).value(); + ); }, canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema, canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema, @@ -184,7 +184,7 @@ function( Alertify.confirm( gettext('Truncate Table'), - S(gettext('Are you sure you want to truncate table %s?')).sprintf(d.label).value(), + gettext('Are you sure you want to truncate table %s?', d.label), function (e) { if (e) { var data = d; @@ -229,7 +229,7 @@ function( Alertify.confirm( gettext('Reset statistics'), - S(gettext('Are you sure you want to reset the statistics for table "%s"?')).sprintf(d._label).value(), + gettext('Are you sure you want to reset the statistics for table "%s"?', d._label), function (e) { if (e) { var data = d; @@ -273,7 +273,7 @@ function( Alertify.confirm( gettext('Detach Partition'), - S(gettext('Are you sure you want to detach the partition %s?')).sprintf(d._label).value(), + gettext('Are you sure you want to detach the partition %s?', d._label), function (e) { if (e) { $.ajax({ diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js index da3738a7..fe733df0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js @@ -10,7 +10,7 @@ define('pgadmin.node.table', [ 'pgadmin.tables.js/enable_disable_triggers', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.tables.js/show_advanced_tab', 'pgadmin.node.schema.dir/child','pgadmin.node.schema.dir/schema_child_tree_node', @@ -18,7 +18,7 @@ define('pgadmin.node.table', [ 'pgadmin.node.constraints', 'pgadmin.browser.table.partition.utils', ], function( tableFunctions, - gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform, Backgrid, + gettext, url_for, $, _, pgAdmin, pgBrowser, Alertify, Backform, Backgrid, ShowAdvancedTab, SchemaChild, SchemaChildTreeNode ) { @@ -165,7 +165,7 @@ define('pgadmin.node.table', [ Alertify.confirm( gettext('Truncate Table'), - S(gettext('Are you sure you want to truncate table %s?')).sprintf(d.label).value(), + gettext('Are you sure you want to truncate table %s?', d.label), function (e) { if (e) { var data = d; @@ -210,7 +210,7 @@ define('pgadmin.node.table', [ Alertify.confirm( gettext('Reset statistics'), - S(gettext('Are you sure you want to reset the statistics for table "%s"?')).sprintf(d._label).value(), + gettext('Are you sure you want to reset the statistics for table "%s"?', d._label), function (e) { if (e) { var data = d; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js index 1a01268a..a38894f6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js @@ -9,12 +9,12 @@ define('pgadmin.node.trigger', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backform', 'pgadmin.alertifyjs', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection', ], function( - gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, + gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, alertify, SchemaChildTreeNode ) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js index 21ef722c..b34d845f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js @@ -218,9 +218,9 @@ define('pgadmin.node.type', [ else if (this.get('is_tlength') && !_.isUndefined(this.get('tlength'))) { if (this.get('tlength') < this.get('min_val')) - errmsg = gettext('Length/precision should not be less than %(value)s', {value: this.get('min_val')}); + errmsg = gettext('Length/precision should not be less than %s', this.get('min_val')); if (this.get('tlength') > this.get('max_val') ) - errmsg = gettext('Length/precision should not be greater than %(value)s', {value: this.get('max_val')}); + errmsg = gettext('Length/precision should not be greater than %s', this.get('max_val')); // If we have any error set then throw it to user if(errmsg) { this.errorModel.set('tlength', errmsg); @@ -231,9 +231,9 @@ define('pgadmin.node.type', [ else if (this.get('is_precision') && !_.isUndefined(this.get('precision'))) { if (this.get('precision') < this.get('min_val')) - errmsg = gettext('Scale should not be less than %(value)s', {value: this.get('min_val')}); + errmsg = gettext('Scale should not be less than %s', this.get('min_val')); if (this.get('precision') > this.get('max_val')) - errmsg = gettext('Scale should not be greater than %(value)s', {value: this.get('max_val')}); + errmsg = gettext('Scale should not be greater than %s', this.get('max_val')); // If we have any error set then throw it to user if(errmsg) { this.errorModel.set('precision', errmsg); diff --git a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js index 9bd93276..ab0df693 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js +++ b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js @@ -9,10 +9,10 @@ define('pgadmin.node.database', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser.utils', + 'sources/utils', 'sources/pgadmin', 'pgadmin.browser.utils', 'pgadmin.alertifyjs', 'pgadmin.backform', 'pgadmin.browser.collection', 'pgadmin.browser.server.privilege', 'pgadmin.browser.server.variable', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform) { +], function(gettext, url_for, $, _, pgadminUtils, pgAdmin, pgBrowser, Alertify, Backform) { if (!pgBrowser.Nodes['coll-database']) { pgBrowser.Nodes['coll-database'] = @@ -190,7 +190,7 @@ define('pgadmin.node.database', [ Alertify.confirm( gettext('Disconnect the database'), - S(gettext('Are you sure you want to disconnect the database - %s?')).sprintf(d.label).value(), + pgadminUtils.sprintf(gettext('Are you sure you want to disconnect the database - %s?'), d.label), function() { var data = d; $.ajax({ diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule.js b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule.js index 8f6cd285..f1af97e9 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule.js +++ b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule.js @@ -9,10 +9,10 @@ define('pgadmin.node.pga_schedule', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'moment', 'pgadmin.browser', 'alertify', + 'sources/pgadmin', 'moment', 'pgadmin.browser', 'alertify', 'pgadmin.backform', 'pgadmin.backgrid', ], function( - gettext, url_for, $, _, S, pgAdmin, moment, pgBrowser, Alertify, Backform, + gettext, url_for, $, _, pgAdmin, moment, pgBrowser, Alertify, Backform, Backgrid ) { diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js b/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js index 8cc7a91a..4f719043 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js +++ b/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js @@ -9,9 +9,9 @@ define('pgadmin.node.pga_job', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.node.pga_jobstep', 'pgadmin.node.pga_schedule', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, alertify) { if (!pgBrowser.Nodes['coll-pga_job']) { pgBrowser.Nodes['coll-pga_job'] = diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js index 74787bcb..39ded81b 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js +++ b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js @@ -9,9 +9,9 @@ define('pgadmin.node.pga_jobstep', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'alertify', 'backform', + 'sources/pgadmin', 'pgadmin.browser', 'alertify', 'backform', 'backgrid', 'pgadmin.backform', 'pgadmin.backgrid', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform, Backgrid) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Alertify, Backform, Backgrid) { if (!pgBrowser.Nodes['coll-pga_jobstep']) { pgBrowser.Nodes['coll-pga_jobstep'] = @@ -190,11 +190,9 @@ define('pgadmin.node.pga_jobstep', [ id: 'jstconnstr', label: gettext('Connection string'), type: 'text', deps: ['jstkind', 'jstconntype'], disabled: function(m) { return !m.get('jstkind') || m.get('jstconntype'); - }, helpMessage: S( - gettext('Please specify the connection string for the remote database server. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value, or a value containing spaces, surround it with single quotes, e.g., keyword = \'a value\'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.
For more information, please see the documentation on %s') - ).sprintf( + }, helpMessage: gettext('Please specify the connection string for the remote database server. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value, or a value containing spaces, surround it with single quotes, e.g., keyword = \'a value\'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.
For more information, please see the documentation on %s', 'libpq connection strings' - ).value(), mode: ['create', 'edit'], + ), mode: ['create', 'edit'], },{ id: 'jstonerror', label: gettext('On error'), cell: 'select2', control: 'select2', options: [ @@ -273,9 +271,7 @@ define('pgadmin.node.pga_jobstep', [ break; } - msg = S( - gettext('Invalid parameter in the connection string - %s.') - ).sprintf(m[1]).value(); + msg = gettext('Invalid parameter in the connection string - %s.', m[1]); break; } } diff --git a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js index 94aad6d1..93253280 100644 --- a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js +++ b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js @@ -9,10 +9,10 @@ define('pgadmin.node.role', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'alertify', + 'sources/pgadmin', 'pgadmin.browser', 'alertify', 'pgadmin.backform', 'select2', 'pgadmin.browser.collection', 'pgadmin.browser.node.ui', 'pgadmin.browser.server.variable', -], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, Backform) { +], function(gettext, url_for, $, _, pgAdmin, pgBrowser, alertify, Backform) { if (!pgBrowser.Nodes['coll-role']) { pgAdmin.Browser.Nodes['coll-role'] = diff --git a/web/pgadmin/browser/server_groups/servers/static/js/server.js b/web/pgadmin/browser/server_groups/servers/static/js/server.js index 29419243..99fed949 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/server.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/server.js @@ -9,13 +9,13 @@ define('pgadmin.node.server', [ 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone', - 'underscore.string', 'sources/pgadmin', 'pgadmin.browser', + 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.server.supported_servers', 'pgadmin.user_management.current_user', 'pgadmin.alertifyjs', 'pgadmin.backform', 'sources/browser/server_groups/servers/model_validation', 'pgadmin.browser.server.privilege', ], function( - gettext, url_for, $, _, Backbone, S, pgAdmin, pgBrowser, + gettext, url_for, $, _, Backbone, pgAdmin, pgBrowser, supported_servers, current_user, Alertify, Backform, modelValidation ) { @@ -260,10 +260,7 @@ define('pgadmin.node.server', [ if (notify) { Alertify.confirm( gettext('Disconnect server'), - gettext( - 'Are you sure you want to disconnect the server %(server)s?', - {server: d.label} - ), + gettext('Are you sure you want to disconnect the server %s?', d.label), function() { disconnect(); }, function() { return true;} ); @@ -310,9 +307,7 @@ define('pgadmin.node.server', [ Alertify.confirm( gettext('Reload server configuration'), - S( - gettext('Are you sure you want to reload the server configuration on %s?') - ).sprintf(d.label).value(), + gettext('Are you sure you want to reload the server configuration on %s?', d.label), function() { $.ajax({ url: obj.generate_url(i, 'reload', d, true), @@ -643,9 +638,7 @@ define('pgadmin.node.server', [ Alertify.confirm( gettext('Clear saved password'), - S( - gettext('Are you sure you want to clear the saved password for server %s?') - ).sprintf(d.label).value(), + gettext('Are you sure you want to clear the saved password for server %s?', d.label), function() { $.ajax({ url: obj.generate_url(i, 'clear_saved_password', d, true), @@ -683,9 +676,7 @@ define('pgadmin.node.server', [ Alertify.confirm( gettext('Clear SSH Tunnel password'), - S( - gettext('Are you sure you want to clear the saved password of SSH Tunnel for server %s?') - ).sprintf(d.label).value(), + gettext('Are you sure you want to clear the saved password of SSH Tunnel for server %s?', d.label), function() { $.ajax({ url: obj.generate_url(i, 'clear_sshtunnel_password', d, true), diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js b/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js index 82b7ba5a..5ba3682b 100644 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js +++ b/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js @@ -281,8 +281,8 @@ define('pgadmin.node.tablespace', [ Alertify.confirm( gettext('Move objects...'), gettext( - 'Are you sure you wish to move the objects from %(old_tablespace)s to %(new_tablespace)s?', - {old_tablespace: args.old_tblspc, new_tablespace: args.tblspc} + 'Are you sure you wish to move the objects from %s to %s?', + args.old_tblspc, args.tblspc ), function() { $.ajax({ diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index f492a1f5..7cedd1ca 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -9,7 +9,7 @@ define('pgadmin.browser', [ 'sources/tree/tree', - 'sources/gettext', 'sources/url_for', 'require', 'jquery', 'underscore', 'underscore.string', + 'sources/gettext', 'sources/url_for', 'require', 'jquery', 'underscore', 'bootstrap', 'sources/pgadmin', 'pgadmin.alertifyjs', 'bundled_codemirror', 'sources/check_node_visibility', './toolbar', 'pgadmin.help', 'sources/csrf', 'sources/utils', 'sources/window', 'pgadmin.browser.utils', @@ -22,7 +22,7 @@ define('pgadmin.browser', [ 'pgadmin.browser.keyboard', 'sources/tree/pgadmin_tree_save_state', ], function( tree, - gettext, url_for, require, $, _, S, + gettext, url_for, require, $, _, Bootstrap, pgAdmin, Alertify, codemirror, checkNodeVisibility, toolBar, help, csrfToken, pgadminUtils, pgWindow ) { @@ -724,7 +724,7 @@ define('pgadmin.browser', [ if(!_.isUndefined(confirm_on_refresh_close) && confirm_on_refresh_close.value) { /* This message will not be displayed in Chrome, Firefox, Safari as they have disabled it*/ - let msg = S(gettext('Are you sure you want to close the %s browser?')).sprintf(pgBrowser.utils.app_name).value(); + let msg = gettext('Are you sure you want to close the %s browser?', pgBrowser.utils.app_name); e.originalEvent.returnValue = msg; return msg; } diff --git a/web/pgadmin/browser/static/js/collection.js b/web/pgadmin/browser/static/js/collection.js index c19b0f27..1b4d1959 100644 --- a/web/pgadmin/browser/static/js/collection.js +++ b/web/pgadmin/browser/static/js/collection.js @@ -11,11 +11,11 @@ //import Mousetrap from 'mousetrap'; define([ - 'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin', + 'sources/gettext', 'jquery', 'underscore', 'sources/pgadmin', 'backbone', 'alertify', 'backform', 'backgrid', 'sources/browser/generate_url', 'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser.node', 'backgrid.select.all', -], function(gettext, $, _, S, pgAdmin, Backbone, Alertify, Backform, Backgrid, generateUrl) { +], function(gettext, $, _, pgAdmin, Backbone, Alertify, Backform, Backgrid, generateUrl) { var pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {}; @@ -315,8 +315,7 @@ define([ info: info, })) { Alertify.pgNotifier( - error, xhr, S(gettext('Error retrieving properties - %s')).sprintf( - error.message || that.label).value(), + error, xhr, gettext('Error retrieving properties - %s', error.message || that.label), function(msg) { if(msg === 'CRYPTKEY_SET') { getAjaxHook(); @@ -383,8 +382,8 @@ define([ }).fail(function(xhr, error) { Alertify.pgNotifier( error, xhr, - S(gettext('Error dropping %s')) - .sprintf(d._label.toLowerCase()).value(), function(msg) { + gettext('Error dropping %s', d._label.toLowerCase()), + function(msg) { if (msg == 'CRYPTKEY_SET') { onDrop(type, false); } else { diff --git a/web/pgadmin/browser/static/js/datamodel.js b/web/pgadmin/browser/static/js/datamodel.js index ac4f84ae..ed663547 100644 --- a/web/pgadmin/browser/static/js/datamodel.js +++ b/web/pgadmin/browser/static/js/datamodel.js @@ -8,8 +8,8 @@ ////////////////////////////////////////////////////////////// define([ - 'underscore', 'underscore.string', 'sources/pgadmin', 'jquery', 'backbone', -], function(_, S, pgAdmin, $, Backbone) { + 'underscore', 'sources/pgadmin', 'jquery', 'backbone', 'sources/utils', +], function(_, pgAdmin, $, Backbone, pgadminUtils) { var pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {}; pgBrowser.DataModel = Backbone.Model.extend({ @@ -777,23 +777,23 @@ define([ max_value = field.max; if (!_.isUndefined(min_value) && value < min_value) { - return S(pgAdmin.Browser.messages.MUST_GR_EQ).sprintf(label, min_value).value(); + return pgadminUtils.sprintf(pgAdmin.Browser.messages.MUST_GR_EQ, label, min_value); } else if (!_.isUndefined(max_value) && value > max_value) { - return S(pgAdmin.Browser.messages.MUST_LESS_EQ).sprintf(label, max_value).value(); + return pgadminUtils.sprintf(pgAdmin.Browser.messages.MUST_LESS_EQ, label, max_value); } return null; }, number_validate: function(value, field) { var pattern = new RegExp('^-?[0-9]+(\.?[0-9]*)?$'); if (!pattern.test(value)) { - return S(pgAdmin.Browser.messages.MUST_BE_NUM).sprintf(field.label).value(); + return pgadminUtils.sprintf(pgAdmin.Browser.messages.MUST_BE_NUM, field.label); } return this.check_min_max(value, field); }, integer_validate: function(value, field) { var pattern = new RegExp('^-?[0-9]*$'); if (!pattern.test(value)) { - return S(pgAdmin.Browser.messages.MUST_BE_INT).sprintf(field.label).value(); + return pgadminUtils.sprintf(pgAdmin.Browser.messages.MUST_BE_INT, field.label); } return this.check_min_max(value, field); }, diff --git a/web/pgadmin/browser/static/js/menu.js b/web/pgadmin/browser/static/js/menu.js index e76c9ed2..de95490b 100644 --- a/web/pgadmin/browser/static/js/menu.js +++ b/web/pgadmin/browser/static/js/menu.js @@ -8,8 +8,8 @@ ////////////////////////////////////////////////////////////// define([ - 'underscore', 'underscore.string', 'sources/pgadmin', 'jquery', -], function(_, S, pgAdmin, $) { + 'underscore', 'sources/pgadmin', 'jquery', 'sources/utils', +], function(_, pgAdmin, $, pgadminUtils) { 'use strict'; pgAdmin.Browser = pgAdmin.Browser || {}; @@ -141,7 +141,7 @@ define([ cb.apply(o.module, [o.data, item]); } else { pgAdmin.Browser.report_error( - S('Developer Warning: Callback - "%s" not found!').sprintf(o.cb).value() + pgadminUtils.sprintf('Developer Warning: Callback - "%s" not found!', o.cb) ); } }, diff --git a/web/pgadmin/browser/static/js/node.js b/web/pgadmin/browser/static/js/node.js index 1a9d3c91..00d5b44a 100644 --- a/web/pgadmin/browser/static/js/node.js +++ b/web/pgadmin/browser/static/js/node.js @@ -9,13 +9,13 @@ define('pgadmin.browser.node', [ 'sources/tree/pgadmin_tree_node', 'sources/url_for', - 'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'sources/pgadmin', + 'sources/gettext', 'jquery', 'underscore', 'sources/pgadmin', 'pgadmin.browser.menu', 'backbone', 'pgadmin.alertifyjs', 'pgadmin.browser.datamodel', 'backform', 'sources/browser/generate_url', 'pgadmin.help', 'sources/utils', 'pgadmin.browser.utils', 'pgadmin.backform', ], function( pgadminTreeNode, url_for, - gettext, $, _, S, pgAdmin, + gettext, $, _, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform, generateUrl, help, commonUtils @@ -203,9 +203,7 @@ define('pgadmin.browser.node', [ // For each script type create menu _.each(self.hasScriptTypes, function(stype) { - var type_label = S( - gettext('%s Script') - ).sprintf(stype.toUpperCase()).value(); + var type_label = gettext('%s Script',stype.toUpperCase()); stype = stype.toLowerCase(); @@ -435,9 +433,8 @@ define('pgadmin.browser.node', [ )) { Alertify.pgNotifier( options.textStatus, xhr, - S( - gettext('Error retrieving properties - %s') - ).sprintf(options.errorThrown || _label).value(), function(msg) { + gettext('Error retrieving properties - %s', options.errorThrown || _label), + function(msg) { if(msg === 'CRYPTKEY_SET') { fetchAjaxHook(); } else { @@ -672,8 +669,7 @@ define('pgadmin.browser.node', [ if (!d) return; - l = S(gettext('Create - %s')).sprintf( - [this.label]).value(); + l = gettext('Create - %s', this.label); p = addPanel(); setTimeout(function() { @@ -696,7 +692,7 @@ define('pgadmin.browser.node', [ Alertify.confirm( gettext('Edit in progress?'), - S(msg).sprintf(o.label.toLowerCase(), d.label).value(), + commonUtils.sprintf(msg, o.label.toLowerCase(), d.label), function() { setTimeout(function() { o.showProperties(i, d, p, args.action); @@ -746,29 +742,26 @@ define('pgadmin.browser.node', [ var msg, title; if (input.url == 'delete') { - msg = S(gettext('Are you sure you want to drop %s "%s" and all the objects that depend on it?')) - .sprintf(obj.label.toLowerCase(), d.label).value(); - title = S(gettext('DROP CASCADE %s?')).sprintf(obj.label).value(); + msg = gettext('Are you sure you want to drop %s "%s" and all the objects that depend on it?', + obj.label.toLowerCase(), d.label); + title = gettext('DROP CASCADE %s?', obj.label); if (!(_.isFunction(obj.canDropCascade) ? obj.canDropCascade.apply(obj, [d, i]) : obj.canDropCascade)) { Alertify.error( - S(gettext('The %s "%s" cannot be dropped.')) - .sprintf(obj.label, d.label).value(), + gettext('The %s "%s" cannot be dropped.', obj.label, d.label), 10 ); return; } } else { - msg = S(gettext('Are you sure you want to drop %s "%s"?')) - .sprintf(obj.label.toLowerCase(), d.label).value(); - title = S(gettext('DROP %s?')).sprintf(obj.label).value(); + msg = gettext('Are you sure you want to drop %s "%s"?', obj.label.toLowerCase(), d.label); + title = gettext('DROP %s?', obj.label); if (!(_.isFunction(obj.canDrop) ? obj.canDrop.apply(obj, [d, i]) : obj.canDrop)) { Alertify.error( - S(gettext('The %s "%s" cannot be dropped.')) - .sprintf(obj.label, d.label).value(), + gettext('The %s "%s" cannot be dropped.', obj.label, d.label), 10 ); return; @@ -800,9 +793,7 @@ define('pgadmin.browser.node', [ } } pgBrowser.report_error( - S(gettext('Error dropping %s: "%s"')) - .sprintf(obj.label, objName) - .value(), msg); + gettext('Error dropping %s: "%s"', obj.label, objName), msg); }); }, null).show(); @@ -1659,7 +1650,7 @@ define('pgadmin.browser.node', [ )), function(o) { return o.priority; }), function(o) { - hash = S('%s/%s').sprintf(hash, encodeURI(o._id)).value(); + hash = commonUtils.sprintf('%s/%s', hash, encodeURI(o._id)); }); } diff --git a/web/pgadmin/browser/templates/browser/index.html b/web/pgadmin/browser/templates/browser/index.html index 8b3866c2..76e222f5 100644 --- a/web/pgadmin/browser/templates/browser/index.html +++ b/web/pgadmin/browser/templates/browser/index.html @@ -11,7 +11,7 @@ {% block init_script %} try { require( -['sources/generated/app.bundle'], +['sources/generated/app.bundle', 'sources/generated/codemirror', 'sources/generated/browser_nodes'], function() { }, function() { diff --git a/web/pgadmin/dashboard/static/js/charting.js b/web/pgadmin/dashboard/static/js/charting.js index b60a02ad..3b9a4c24 100644 --- a/web/pgadmin/dashboard/static/js/charting.js +++ b/web/pgadmin/dashboard/static/js/charting.js @@ -7,11 +7,16 @@ // ////////////////////////////////////////////////////////////// -import Flotr from 'flotr2'; - export class Chart { constructor(container, options) { - this.chartApi = Flotr; + let self = this; + + require.ensure(['flotr2'], function(require) { + self.chartApi = require('flotr2'); + }, function(error){ + throw(error); + }, 'chart'); + /* Html Node where the graph goes */ this._container = container; /* Graph library options */ @@ -104,7 +109,9 @@ export class Chart { draw(dataset) { this._dataset = dataset; if(this._container) { - Flotr.draw(this._container, this._dataset, this._options); + if(this.chartApi) { + this.chartApi.draw(this._container, this._dataset, this._options); + } } } } diff --git a/web/pgadmin/misc/bgprocess/static/js/bgprocess.js b/web/pgadmin/misc/bgprocess/static/js/bgprocess.js index fa69d978..01301cc6 100644 --- a/web/pgadmin/misc/bgprocess/static/js/bgprocess.js +++ b/web/pgadmin/misc/bgprocess/static/js/bgprocess.js @@ -9,9 +9,9 @@ define('misc.bgprocess', [ 'sources/pgadmin', 'sources/gettext', 'sources/url_for', 'underscore', - 'underscore.string', 'jquery', 'pgadmin.browser', 'alertify', + 'jquery', 'pgadmin.browser', 'alertify', ], function( - pgAdmin, gettext, url_for, _, S, $, pgBrowser, Alertify + pgAdmin, gettext, url_for, _, $, pgBrowser, Alertify ) { pgBrowser.BackgroundProcessObsorver = pgBrowser.BackgroundProcessObsorver || {}; @@ -226,7 +226,7 @@ define('misc.bgprocess', [ self.curr_status = self.success_status_tpl({status_text:gettext('Successfully completed.')}); } else { self.curr_status = self.failed_status_tpl( - {status_text:S(gettext('Failed (exit code: %s).')).sprintf(String(self.exit_code)).value()} + {status_text:gettext('Failed (exit code: %s).', String(self.exit_code))} ); } } diff --git a/web/pgadmin/misc/dependencies/static/js/dependencies.js b/web/pgadmin/misc/dependencies/static/js/dependencies.js index 59c3cbaf..09dbd691 100644 --- a/web/pgadmin/misc/dependencies/static/js/dependencies.js +++ b/web/pgadmin/misc/dependencies/static/js/dependencies.js @@ -8,9 +8,10 @@ ////////////////////////////////////////////////////////////// define('misc.dependencies', [ - 'sources/gettext', 'underscore', 'underscore.string', 'jquery', 'backbone', + 'sources/gettext', 'underscore', 'jquery', 'backbone', 'pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.backgrid', -], function(gettext, _, S, $, Backbone, pgAdmin, pgBrowser, Alertify, Backgrid) { + 'sources/utils', +], function(gettext, _, $, Backbone, pgAdmin, pgBrowser, Alertify, Backgrid, pgadminUtils) { if (pgBrowser.NodeDependencies) return pgBrowser.NodeDependencies; @@ -52,7 +53,7 @@ define('misc.dependencies', [ (node['node_image'] || ('icon-' + res.type))) : ('icon-' + res.type); } - res.type = S.titleize(res.type.replace(/_/g, ' '), true); + res.type = pgadminUtils.titleize(res.type.replace(/_/g, ' '), true); return res; }, }); @@ -216,8 +217,7 @@ define('misc.dependencies', [ })) { Alertify.pgNotifier( error, xhr, - S(gettext('Error retrieving data from the server: %s')).sprintf( - message || _label).value(), + gettext('Error retrieving data from the server: %s', message || _label), function(msg) { if(msg === 'CRYPTKEY_SET') { self.showDependencies(item, data, node); diff --git a/web/pgadmin/misc/dependents/static/js/dependents.js b/web/pgadmin/misc/dependents/static/js/dependents.js index 1b16305a..ec00d618 100644 --- a/web/pgadmin/misc/dependents/static/js/dependents.js +++ b/web/pgadmin/misc/dependents/static/js/dependents.js @@ -8,9 +8,10 @@ ////////////////////////////////////////////////////////////// define('misc.dependents', [ - 'sources/gettext', 'underscore', 'underscore.string', 'jquery', 'backbone', + 'sources/gettext', 'underscore', 'jquery', 'backbone', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.backgrid', -], function(gettext, _, S, $, Backbone, pgAdmin, pgBrowser, Alertify, Backgrid) { + 'sources/utils', +], function(gettext, _, $, Backbone, pgAdmin, pgBrowser, Alertify, Backgrid, pgadminUtils) { if (pgBrowser.NodeDependents) return pgBrowser.NodeDependents; @@ -52,7 +53,7 @@ define('misc.dependents', [ (node['node_image'] || ('icon-' + res.type))) : ('icon-' + res.type); } - res.type = S.titleize(res.type.replace(/_/g, ' '), true); + res.type = pgadminUtils.titleize(res.type.replace(/_/g, ' '), true); return res; }, }); @@ -222,8 +223,7 @@ define('misc.dependents', [ })) { Alertify.pgNotifier( error, xhr, - S(gettext('Error retrieving data from the server: %s')).sprintf( - message || _label).value(), + gettext('Error retrieving data from the server: %s', message || _label), function(msg) { if(msg === 'CRYPTKEY_SET') { self.showDependents(item, data, node); diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js index 98cbc41c..77acc5be 100644 --- a/web/pgadmin/misc/file_manager/static/js/utility.js +++ b/web/pgadmin/misc/file_manager/static/js/utility.js @@ -18,10 +18,10 @@ * @copyright Authors */ define([ - 'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs', + 'jquery', 'underscore', 'pgadmin.alertifyjs', 'sources/gettext', 'sources/url_for', 'dropzone', 'sources/pgadmin', 'sources/csrf', 'tablesorter', -], function($, _, S, Alertify, gettext, url_for, Dropzone, pgAdmin, csrfToken) { +], function($, _, Alertify, gettext, url_for, Dropzone, pgAdmin, csrfToken) { /*--------------------------------------------------------- Define functions used for various operations @@ -1394,7 +1394,7 @@ define([ path = path.replace(/\//g, '\\'); } else { path = path.replace(/\\/g, '/'); - if (!S.startsWith(path, '/')) { + if (!path.startsWith('/')) { path = '/' + path; } } @@ -1554,7 +1554,7 @@ define([ $('.storage_dialog #uploader .input-path').val(path); } } else if (!(config.options.platform_type === 'win32') && - (path == '' || !S.startsWith(path, '/'))) { + (path == '' || !path.startsWith('/'))) { path = '/' + path; $('.storage_dialog #uploader .input-path').val(path); } else { diff --git a/web/pgadmin/misc/sql/static/js/sql.js b/web/pgadmin/misc/sql/static/js/sql.js index 47ca67e2..a5167d36 100644 --- a/web/pgadmin/misc/sql/static/js/sql.js +++ b/web/pgadmin/misc/sql/static/js/sql.js @@ -8,9 +8,9 @@ ////////////////////////////////////////////////////////////// define('misc.sql', [ - 'sources/gettext', 'underscore', 'underscore.string', 'jquery', + 'sources/gettext', 'underscore', 'jquery', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs', -], function(gettext, _, S, $, pgAdmin, pgBrowser, Alertify) { +], function(gettext, _, $, pgAdmin, pgBrowser, Alertify) { pgBrowser.ShowNodeSQL = pgBrowser.ShowNodeSQL || {}; @@ -151,9 +151,8 @@ define('misc.sql', [ })) { Alertify.pgNotifier( error, xhr, - S(gettext('Error retrieving the information - %s')).sprintf( - message || _label - ).value(), function(msg) { + gettext('Error retrieving the information - %s', message || _label), + function(msg) { if(msg === 'CRYPTKEY_SET') { ajaxHook(); } else { diff --git a/web/pgadmin/misc/static/explain/js/explain.js b/web/pgadmin/misc/static/explain/js/explain.js index 2f7983c5..8d3ea37a 100644 --- a/web/pgadmin/misc/static/explain/js/explain.js +++ b/web/pgadmin/misc/static/explain/js/explain.js @@ -8,90 +8,94 @@ ////////////////////////////////////////////////////////////// define('pgadmin.misc.explain', [ - 'sources/url_for', 'jquery', 'underscore', 'underscore.string', - 'sources/pgadmin', 'backbone', 'snapsvg', 'explain_statistics', + 'sources/url_for', 'jquery', 'underscore', + 'sources/pgadmin', 'backbone', 'explain_statistics', 'svg_downloader', 'image_maper', -], function(url_for, $, _, S, pgAdmin, Backbone, Snap, StatisticsModel, +], function(url_for, $, _, pgAdmin, Backbone, StatisticsModel, svgDownloader, imageMapper) { pgAdmin = pgAdmin || window.pgAdmin || {}; svgDownloader = svgDownloader.default; var pgBrowser = pgAdmin.Browser; + var Snap = null; - // Snap.svg plug-in to write multitext as image name - Snap.plugin(function(Snap, Element, Paper) { - Paper.prototype.multitext = function(x, y, txt, max_width, attributes) { - var svg = Snap(), - abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', - temp = svg.text(0, 0, abc); + var initSnap = function(snapModule) { + Snap = snapModule; + // Snap.svg plug-in to write multitext as image name + Snap.plugin(function(Snap, Element, Paper) { + Paper.prototype.multitext = function(x, y, txt, max_width, attributes) { + var svg = Snap(), + abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', + temp = svg.text(0, 0, abc); - temp.attr(attributes); + temp.attr(attributes); - /* - * Find letter width in pixels and - * index from where the text should be broken - */ - var letter_width = temp.getBBox().width / abc.length, - word_break_index = Math.round((max_width / letter_width)) - 1; - - svg.remove(); - - var words = txt.split(' '), - width_so_far = 0, - lines = [], - curr_line = '', /* - * Function to divide string into multiple lines - * and store them in an array if it size crosses - * the max-width boundary. + * Find letter width in pixels and + * index from where the text should be broken */ - splitTextInMultiLine = function(leading, so_far, line) { - var l = line.length, - res = []; - - if (l == 0) - return res; - - if (so_far && (so_far + (l * letter_width) > max_width)) { - res.push(leading); - res = res.concat(splitTextInMultiLine('', 0, line)); - } else if (so_far) { - res.push(leading + ' ' + line); - } else { - if (leading) + var letter_width = temp.getBBox().width / abc.length, + word_break_index = Math.round((max_width / letter_width)) - 1; + + svg.remove(); + + var words = txt.split(' '), + width_so_far = 0, + lines = [], + curr_line = '', + /* + * Function to divide string into multiple lines + * and store them in an array if it size crosses + * the max-width boundary. + */ + splitTextInMultiLine = function(leading, so_far, line) { + var l = line.length, + res = []; + + if (l == 0) + return res; + + if (so_far && (so_far + (l * letter_width) > max_width)) { res.push(leading); - if (line.length > word_break_index + 1) - res.push(line.slice(0, word_break_index) + '-'); - else - res.push(line); - res = res.concat(splitTextInMultiLine('', 0, line.slice(word_break_index))); - } + res = res.concat(splitTextInMultiLine('', 0, line)); + } else if (so_far) { + res.push(leading + ' ' + line); + } else { + if (leading) + res.push(leading); + if (line.length > word_break_index + 1) + res.push(line.slice(0, word_break_index) + '-'); + else + res.push(line); + res = res.concat(splitTextInMultiLine('', 0, line.slice(word_break_index))); + } - return res; - }; + return res; + }; - for (var i = 0; i < words.length; i++) { - var tmpArr = splitTextInMultiLine( - curr_line, width_so_far, words[i] - ); + for (var i = 0; i < words.length; i++) { + var tmpArr = splitTextInMultiLine( + curr_line, width_so_far, words[i] + ); - if (curr_line) { - lines = lines.slice(0, lines.length - 1); + if (curr_line) { + lines = lines.slice(0, lines.length - 1); + } + lines = lines.concat(tmpArr); + curr_line = lines[lines.length - 1]; + width_so_far = (curr_line.length * letter_width); } - lines = lines.concat(tmpArr); - curr_line = lines[lines.length - 1]; - width_so_far = (curr_line.length * letter_width); - } - // Create multiple tspan for each string in array - var t = this.text(x, y, lines).attr(attributes); - t.selectAll('tspan:nth-child(n+2)').attr({ - dy: '1.2em', - x: x, - }); - return t; - }; - }); + // Create multiple tspan for each string in array + var t = this.text(x, y, lines).attr(attributes); + t.selectAll('tspan:nth-child(n+2)').attr({ + dy: '1.2em', + x: x, + }); + return t; + }; + }); + }; if (pgAdmin.Explain) return pgAdmin.Explain; @@ -161,7 +165,7 @@ define('pgadmin.misc.explain', [ ypos += yMargin; } - if (S.startsWith(node_type, '(slice')) + if (node_type.startsWith('(slice')) node_type = node_type.substring(0, 7); // Get the image information for current node @@ -494,7 +498,7 @@ define('pgadmin.misc.explain', [ ypos += yMargin; } - if (S.startsWith(node_type, '(slice')) + if (node_type.startsWith(node_type, '(slice')) node_type = node_type.substring(0, 7); // Get the image information for current node let imageStore = imageMapper.default; @@ -769,8 +773,21 @@ define('pgadmin.misc.explain', [ // Parse and draw full graphical explain _.extend(pgExplain, { - // Assumption container is a jQuery object + DrawJSONPlan: function(container, plan, isDownload) { + let self = this; + require.ensure(['snapsvg'], function(require) { + var module = require('snapsvg'); + initSnap(module); + self.goForDraw(container, plan, isDownload); + }, function(error){ + throw(error); + }, 'snapsvg'); + }, + + // Assumption container is a jQuery object + goForDraw: function(container, plan, isDownload) { + pgExplain.totalNodes = 0; pgExplain.totalDownloadedNodes = 0; pgExplain.isDownloaded = false; diff --git a/web/pgadmin/misc/static/explain/js/image_maper.js b/web/pgadmin/misc/static/explain/js/image_maper.js index 3a66653e..babd2a63 100644 --- a/web/pgadmin/misc/static/explain/js/image_maper.js +++ b/web/pgadmin/misc/static/explain/js/image_maper.js @@ -7,7 +7,6 @@ // ////////////////////////////////////////////////////////////// -import S from 'underscore.string'; /* * A map which is used to fetch the image to be drawn and * text which will appear below it @@ -223,7 +222,7 @@ let imageMapper = { command = data['Command']; if (strategy == 'Hashed') { - if (S.startsWith(command, 'Intersect')) { + if (command.startsWith('Intersect')) { if (command == 'Intersect All') return { 'image': 'ex_hash_setop_intersect_all.svg', @@ -233,7 +232,7 @@ let imageMapper = { 'image': 'ex_hash_setop_intersect.svg', 'image_text': 'Hashed Intersect', }; - } else if (S.startsWith(command, 'Except')) { + } else if (command.startsWith('Except')) { if (command == 'Except All') return { 'image': 'ex_hash_setop_except_all.svg', diff --git a/web/pgadmin/misc/statistics/static/js/statistics.js b/web/pgadmin/misc/statistics/static/js/statistics.js index d4c062d4..101ebd5f 100644 --- a/web/pgadmin/misc/statistics/static/js/statistics.js +++ b/web/pgadmin/misc/statistics/static/js/statistics.js @@ -8,11 +8,11 @@ ////////////////////////////////////////////////////////////// define('misc.statistics', [ - 'sources/gettext', 'underscore', 'underscore.string', 'jquery', 'backbone', + 'sources/gettext', 'underscore', 'jquery', 'backbone', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.backgrid', 'alertify', 'sources/size_prettify', 'sources/misc/statistics/statistics', ], function( - gettext, _, S, $, Backbone, pgAdmin, pgBrowser, Backgrid, Alertify, sizePrettify, + gettext, _, $, Backbone, pgAdmin, pgBrowser, Backgrid, Alertify, sizePrettify, statisticsHelper ) { @@ -315,9 +315,8 @@ define('misc.statistics', [ })) { Alertify.pgNotifier( error, xhr, - S(gettext('Error retrieving the information - %s')).sprintf( - message || _label - ).value(), function(msg) { + gettext('Error retrieving the information - %s', message || _label), + function(msg) { if(msg === 'CRYPTKEY_SET') { ajaxHook(); } else { diff --git a/web/pgadmin/static/bundle/app.js b/web/pgadmin/static/bundle/app.js index 68f8a3b1..71034c93 100644 --- a/web/pgadmin/static/bundle/app.js +++ b/web/pgadmin/static/bundle/app.js @@ -8,8 +8,8 @@ ////////////////////////////////////////////////////////////// define('app', [ - 'babel-polyfill', 'sources/pgadmin', 'bundled_browser', 'pgadmin.datagrid', -], function(babelPolyFill, pgAdmin) { + 'sources/pgadmin', 'bundled_browser', 'pgadmin.datagrid', +], function(pgAdmin) { var initializeModules = function(Object) { for (var key in Object) { var module = Object[key]; diff --git a/web/pgadmin/static/bundle/slickgrid.js b/web/pgadmin/static/bundle/slickgrid.js index 34fe1413..731b4202 100644 --- a/web/pgadmin/static/bundle/slickgrid.js +++ b/web/pgadmin/static/bundle/slickgrid.js @@ -20,4 +20,3 @@ import 'slickgrid/plugins/slick.cellrangeselector'; import 'sources/slickgrid/custom_header_buttons'; export default window.Slick; - diff --git a/web/pgadmin/static/css/alertify.noanimation.css b/web/pgadmin/static/css/alertify.noanimation.css deleted file mode 100644 index 6d7589a9..00000000 --- a/web/pgadmin/static/css/alertify.noanimation.css +++ /dev/null @@ -1,41 +0,0 @@ -.alertify .ajs-dimmer, -.alertify .ajs-modal, -.alertify-notifier, -.alertify-notifier .ajs-message.ajs-visible, -.alertify-notifier .ajs-message, -.alertify-notifier.ajs-center .ajs-message.ajs-visible, -.alertify-notifier.ajs-center .ajs-message -{ - -moz-transition: none; - -webkit-transition: none; - -o-transition: none; - transition: none; - -webkit-transform: none; - transform: none; -} - -.alertify.ajs-zoom.ajs-in:not(.ajs-hidden) .ajs-dialog { - -webkit-animation-name: ajs-zoomIn; - animation-name: ajs-zoomIn; -} -.alertify.ajs-zoom.ajs-out.ajs-hidden .ajs-dialog { - -webkit-animation-name: ajs-zoomOut; - animation-name: ajs-zoomOut; -} - -@-webkit-keyframes ajs-zoomIn { - -webkit-transform: none; - transform: none; -} -@keyframes ajs-zoomIn { - -webkit-transform: none; - transform: none; -} -@-webkit-keyframes ajs-zoomOut { - -webkit-transform: none; - transform: none; -} -@keyframes ajs-zoomeOut { - -webkit-transform: none; - transform: none; -} diff --git a/web/pgadmin/static/css/pgadmin.css b/web/pgadmin/static/css/pgadmin.css index 676e933c..fe48add2 100644 --- a/web/pgadmin/static/css/pgadmin.css +++ b/web/pgadmin/static/css/pgadmin.css @@ -1,39 +1,3 @@ -@font-face { - font-family: "Open Sans"; - src: url("~top/static/fonts/OpenSans-Regular.ttf") format("truetype"); - speak: none; - font-style: normal; - font-weight: normal; - font-variant: normal; - text-transform: none; - line-height: 1; - -webkit-font-smoothing: antialiased; -} - -@font-face { - font-family: "Open Sans Semibold"; - src: url("~top/static/fonts/OpenSans-SemiBold.ttf") format("truetype"); - speak: none; - font-style: normal; - font-weight: normal; - font-variant: normal; - text-transform: none; - line-height: 1; - -webkit-font-smoothing: antialiased; -} - -@font-face { - font-family: "Open Sans Bold"; - src: url("~top/static/fonts/OpenSans-Bold.ttf") format("truetype"); - speak: none; - font-style: normal; - font-weight: normal; - font-variant: normal; - text-transform: none; - line-height: 1; - -webkit-font-smoothing: antialiased; -} - @font-face { font-family: "Source Code Pro"; src: url("~top/static/fonts/SourceCodePro-Regular.ttf") format("truetype"); @@ -43,6 +7,7 @@ font-variant: normal; text-transform: none; line-height: 1; + font-display: swap; -webkit-font-smoothing: antialiased; } @@ -55,6 +20,7 @@ font-variant: normal; text-transform: none; line-height: 1; + font-display: swap; -webkit-font-smoothing: antialiased; } @@ -67,6 +33,7 @@ font-variant: normal; text-transform: none; line-height: 1; + font-display: swap; -webkit-font-smoothing: antialiased; } diff --git a/web/pgadmin/static/css/style.css b/web/pgadmin/static/css/style.css index e7293d47..26b8dfc4 100644 --- a/web/pgadmin/static/css/style.css +++ b/web/pgadmin/static/css/style.css @@ -6,7 +6,6 @@ @import '~bootstrap4-toggle/css/bootstrap4-toggle.css'; @import '~backgrid-select-all/backgrid-select-all.css'; @import '~backgrid-filter/backgrid-filter.css'; -@import '~backgrid-sizeable-columns/backgrid-sizeable-columns.css'; @import '~slickgrid/css/select2.css'; @import '~jquery-contextmenu/dist/jquery.contextMenu.css'; @import '~webcabin-docker/Build/wcDocker.css'; @@ -21,3 +20,5 @@ @import '~slickgrid/slick.grid.css'; @import '~slickgrid/slick-default-theme.css'; @import '~slickgrid/css/smoothness/jquery-ui-1.11.3.custom.css'; + +@import '../vendor/backgrid/backgrid.css'; diff --git a/web/pgadmin/static/js/alertify/dialog.js b/web/pgadmin/static/js/alertify/dialog.js index fa1100b1..e67c3dbe 100644 --- a/web/pgadmin/static/js/alertify/dialog.js +++ b/web/pgadmin/static/js/alertify/dialog.js @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////// import gettext from '../gettext'; -import {sprintf} from 'sprintf-js'; +import {sprintf} from 'sources/utils'; import {DialogFactory} from './dialog_factory'; import Backform from '../backform.pgadmin'; import {getTreeNodeHierarchyFromIdentifier} from '../tree/pgadmin_tree_node'; diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js index 559a4dd5..4568f0f5 100644 --- a/web/pgadmin/static/js/backform.pgadmin.js +++ b/web/pgadmin/static/js/backform.pgadmin.js @@ -8,11 +8,11 @@ ////////////////////////////////////////////////////////////// define([ - 'sources/gettext', 'underscore', 'underscore.string', 'jquery', + 'sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', 'backgrid', 'codemirror', 'sources/sqleditor_utils', 'sources/keyboard_shortcuts', 'sources/window', 'spectrum', 'pgadmin.backgrid', 'select2', 'bootstrap.toggle', -], function(gettext, _, S, $, Backbone, Backform, Backgrid, CodeMirror, +], function(gettext, _, $, Backbone, Backform, Backgrid, CodeMirror, SqlEditorUtils, keyboardShortcuts, pgWindow) { var pgAdmin = (window.pgAdmin = window.pgAdmin || {}), diff --git a/web/pgadmin/static/js/check_node_visibility.js b/web/pgadmin/static/js/check_node_visibility.js index 4253a35e..c172a6e8 100644 --- a/web/pgadmin/static/js/check_node_visibility.js +++ b/web/pgadmin/static/js/check_node_visibility.js @@ -7,8 +7,8 @@ // ////////////////////////////////////////////////////////////////////////// -define(['jquery', 'underscore', 'underscore.string'], - function ($, _, S) { +define(['jquery', 'underscore'], + function ($, _) { var check_node_visibility = function (pgBrowser, node_type) { if(_.isUndefined(node_type) || _.isNull(node_type)) { @@ -18,7 +18,7 @@ define(['jquery', 'underscore', 'underscore.string'], // Target actual node instead of collection. // If node is disabled then there is no meaning of // adding collection node menu - if(S.startsWith(node_type, 'coll-')) { + if(node_type.startsWith('coll-')) { node_type = node_type.replace('coll-', ''); } diff --git a/web/pgadmin/static/js/gettext.js b/web/pgadmin/static/js/gettext.js index e3df9562..bb3b15ac 100644 --- a/web/pgadmin/static/js/gettext.js +++ b/web/pgadmin/static/js/gettext.js @@ -12,30 +12,32 @@ define(['translations'], function (translations) { /*** * This method behaves as a drop-in replacement for flask translation rendering. * It uses the same translation file under the hood and uses flask to determine the language. - * - * ex. translate("some %(adjective)s text", {adjective: "cool"}) + * It is slightly tweaked to work like sprintf + * ex. translate("some %s text", "cool") * * @param {String} text - * @param {Object} substitutions */ - return function gettext(text, substitutions) { + return function gettext(text) { var rawTranslation = translations[text] ? translations[text] : text; - // captures things of the form %(substitutionName)s - var substitutionGroupsRegExp = /([^%]*)%\(([^\)]+)\)s(.*)/; - var matchFound; - - var interpolated = rawTranslation; - do { - matchFound = false; - interpolated = interpolated.replace(substitutionGroupsRegExp, function (_, textBeginning, substitutionName, textEnd) { - matchFound = true; - return textBeginning + substitutions[substitutionName] + textEnd; - }); - } while (matchFound); - - return interpolated; + try { + return rawTranslation.split('%s') + .map(function(w, i) { + if(i > 0) { + if(arguments[i]) { + return [arguments[i], w].join(''); + } else { + return ['%s', w].join(''); + } + } else { + return w; + } + }) + .join(''); + } catch(e) { + console.error(e); + return rawTranslation; + } }; - -}); \ No newline at end of file +}); diff --git a/web/pgadmin/static/js/keyboard_shortcuts.js b/web/pgadmin/static/js/keyboard_shortcuts.js index b0c92634..69590051 100644 --- a/web/pgadmin/static/js/keyboard_shortcuts.js +++ b/web/pgadmin/static/js/keyboard_shortcuts.js @@ -80,20 +80,14 @@ function shortcut_title(title, shortcut) { } text_representation += shortcut_key(shortcut); - return gettext('%(title)s (%(text_representation)s)',{ - 'title': title, - 'text_representation': text_representation, - }); + return `${title} (${text_representation})`; } /* Returns the key char of shortcut * shortcut object is browser.get_preference().value */ function shortcut_accesskey_title(title, shortcut) { - return gettext('%(title)s (accesskey + %(key)s)',{ - 'title': title, - 'key': shortcut_key(shortcut), - }); + return `${title} (${gettext('accesskey')} + ${shortcut_key(shortcut)})`; } diff --git a/web/pgadmin/static/js/modify_animation.js b/web/pgadmin/static/js/modify_animation.js index 8852ecd0..f0e4494d 100644 --- a/web/pgadmin/static/js/modify_animation.js +++ b/web/pgadmin/static/js/modify_animation.js @@ -53,18 +53,14 @@ function modifyAlertifyAnimation(pgBrowser) { ).value; if(enableAcitreeAnimation) { - $(document).find('link#alertify-no-animation') - .attr('disabled', 'disabled'); + $(document).find('body').removeClass('alertify-no-animation'); _.each(document.getElementsByTagName('iframe'), function(frame) { - $(frame.contentDocument).find('link#alertify-no-animation') - .attr('disabled', 'disabled'); + $(frame.contentDocument).find('body').removeClass('alertify-no-animation'); }); } else { - $(document).find('link#alertify-no-animation') - .removeAttr('disabled', 'disabled'); + $(document).find('body').addClass('alertify-no-animation'); _.each(document.getElementsByTagName('iframe'), function(frame) { - $(frame.contentDocument).find('link#alertify-no-animation') - .removeAttr('disabled', 'disabled'); + $(frame.contentDocument).find('body').addClass('alertify-no-animation'); }); } } diff --git a/web/pgadmin/static/js/sqleditor/call_render_after_poll.js b/web/pgadmin/static/js/sqleditor/call_render_after_poll.js index ec18b10b..c3d21730 100644 --- a/web/pgadmin/static/js/sqleditor/call_render_after_poll.js +++ b/web/pgadmin/static/js/sqleditor/call_render_after_poll.js @@ -9,7 +9,7 @@ import {calculateQueryRunTime} from './calculate_query_run_time'; import gettext from '../gettext'; -import {sprintf} from 'sprintf-js'; +import {sprintf} from 'sources/utils'; function hasResultsToDisplay(res) { return res.colinfo != null; diff --git a/web/pgadmin/static/js/sqleditor/geometry_viewer.js b/web/pgadmin/static/js/sqleditor/geometry_viewer.js index bd07d070..559f66f3 100644 --- a/web/pgadmin/static/js/sqleditor/geometry_viewer.js +++ b/web/pgadmin/static/js/sqleditor/geometry_viewer.js @@ -8,16 +8,17 @@ ////////////////////////////////////////////////////////////// import gettext from 'sources/gettext'; -import {Geometry} from 'wkx'; import {Buffer} from 'buffer'; -import L from 'leaflet'; import $ from 'jquery'; +var L = null; +var Geometry = null; let GeometryViewer = { panel_closed: true, - render_geometries: function (handler, items, columns, columnIndex) { + go_for_render: function(handler, items, columns, columnIndex) { let self = this; + if (!self.map_component) { self.map_component = initMapComponent(); } @@ -53,10 +54,21 @@ let GeometryViewer = { handler.gridView.geometry_viewer.focus(); self.map_component.clearMap(); - let dataObj = parseData(items, columns, columnIndex); + let dataObj = parseData(items, columns, columnIndex, Geometry); self.map_component.renderMap(dataObj); }, + render_geometries: function (handler, items, columns, columnIndex) { + let self = this; + require.ensure(['leaflet', 'wkx'], function(require) { + L = require('leaflet'); + Geometry = require('wkx').Geometry; + self.go_for_render(handler, items, columns, columnIndex); + }, function(error){ + throw(error); + }, 'geometry'); + }, + add_header_button: function (columnDefinition) { columnDefinition.header = { buttons: [ @@ -275,7 +287,7 @@ function initMapComponent() { }; } -function parseData(items, columns, columnIndex) { +function parseData(items, columns, columnIndex, GeometryLib) { const maxRenderByteLength = 20 * 1024 * 1024; //render geometry data up to 20MB const maxRenderGeometries = 100000; // render geometries up to 100000 let field = columns[columnIndex].field; @@ -304,7 +316,7 @@ function parseData(items, columns, columnIndex) { try { let value = item[field]; let buffer = Buffer.from(value, 'hex'); - let geometry = Geometry.parse(buffer); + let geometry = GeometryLib.parse(buffer); if (geometry.hasZ) { geometries3D.push(geometry); } else { diff --git a/web/pgadmin/static/js/utils.js b/web/pgadmin/static/js/utils.js index 1f15858d..645a415a 100644 --- a/web/pgadmin/static/js/utils.js +++ b/web/pgadmin/static/js/utils.js @@ -205,3 +205,30 @@ export function getRandomInt(min, max) { max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } + +export function titleize(i_str) { + return i_str.split(' ') + .map(w => w[0].toUpperCase() + w.substr(1).toLowerCase()) + .join(' '); +} + +export function sprintf(i_str) { + try { + return i_str.split('%s') + .map((w, i) => { + if(i > 0) { + if(arguments[i]) { + return [arguments[i], w].join(''); + } else { + return ['%s', w].join(''); + } + } else { + return w; + } + }) + .join(''); + } catch(e) { + console.error(e); + return i_str; + } +} diff --git a/web/pgadmin/static/scss/_alertify.overrides.scss b/web/pgadmin/static/scss/_alertify.overrides.scss index d43becd5..0c579dd6 100644 --- a/web/pgadmin/static/scss/_alertify.overrides.scss +++ b/web/pgadmin/static/scss/_alertify.overrides.scss @@ -234,3 +234,39 @@ .alertify .ajs-dialog.ajs-capture:before { display: none; } + +.alertify-no-animation { + .alertify .ajs-dimmer, + .alertify .ajs-modal, + .alertify-notifier, + .alertify-notifier .ajs-message.ajs-visible, + .alertify-notifier .ajs-message, + .alertify-notifier.ajs-center .ajs-message.ajs-visible, + .alertify-notifier.ajs-center .ajs-message + { + -moz-transition: none; + -webkit-transition: none; + -o-transition: none; + transition: none; + -webkit-transform: none; + transform: none; + } + + .alertify.ajs-zoom.ajs-in:not(.ajs-hidden) .ajs-dialog { + -webkit-animation-name: ajs-noanimate; + animation-name: ajs-noanimate; + } + .alertify.ajs-zoom.ajs-out.ajs-hidden .ajs-dialog { + -webkit-animation-name: ajs-noanimate; + animation-name: ajs-noanimate; + } + + @-webkit-keyframes ajs-noanimate { + -webkit-transform: none; + transform: none; + } + @keyframes ajs-noanimate { + -webkit-transform: none; + transform: none; + } +} diff --git a/web/pgadmin/static/vendor/backgrid/backgrid.css b/web/pgadmin/static/vendor/backgrid/backgrid.css index c4298e22..a8cef8c3 100644 --- a/web/pgadmin/static/vendor/backgrid/backgrid.css +++ b/web/pgadmin/static/vendor/backgrid/backgrid.css @@ -1,8 +1,8 @@ /* backgrid - http://github.com/wyuenho/backgrid + http://github.com/cloudflare/backgrid - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present Cloudflare, Inc. and contributors Licensed under the MIT license. */ @@ -233,4 +233,4 @@ .backgrid .select-cell.editor optgroup::-o-focus-inner, .backgrid .select-cell.editor option::-o-focus-inner { border: 0; -} \ No newline at end of file +} diff --git a/web/pgadmin/static/vendor/backgrid/backgrid.js b/web/pgadmin/static/vendor/backgrid/backgrid.js index 963ddca2..b250ebee 100644 --- a/web/pgadmin/static/vendor/backgrid/backgrid.js +++ b/web/pgadmin/static/vendor/backgrid/backgrid.js @@ -1,39 +1,33 @@ -///////////////////////////////////////////////////////////// -// -// pgAdmin 4 - PostgreSQL Tools -// -// Copyright (C) 2013 - 2019, The pgAdmin Development Team -// This software is released under the PostgreSQL Licence -// -////////////////////////////////////////////////////////////// - /*! - backgrid - http://github.com/wyuenho/backgrid + backgrid 0.3.8 + http://github.com/cloudflare/backgrid - Copyright (c) 2014 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2017 Cloudflare, Inc. and contributors Licensed under the MIT license. */ -(function (factory) { +(function (root, factory) { - // CommonJS - if (typeof exports == "object") { - module.exports = factory(module.exports, - require("underscore"), - require("backbone")); - } - // Browser - else factory(this, this._, this.Backbone); -}(function (root, _, Backbone) { + if (typeof define === "function" && define.amd) { + // AMD (+ global for extensions) + define(["underscore", "backbone"], function (_, Backbone) { + return (root.Backgrid = factory(_, Backbone)); + }); + } else if (typeof exports === "object") { + // CommonJS + module.exports = factory(require("underscore"), require("backbone")); + } else { + // Browser + root.Backgrid = factory(root._, root.Backbone); + }}(this, function (_, Backbone) { "use strict"; /* backgrid - http://github.com/wyuenho/backgrid + http://github.com/cloudflare/backgrid - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present Cloudflare, Inc. and contributors Licensed under the MIT license. */ @@ -72,7 +66,7 @@ function lpad(str, length, padstr) { var $ = Backbone.$; -var Backgrid = root.Backgrid = { +var Backgrid = { Extension: {}, @@ -180,9 +174,9 @@ _.extend(Command.prototype, { /* backgrid - http://github.com/wyuenho/backgrid + http://github.com/cloudflare/backgrid - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present Cloudflare, Inc. and contributors Licensed under the MIT license. */ @@ -285,7 +279,7 @@ _.extend(NumberFormatter.prototype, { fromRaw: function (number, model) { if (_.isNull(number) || _.isUndefined(number)) return ''; - number = number.toFixed(~~this.decimals); + number = parseFloat(number).toFixed(~~this.decimals); var parts = number.split('.'); var integerPart = parts[0]; @@ -625,9 +619,9 @@ _.extend(SelectFormatter.prototype, { /* backgrid - http://github.com/wyuenho/backgrid + http://github.com/cloudflare/backgrid - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present Cloudflare, Inc. and contributors Licensed under the MIT license. */ @@ -873,9 +867,16 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ } }); - if (Backgrid.callByNeed(column.editable(), column, model)) $el.addClass("editable"); - if (Backgrid.callByNeed(column.sortable(), column, model)) $el.addClass("sortable"); - if (Backgrid.callByNeed(column.renderable(), column, model)) $el.addClass("renderable"); + this.updateStateClassesMaybe(); + }, + + updateStateClassesMaybe: function () { + var model = this.model; + var column = this.column; + var $el = this.$el; + $el.toggleClass("editable", Backgrid.callByNeed(column.editable(), column, model)); + $el.toggleClass("sortable", Backgrid.callByNeed(column.sortable(), column, model)); + $el.toggleClass("renderable", Backgrid.callByNeed(column.renderable(), column, model)); }, /** @@ -883,9 +884,13 @@ var Cell = Backgrid.Cell = Backbone.View.extend({ model's raw value for this cell's column. */ render: function () { - this.$el.empty(); + var $el = this.$el; + $el.empty(); var model = this.model; - this.$el.text(this.formatter.fromRaw(model.get(this.column.get("name")), model)); + var columnName = this.column.get("name"); + $el.text(this.formatter.fromRaw(model.get(columnName), model)); + $el.addClass(columnName); + this.updateStateClassesMaybe(); this.delegateEvents(); return this; }, @@ -1408,7 +1413,15 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({ }, /** @property {function(Object, ?Object=): string} template */ - template: _.template('', null, {variable: null}), + template: _.template( + '', + null, + { + variable : null, + evaluate : /<%([\s\S]+?)%>/g, + interpolate : /<%=([\s\S]+?)%>/g, + escape : /<%-([\s\S]+?)%>/g + }), setOptionValues: function (optionValues) { this.optionValues = optionValues; @@ -1651,9 +1664,9 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({ /* backgrid - http://github.com/wyuenho/backgrid + http://github.com/cloudflare/backgrid - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present Cloudflare, Inc. and contributors Licensed under the MIT license. */ @@ -1706,19 +1719,20 @@ var Column = Backgrid.Column = Backbone.Model.extend({ this column is sortable. If the value is a string, a method will the same name will be looked up from the column instance to determine whether the column should be sortable. The method's signature must be `function - (Backgrid.Column, Backbone.Model): boolean`. + (Backbone.Model): boolean`. The function's context is the column instance. @cfg {boolean|string|function(): boolean} [defaults.editable=true] Whether this column is editable. If the value is a string, a method will the same name will be looked up from the column instance to determine whether the column should be editable. The method's signature must be `function - (Backgrid.Column, Backbone.Model): boolean`. + (Backbone.Model): boolean`. The function's context is the column instance. @cfg {boolean|string|function(): boolean} [defaults.renderable=true] Whether this column is renderable. If the value is a string, a method will the same name will be looked up from the column instance to determine whether the column should be renderable. The method's signature must be - `function (Backrid.Column, Backbone.Model): boolean`. + `function (Backbone.Model): boolean`. The function's context is the column + instance. @cfg {Backgrid.CellFormatter | Object | string} [defaults.formatter] The formatter to use to convert between raw model values and user input. @@ -1824,24 +1838,33 @@ var Column = Backgrid.Column = Backbone.Model.extend({ } /** + If you cannot always determine whether a column should be sortable before + the grid get initialized, you can override this method. + @member Backgrid.Column @protected @method sortable - @return {function(Backgrid.Column, Backbone.Model): boolean | boolean} + @return {function(Backbone.Model): boolean | boolean} */ /** + If you cannot always determine whether a column should be editable before + the grid get initialized, you can override this method. + @member Backgrid.Column @protected @method editable - @return {function(Backgrid.Column, Backbone.Model): boolean | boolean} + @return {function(Backbone.Model): boolean | boolean} */ /** + If you cannot always determine whether a column should be renderable before + the grid get initialized, you can override this method. + @member Backgrid.Column @protected @method renderable - @return {function(Backgrid.Column, Backbone.Model): boolean | boolean} + @return {function(Backbone.Model): boolean | boolean} */ }); @@ -1871,9 +1894,9 @@ var Columns = Backgrid.Columns = Backbone.Collection.extend({ /* backgrid - http://github.com/wyuenho/backgrid + http://github.com/cloudflare/backgrid - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present Cloudflare, Inc. and contributors Licensed under the MIT license. */ @@ -2020,7 +2043,9 @@ var EmptyRow = Backgrid.EmptyRow = Backbone.View.extend({ var td = document.createElement("td"); td.setAttribute("colspan", this.columns.length); - td.appendChild(document.createTextNode(_.result(this, "emptyText"))); + var span = document.createElement("span"); + span.innerHTML = _.result(this, "emptyText"); + td.appendChild(span); this.el.className = "empty"; this.el.appendChild(td); @@ -2031,9 +2056,9 @@ var EmptyRow = Backgrid.EmptyRow = Backbone.View.extend({ /* backgrid - http://github.com/wyuenho/backgrid + http://github.com/cloudflare/backgrid - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present Cloudflare, Inc. and contributors Licensed under the MIT license. */ @@ -2052,7 +2077,7 @@ var HeaderCell = Backgrid.HeaderCell = Backbone.View.extend({ /** @property */ events: { - "click a": "onClick" + "click button": "onClick" }, /** @@ -2087,12 +2112,12 @@ var HeaderCell = Backgrid.HeaderCell = Backbone.View.extend({ if (Backgrid.callByNeed(column.sortable(), column, collection)) $el.addClass("sortable"); if (Backgrid.callByNeed(column.renderable(), column, collection)) $el.addClass("renderable"); - this.listenTo(collection.fullCollection || collection, "sort", this.removeCellDirection); + this.listenTo(collection.fullCollection || collection, "backgrid:sorted", this.removeCellDirection); }, /** - Event handler for the collection's `sort` event. Removes all the CSS - direction classes. + Event handler for the collection's `backgrid:sorted` event. Removes + all the CSS direction classes. */ removeCellDirection: function () { this.$el.removeClass("ascending").removeClass("descending"); @@ -2151,7 +2176,7 @@ var HeaderCell = Backgrid.HeaderCell = Backbone.View.extend({ var sortable = Backgrid.callByNeed(column.sortable(), column, this.collection); var label; if(sortable){ - label = $("").text(column.get("label")).append(""); + label = $("