From 71d7b143202ab492eb6b8251169dec5912871fba Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Wed, 22 Sep 2021 13:12:46 +0530 Subject: [PATCH] Remove unused files. --- web/pgadmin/static/js/browser/index.js | 2 - .../static/js/browser/server_groups/index.js | 10 -- .../external_tables/external_tables.js | 88 ----------- .../databases/external_tables/index.js | 18 --- .../server_groups/servers/databases/index.js | 10 -- .../js/browser/server_groups/servers/index.js | 11 -- .../server_groups/servers/model_validation.js | 147 ------------------ 7 files changed, 286 deletions(-) delete mode 100644 web/pgadmin/static/js/browser/server_groups/index.js delete mode 100644 web/pgadmin/static/js/browser/server_groups/servers/databases/external_tables/external_tables.js delete mode 100644 web/pgadmin/static/js/browser/server_groups/servers/databases/external_tables/index.js delete mode 100644 web/pgadmin/static/js/browser/server_groups/servers/databases/index.js delete mode 100644 web/pgadmin/static/js/browser/server_groups/servers/index.js delete mode 100644 web/pgadmin/static/js/browser/server_groups/servers/model_validation.js diff --git a/web/pgadmin/static/js/browser/index.js b/web/pgadmin/static/js/browser/index.js index 86b123a3a..cac68afaa 100644 --- a/web/pgadmin/static/js/browser/index.js +++ b/web/pgadmin/static/js/browser/index.js @@ -6,5 +6,3 @@ // This software is released under the PostgreSQL Licence // ////////////////////////////////////////////////////////////// - -import 'server_groups'; diff --git a/web/pgadmin/static/js/browser/server_groups/index.js b/web/pgadmin/static/js/browser/server_groups/index.js deleted file mode 100644 index 38fd568cc..000000000 --- a/web/pgadmin/static/js/browser/server_groups/index.js +++ /dev/null @@ -1,10 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// pgAdmin 4 - PostgreSQL Tools -// -// Copyright (C) 2013 - 2021, The pgAdmin Development Team -// This software is released under the PostgreSQL Licence -// -////////////////////////////////////////////////////////////// - -import 'servers'; diff --git a/web/pgadmin/static/js/browser/server_groups/servers/databases/external_tables/external_tables.js b/web/pgadmin/static/js/browser/server_groups/servers/databases/external_tables/external_tables.js deleted file mode 100644 index 738f55e7e..000000000 --- a/web/pgadmin/static/js/browser/server_groups/servers/databases/external_tables/external_tables.js +++ /dev/null @@ -1,88 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// pgAdmin 4 - PostgreSQL Tools -// -// Copyright (C) 2013 - 2021, The pgAdmin Development Team -// This software is released under the PostgreSQL Licence -// -////////////////////////////////////////////////////////////// - -export function initialize(pgBrowser, gettext) { - if (!pgBrowser.Nodes['coll-external_table']) { - pgBrowser.Nodes['coll-external_table'] = - pgBrowser.Collection.extend({ - node: 'external_table', - label: gettext('External Tables'), - type: 'coll-external_tables', - columns: ['name', 'fdwowner', 'description'], - }); - } - - if (!pgBrowser.Nodes['external_table']) { - pgBrowser.Nodes['external_table'] = pgBrowser.Node.extend({ - parent_type: 'database', - type: 'external_table', - label: gettext('External Table'), - collection_type: 'coll-external_table', - hasSQL: true, - model: pgBrowser.Node.Model.extend({ - defaults: { - name: undefined, - type: undefined, - encoding: undefined, - format_type: undefined, - format_option: undefined, - external_options: undefined, - command: undefined, - execute_on: undefined, - }, - schema: [ - { - id: 'name', - label: gettext('Name'), - type: 'text', - mode: ['properties'], - }, { - id: 'type', - label: gettext('Type'), - type: 'text', - mode: ['properties'], - }, { - id: 'encoding', - label: gettext('Encoding'), - type: 'text', - mode: ['properties'], - }, { - id: 'format_type', - label: gettext('Format Type'), - type: 'text', - mode: ['properties'], - }, { - id: 'format_option', - label: gettext('Format Options'), - type: 'text', - mode: ['properties'], - }, { - id: 'external_options', - label: gettext('External Options'), - type: 'text', - mode: ['properties'], - }, { - id: 'command', - label: gettext('Command'), - type: 'text', - mode: ['properties'], - }, { - id: 'execute_on', - label: gettext('Execute on'), - type: 'text', - mode: ['properties'], - }, - ], - }), - }); - } - - return pgBrowser; -} - diff --git a/web/pgadmin/static/js/browser/server_groups/servers/databases/external_tables/index.js b/web/pgadmin/static/js/browser/server_groups/servers/databases/external_tables/index.js deleted file mode 100644 index c7814d18a..000000000 --- a/web/pgadmin/static/js/browser/server_groups/servers/databases/external_tables/index.js +++ /dev/null @@ -1,18 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// pgAdmin 4 - PostgreSQL Tools -// -// Copyright (C) 2013 - 2021, The pgAdmin Development Team -// This software is released under the PostgreSQL Licence -// -////////////////////////////////////////////////////////////// - -import pgBrowser from 'top/browser/static/js/browser'; -import gettext from 'sources/gettext'; -import {initialize} from './external_tables'; - -let pgBrowserOut = initialize(pgBrowser, gettext); - -module.exports = { - pgBrowser: pgBrowserOut, -}; diff --git a/web/pgadmin/static/js/browser/server_groups/servers/databases/index.js b/web/pgadmin/static/js/browser/server_groups/servers/databases/index.js deleted file mode 100644 index 5ed80b594..000000000 --- a/web/pgadmin/static/js/browser/server_groups/servers/databases/index.js +++ /dev/null @@ -1,10 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// pgAdmin 4 - PostgreSQL Tools -// -// Copyright (C) 2013 - 2021, The pgAdmin Development Team -// This software is released under the PostgreSQL Licence -// -////////////////////////////////////////////////////////////// - -import 'external_tables'; diff --git a/web/pgadmin/static/js/browser/server_groups/servers/index.js b/web/pgadmin/static/js/browser/server_groups/servers/index.js deleted file mode 100644 index 470f31c70..000000000 --- a/web/pgadmin/static/js/browser/server_groups/servers/index.js +++ /dev/null @@ -1,11 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// pgAdmin 4 - PostgreSQL Tools -// -// Copyright (C) 2013 - 2021, The pgAdmin Development Team -// This software is released under the PostgreSQL Licence -// -////////////////////////////////////////////////////////////// - -import 'databases'; -import 'model_validation'; diff --git a/web/pgadmin/static/js/browser/server_groups/servers/model_validation.js b/web/pgadmin/static/js/browser/server_groups/servers/model_validation.js deleted file mode 100644 index 9b94a6c83..000000000 --- a/web/pgadmin/static/js/browser/server_groups/servers/model_validation.js +++ /dev/null @@ -1,147 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// pgAdmin 4 - PostgreSQL Tools -// -// Copyright (C) 2013 - 2021, The pgAdmin Development Team -// This software is released under the PostgreSQL Licence -// -////////////////////////////////////////////////////////////// - -import gettext from 'sources/gettext'; -import _ from 'underscore'; -import {Address4, Address6} from 'ip-address'; - -export class ModelValidation { - constructor(model) { - this.err = {}; - this.errmsg = ''; - this.model = model; - } - - validate() { - const serviceId = this.model.get('service'), - pub = this.model.get('pub'); - - if (!this.model.isNew() && 'id' in this.model.sessAttrs) { - this.err['id'] = gettext('The ID cannot be changed.'); - this.errmsg = this.err['id']; - } else { - this.model.errorModel.unset('id'); - } - - this.checkForEmpty('name', gettext('Name must be specified.')); - - if (ModelValidation.isEmptyString(serviceId)) { - // Do not sent empty string - this.setNullValueForEmptyString('service'); - this.checkHostAndHostAddress(); - - this.checkForEmpty('db', gettext('Maintenance database must be specified.')); - this.checkForEmpty('username', gettext('Username must be specified.')); - this.checkForEmpty('port', gettext('Port must be specified.')); - if(!_.isUndefined(pub)){ - this.checkForEmpty('pub', gettext('Publication must be specified.')); - } - } else { - this.checkForEmpty('db', gettext('Maintenance database must be specified.')); - if(!_.isUndefined(pub)){ - this.checkForEmpty('pub', gettext('Publication must be specified.')); - } - this.clearHostAddressAndDbErrors(); - } - - if (this.model.get('use_ssh_tunnel')) { - this.checkForEmpty('tunnel_host', gettext('SSH Tunnel host must be specified.')); - this.checkForEmpty('tunnel_port', gettext('SSH Tunnel port must be specified.')); - this.checkForEmpty('tunnel_username', gettext('SSH Tunnel username must be specified.')); - if (this.model.get('tunnel_authentication')) { - this.checkForEmpty('tunnel_identity_file', gettext('SSH Tunnel identity file must be specified.')); - } - } - - this.model.errorModel.set(this.err); - - if (_.size(this.err)) { - return this.errmsg; - } - - return null; - } - - setNullValueForEmptyString(field) { - let val = this.model.get(field); - if (_.isUndefined(val) || _.isNull(val)) - return; - - // To avoid passing empty string to connection parameter - if(String(val).trim() === '') { - this.model.set(field, null); - } - } - - clearHostAddressAndDbErrors() { - _.each(['host', 'hostaddr', 'db', 'username', 'port'], (item) => { - this.setNullValueForEmptyString(item); - this.model.errorModel.unset(item); - }); - } - - checkHostAndHostAddress() { - - let pub = this.model.get('pub'), - errmsg; - if(!_.isUndefined(pub)){ - errmsg = gettext('Host name, Address must ' + - 'be specified.'); - }else{ - errmsg = gettext('Either Host name, Address or Service must ' + - 'be specified.'); - } - const translatedStr = errmsg; - if (this.checkForEmpty('host', translatedStr) && - this.checkForEmpty('hostaddr', translatedStr)) { - this.errmsg = this.errmsg || translatedStr; - } else { - this.errmsg = undefined; - delete this.err['host']; - delete this.err['hostaddr']; - } - - this.checkForValidIp(this.model.get('hostaddr'), - gettext('Host address must be valid IPv4 or IPv6 address.')); - } - - checkForValidIp(ipAddress, msg) { - if (ipAddress) { - try { - new Address4(ipAddress); - } catch(e) { - try { - new Address6(ipAddress); - } catch(ex) { - this.err['hostaddr'] = msg; - this.errmsg = msg; - } - } - } else { - this.model.errorModel.unset('hostaddr'); - } - } - - checkForEmpty(id, msg) { - const value = this.model.get(id); - - if (ModelValidation.isEmptyString(value)) { - this.err[id] = msg; - this.errmsg = this.errmsg || msg; - return true; - } else { - this.model.errorModel.unset(id); - return false; - } - } - - static isEmptyString(string) { - return _.isUndefined(string) || _.isNull(string) || String(string).trim() === ''; - } -}