Fixed SonarQube issues.

This commit is contained in:
Akshay Joshi
2022-09-08 18:08:58 +05:30
parent 603ce21d24
commit 7086719640
129 changed files with 945 additions and 981 deletions

View File

@@ -16,7 +16,7 @@ define([
'pgadmin.browser.node', 'backgrid.select.all',
], function(gettext, pgAdmin, generateUrl) {
var pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
let pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
// It has already been defined.
// Avoid running this script again.
@@ -103,17 +103,17 @@ define([
* Using list, and collection functions of a node to get the nodes
* under the collection, and properties of the collection respectively.
*/
var opURL = {
let opURL = {
'properties': 'obj',
'children': 'nodes',
'drop': 'obj',
},
self = this;
var collectionPickFunction = function (treeInfoValue, treeInfoKey) {
let collectionPickFunction = function (treeInfoValue, treeInfoKey) {
return (treeInfoKey != self.type);
};
var treeInfo = pgBrowser.tree.getTreeNodeHierarchy(item);
var actionType = type in opURL ? opURL[type] : type;
let treeInfo = pgBrowser.tree.getTreeNodeHierarchy(item);
let actionType = type in opURL ? opURL[type] : type;
return generateUrl.generate_url(
pgAdmin.Browser.URL, treeInfo, actionType, self.node,
collectionPickFunction
@@ -130,7 +130,7 @@ define([
}
},
show_psql_tool: function(args) {
var input = args || {},
let input = args || {},
t = pgBrowser.tree,
i = input.item || t.selected(),
d = i ? t.itemData(i) : undefined;

View File

@@ -11,7 +11,7 @@ import _ from 'lodash';
define([
'sources/pgadmin', 'jquery', 'backbone', 'sources/utils',
], function(pgAdmin, $, Backbone, pgadminUtils) {
var pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
let pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
pgBrowser.DataModel = Backbone.Model.extend({
/*
@@ -19,15 +19,15 @@ define([
*/
on_server: false,
parse: function(res) {
var self = this;
let self = this;
if (res && _.isObject(res) && 'node' in res && res['node']) {
self.tnode = _.extend({}, res.node);
delete res.node;
}
var objectOp = function(schema) {
let objectOp = function(schema) {
if (schema && _.isArray(schema)) {
_.each(schema, function(s) {
var obj, val;
let obj, val;
switch (s.type) {
case 'collection':
obj = self.get(s.id);
@@ -132,7 +132,7 @@ define([
},
primary_key: function() {
if (this.keys && _.isArray(this.keys)) {
var res = {},
let res = {},
self = this;
_.each(self.keys, function(k) {
@@ -144,7 +144,7 @@ define([
return this.cid;
},
initialize: function(attributes, options) {
var self = this;
let self = this;
self._previous_key_values = {};
if (!_.isUndefined(options) && 'on_server' in options && options.on_server) {
@@ -170,8 +170,8 @@ define([
self.errorModel = new Backbone.Model();
self.node_info = options.node_info;
var obj;
var objectOp = function(schema) {
let obj;
let objectOp = function(schema) {
if (schema && _.isArray(schema)) {
_.each(schema, function(s) {
@@ -204,7 +204,7 @@ define([
if (!obj || !(obj instanceof pgBrowser.Node.Collection)) {
if (_.isString(s.model) &&
s.model in pgBrowser.Nodes) {
var node = pgBrowser.Nodes[s.model];
let node = pgBrowser.Nodes[s.model];
obj = new(node.Collection)(obj, {
model: node.model,
top: self.top || self,
@@ -283,7 +283,7 @@ define([
},
// Create a reset function, which allow us to remove the nested object.
reset: function(opts) {
var obj,
let obj,
reindex = !!(opts && opts.reindex);
if (opts && opts.stop)
@@ -294,7 +294,7 @@ define([
return;
}
for (var id in this.objects) {
for (let id in this.objects) {
obj = this.get(id);
if (obj) {
@@ -318,11 +318,11 @@ define([
Backbone.Collection.prototype.reset.apply(this, arguments);
},
sessChanged: function() {
var self = this;
let self = this;
return (_.size(self.sessAttrs) > 0 ||
_.some(self.objects, function(k) {
var obj = self.get(k);
let obj = self.get(k);
if (!(_.isNull(obj) || _.isUndefined(obj))) {
return obj.sessChanged();
}
@@ -330,7 +330,7 @@ define([
}));
},
sessValid: function() {
var self = this;
let self = this;
// Perform default validations.
if ('default_validate' in self && typeof(self.default_validate) == 'function' &&
_.isString(self.default_validate())) {
@@ -344,13 +344,13 @@ define([
return true;
},
set: function(key, val, options) {
var opts = _.isObject(key) ? val : options;
let opts = _.isObject(key) ? val : options;
this._changing = true;
this._previousAttributes = _.clone(this.attributes);
this.changed = {};
var res = Backbone.Model.prototype.set.call(this, key, val, options);
let res = Backbone.Model.prototype.set.call(this, key, val, options);
this._changing = false;
if ((opts && opts.internal) || !this.trackChanges) {
@@ -358,11 +358,11 @@ define([
}
if (key != null && res) {
var attrs = {},
let attrs = {},
self = this,
msg;
var attrChanged = function(v, k) {
let attrChanged = function(v, k) {
if (k in self.objects) {
return;
}
@@ -442,7 +442,7 @@ define([
* only from the parent object.
*/
toJSON: function(session, method) {
var self = this,
let self = this,
res, isNew = self.isNew();
session = (typeof(session) != 'undefined' && session == true);
@@ -462,7 +462,7 @@ define([
_.each(
self.objects,
function(k) {
var obj = self.get(k);
let obj = self.get(k);
/*
* For session changes, we only need the modified data to be
* transformed to JSON data.
@@ -506,7 +506,7 @@ define([
return res;
},
startNewSession: function() {
var self = this;
let self = this;
if (self.trackChanges) {
self.trigger('pgadmin-session:stop', self);
@@ -522,7 +522,7 @@ define([
self.origSessAttrs = _.clone(self.attributes);
_.each(self.objects, function(o) {
var obj = self.get(o);
let obj = self.get(o);
if (_.isUndefined(obj) || _.isNull(obj)) {
return;
@@ -549,18 +549,18 @@ define([
},
onChildInvalid: function(msg, obj) {
var self = this;
let self = this;
if (self.trackChanges && obj) {
var objName = obj.attrName;
let objName = obj.attrName;
if (!objName) {
var hasPrimaryKey = obj.primary_key &&
let hasPrimaryKey = obj.primary_key &&
typeof(obj.primary_key) === 'function';
var key = hasPrimaryKey ? obj.primary_key() : obj.cid,
let key = hasPrimaryKey ? obj.primary_key() : obj.cid,
comparator = hasPrimaryKey ?
function(k) {
var o = self.get('k');
let o = self.get('k');
if (o && o.primary_key() === key) {
objName = k;
@@ -570,7 +570,7 @@ define([
return false;
} :
function(k) {
var o = self.get(k);
let o = self.get(k);
if (o.cid === key) {
objName = k;
@@ -599,18 +599,18 @@ define([
return this;
},
onChildValid: function(obj) {
var self = this;
let self = this;
if (self.trackChanges && obj) {
var objName = obj.attrName;
let objName = obj.attrName;
if (!objName) {
var hasPrimaryKey = (obj.primary_key &&
let hasPrimaryKey = (obj.primary_key &&
(typeof(obj.primary_key) === 'function'));
var key = hasPrimaryKey ? obj.primary_key() : obj.cid,
let key = hasPrimaryKey ? obj.primary_key() : obj.cid,
comparator = hasPrimaryKey ?
function(k) {
var o = self.get('k');
let o = self.get('k');
if (o && o.primary_key() === key) {
objName = k;
@@ -620,7 +620,7 @@ define([
return false;
} :
function(k) {
var o = self.get('k');
let o = self.get('k');
if (o && o.cid === key) {
objName = k;
@@ -633,7 +633,7 @@ define([
_.findIndex(self.objects, comparator);
}
var msg = null,
let msg = null,
validate = function(m, attrs) {
if ('default_validate' in m && typeof(m.default_validate) == 'function') {
msg = m.default_validate();
@@ -651,7 +651,7 @@ define([
};
if (obj instanceof Backbone.Collection) {
for (var idx in obj.models) {
for (let idx in obj.models) {
if (validate(obj.models[idx]))
break;
}
@@ -704,11 +704,11 @@ define([
onChildCollectionChanged: function(obj, obj_hand) {
var self = this;
let self = this;
setTimeout(() => {
var msg = null,
let msg = null,
validate = function(m, attrs) {
if ('default_validate' in m && typeof(m.default_validate) == 'function') {
msg = m.default_validate();
@@ -729,13 +729,13 @@ define([
let collection = self.collection || obj_hand;
if(collection) {
var collection_selector = collection.attrName || collection.name;
let collection_selector = collection.attrName || collection.name;
let activeTab = $('.show.active div.'+collection_selector);
$(activeTab).find('.error-in-grid').removeClass('error-in-grid');
model_collection_exit : if (collection instanceof Backbone.Collection) {
for (var cid in collection.models) {
for (let cid in collection.models) {
let model = collection.models[cid];
for(let mod_obj of model.objects) {
@@ -765,7 +765,7 @@ define([
},
onChildChanged: function(obj) {
var self = this;
let self = this;
if (self.trackChanges && self.collection) {
(self.collection).trigger('change', self);
@@ -774,7 +774,7 @@ define([
},
stopSession: function() {
var self = this;
let self = this;
if (self.trackChanges) {
self.off('pgadmin-session:model:invalid', self.onChildInvalid);
@@ -790,7 +790,7 @@ define([
self.origSessAttrs = {};
_.each(self.objects, function(o) {
var obj = self.get(o);
let obj = self.get(o);
if (_.isUndefined(obj) || _.isNull(obj)) {
return;
@@ -807,9 +807,9 @@ define([
self.trigger('pgadmin-session:stop');
},
default_validate: function() {
var msg, field, value, type;
let msg, field, value, type;
for (var i = 0, keys = _.keys(this.attributes), l = keys.length; i < l; i++) {
for (let i = 0, keys = _.keys(this.attributes), l = keys.length; i < l; i++) {
value = this.attributes[keys[i]];
field = this.fieldData[keys[i]];
@@ -850,7 +850,7 @@ define([
},
check_min_max: function(value, field) {
var label = field.label,
let label = field.label,
min_value = field.min,
max_value = field.max;
@@ -862,14 +862,14 @@ define([
return null;
},
number_validate: function(value, field) {
var pattern = new RegExp('^-?[0-9]+(\.?[0-9]*)?$');
let pattern = new RegExp('^-?[0-9]+(\.?[0-9]*)?$');
if (!pattern.test(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]*$');
let pattern = new RegExp('^-?[0-9]*$');
if (!pattern.test(value)) {
return pgadminUtils.sprintf(pgAdmin.Browser.messages.MUST_BE_INT, field.label);
}
@@ -880,7 +880,7 @@ define([
pgBrowser.DataCollection = Backbone.Collection.extend({
// Model collection
initialize: function(attributes, options) {
var self = this;
let self = this;
options = options || {};
/*
@@ -915,7 +915,7 @@ define([
return self;
},
startNewSession: function() {
var self = this,
let self = this,
msg;
if (self.trackChanges) {
@@ -961,7 +961,7 @@ define([
self.on('pgadmin-session:model:valid', self.onModelValid);
},
onModelInvalid: function(msg, m) {
var self = this,
let self = this,
invalidModels = self.sessAttrs['invalid'];
if (self.trackChanges) {
@@ -979,12 +979,12 @@ define([
return true;
},
onModelValid: function(m) {
var self = this,
let self = this,
invalidModels = self.sessAttrs['invalid'];
if (self.trackChanges) {
// Now check uniqueness of current model with other models.
var isUnique = self.checkDuplicateWithModel(m);
let isUnique = self.checkDuplicateWithModel(m);
// If unique then find the object the invalid list, if found remove it from the list
// and inform the parent that - I am a valid object now.
@@ -1001,7 +1001,7 @@ define([
return true;
},
stopSession: function() {
var self = this;
let self = this;
self.trackChanges = false;
self.sessAttrs = {
@@ -1039,13 +1039,13 @@ define([
* }
*/
toJSON: function(session) {
var self = this;
let self = this;
session = (typeof(session) != 'undefined' && session == true);
if (!session) {
return Backbone.Collection.prototype.toJSON.call(self);
} else {
var res = {};
let res = {};
res['added'] = [];
_.each(this.sessAttrs['added'], function(o) {
@@ -1089,7 +1089,7 @@ define([
Backbone.Collection.prototype.reset.apply(this, arguments);
},
objFindInSession: function(m, type) {
var hasPrimaryKey = m.primary_key &&
let hasPrimaryKey = m.primary_key &&
typeof(m.primary_key) == 'function',
key = hasPrimaryKey ? m.primary_key() : m.cid,
comparator = hasPrimaryKey ? function(o) {
@@ -1102,14 +1102,14 @@ define([
},
onModelAdd: function(obj) {
if (this.trackChanges) {
var self = this,
let self = this,
msg,
idx = self.objFindInSession(obj, 'deleted');
// Hmm.. - it was originally deleted from this collection, we should
// remove it from the 'deleted' list.
if (idx >= 0) {
var origObj = self.sessAttrs['deleted'][idx];
let origObj = self.sessAttrs['deleted'][idx];
obj.origSessAttrs = _.clone(origObj.origSessAttrs);
obj.attributes = _.extend(obj.attributes, origObj.attributes);
@@ -1175,7 +1175,7 @@ define([
*/
obj.errorModel.clear();
var self = this,
let self = this,
invalidModels = self.sessAttrs['invalid'],
copy = _.clone(obj),
idx = self.objFindInSession(obj, 'added');
@@ -1225,12 +1225,12 @@ define([
return true;
},
triggerValidationEvent: function() {
var self = this,
let self = this,
msg = null,
invalidModels = self.sessAttrs['invalid'],
validModels = [];
for (var key in invalidModels) {
for (let key in invalidModels) {
msg = invalidModels[key];
if (msg) {
break;
@@ -1243,7 +1243,7 @@ define([
}
// Let's remove the un
for (key in validModels) {
for (let key in validModels) {
delete invalidModels[validModels[key]];
}
@@ -1262,10 +1262,10 @@ define([
}
},
onModelChange: function(obj) {
var self = this;
let self = this;
if (this.trackChanges && obj instanceof pgBrowser.Node.Model) {
var idx = self.objFindInSession(obj, 'added');
let idx = self.objFindInSession(obj, 'added');
// It was newly added model, we don't need to add into the changed
// list.
@@ -1311,7 +1311,7 @@ define([
return true;
}
var self = this,
let self = this,
condition = {},
previous_condition = {};
@@ -1327,21 +1327,21 @@ define([
// Reset previously changed values.
model._previous_key_values = {};
var old_conflicting_models = self.where(previous_condition);
let old_conflicting_models = self.where(previous_condition);
if (old_conflicting_models.length == 1) {
var m = old_conflicting_models[0];
let m = old_conflicting_models[0];
self.clearInvalidSessionIfModelValid(m);
}
var new_conflicting_models = self.where(condition);
let new_conflicting_models = self.where(condition);
if (new_conflicting_models.length == 0) {
self.clearInvalidSessionIfModelValid(model);
} else if (new_conflicting_models.length == 1) {
self.clearInvalidSessionIfModelValid(model);
self.clearInvalidSessionIfModelValid(new_conflicting_models[0]);
} else {
var msg = 'Duplicate rows.';
let msg = 'Duplicate rows.';
setTimeout(function() {
_.each(new_conflicting_models, function(local_model) {
self.trigger(
@@ -1358,7 +1358,7 @@ define([
return true;
},
clearInvalidSessionIfModelValid: function(m) {
var errors = m.errorModel.attributes,
let errors = m.errorModel.attributes,
invalidModels = this.sessAttrs['invalid'];
m.trigger('pgadmin-session:model:unique', m);

View File

@@ -11,12 +11,12 @@ define([
'sources/pgadmin', 'jquery', 'wcdocker',
], function(pgAdmin, $) {
var pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {},
let pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {},
wcDocker = window.wcDocker,
wcIFrame = window.wcIFrame;
pgAdmin.Browser.Frame = function(options) {
var defaults = [
let defaults = [
'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
'isPrivate', 'url', 'icon', 'onCreate', 'isLayoutMember', 'isRenamable',
];
@@ -39,7 +39,7 @@ define([
frame: null,
onCreate: null,
load: function(docker) {
var that = this;
let that = this;
if (!that.panel) {
docker.registerPanelType(this.name, {
title: that.title,
@@ -57,10 +57,10 @@ define([
myPanel.closeable(!!that.isCloseable);
myPanel.renamable(that.isRenamable);
var $frameArea = $('<div style="position:absolute;top:0 !important;width:100%;height:100%;display:table;z-index:0;">');
let $frameArea = $('<div style="position:absolute;top:0 !important;width:100%;height:100%;display:table;z-index:0;">');
myPanel.layout().addItem($frameArea);
that.panel = myPanel;
var frame = new wcIFrame($frameArea, myPanel);
let frame = new wcIFrame($frameArea, myPanel);
$(myPanel).data('frameInitialized', false);
$(myPanel).data('embeddedFrame', frame);
@@ -112,7 +112,7 @@ define([
}
},
eventFunc: function(eventName) {
var name = $(this).data('pgAdminName');
let name = $(this).data('pgAdminName');
try {
pgBrowser.Events.trigger('pgadmin-browser:frame', eventName, this, arguments);

View File

@@ -17,7 +17,7 @@ import Notify from '../../../static/js/helpers/Notifier';
const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
var wcDocker = window.wcDocker;
let wcDocker = window.wcDocker;
/* Add cache related methods and properties */
_.extend(pgBrowser, {
@@ -29,8 +29,8 @@ _.extend(pgBrowser, {
// Build the default layout
buildDefaultLayout: function(docker) {
var browserPanel = docker.addPanel('browser', wcDocker.DOCK.LEFT);
var dashboardPanel = docker.addPanel(
let browserPanel = docker.addPanel('browser', wcDocker.DOCK.LEFT);
let dashboardPanel = docker.addPanel(
'dashboard', wcDocker.DOCK.RIGHT, browserPanel);
docker.addPanel('properties', wcDocker.DOCK.STACKED, dashboardPanel, {
tabOrientation: wcDocker.TAB.TOP,
@@ -48,7 +48,7 @@ _.extend(pgBrowser, {
save_current_layout: function(layout_id, docker) {
if(docker) {
var layout = docker.save(),
let layout = docker.save(),
settings = { setting: layout_id, value: layout };
$.ajax({
type: 'POST',
@@ -65,7 +65,7 @@ _.extend(pgBrowser, {
docker.restore(layout);
if(checkLayout) {
// Check restore layout is restored pgAdmin 4 layout successfully if not then reset layout to default pgAdmin 4 layout.
var _panel = docker.findPanels('properties');
let _panel = docker.findPanels('properties');
if(_panel.length == 0 && defaultLayoutCallback){
// clear the wcDocker before reset layout.
docker.clear();

View File

@@ -16,8 +16,8 @@ define([
pgAdmin.Browser = pgAdmin.Browser || {};
// Individual menu-item class
var MenuItem = pgAdmin.Browser.MenuItem = function(opts) {
var menu_opts = [
let MenuItem = pgAdmin.Browser.MenuItem = function(opts) {
let menu_opts = [
'name', 'label', 'priority', 'module', 'callback', 'data', 'enable',
'category', 'target', 'url' /* Do not show icon in the menus, 'icon' */ , 'node',
'checked', 'below', 'menu_items',
@@ -62,17 +62,17 @@ define([
_.each(this.menu_items, function(submenu_item){
submenu_item.generate(node, item);
});
var create_submenu = pgAdmin.Browser.MenuGroup({
let create_submenu = pgAdmin.Browser.MenuGroup({
'label': this.label,
'id': this.name,
}, this.menu_items);
this.$el = create_submenu.$el;
} else {
var data_disabled = null;
let data_disabled = null;
if(this.data != undefined && this.data.data_disabled != undefined){
data_disabled = this.data.data_disabled;
}
var url = $('<a></a>', {
let url = $('<a></a>', {
'id': this.name,
'href': this.url,
'target': this.target,
@@ -98,11 +98,11 @@ define([
url.addClass((this.is_disabled ? ' disabled' : ''));
var textSpan = $('<span data-test="menu-item-text"></span>').text(' ' + this.label);
let textSpan = $('<span data-test="menu-item-text"></span>').text(' ' + this.label);
url.append(textSpan);
var mnu_element = $('<li/>').append(url);
let mnu_element = $('<li/>').append(url);
// Check if below parameter is defined and true then we need to add
// separator.
if (!_.isUndefined(this.below) && this.below === true) {
@@ -141,7 +141,7 @@ define([
* This will be called when context-menu is clicked.
*/
context_menu_callback: function(item) {
var o = this,
let o = this,
cb;
if (o.module['callbacks'] && (
@@ -219,7 +219,7 @@ define([
*/
pgAdmin.Browser.MenuGroup = function(opts, items, prev, ctx) {
var template = _.template([
let template = _.template([
'<% if (above) { %><li class="dropdown-divider"></li><% } %>',
'<li class="dropdown-submenu" role="menuitem">',
' <a href="#" class="dropdown-item">',
@@ -254,7 +254,7 @@ define([
return a.priority - b.priority;
});
for (var idx in items) {
for (let idx in items) {
m = items[idx];
$menu.append(m.$el);
if (!m.is_disabled) {
@@ -263,7 +263,7 @@ define([
ctxId++;
}
var is_disabled = (_.size(submenus) == 0);
let is_disabled = (_.size(submenus) == 0);
return {
$el: $el,
@@ -319,7 +319,7 @@ define([
return;
}
var groups = {
let groups = {
'common': [],
},
common, idx = 0,
@@ -331,11 +331,11 @@ define([
delete m.$el;
}
m.generate(d, item);
var group = groups[m.category || 'common'] =
let group = groups[m.category || 'common'] =
groups[m.category || 'common'] || [];
group.push(m);
} else {
for (var key in m) {
for (let key in m) {
update_menuitem(m[key]);
}
}
@@ -352,10 +352,10 @@ define([
common = groups['common'];
delete groups['common'];
var prev = true;
let prev = true;
for (var name in groups) {
var g = groups[name],
for (let name in groups) {
let g = groups[name],
c = categories[name] || {
'label': name,
single: false,
@@ -384,14 +384,14 @@ define([
common.sort(function(a, b) {
return a.priority - b.priority;
});
var len = _.size(common);
let len = _.size(common);
for (idx in common) {
item = common[idx];
item.priority = (item.priority || 10);
$mnu.append(item.$el);
var prefix = ctxId + '_' + item.priority + '_' + ctxIdx;
let prefix = ctxId + '_' + item.priority + '_' + ctxIdx;
if (ctxIdx != 1 && item.above && !item.is_disabled) {
// For creatign the seprator any string will do.
@@ -413,7 +413,7 @@ define([
// MENU PUBLIC CLASS DEFINITION
// ==============================
var Menu = function(element, options) {
let Menu = function(element, options) {
this.$element = $(element);
this.options = $.extend({}, Menu.DEFAULTS, options);
this.isLoading = false;
@@ -422,15 +422,15 @@ define([
Menu.DEFAULTS = {};
Menu.prototype.toggle = function(ev) {
var $parent = this.$element.closest('.dropdown-item');
let $parent = this.$element.closest('.dropdown-item');
if ($parent.hasClass('disabled')) {
ev.preventDefault();
return false;
}
var d = this.$element.data('pgMenu');
let d = this.$element.data('pgMenu');
if (d.cb) {
var cb = d.module && d.module['callbacks'] && d.module['callbacks'][d.cb] || d.module && d.module[d.cb];
let cb = d.module && d.module['callbacks'] && d.module['callbacks'][d.cb] || d.module && d.module[d.cb];
if (cb) {
cb.apply(d.module, [d.data, pgAdmin.Browser.tree.selected()]);
ev.preventDefault();
@@ -446,9 +446,9 @@ define([
function Plugin(option, ev) {
return this.each(function() {
var $this = $(this);
var data = $this.data('pg.menu');
var options = typeof option == 'object' && option;
let $this = $(this);
let data = $this.data('pg.menu');
let options = typeof option == 'object' && option;
if (!data) $this.data('pg.menu', (data = new Menu(this, options)));
@@ -456,7 +456,7 @@ define([
});
}
var old = $.fn.button;
let old = $.fn.button;
$.fn.pgmenu = Plugin;
$.fn.pgmenu.Constructor = Menu;
@@ -475,7 +475,7 @@ define([
$(document)
.on('click.pg.menu.data-api', '[data-toggle^="pg-menu"]', function(ev) {
var $menu = $(ev.target);
let $menu = $(ev.target);
if (!$menu.hasClass('dropdown-item'))
$menu = $menu.closest('.dropdown-item');
Plugin.call($menu, 'toggle', ev);

View File

@@ -106,7 +106,7 @@ define([
* specify the 'transform' function too, which will convert the fetched
* data to proper 'label', 'value' format.
*/
var NodeAjaxOptionsControl = Backform.NodeAjaxOptionsControl =
let NodeAjaxOptionsControl = Backform.NodeAjaxOptionsControl =
Backform.Select2Control.extend({
defaults: _.extend(Backform.Select2Control.prototype.defaults, {
url: undefined,
@@ -127,7 +127,7 @@ define([
/*
* We're about to fetch the options required for this control.
*/
var self = this,
let self = this,
url = self.field.get('url') || self.defaults.url,
m = self.model.top || self.model,
url_jump_after_node = self.field.get('url_jump_after_node') || null;
@@ -135,7 +135,7 @@ define([
// Hmm - we found the url option.
// That means - we needs to fetch the options from that node.
if (url) {
var node = this.field.get('schema_node'),
let node = this.field.get('schema_node'),
node_info = this.field.get('node_info'),
with_id = this.field.get('url_with_id') || false,
full_url = node.generate_url.apply(
@@ -158,7 +158,7 @@ define([
* If yes - use that, and do not bother about fetching it again,
* and use it.
*/
var data = cache_node.cache(node.type + '#' + url, node_info, cache_level);
let data = cache_node.cache(node.type + '#' + url, node_info, cache_level);
if (this.field.get('version_compatible') &&
(_.isUndefined(data) || _.isNull(data))) {
@@ -188,7 +188,7 @@ define([
/*
* Transform the data
*/
var transform = this.field.get('transform') || self.defaults.transform;
let transform = this.field.get('transform') || self.defaults.transform;
if (transform && _.isFunction(transform)) {
// We will transform the data later, when rendering.
// It will allow us to generate different data based on the
@@ -201,12 +201,12 @@ define([
},
});
var formatNode = function(opt) {
let formatNode = function(opt) {
if (!opt.id) {
return opt.text;
}
var optimage = $(opt.element).data('image');
let optimage = $(opt.element).data('image');
if (!optimage) {
return opt.text;
@@ -219,11 +219,11 @@ define([
}
};
var filterRows = function(self, filter, rows, node) {
var res = [];
let filterRows = function(self, filter, rows, node) {
let res = [];
_.each(rows, function(r) {
if (filter(r)) {
var l = (_.isFunction(node['node_label']) ?
let l = (_.isFunction(node['node_label']) ?
(node['node_label']).apply(node, [r, self.model, self]) :
r.label),
image = (_.isFunction(node['node_image']) ?
@@ -243,13 +243,13 @@ define([
return res;
};
var NodeListByIdControl = Backform.NodeListByIdControl = NodeAjaxOptionsControl.extend({
let NodeListByIdControl = Backform.NodeListByIdControl = NodeAjaxOptionsControl.extend({
controlClassName: 'pgadmin-node-select form-control',
defaults: _.extend({}, NodeAjaxOptionsControl.prototype.defaults, {
url: 'nodes',
filter: undefined,
transform: function(rows) {
var self = this,
let self = this,
node = self.field.get('schema_node'),
filter = self.field.get('filter') || function() {
return true;
@@ -271,7 +271,7 @@ define([
Backform.NodeListByNameControl = NodeListByIdControl.extend({
defaults: _.extend({}, NodeListByIdControl.prototype.defaults, {
transform: function(rows) {
var self = this,
let self = this,
node = self.field.get('schema_node'),
res = [],
filter = self.field.get('filter') || function() {
@@ -282,7 +282,7 @@ define([
_.each(rows, function(r) {
if (filter(r)) {
var l = (_.isFunction(node['node_label']) ?
let l = (_.isFunction(node['node_label']) ?
(node['node_label']).apply(node, [r, self.model, self]) :
r.label),
image = (_.isFunction(node['node_image']) ?
@@ -311,7 +311,7 @@ define([
return this.each(function() {
if (!this || !$(this.length))
return;
var top, p = $(this),
let top, p = $(this),
hasScrollbar = function(j) {
if (j && j.length > 0) {
return j.get(0).scrollHeight > j.height();
@@ -340,7 +340,7 @@ define([
if (!this || !$(this.length))
return;
var elem = $(this),
let elem = $(this),
backgridDiv = $(this).offsetParent().parent(), // Backgrid div.subnode
backgridDivTop = backgridDiv.offset().top,
backgridDivHeight = backgridDiv.height(),
@@ -353,7 +353,7 @@ define([
gridScroll = backformTab[0].offsetHeight - backgridDivTop;
if (backgridDivHeight > gridScroll) {
var top = elem.get(0).offsetTop + elem.height();
let top = elem.get(0).offsetTop + elem.height();
backformTab.find('.tab-content').scrollTop(top);
}
return true;
@@ -372,7 +372,7 @@ define([
* specify the 'transform' function too, which will convert the fetched
* data to proper 'label', 'value' format.
*/
var NodeAjaxOptionsCell = Backgrid.Extension.NodeAjaxOptionsCell = Backgrid.Extension.Select2Cell.extend({
let NodeAjaxOptionsCell = Backgrid.Extension.NodeAjaxOptionsCell = Backgrid.Extension.Select2Cell.extend({
defaults: _.extend({}, Backgrid.Extension.Select2Cell.prototype.defaults, {
url: undefined,
transform: undefined,
@@ -395,14 +395,14 @@ define([
initialize: function() {
Backgrid.Extension.Select2Cell.prototype.initialize.apply(this, arguments);
var url = this.column.get('url') || this.defaults.url,
let url = this.column.get('url') || this.defaults.url,
is_options_cached = _.has(this.column.attributes, 'options_cached'),
options_cached = is_options_cached && this.column.get('options_cached');
// Hmm - we found the url option.
// That means - we needs to fetch the options from that node.
if (url && !options_cached) {
var self = this,
let self = this,
m = this.model,
column = this.column,
eventHandler = m.top || m,
@@ -430,7 +430,7 @@ define([
* If yes - use that, and do not bother about fetching it again,
* and use it.
*/
var data = cache_node.cache(node.type + '#' + url, node_info, cache_level);
let data = cache_node.cache(node.type + '#' + url, node_info, cache_level);
if (column.get('version_compatible') &&
(_.isUndefined(data) || _.isNull(data))) {
@@ -460,7 +460,7 @@ define([
/*
* Transform the data
*/
var transform = column.get('transform') || self.defaults.transform;
let transform = column.get('transform') || self.defaults.transform;
if (transform && _.isFunction(transform)) {
// We will transform the data later, when rendering.
// It will allow us to generate different data based on the
@@ -477,8 +477,8 @@ define([
},
});
var transformFunc = function(rows, control) {
var self = control || this,
let transformFunc = function(rows, control) {
let self = control || this,
node = self.column.get('schema_node'),
filter = self.column.get('filter') || function() {
return true;
@@ -537,7 +537,7 @@ define([
},
}),
getValueFromDOM: function() {
var res = [];
let res = [];
this.$el.find('select').find(':selected').each(function() {
res.push($(this).attr('value'));

View File

@@ -14,18 +14,18 @@ import pgAdmin from 'sources/pgadmin';
/* It generates the URL based on collection node selected */
export function generateCollectionURL(item, type) {
var opURL = {
let opURL = {
'properties': 'obj',
'children': 'nodes',
'drop': 'obj',
};
let nodeObj= this;
var collectionPickFunction = function (treeInfoValue, treeInfoKey) {
let collectionPickFunction = function (treeInfoValue, treeInfoKey) {
return (treeInfoKey != nodeObj.type);
};
var treeInfo = pgAdmin.Browser.tree.getTreeNodeHierarchy(item);
var actionType = type in opURL ? opURL[type] : type;
var nodeType = type === 'properties' ? nodeObj.type : nodeObj.node;
let treeInfo = pgAdmin.Browser.tree.getTreeNodeHierarchy(item);
let actionType = type in opURL ? opURL[type] : type;
let nodeType = type === 'properties' ? nodeObj.type : nodeObj.node;
return generate_url(
pgAdmin.Browser.URL, treeInfo, actionType, nodeType,
collectionPickFunction
@@ -69,7 +69,7 @@ export function generateNodeUrl(treeNodeInfo, actionType, itemNodeData, withId,
jump_after_priority = treeNodeInfo[jumpAfterNode].priority;
}
var nodePickFunction = function(treeInfoValue) {
let nodePickFunction = function(treeInfoValue) {
return (treeInfoValue.priority <= jump_after_priority || treeInfoValue.priority == priority);
};
@@ -111,7 +111,7 @@ export function getNodeAjaxOptions(url, nodeObj, treeNodeInfo, itemNodeData, par
* If yes - use that, and do not bother about fetching it again,
* and use it.
*/
var data = cacheNode.cache(nodeObj.type + '#' + url, treeNodeInfo, cacheLevel);
let data = cacheNode.cache(nodeObj.type + '#' + url, treeNodeInfo, cacheLevel);
if (_.isUndefined(data) || _.isNull(data)) {
api.get(fullUrl, {
@@ -139,11 +139,11 @@ export function getNodeAjaxOptions(url, nodeObj, treeNodeInfo, itemNodeData, par
export function getNodeListById(nodeObj, treeNodeInfo, itemNodeData, params={}, filter=()=>true) {
/* Transform the result to add image details */
const transform = (rows) => {
var res = [];
let res = [];
_.each(rows, function(r) {
if (filter(r)) {
var l = (_.isFunction(nodeObj['node_label']) ?
let l = (_.isFunction(nodeObj['node_label']) ?
(nodeObj['node_label']).apply(nodeObj, [r]) :
r.label),
image = (_.isFunction(nodeObj['node_image']) ?
@@ -170,11 +170,11 @@ export function getNodeListByName(node, treeNodeInfo, itemNodeData, params={}, f
let {includeItemKeys} = params;
/* Transform the result to add image details */
const transform = (rows) => {
var res = [];
let res = [];
_.each(rows, function(r) {
if (filter(r)) {
var l = (_.isFunction(nodeObj['node_label']) ?
let l = (_.isFunction(nodeObj['node_label']) ?
(nodeObj['node_label']).apply(nodeObj, [r]) :
r.label),
image = (_.isFunction(nodeObj['node_image']) ?

View File

@@ -14,11 +14,11 @@ define(
['sources/pgadmin', 'jquery', 'wcdocker'],
function(pgAdmin, $) {
var pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {},
let pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {},
wcDocker = window.wcDocker;
pgAdmin.Browser.Panel = function(options) {
var defaults = [
let defaults = [
'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
'isPrivate', 'isLayoutMember', 'content', 'icon', 'events', 'onCreate', 'elContainer',
'canHide', 'limit', 'extraClasses', 'canMaximise',
@@ -44,7 +44,7 @@ define(
limit: null,
extraClasses: null,
load: function(docker, title) {
var that = this;
let that = this;
if (!that.panel) {
docker.registerPanelType(that.name, {
title: that.title,
@@ -58,13 +58,13 @@ define(
if (!that.showTitle)
myPanel.title(false);
else {
var title_elem = '<a href="#" tabindex="-1" class="panel-link-heading">' + (title || that.title) + '</a>';
let title_elem = '<a href="#" tabindex="-1" class="panel-link-heading">' + (title || that.title) + '</a>';
myPanel.title(title_elem);
if (that.icon != '')
myPanel.icon(that.icon);
}
var $container = $('<div>', {
let $container = $('<div>', {
'class': 'pg-panel-content',
}).append($(that.content));
@@ -197,7 +197,7 @@ define(
}
},
eventFunc: function(eventName) {
var name = $(this).data('pgAdminName');
let name = $(this).data('pgAdminName');
try {
pgBrowser.Events.trigger(
'pgadmin-browser:panel', eventName, this, arguments
@@ -219,7 +219,7 @@ define(
}
},
resizedContainer: function() {
var p = this;
let p = this;
if (p.pgElContainer && !p.pgResizeTimeout) {
if (!p.isVisible()) {
@@ -230,7 +230,7 @@ define(
}
p.pgResizeTimeout = setTimeout(
function() {
var w = p.width(),
let w = p.width(),
elAttr = 'xs';
p.pgResizeTimeout = null;
@@ -259,7 +259,7 @@ define(
let selectedPanel = pgBrowser.docker.findPanels(this._type)[0];
let isPanelVisible = selectedPanel.isVisible();
var $container = selectedPanel
let $container = selectedPanel
.layout()
.scene()
.find('.pg-panel-content');

View File

@@ -54,7 +54,7 @@ _.extend(pgBrowser, {
/* Get all the preferences of a module */
get_preferences_for_module: function(module) {
var self = this;
let self = this;
let preferences = {};
_.each(
_.where(self.preferences_cache, {'module': module}),
@@ -69,14 +69,14 @@ _.extend(pgBrowser, {
/* Get preference of an id, id is numeric */
get_preference_for_id : function(id) {
var self = this;
let self = this;
/* findWhere returns undefined if not found */
return _.findWhere(self.preferences_cache, {'id': id});
},
// Get and cache the preferences
cache_preferences: function (modulesChanged) {
var self = this,
let self = this,
headers = {};
headers[pgAdmin.csrf_token_header] = pgAdmin.csrf_token;

View File

@@ -120,7 +120,7 @@ export function initializeToolbar(panel, wcDocker) {
else if ('name' in data && data.name === gettext('Search objects'))
pgAdmin.Tools.SearchObjects.show_search_objects('', pgAdmin.Browser.tree.selected());
else if ('name' in data && data.name === gettext('PSQL Tool')){
var input = {},
let input = {},
t = pgAdmin.Browser.tree,
i = input.item || t.selected(),
d = i ? t.itemData(i) : undefined;