mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed following code smells reported by SonarQube:
1) Immediately return this expression instead of assigning it to the temporary variable. 2) Extract this nested ternary operation into an independent statement. 3) Expected a `for-of` loop instead of a `for` loop with this simple iteration.
This commit is contained in:
@@ -293,8 +293,8 @@ const setZoomEvents = () => {
|
||||
// This function is used to iterate all open windows and set the zoom level.
|
||||
const setZoomLevelForAllWindows = () => {
|
||||
nw.Window.getAll(function(winArray) {
|
||||
for (var i = 0; i < winArray.length; i++) {
|
||||
winArray[i].zoomLevel = pgAdminWindowObject.zoomLevel;
|
||||
for (let arr_val of winArray) {
|
||||
arr_val.zoomLevel = pgAdminWindowObject.zoomLevel;
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -336,9 +336,9 @@ const toggleFullScreen = () => {
|
||||
|
||||
// Change the menu label.
|
||||
var menu_label = pgAdminWindowObject.window.document.querySelector('#mnu_toggle_fullscreen_runtime span').innerHTML;
|
||||
if (menu_label.indexOf('Enter Full Screen') > 0) {
|
||||
if (menu_label.indexOf('Enter Full Screen') >= 0) {
|
||||
pgAdminWindowObject.window.document.querySelector('#mnu_toggle_fullscreen_runtime span').innerHTML = menu_label.replace('Enter', 'Exit');
|
||||
} else if (menu_label.indexOf('Exit Full Screen') > 0) {
|
||||
} else if (menu_label.indexOf('Exit Full Screen') >= 0) {
|
||||
pgAdminWindowObject.window.document.querySelector('#mnu_toggle_fullscreen_runtime span').innerHTML = menu_label.replace('Exit', 'Enter');
|
||||
}
|
||||
}
|
||||
|
@@ -265,10 +265,10 @@ define('pgadmin.node.primary_key', [
|
||||
});
|
||||
}
|
||||
path = path.split('.');
|
||||
for (var i = 0; i < path.length; i++) {
|
||||
for (let path_val of path) {
|
||||
if (_.isNull(res)) return null;
|
||||
if (_.isEmpty(path[i])) continue;
|
||||
if (!_.isUndefined(res[path[i]])) res = res[path[i]];
|
||||
if (_.isEmpty(path_val)) continue;
|
||||
if (!_.isUndefined(res[path_val])) res = res[path_val];
|
||||
}
|
||||
return _.isObject(res) && !_.isArray(res) ? null : res;
|
||||
},
|
||||
|
@@ -798,9 +798,13 @@ define('pgadmin.browser', [
|
||||
category: _m.category, callback: _m.callback,
|
||||
priority: _m.priority, data: _m.data, url: _m.url || '#',
|
||||
target: _m.target, icon: _m.icon,
|
||||
enable: (_m.enable == '' ? true : (_.isString(_m.enable) &&
|
||||
_m.enable.toLowerCase() == 'false') ?
|
||||
false : _m.enable),
|
||||
enable: function() {
|
||||
if(_m.enable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (_.isString(_m.enable) && _m.enable.toLowerCase() == 'false') ? false : _m.enable;
|
||||
},
|
||||
node: _m.node, checked: _m.checked, below: _m.below,
|
||||
});
|
||||
};
|
||||
@@ -811,8 +815,8 @@ define('pgadmin.browser', [
|
||||
if(m.menu_items) {
|
||||
let sub_menu_items = [];
|
||||
|
||||
for(let i=0; i<m.menu_items.length; i++) {
|
||||
sub_menu_items.push(get_menuitem_obj(m.menu_items[i]));
|
||||
for(let mnu_val of m.menu_items) {
|
||||
sub_menu_items.push(get_menuitem_obj(mnu_val));
|
||||
}
|
||||
_menus[m.name]['menu_items'] = sub_menu_items;
|
||||
}
|
||||
@@ -936,8 +940,6 @@ define('pgadmin.browser', [
|
||||
_o.notFound && typeof(_o.notFound) == 'function' &&
|
||||
_o.notFound(_d);
|
||||
}
|
||||
|
||||
return;
|
||||
},
|
||||
|
||||
onAddTreeNode: function(_data, _hierarchy, _opts) {
|
||||
@@ -948,9 +950,10 @@ define('pgadmin.browser', [
|
||||
i: null, // current item
|
||||
p: _.toArray(_hierarchy || {}).sort(
|
||||
function(a, b) {
|
||||
return (a.priority === b.priority) ? 0 : (
|
||||
a.priority < b.priority ? -1 : 1
|
||||
);
|
||||
if (a.priority === b.priority) {
|
||||
return 0;
|
||||
}
|
||||
return (a.priority < b.priority ? -1 : 1);
|
||||
}
|
||||
), // path of the parent
|
||||
pathOfTreeItems: [], // path Item
|
||||
@@ -1210,9 +1213,10 @@ define('pgadmin.browser', [
|
||||
hasId: true,
|
||||
p: _.toArray(_hierarchy || {}).sort(
|
||||
function(a, b) {
|
||||
return (a.priority === b.priority) ? 0 : (
|
||||
a.priority < b.priority ? -1 : 1
|
||||
);
|
||||
if (a.priority === b.priority) {
|
||||
return 0;
|
||||
}
|
||||
return (a.priority < b.priority ? -1 : 1);
|
||||
}
|
||||
), // path of the old object
|
||||
pathOfTreeItems: [], // path items
|
||||
@@ -1306,13 +1310,11 @@ define('pgadmin.browser', [
|
||||
// it right now.
|
||||
this.notFound = errorOut;
|
||||
|
||||
// var _d = {_id: this.new._pid, _type: self.d._type};
|
||||
var loaded = this.t.wasLoad(parent),
|
||||
onLoad = function() {
|
||||
self.i = parent;
|
||||
self.pathOfTreeItems.push({coll: false, item: parent, d: self.d});
|
||||
self.success();
|
||||
return;
|
||||
};
|
||||
|
||||
if (!loaded && self.load) {
|
||||
@@ -1333,7 +1335,6 @@ define('pgadmin.browser', [
|
||||
onLoad();
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
// This is for rest of the nodes
|
||||
var _parentData = this.d;
|
||||
@@ -1357,7 +1358,6 @@ define('pgadmin.browser', [
|
||||
} else {
|
||||
addItemNode();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
@@ -1706,7 +1706,6 @@ define('pgadmin.browser', [
|
||||
this.tree.refresh(_i).then(() =>{
|
||||
if (_opts && _opts.success) _opts.success();
|
||||
});
|
||||
return;
|
||||
},
|
||||
|
||||
onRefreshTreeNode: function(_i, _opts) {
|
||||
|
@@ -340,8 +340,8 @@ define([
|
||||
// as we have created a new grid instance.
|
||||
if(selectedModels.length > 0) {
|
||||
that.collection.each(function (model) {
|
||||
for(var inx=0; inx < selectedModels.length; inx++){
|
||||
if (selectedModels[inx].id == model.id){
|
||||
for(let model_val of selectedModels){
|
||||
if (model_val.id == model.id){
|
||||
model.trigger('backgrid:select', model, true);
|
||||
}
|
||||
}
|
||||
@@ -467,7 +467,6 @@ define([
|
||||
} else {
|
||||
dropAjaxHook();
|
||||
}
|
||||
return;
|
||||
}.bind(that);
|
||||
},
|
||||
__loadMoreRows: function(e) {
|
||||
|
@@ -73,7 +73,7 @@ define('pgadmin.browser.node', [
|
||||
}
|
||||
},
|
||||
callbacks = _.keys(child.callbacks);
|
||||
for (var idx = 0; idx < callbacks.length; idx++) bindToChild(callbacks[idx]);
|
||||
for (let cb_val of callbacks) bindToChild(cb_val);
|
||||
|
||||
// Registering the node by calling child.Init(...) function
|
||||
child.Init.apply(child);
|
||||
@@ -504,12 +504,19 @@ define('pgadmin.browser.node', [
|
||||
|
||||
body.insertBefore(el, body.firstChild);
|
||||
|
||||
var new_width = screen.width < 700 ? screen.width * 0.95 : screen.width * 0.5,
|
||||
new_height = screen.height < 500 ? screen.height * 0.95 : screen.height * 0.4;
|
||||
if (!_.isUndefined(width) && !_.isNull(width)) {
|
||||
new_width = width;
|
||||
}
|
||||
if (!_.isUndefined(height) && !_.isNull(height)) {
|
||||
new_height = height;
|
||||
}
|
||||
|
||||
var new_panel = pgBrowser.docker.addPanel(
|
||||
'utility_props', window.wcDocker.DOCK.FLOAT, undefined, {
|
||||
w: (!_.isUndefined(width) && !_.isNull(width)) ? width :
|
||||
(screen.width < 700 ? screen.width * 0.95 : screen.width * 0.5),
|
||||
h: (!_.isUndefined(height) && !_.isNull(height)) ? height :
|
||||
(screen.height < 500 ? screen.height * 0.95 : screen.height * 0.4),
|
||||
w: new_width,
|
||||
h: new_height,
|
||||
x: (screen.width < 700 ? '2%' : '25%'),
|
||||
y: (screen.height < 500 ? '2%' : '25%'),
|
||||
}
|
||||
|
@@ -13,8 +13,8 @@ import url_for from 'sources/url_for';
|
||||
|
||||
const extractSearchResult = (list) => {
|
||||
let result = {};
|
||||
for (let idx = 0; idx < list.length; idx++) {
|
||||
let link = list[idx].getElementsByTagName('A');
|
||||
for (let list_val of list) {
|
||||
let link = list_val.getElementsByTagName('A');
|
||||
// we are not going to display more than first 10 result as per design
|
||||
if (link.length == 0) {
|
||||
break;
|
||||
|
@@ -167,7 +167,6 @@ export function Search() {
|
||||
if(input_value && input_value.length > 0){
|
||||
toggleDropdownMenu();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Bind the event listener
|
||||
|
@@ -43,10 +43,10 @@ export function transformData(labels, refreshRate) {
|
||||
export function legendCallback(chart) {
|
||||
var text = [];
|
||||
text.push('<div class="' + chart.id + '-legend d-flex">');
|
||||
for (var i = 0; i < chart.data.datasets.length; i++) {
|
||||
text.push('<div class="legend-value"><span style="background-color:' + chart.data.datasets[i].backgroundColor + '"> </span>');
|
||||
if (chart.data.datasets[i].label) {
|
||||
text.push('<span class="legend-label">' + chart.data.datasets[i].label + '</span>');
|
||||
for (let chart_val of chart.data.datasets) {
|
||||
text.push('<div class="legend-value"><span style="background-color:' + chart_val.backgroundColor + '"> </span>');
|
||||
if (chart_val.label) {
|
||||
text.push('<span class="legend-label">' + chart_val.label + '</span>');
|
||||
}
|
||||
text.push('</div>');
|
||||
}
|
||||
|
@@ -51,10 +51,13 @@ define('misc.dependencies', [
|
||||
parse: function(res) {
|
||||
var node = pgBrowser.Nodes[res.type];
|
||||
if(res.icon == null || res.icon == '') {
|
||||
res.icon = node ? (_.isFunction(node['node_image']) ?
|
||||
(node['node_image']).apply(node, [null, null]) :
|
||||
(node['node_image'] || ('icon-' + res.type))) :
|
||||
('icon-' + res.type);
|
||||
if (node) {
|
||||
res.icon = _.isFunction(node['node_image']) ?
|
||||
(node['node_image']).apply(node, [null, null]) :
|
||||
(node['node_image'] || ('icon-' + res.type));
|
||||
} else {
|
||||
res.icon = ('icon-' + res.type);
|
||||
}
|
||||
}
|
||||
res.type = pgadminUtils.titleize(res.type.replace(/_/g, ' '), true);
|
||||
return res;
|
||||
|
@@ -51,10 +51,13 @@ define('misc.dependents', [
|
||||
parse: function(res) {
|
||||
var node = pgBrowser.Nodes[res.type];
|
||||
if(res.icon == null || res.icon == '') {
|
||||
res.icon = node ? (_.isFunction(node['node_image']) ?
|
||||
(node['node_image']).apply(node, [null, null]) :
|
||||
(node['node_image'] || ('icon-' + res.type))) :
|
||||
('icon-' + res.type);
|
||||
if (node) {
|
||||
res.icon = _.isFunction(node['node_image']) ?
|
||||
(node['node_image']).apply(node, [null, null]) :
|
||||
(node['node_image'] || ('icon-' + res.type));
|
||||
} else {
|
||||
res.icon = ('icon-' + res.type);
|
||||
}
|
||||
}
|
||||
res.type = pgadminUtils.titleize(res.type.replace(/_/g, ' '), true);
|
||||
return res;
|
||||
|
@@ -74,9 +74,9 @@ define('pgadmin.misc.explain', [
|
||||
return res;
|
||||
};
|
||||
|
||||
for (var i = 0; i < words.length; i++) {
|
||||
for (let word_val of words) {
|
||||
var tmpArr = splitTextInMultiLine(
|
||||
curr_line, width_so_far, words[i]
|
||||
curr_line, width_so_far, word_val
|
||||
);
|
||||
|
||||
if (curr_line) {
|
||||
@@ -666,9 +666,16 @@ define('pgadmin.misc.explain', [
|
||||
data['inclusive_factor'] = data['inclusive'] / (
|
||||
data['total_time'] || data['Actual Total Time']
|
||||
);
|
||||
data['inclusive_flag'] = data['inclusive_factor'] <= 0.1 ? '1' :
|
||||
data['inclusive_factor'] < 0.5 ? '2' :
|
||||
data['inclusive_factor'] <= 0.9 ? '3' : '4';
|
||||
|
||||
if (data['inclusive_factor'] <= 0.1) {
|
||||
data['inclusive_flag'] = '1';
|
||||
} else if (data['inclusive_factor'] < 0.5) {
|
||||
data['inclusive_flag'] = '2';
|
||||
} else if (data['inclusive_factor'] <= 0.9) {
|
||||
data['inclusive_flag'] = '3';
|
||||
} else {
|
||||
data['inclusive_flag'] = '4';
|
||||
}
|
||||
}
|
||||
|
||||
if ('Actual Rows' in data && 'Plan Rows' in data) {
|
||||
@@ -684,9 +691,17 @@ define('pgadmin.misc.explain', [
|
||||
);
|
||||
data['rowsx_direction'] = 'positive';
|
||||
}
|
||||
data['rowsx_flag'] = data['rowsx'] <= 10 ? '1' : (
|
||||
data['rowsx'] <= 100 ? '2' : (data['rowsx'] <= 1000 ? '3' : '4')
|
||||
);
|
||||
|
||||
if (data['rowsx'] <= 10) {
|
||||
data['rowsx_flag'] = '1';
|
||||
} else if (data['rowsx'] <= 100 ) {
|
||||
data['rowsx_flag'] = '2';
|
||||
} else if (data['rowsx'] <= 1000 ) {
|
||||
data['rowsx_flag'] = '3';
|
||||
} else {
|
||||
data['rowsx_flag'] = '4';
|
||||
}
|
||||
|
||||
if('loops' in data) {
|
||||
data['rowsx'] = Math.ceil10(data['rowsx'] / data['loops'] || 1, -2);
|
||||
} else {
|
||||
@@ -751,9 +766,16 @@ define('pgadmin.misc.explain', [
|
||||
data['exclusive_factor'] = (
|
||||
data['exclusive'] / (data['total_time'] || data['Actual Total Time'])
|
||||
);
|
||||
data['exclusive_flag'] = data['exclusive_factor'] <= 0.1 ? '1' :
|
||||
data['exclusive_factor'] < 0.5 ? '2' :
|
||||
data['exclusive_factor'] <= 0.9 ? '3' : '4';
|
||||
|
||||
if (data['exclusive_factor'] <= 0.1) {
|
||||
data['exclusive_flag'] = '1';
|
||||
} else if (data['exclusive_factor'] < 0.5) {
|
||||
data['exclusive_flag'] = '2';
|
||||
} else if (data['exclusive_factor'] <= 0.9) {
|
||||
data['exclusive_flag'] = '3';
|
||||
} else {
|
||||
data['exclusive_flag'] = '4';
|
||||
}
|
||||
}
|
||||
|
||||
// Final Width and Height of current node
|
||||
@@ -844,7 +866,11 @@ define('pgadmin.misc.explain', [
|
||||
// Calculate arrow width according to cost of a particular plan
|
||||
if (start_cost != undefined && total_cost != undefined) {
|
||||
arrow_size = Math.round(Math.log((start_cost + total_cost) / 2 + start_cost));
|
||||
arrow_size = arrow_size < 1 ? 1 : arrow_size > 10 ? 10 : arrow_size;
|
||||
if (arrow_size < 1) {
|
||||
arrow_size = 1;
|
||||
} else if (arrow_size > 10) {
|
||||
arrow_size = 10;
|
||||
}
|
||||
}
|
||||
|
||||
var arrow_view_box = [0, 0, 2 * ARROW_WIDTH, 2 * ARROW_HEIGHT];
|
||||
|
@@ -413,12 +413,14 @@ define('misc.statistics', [
|
||||
this.columns = this.statistic_columns;
|
||||
for (var idx in columns) {
|
||||
name = (columns[idx])['name'];
|
||||
let val = null;
|
||||
if (row && row[name]) {
|
||||
val = _.indexOf(prettifyFields, name) != -1 ? sizePrettify(row[name]) : row[name];
|
||||
}
|
||||
res.push({
|
||||
'statistics': name,
|
||||
// Check if row is undefined?
|
||||
'value': row && row[name] ?
|
||||
((_.indexOf(prettifyFields, name) != -1) ?
|
||||
sizePrettify(row[name]) : row[name]) : null,
|
||||
'value': val,
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -277,7 +277,7 @@ export default function DataGridView({
|
||||
/>;
|
||||
}
|
||||
};
|
||||
colInfo.Cell.displayName = 'Cell',
|
||||
colInfo.Cell.displayName = 'Cell';
|
||||
colInfo.Cell.propTypes = {
|
||||
row: PropTypes.object.isRequired,
|
||||
};
|
||||
@@ -316,7 +316,7 @@ export default function DataGridView({
|
||||
);
|
||||
}
|
||||
};
|
||||
colInfo.Cell.displayName = 'Cell',
|
||||
colInfo.Cell.displayName = 'Cell';
|
||||
colInfo.Cell.propTypes = {
|
||||
row: PropTypes.object.isRequired,
|
||||
};
|
||||
@@ -381,7 +381,7 @@ export default function DataGridView({
|
||||
/>;
|
||||
},
|
||||
};
|
||||
colInfo.Cell.displayName = 'Cell',
|
||||
colInfo.Cell.displayName = 'Cell';
|
||||
colInfo.Cell.propTypes = {
|
||||
row: PropTypes.object.isRequired,
|
||||
value: PropTypes.any,
|
||||
|
@@ -101,14 +101,18 @@ export function getFieldMetaData(field, schema, value, viewHelperProps, onlyMode
|
||||
}
|
||||
|
||||
let {visible, disabled, readonly, editable} = field;
|
||||
let verInLimit;
|
||||
|
||||
let verInLimit = (_.isUndefined(viewHelperProps.serverInfo) ? true :
|
||||
((_.isUndefined(field.server_type) ? true :
|
||||
if (_.isUndefined(viewHelperProps.serverInfo)) {
|
||||
verInLimit= true;
|
||||
} else {
|
||||
verInLimit = ((_.isUndefined(field.server_type) ? true :
|
||||
(viewHelperProps.serverInfo.type in field.server_type)) &&
|
||||
(_.isUndefined(field.min_version) ? true :
|
||||
(viewHelperProps.serverInfo.version >= field.min_version)) &&
|
||||
(_.isUndefined(field.max_version) ? true :
|
||||
(viewHelperProps.serverInfo.version <= field.max_version))));
|
||||
(viewHelperProps.serverInfo.version <= field.max_version)));
|
||||
}
|
||||
|
||||
retData.readonly = viewHelperProps.inCatalog || (viewHelperProps.mode == 'properties');
|
||||
if(!retData.readonly) {
|
||||
|
@@ -36,9 +36,6 @@ define([
|
||||
this.pgResizeTimeout = null;
|
||||
|
||||
/** Calculations based on https://getbootstrap.com/docs/4.1/layout/grid/#grid-options **/
|
||||
if (w < 480) {
|
||||
elAttr = 'xs';
|
||||
}
|
||||
if (w >= 480) {
|
||||
elAttr = 'sm';
|
||||
}
|
||||
@@ -104,9 +101,9 @@ define([
|
||||
* with undefined keyCode. The undefined keyCode matches the undefined key
|
||||
* of alertify and triggers the button
|
||||
*/
|
||||
for(let i=0; i<this.__internal.buttons.length; i++) {
|
||||
if(_.isUndefined(this.__internal.buttons[i]['key'])) {
|
||||
this.__internal.buttons[i]['key'] = null;
|
||||
for(let btn_val of this.__internal.buttons) {
|
||||
if(_.isUndefined(btn_val['key'])) {
|
||||
btn_val['key'] = null;
|
||||
}
|
||||
}
|
||||
let self = this;
|
||||
@@ -288,8 +285,8 @@ define([
|
||||
if(ev.which === 13 || ev.which === 27) {
|
||||
let suppressForClasses = ['select2-selection', 'select2-search__field'];
|
||||
let $el = $(ev.target);
|
||||
for(let i=0; i<suppressForClasses.length; i++){
|
||||
if($el.hasClass(suppressForClasses[i])){
|
||||
for(let class_val of suppressForClasses){
|
||||
if($el.hasClass(class_val)){
|
||||
ev.preventDefault();
|
||||
ev.stopImmediatePropagation();
|
||||
ev.stopPropagation();
|
||||
|
@@ -14,14 +14,13 @@ import axios from 'axios';
|
||||
/* Get the axios instance to call back end APIs.
|
||||
Do not import axios directly, instead use this */
|
||||
export default function getApiInstance(headers={}) {
|
||||
const api = axios.create({
|
||||
return axios.create({
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
[pgAdmin.csrf_token_header]: pgAdmin.csrf_token,
|
||||
...headers,
|
||||
}
|
||||
});
|
||||
return api;
|
||||
}
|
||||
|
||||
export function parseApiError(error) {
|
||||
|
@@ -1128,6 +1128,14 @@ define([
|
||||
},
|
||||
});
|
||||
|
||||
let placeholder = pgAdmin.enable_binary_path_browsing ? gettext('Select binary path...') : gettext('Enter binary path...'),
|
||||
browse_btn_visible = pgAdmin.enable_binary_path_browsing ? true : false;
|
||||
|
||||
if (pgAdmin.server_mode === 'False') {
|
||||
placeholder = gettext('Select binary path...');
|
||||
browse_btn_visible = true;
|
||||
}
|
||||
|
||||
this.gridColumns = [{
|
||||
name: 'isDefault',
|
||||
label: gettext('Set as default'),
|
||||
@@ -1161,10 +1169,10 @@ define([
|
||||
cell: Backgrid.Extension.SelectFileCell,
|
||||
dialog_type: 'select_folder',
|
||||
dialog_title: gettext('Select Folder'),
|
||||
placeholder: pgAdmin.server_mode === 'False' ? gettext('Select binary path...') : pgAdmin.enable_binary_path_browsing ? gettext('Select binary path...') : gettext('Enter binary path...'),
|
||||
placeholder: placeholder,
|
||||
browse_btn_label: gettext('Select path'),
|
||||
check_btn_label: gettext('Validate utilities'),
|
||||
browse_btn_visible: pgAdmin.server_mode === 'False' ? true : pgAdmin.enable_binary_path_browsing ? true : false
|
||||
browse_btn_visible: browse_btn_visible
|
||||
}];
|
||||
|
||||
var BinPathCollection = this.BinPathCollection = new (Backbone.Collection.extend({
|
||||
@@ -1224,8 +1232,7 @@ define([
|
||||
|
||||
// Check if unique columns provided are also in model attributes.
|
||||
if (uniqueCol.length > _.intersection(columns, uniqueCol).length) {
|
||||
var errorMsg = 'Developer: Unique columns [ ' + _.difference(uniqueCol, columns) + ' ] not found in collection model [ ' + columns + ' ].';
|
||||
throw errorMsg;
|
||||
throw new Error('Developer: Unique columns [ ' + _.difference(uniqueCol, columns) + ' ] not found in collection model [ ' + columns + ' ].');
|
||||
}
|
||||
|
||||
var collection = self.collection = self.model.get(self.field.get('name'));
|
||||
@@ -2061,13 +2068,16 @@ define([
|
||||
// here?
|
||||
if (s.type == 'group') {
|
||||
var visible = true;
|
||||
ver_in_limit = (_.isUndefined(server_info) ? true :
|
||||
((_.isUndefined(s.server_type) ? true :
|
||||
if (_.isUndefined(server_info)) {
|
||||
ver_in_limit = true;
|
||||
} else {
|
||||
ver_in_limit = ((_.isUndefined(s.server_type) ? true :
|
||||
(server_info.type in s.server_type)) &&
|
||||
(_.isUndefined(s.min_version) ? true :
|
||||
(server_info.version >= s.min_version)) &&
|
||||
(_.isUndefined(s.max_version) ? true :
|
||||
(server_info.version <= s.max_version))));
|
||||
(server_info.version <= s.max_version)));
|
||||
}
|
||||
|
||||
if (s.mode && _.isObject(s.mode))
|
||||
visible = (_.indexOf(s.mode, mode) > -1);
|
||||
@@ -2097,13 +2107,16 @@ define([
|
||||
|
||||
// Generate the empty group list (if not exists)
|
||||
groups[group] = (groups[group] || []);
|
||||
ver_in_limit = (_.isUndefined(server_info) ? true :
|
||||
((_.isUndefined(s.server_type) ? true :
|
||||
if (_.isUndefined(server_info)) {
|
||||
ver_in_limit = true;
|
||||
} else {
|
||||
ver_in_limit = ((_.isUndefined(s.server_type) ? true :
|
||||
(server_info.type in s.server_type)) &&
|
||||
(_.isUndefined(s.min_version) ? true :
|
||||
(server_info.version >= s.min_version)) &&
|
||||
(_.isUndefined(s.max_version) ? true :
|
||||
(server_info.version <= s.max_version))));
|
||||
(server_info.version <= s.max_version)));
|
||||
}
|
||||
|
||||
var disabled = (
|
||||
!ver_in_limit || in_catalog
|
||||
@@ -3434,10 +3447,10 @@ define([
|
||||
keyPathAccessor: function(obj, path) {
|
||||
var res = obj;
|
||||
path = path.split('.');
|
||||
for (var i = 0; i < path.length; i++) {
|
||||
for (let path_val of path) {
|
||||
if (_.isNull(res)) return null;
|
||||
if (_.isEmpty(path[i])) continue;
|
||||
if (!_.isUndefined(res[path[i]])) res = res[path[i]];
|
||||
if (_.isEmpty(path_val)) continue;
|
||||
if (!_.isUndefined(res[path_val])) res = res[path_val];
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
@@ -1040,8 +1040,8 @@ define([
|
||||
if(select2_opts.first_empty) {
|
||||
optionValues.unshift(this.defaults.opt);
|
||||
}
|
||||
for (var i = 0; i < optionValues.length; i++) {
|
||||
var opt = optionValues[i];
|
||||
for (let option_val of optionValues) {
|
||||
var opt = option_val;
|
||||
|
||||
if (_.isArray(opt)) {
|
||||
|
||||
@@ -1331,7 +1331,6 @@ define([
|
||||
}, 10);
|
||||
}
|
||||
}, 10);
|
||||
return;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1759,12 +1758,16 @@ define([
|
||||
*/
|
||||
fromRaw: function(rawData) {
|
||||
if (rawData == null) return '';
|
||||
|
||||
var m = this.modelInUnixOffset ? moment(rawData) :
|
||||
this.modelInUnixTimestamp ? moment.unix(rawData) :
|
||||
this.modelInUTC ?
|
||||
moment.utc(rawData, this.modelFormat, this.modelLang) :
|
||||
moment(rawData, this.modelFormat, this.modelLang);
|
||||
var m = null;
|
||||
if (this.modelInUnixOffset) {
|
||||
m = moment(rawData);
|
||||
} else if (this.modelInUnixTimestamp) {
|
||||
m = moment.unix(rawData);
|
||||
} else if (this.modelInUTC) {
|
||||
m = moment.utc(rawData, this.modelFormat, this.modelLang);
|
||||
} else {
|
||||
m = moment(rawData, this.modelFormat, this.modelLang);
|
||||
}
|
||||
|
||||
if (this.displayInUnixOffset) return +m;
|
||||
|
||||
@@ -1789,12 +1792,16 @@ define([
|
||||
@return {string}
|
||||
*/
|
||||
toRaw: function(formattedData) {
|
||||
|
||||
var m = this.displayInUnixOffset ? moment(+formattedData) :
|
||||
this.displayInUnixTimestamp ? moment.unix(+formattedData) :
|
||||
this.displayInUTC ?
|
||||
moment.utc(formattedData, this.displayFormat, this.displayLang) :
|
||||
moment(formattedData, this.displayFormat, this.displayLang);
|
||||
var m = null;
|
||||
if (this.displayInUnixOffset) {
|
||||
m = moment(+formattedData);
|
||||
} else if (this.displayInUnixTimestamp) {
|
||||
m = moment.unix(+formattedData);
|
||||
} else if (this.displayInUTC) {
|
||||
m = moment.utc(formattedData, this.displayFormat, this.displayLang);
|
||||
} else {
|
||||
m = moment(formattedData, this.displayFormat, this.displayLang);
|
||||
}
|
||||
|
||||
if (!m || !m.isValid()) return (this.allowEmpty && formattedData === '') ? null : undefined;
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
define(['jquery', 'underscore'],
|
||||
function ($, _) {
|
||||
|
||||
var check_node_visibility = function (pgBrowser, node_type) {
|
||||
return function (pgBrowser, node_type) {
|
||||
if(_.isUndefined(node_type) || _.isNull(node_type)) {
|
||||
return true;
|
||||
}
|
||||
@@ -39,6 +39,4 @@ define(['jquery', 'underscore'],
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
return check_node_visibility;
|
||||
});
|
||||
|
@@ -123,12 +123,11 @@
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper('fold', 'sql', function(cm, start) {
|
||||
var fromToPos = pgadminKeywordRangeFinder(cm, start, [
|
||||
return pgadminKeywordRangeFinder(cm, start, [
|
||||
{start: 'BEGIN', end:'END;'},
|
||||
{start: 'IF', end:'END IF'},
|
||||
{start: 'LOOP', end:'END LOOP'},
|
||||
{start: 'CASE', end:'END CASE'},
|
||||
]);
|
||||
return fromToPos;
|
||||
});
|
||||
});
|
||||
|
@@ -632,13 +632,17 @@ const customReactSelectStyles = (theme, readonly)=>({
|
||||
color: 'inherit',
|
||||
}),
|
||||
option: (provided, state)=>{
|
||||
let bgColor = 'inherit';
|
||||
if (state.isFocused) {
|
||||
bgColor = theme.palette.grey[400];
|
||||
} else if (state.isSelected) {
|
||||
bgColor = theme.palette.primary.light;
|
||||
}
|
||||
return {
|
||||
...provided,
|
||||
padding: '0.5rem',
|
||||
color: 'inherit',
|
||||
backgroundColor: state.isFocused ?
|
||||
theme.palette.grey[400] : (state.isSelected ?
|
||||
theme.palette.primary.light : 'inherit'),
|
||||
backgroundColor: bgColor,
|
||||
};
|
||||
},
|
||||
multiValue: (provided)=>({
|
||||
|
@@ -185,9 +185,8 @@ export default function PgTable({ columns, data, isSelectRow, ...props }) {
|
||||
.filter((column) => {
|
||||
if (column.isVisible === undefined || columns.isVisible === true) {
|
||||
return false;
|
||||
} else{
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
)
|
||||
.map((column) => column.accessor)
|
||||
|
@@ -12,7 +12,7 @@ define([
|
||||
'sources/selection/range_selection_helper',
|
||||
], function ($, RangeSelectionHelper) {
|
||||
|
||||
var ActiveCellCapture = function () {
|
||||
return function () {
|
||||
var KEY_RIGHT = 39;
|
||||
var KEY_LEFT = 37;
|
||||
var KEY_UP = 38;
|
||||
@@ -200,6 +200,4 @@ define([
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return ActiveCellCapture;
|
||||
});
|
||||
|
@@ -10,7 +10,7 @@
|
||||
import Notify from '../helpers/Notifier';
|
||||
|
||||
define(['sources/gettext'], function (gettext) {
|
||||
var clipboard = {
|
||||
return {
|
||||
copyTextToClipboard: function (text) {
|
||||
var textArea = document.createElement('textarea');
|
||||
|
||||
@@ -92,5 +92,4 @@ define(['sources/gettext'], function (gettext) {
|
||||
return window.parent.window.clipboardData || '';
|
||||
},
|
||||
};
|
||||
return clipboard;
|
||||
});
|
||||
|
@@ -12,7 +12,7 @@ define([
|
||||
'sources/selection/range_selection_helper',
|
||||
'slickgrid',
|
||||
], function ($, RangeSelectionHelper) {
|
||||
var ColumnSelector = function () {
|
||||
return function () {
|
||||
var Slick = window.Slick,
|
||||
gridEventBus = new Slick.EventHandler(),
|
||||
onBeforeColumnSelectAll = new Slick.Event(),
|
||||
@@ -161,5 +161,4 @@ define([
|
||||
'toggleColumnHeaderForCopyHeader': toggleColumnHeaderForCopyHeader,
|
||||
});
|
||||
};
|
||||
return ColumnSelector;
|
||||
});
|
||||
|
@@ -14,7 +14,7 @@ define(['jquery',
|
||||
'sources/selection/range_selection_helper',
|
||||
'sources/url_for',
|
||||
], function ($, gettext, ColumnSelector, RowSelector, RangeSelectionHelper, url_for) {
|
||||
var GridSelector = function (columnDefinitions) {
|
||||
return function (columnDefinitions) {
|
||||
var Slick = window.Slick,
|
||||
rowSelector = new RowSelector(columnDefinitions),
|
||||
columnSelector = new ColumnSelector(columnDefinitions),
|
||||
@@ -89,6 +89,4 @@ define(['jquery',
|
||||
'onGridColumnSelectAll': onGridColumnSelectAll,
|
||||
});
|
||||
};
|
||||
|
||||
return GridSelector;
|
||||
});
|
||||
|
@@ -13,7 +13,7 @@ define([
|
||||
'sources/selection/column_selector',
|
||||
'slickgrid',
|
||||
], function ($, RangeSelectionHelper, ColumnSelector) {
|
||||
var RowSelector = function () {
|
||||
return function () {
|
||||
var Slick = window.Slick;
|
||||
|
||||
var gridEventBus = new Slick.EventHandler();
|
||||
@@ -107,6 +107,4 @@ define([
|
||||
'getColumnDefinitions': getColumnDefinitions,
|
||||
});
|
||||
};
|
||||
|
||||
return RowSelector;
|
||||
});
|
||||
|
@@ -59,11 +59,10 @@ define(
|
||||
|
||||
function getPrimaryKeysForSelectedRows(self, selectedRows) {
|
||||
var dataView = self.grid.getData();
|
||||
var stagedRows = getRowPrimaryKeyValuesToStage(selectedRows, _.keys(self.keys), dataView, self.client_primary_key);
|
||||
return stagedRows;
|
||||
return getRowPrimaryKeyValuesToStage(selectedRows, _.keys(self.keys), dataView, self.client_primary_key);
|
||||
}
|
||||
|
||||
var setStagedRows = function () {
|
||||
return function () {
|
||||
var self = this;
|
||||
|
||||
function setStagedRows(rowsToStage) {
|
||||
@@ -103,6 +102,5 @@ define(
|
||||
setStagedRows({});
|
||||
}
|
||||
};
|
||||
return setStagedRows;
|
||||
}
|
||||
);
|
||||
|
@@ -14,7 +14,7 @@ define([
|
||||
'sources/window',
|
||||
'slickgrid',
|
||||
], function ($, _, RangeSelectionHelper, pgWindow) {
|
||||
var XCellSelectionModel = function (options) {
|
||||
return function (options) {
|
||||
|
||||
var KEY_ARROW_RIGHT = 39;
|
||||
var KEY_ARROW_LEFT = 37;
|
||||
@@ -65,8 +65,8 @@ define([
|
||||
function removeInvalidRanges(ranges) {
|
||||
var result = [];
|
||||
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var r = ranges[i];
|
||||
for (let range_val of ranges) {
|
||||
var r = range_val;
|
||||
if (_grid.canCellBeSelected(r.fromRow, r.fromCell) && _grid.canCellBeSelected(r.toRow, r.toCell)) {
|
||||
result.push(r);
|
||||
}
|
||||
@@ -90,8 +90,8 @@ define([
|
||||
function setSelectedRows(rows) {
|
||||
_ranges = [];
|
||||
|
||||
for(var i = 0 ; i < rows.length ; i++) {
|
||||
_ranges.push(RangeSelectionHelper.rangeForRow(_grid, rows[i]));
|
||||
for(let row_val of rows) {
|
||||
_ranges.push(RangeSelectionHelper.rangeForRow(_grid, row_val));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,5 +237,4 @@ define([
|
||||
'onSelectedRangesChanged': new Slick.Event(),
|
||||
});
|
||||
};
|
||||
return XCellSelectionModel;
|
||||
});
|
||||
|
@@ -9,7 +9,7 @@
|
||||
|
||||
define([],
|
||||
function () {
|
||||
var sizePrettify = function (rawSize) {
|
||||
return function (rawSize) {
|
||||
var size = Math.abs(rawSize),
|
||||
limit = 10 * 1024,
|
||||
limit2 = limit - 1,
|
||||
@@ -28,6 +28,4 @@ define([],
|
||||
return Math.round(size) + ' ' + sizeUnits[cnt];
|
||||
}
|
||||
};
|
||||
|
||||
return sizePrettify;
|
||||
});
|
||||
|
@@ -95,8 +95,8 @@
|
||||
if (window.Slick.Data && data instanceof window.Slick.Data.DataView) {
|
||||
data = data.getItems();
|
||||
}
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
texts.push(data[i][columnDef.field]);
|
||||
for (let data_val of data) {
|
||||
texts.push(data_val[columnDef.field]);
|
||||
}
|
||||
var template = getMaxTextTemplate(texts, columnDef, colIndex, data, rowEl);
|
||||
var width = getTemplateWidth(rowEl, template);
|
||||
|
@@ -231,11 +231,10 @@ class ExecuteQuery {
|
||||
}
|
||||
|
||||
static prepareAnalyzeSql(sqlStatement, analyzeSql) {
|
||||
let sqlStatementWithAnalyze = {
|
||||
return {
|
||||
sql: sqlStatement,
|
||||
explain_plan: analyzeSql,
|
||||
};
|
||||
return sqlStatementWithAnalyze;
|
||||
}
|
||||
|
||||
onExecuteHTTPError(httpMessage) {
|
||||
|
@@ -133,6 +133,5 @@ export default function filterDialogModel(response) {
|
||||
},
|
||||
});
|
||||
|
||||
let model = new FilterCollectionModel();
|
||||
return model;
|
||||
return new FilterCollectionModel();
|
||||
}
|
||||
|
@@ -428,8 +428,7 @@ function itemToTable(item, columns, ignoredColumnIndex) {
|
||||
}
|
||||
|
||||
function generateInfoContent(infoList) {
|
||||
let infoContent = infoList.join('<br>');
|
||||
return infoContent;
|
||||
return infoList.join('<br>');
|
||||
}
|
||||
|
||||
module.exports = GeometryViewer;
|
||||
|
@@ -210,9 +210,7 @@ export default function macroModel(transId) {
|
||||
// Render subNode grid
|
||||
var subNodeGrid = grid.render().$el;
|
||||
|
||||
var $dialog = gridBody.append(subNodeGrid);
|
||||
|
||||
return $dialog;
|
||||
return gridBody.append(subNodeGrid);
|
||||
},
|
||||
}),
|
||||
columns: ['key_label', 'name', 'sql'],
|
||||
@@ -223,6 +221,5 @@ export default function macroModel(transId) {
|
||||
},
|
||||
});
|
||||
|
||||
let model = new MacroCollectionModel();
|
||||
return model;
|
||||
return new MacroCollectionModel();
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ let queryToolActions = {
|
||||
},
|
||||
|
||||
explain: function (sqlEditorController) {
|
||||
// let explainQuery = `EXPLAIN (FORMAT JSON, ANALYZE OFF, VERBOSE ${verbose}, COSTS ${costEnabled}, BUFFERS OFF, TIMING OFF) `;
|
||||
/* let explainQuery = `EXPLAIN (FORMAT JSON, ANALYZE OFF, VERBOSE ${verbose}, COSTS ${costEnabled}, BUFFERS OFF, TIMING OFF) `; */
|
||||
const explainObject = {
|
||||
format: 'json',
|
||||
analyze: false,
|
||||
|
@@ -231,7 +231,10 @@ export class Tree {
|
||||
|
||||
children(item) {
|
||||
const model = this.tree.getModel();
|
||||
return item ? (item.children !== null ? item.children : []) : model.root.children;
|
||||
if (item) {
|
||||
return (item.children !== null ? item.children : []);
|
||||
}
|
||||
return model.root.children;
|
||||
}
|
||||
|
||||
itemFrom(domElem) {
|
||||
|
70
web/pgadmin/static/vendor/backgrid/backgrid.js
vendored
70
web/pgadmin/static/vendor/backgrid/backgrid.js
vendored
@@ -306,14 +306,14 @@ _.extend(NumberFormatter.prototype, {
|
||||
var rawData = '';
|
||||
|
||||
var thousands = formattedData.split(this.orderSeparator);
|
||||
for (var i = 0; i < thousands.length; i++) {
|
||||
rawData += thousands[i];
|
||||
for (let thousand_val of thousands) {
|
||||
rawData += thousand_val;
|
||||
}
|
||||
|
||||
var decimalParts = rawData.split(this.decimalSeparator);
|
||||
rawData = '';
|
||||
for (var j = 0; j < decimalParts.length; j++) {
|
||||
rawData = rawData + decimalParts[j] + '.';
|
||||
for (let decimal_val of decimalParts) {
|
||||
rawData = rawData + decimal_val + '.';
|
||||
}
|
||||
|
||||
if (rawData[rawData.length - 1] === '.') {
|
||||
@@ -456,7 +456,10 @@ _.extend(DatetimeFormatter.prototype, {
|
||||
data = data.trim();
|
||||
var parts = data.split(this.ISO_SPLITTER_RE) || [];
|
||||
date = this.DATE_RE.test(parts[0]) ? parts[0] : '';
|
||||
time = date && parts[1] ? parts[1] : this.TIME_RE.test(parts[0]) ? parts[0] : '';
|
||||
time = this.TIME_RE.test(parts[0]) ? parts[0] : '';
|
||||
if (date && parts[1]) {
|
||||
time = parts[1];
|
||||
}
|
||||
}
|
||||
|
||||
var YYYYMMDD = this.DATE_RE.exec(date) || [];
|
||||
@@ -613,7 +616,10 @@ _.extend(SelectFormatter.prototype, {
|
||||
@return {Array.<*>}
|
||||
*/
|
||||
fromRaw: function (rawValue, model) {
|
||||
return _.isArray(rawValue) ? rawValue : rawValue != null ? [rawValue] : [];
|
||||
if (_.isArray(rawValue)) {
|
||||
return rawValue;
|
||||
}
|
||||
return rawValue != null ? [rawValue] : [];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1447,11 +1453,11 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({
|
||||
|
||||
_renderOptions: function (nvps, selectedValues) {
|
||||
var options = '';
|
||||
for (var i = 0; i < nvps.length; i++) {
|
||||
for (let nvps_val of nvps) {
|
||||
options = options + this.template({
|
||||
text: nvps[i][0],
|
||||
value: nvps[i][1],
|
||||
selected: _.indexOf(selectedValues, nvps[i][1]) > -1
|
||||
text: nvps_val[0],
|
||||
value: nvps_val[1],
|
||||
selected: _.indexOf(selectedValues, nvps_val[1]) > -1
|
||||
});
|
||||
}
|
||||
return options;
|
||||
@@ -1478,8 +1484,8 @@ var SelectCellEditor = Backgrid.SelectCellEditor = CellEditor.extend({
|
||||
var optgroupName = null;
|
||||
var optgroup = null;
|
||||
|
||||
for (var i = 0; i < optionValues.length; i++) {
|
||||
optionValue = optionValues[i];
|
||||
for (let option_val of optionValues) {
|
||||
optionValue = option_val;
|
||||
|
||||
if (_.isArray(optionValue)) {
|
||||
optionText = optionValue[0];
|
||||
@@ -1629,11 +1635,11 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({
|
||||
try {
|
||||
if (!_.isArray(optionValues) || _.isEmpty(optionValues)) throw new TypeError;
|
||||
|
||||
for (var k = 0; k < rawData.length; k++) {
|
||||
var rawDatum = rawData[k];
|
||||
for (let raw_val of rawData) {
|
||||
var rawDatum = raw_val;
|
||||
|
||||
for (var i = 0; i < optionValues.length; i++) {
|
||||
var optionValue = optionValues[i];
|
||||
for (let opt_val of optionValues) {
|
||||
var optionValue = opt_val;
|
||||
|
||||
if (_.isArray(optionValue)) {
|
||||
var optionText = optionValue[0];
|
||||
@@ -1644,8 +1650,8 @@ var SelectCell = Backgrid.SelectCell = Cell.extend({
|
||||
else if (_.isObject(optionValue)) {
|
||||
var optionGroupValues = optionValue.values;
|
||||
|
||||
for (var j = 0; j < optionGroupValues.length; j++) {
|
||||
var optionGroupValue = optionGroupValues[j];
|
||||
for (let opt_grp_val of optionGroupValues) {
|
||||
var optionGroupValue = opt_grp_val;
|
||||
if (optionGroupValue[1] == rawDatum) {
|
||||
selectedText.push(optionGroupValue[0]);
|
||||
}
|
||||
@@ -1993,8 +1999,8 @@ var Row = Backgrid.Row = Backbone.View.extend({
|
||||
this.$el.empty();
|
||||
|
||||
var fragment = document.createDocumentFragment();
|
||||
for (var i = 0; i < this.cells.length; i++) {
|
||||
fragment.appendChild(this.cells[i].render().el);
|
||||
for (let cell_val of this.cells) {
|
||||
fragment.appendChild(cell_val.render().el);
|
||||
}
|
||||
|
||||
this.el.appendChild(fragment);
|
||||
@@ -2010,8 +2016,8 @@ var Row = Backgrid.Row = Backbone.View.extend({
|
||||
@chainable
|
||||
*/
|
||||
remove: function () {
|
||||
for (var i = 0; i < this.cells.length; i++) {
|
||||
var cell = this.cells[i];
|
||||
for (let cell_val of this.cells) {
|
||||
var cell = cell_val;
|
||||
cell.remove.apply(cell, arguments);
|
||||
}
|
||||
return Backbone.View.prototype.remove.apply(this, arguments);
|
||||
@@ -2374,12 +2380,10 @@ var Body = Backgrid.Body = Backbone.View.extend({
|
||||
|
||||
this.row = options.row || this.row || Row;
|
||||
this.rows = this.collection.map(function (model) {
|
||||
var row = new this.row({
|
||||
return new this.row({
|
||||
columns: this.columns,
|
||||
model: model
|
||||
});
|
||||
|
||||
return row;
|
||||
}, this);
|
||||
|
||||
this.emptyText = options.emptyText;
|
||||
@@ -2527,17 +2531,15 @@ var Body = Backgrid.Body = Backbone.View.extend({
|
||||
instance as its sole parameter when done.
|
||||
*/
|
||||
refresh: function () {
|
||||
for (var i = 0; i < this.rows.length; i++) {
|
||||
this.rows[i].remove();
|
||||
for (let row_val of this.rows) {
|
||||
row_val.remove();
|
||||
}
|
||||
|
||||
this.rows = this.collection.map(function (model) {
|
||||
var row = new this.row({
|
||||
return new this.row({
|
||||
columns: this.columns,
|
||||
model: model
|
||||
});
|
||||
|
||||
return row;
|
||||
}, this);
|
||||
this._unshiftEmptyRowMayBe();
|
||||
|
||||
@@ -2557,8 +2559,8 @@ var Body = Backgrid.Body = Backbone.View.extend({
|
||||
this.$el.empty();
|
||||
|
||||
var fragment = document.createDocumentFragment();
|
||||
for (var i = 0; i < this.rows.length; i++) {
|
||||
var row = this.rows[i];
|
||||
for (let row_val of this.rows) {
|
||||
var row = row_val;
|
||||
fragment.appendChild(row.render().el);
|
||||
}
|
||||
|
||||
@@ -2575,8 +2577,8 @@ var Body = Backgrid.Body = Backbone.View.extend({
|
||||
@chainable
|
||||
*/
|
||||
remove: function () {
|
||||
for (var i = 0; i < this.rows.length; i++) {
|
||||
var row = this.rows[i];
|
||||
for (let row_val of this.rows) {
|
||||
var row = row_val;
|
||||
row.remove.apply(row, arguments);
|
||||
}
|
||||
return Backbone.View.prototype.remove.apply(this, arguments);
|
||||
|
@@ -121,10 +121,10 @@ define([
|
||||
},
|
||||
}];
|
||||
|
||||
for (var idx = 0; idx < menuUtils.backupSupportedNodes.length; idx++) {
|
||||
for (let node_val of menuUtils.backupSupportedNodes) {
|
||||
menus.push({
|
||||
name: 'backup_' + menuUtils.backupSupportedNodes[idx],
|
||||
node: menuUtils.backupSupportedNodes[idx],
|
||||
name: 'backup_' + node_val,
|
||||
node: node_val,
|
||||
module: this,
|
||||
applies: ['context'],
|
||||
callback: 'backupObjects',
|
||||
|
@@ -120,10 +120,10 @@ define('pgadmin.datagrid', [
|
||||
}];
|
||||
|
||||
// Create context menu
|
||||
for (var idx = 0; idx < supported_nodes.length; idx++) {
|
||||
for (let node_val of supported_nodes) {
|
||||
menus.push({
|
||||
name: 'view_all_rows_context_' + supported_nodes[idx],
|
||||
node: supported_nodes[idx],
|
||||
name: 'view_all_rows_context_' + node_val,
|
||||
node: node_val,
|
||||
module: this,
|
||||
data: {
|
||||
mnuid: 3,
|
||||
@@ -135,8 +135,8 @@ define('pgadmin.datagrid', [
|
||||
priority: 101,
|
||||
label: gettext('All Rows'),
|
||||
}, {
|
||||
name: 'view_first_100_rows_context_' + supported_nodes[idx],
|
||||
node: supported_nodes[idx],
|
||||
name: 'view_first_100_rows_context_' + node_val,
|
||||
node: node_val,
|
||||
module: this,
|
||||
data: {
|
||||
mnuid: 1,
|
||||
@@ -148,8 +148,8 @@ define('pgadmin.datagrid', [
|
||||
priority: 102,
|
||||
label: gettext('First 100 Rows'),
|
||||
}, {
|
||||
name: 'view_last_100_rows_context_' + supported_nodes[idx],
|
||||
node: supported_nodes[idx],
|
||||
name: 'view_last_100_rows_context_' + node_val,
|
||||
node: node_val,
|
||||
module: this,
|
||||
data: {
|
||||
mnuid: 2,
|
||||
@@ -161,8 +161,8 @@ define('pgadmin.datagrid', [
|
||||
priority: 103,
|
||||
label: gettext('Last 100 Rows'),
|
||||
}, {
|
||||
name: 'view_filtered_rows_context_' + supported_nodes[idx],
|
||||
node: supported_nodes[idx],
|
||||
name: 'view_filtered_rows_context_' + node_val,
|
||||
node: node_val,
|
||||
module: this,
|
||||
data: {
|
||||
mnuid: 4,
|
||||
|
@@ -57,9 +57,7 @@ export function getPanelTitle(pgBrowser, selected_item=null, custom_title=null,
|
||||
'server': parentData.server.label,
|
||||
'type': 'query_tool',
|
||||
};
|
||||
var title = generateTitle(qt_title_placeholder, title_data);
|
||||
|
||||
return title;
|
||||
return generateTitle(qt_title_placeholder, title_data);
|
||||
}
|
||||
|
||||
export function setQueryToolDockerTitle(panel, is_query_tool, panel_title, is_file) {
|
||||
|
@@ -287,7 +287,6 @@ function hasSchemaOrCatalogOrViewInformation(parentData) {
|
||||
}
|
||||
|
||||
export function generateDatagridTitle(pgBrowser, aciTreeIdentifier, custom_title=null, backend_entity=null) {
|
||||
//const baseTitle = getPanelTitle(pgBrowser, aciTreeIdentifier);
|
||||
var preferences = pgBrowser.get_preferences_for_module('browser');
|
||||
const parentData = pgBrowser.tree.getTreeNodeHierarchy(
|
||||
aciTreeIdentifier
|
||||
@@ -313,7 +312,5 @@ export function generateDatagridTitle(pgBrowser, aciTreeIdentifier, custom_title
|
||||
'table': node.getData().label,
|
||||
'type': 'datagrid',
|
||||
};
|
||||
var title = generateTitle(dtg_title_placeholder, title_data);
|
||||
|
||||
return title;
|
||||
return generateTitle(dtg_title_placeholder, title_data);
|
||||
}
|
||||
|
@@ -44,8 +44,7 @@ function hasServerInformations(parentData) {
|
||||
}
|
||||
|
||||
function generateTitle(pgBrowser, aciTreeIdentifier) {
|
||||
const baseTitle = getPanelTitle(pgBrowser, aciTreeIdentifier);
|
||||
return baseTitle;
|
||||
return getPanelTitle(pgBrowser, aciTreeIdentifier);
|
||||
}
|
||||
|
||||
export function showQueryTool(datagrid, pgBrowser, url, aciTreeIdentifier, transId) {
|
||||
|
@@ -447,7 +447,7 @@ define([
|
||||
panelTitleFunc.refresh_db_node(message, dbNode);
|
||||
}
|
||||
|
||||
var label = treeInfo.function ? treeInfo.function.label : treeInfo.trigger_function ? treeInfo.trigger_function.label : treeInfo.trigger ? treeInfo.trigger.label : treeInfo.procedure.label;
|
||||
var label = debuggerUtils.getAppropriateLabel(treeInfo);
|
||||
debuggerUtils.setDebuggerTitle(panel, browser_preferences, label, db_label, db_label, null, pgBrowser);
|
||||
|
||||
panel.focus();
|
||||
@@ -472,7 +472,7 @@ define([
|
||||
// Remove the leading and trailing white spaces.
|
||||
value = value.trim();
|
||||
let preferences = pgBrowser.get_preferences_for_module('browser');
|
||||
var name = treeInfo.function ? treeInfo.function.label : treeInfo.trigger_function ? treeInfo.trigger_function.label : treeInfo.trigger ? treeInfo.trigger.label : treeInfo.procedure.label;
|
||||
var name = debuggerUtils.getAppropriateLabel(treeInfo);
|
||||
debuggerUtils.setDebuggerTitle(panel, preferences, name, treeInfo.schema.label, treeInfo.database.label, value, pgBrowser);
|
||||
}
|
||||
},
|
||||
@@ -621,7 +621,7 @@ define([
|
||||
panelTitleFunc.refresh_db_node(message, dbNode);
|
||||
}
|
||||
|
||||
var label = newTreeInfo.function ? newTreeInfo.function.label : newTreeInfo.trigger_function ? newTreeInfo.trigger_function.label : newTreeInfo.trigger ? newTreeInfo.trigger.label : newTreeInfo.procedure.label;
|
||||
var label = debuggerUtils.getAppropriateLabel(newTreeInfo);
|
||||
debuggerUtils.setDebuggerTitle(panel, browser_preferences, label, newTreeInfo.schema.label, db_label, null, pgBrowser);
|
||||
|
||||
panel.focus();
|
||||
@@ -646,7 +646,7 @@ define([
|
||||
// Remove the leading and trailing white spaces.
|
||||
value = value.trim();
|
||||
let preferences = pgBrowser.get_preferences_for_module('browser');
|
||||
var name = treeInfo.function ? treeInfo.function.label : treeInfo.trigger_function ? treeInfo.trigger_function.label : treeInfo.trigger ? treeInfo.trigger.label : treeInfo.procedure.label;
|
||||
var name = debuggerUtils.getAppropriateLabel(treeInfo);
|
||||
debuggerUtils.setDebuggerTitle(panel, preferences, name, treeInfo.schema.label, treeInfo.database.label, value, pgBrowser);
|
||||
}
|
||||
},
|
||||
|
@@ -167,7 +167,7 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
var res = function(debugInfo, restartDebug, isEdbProc, transId) {
|
||||
return function(debugInfo, restartDebug, isEdbProc, transId) {
|
||||
if (!Alertify.debuggerInputArgsDialog) {
|
||||
Alertify.dialog('debuggerInputArgsDialog', function factory() {
|
||||
return {
|
||||
@@ -782,7 +782,7 @@ define([
|
||||
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
|
||||
);
|
||||
var browser_pref = pgBrowser.get_preferences_for_module('browser');
|
||||
var label = treeInfo.function ? treeInfo.function.label : treeInfo.trigger_function ? treeInfo.trigger_function.label : treeInfo.trigger ? treeInfo.trigger.label : treeInfo.procedure.label;
|
||||
var label = debuggerUtils.getAppropriateLabel(treeInfo);
|
||||
debuggerUtils.setDebuggerTitle(panel, browser_pref, label, treeInfo.schema.label, treeInfo.database.label, null, pgBrowser);
|
||||
panel.focus();
|
||||
|
||||
@@ -805,7 +805,7 @@ define([
|
||||
if(value) {
|
||||
// Remove the leading and trailing white spaces.
|
||||
value = value.trim();
|
||||
var name = treeInfo.function ? treeInfo.function.label : treeInfo.trigger_function ? treeInfo.trigger_function.label : treeInfo.trigger ? treeInfo.trigger.label : treeInfo.procedure.label;
|
||||
var name = debuggerUtils.getAppropriateLabel(treeInfo);
|
||||
debuggerUtils.setDebuggerTitle(panel, self.preferences, name, treeInfo.schema.label, treeInfo.database.label, value, pgBrowser);
|
||||
}
|
||||
},
|
||||
@@ -1054,6 +1054,4 @@ define([
|
||||
).resizeTo(pgBrowser.stdW.md,pgBrowser.stdH.md);
|
||||
|
||||
};
|
||||
|
||||
return res;
|
||||
});
|
||||
|
@@ -86,10 +86,22 @@ function get_function_name(function_name) {
|
||||
}
|
||||
return func_name;
|
||||
}
|
||||
function getAppropriateLabel(treeInfo) {
|
||||
if (treeInfo.function) {
|
||||
return treeInfo.function.label;
|
||||
} else if (treeInfo.trigger_function) {
|
||||
return treeInfo.trigger_function.label;
|
||||
} else if (treeInfo.trigger) {
|
||||
return treeInfo.trigger.label;
|
||||
} else {
|
||||
return treeInfo.procedure.label;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setFocusToDebuggerEditor: setFocusToDebuggerEditor,
|
||||
getFunctionId: getFunctionId,
|
||||
getProcedureId: getProcedureId,
|
||||
setDebuggerTitle: setDebuggerTitle,
|
||||
getAppropriateLabel: getAppropriateLabel,
|
||||
};
|
||||
|
@@ -104,19 +104,19 @@ define([
|
||||
|
||||
var breakpoint_list = new Array();
|
||||
|
||||
for (var i = 0; i < br_list.length; i++) {
|
||||
if (br_list[i].linenumber != -1) {
|
||||
breakpoint_list.push(br_list[i].linenumber);
|
||||
for (let val of br_list) {
|
||||
if (val.linenumber != -1) {
|
||||
breakpoint_list.push(val.linenumber);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < breakpoint_list.length; i++) {
|
||||
var info = pgTools.DirectDebug.editor.lineInfo((breakpoint_list[i] - 1));
|
||||
for (let brk_val of breakpoint_list) {
|
||||
var info = pgTools.DirectDebug.editor.lineInfo((brk_val - 1));
|
||||
|
||||
if (info.gutterMarkers != undefined) {
|
||||
pgTools.DirectDebug.editor.setGutterMarker((breakpoint_list[i] - 1), 'breakpoints', null);
|
||||
pgTools.DirectDebug.editor.setGutterMarker((brk_val - 1), 'breakpoints', null);
|
||||
} else {
|
||||
pgTools.DirectDebug.editor.setGutterMarker((breakpoint_list[i] - 1), 'breakpoints', function() {
|
||||
pgTools.DirectDebug.editor.setGutterMarker((brk_val - 1), 'breakpoints', function() {
|
||||
var marker = document.createElement('div');
|
||||
marker.style.color = '#822';
|
||||
marker.innerHTML = '●';
|
||||
@@ -937,9 +937,9 @@ define([
|
||||
|
||||
var breakpoint_list = new Array();
|
||||
|
||||
for (var i = 0; i < br_list.length; i++) {
|
||||
if (br_list[i].linenumber != -1) {
|
||||
breakpoint_list.push(br_list[i].linenumber);
|
||||
for (let val of br_list) {
|
||||
if (val.linenumber != -1) {
|
||||
breakpoint_list.push(val.linenumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -957,12 +957,12 @@ define([
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.data.status) {
|
||||
for (var j = 0; j < breakpoint_list.length; j++) {
|
||||
var info = pgTools.DirectDebug.editor.lineInfo((breakpoint_list[j] - 1));
|
||||
for (let brk_val of breakpoint_list) {
|
||||
var info = pgTools.DirectDebug.editor.lineInfo((brk_val - 1));
|
||||
|
||||
if (info) {
|
||||
if (info.gutterMarkers != undefined) {
|
||||
pgTools.DirectDebug.editor.setGutterMarker((breakpoint_list[j] - 1), 'breakpoints', null);
|
||||
pgTools.DirectDebug.editor.setGutterMarker((brk_val - 1), 'breakpoints', null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1168,12 +1168,12 @@ define([
|
||||
|
||||
var my_obj = [];
|
||||
if (result.length != 0) {
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
if (result[i].varclass == 'L') {
|
||||
for (let res_val of result) {
|
||||
if (res_val.varclass == 'L') {
|
||||
my_obj.push({
|
||||
'name': result[i].name,
|
||||
'type': result[i].dtype,
|
||||
'value': result[i].value,
|
||||
'name': res_val.name,
|
||||
'type': res_val.dtype,
|
||||
'value': res_val.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1254,12 +1254,12 @@ define([
|
||||
|
||||
var param_obj = [];
|
||||
if (result.length != 0) {
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
if (result[i].varclass == 'A') {
|
||||
for (let res_val of result) {
|
||||
if (res_val.varclass == 'A') {
|
||||
param_obj.push({
|
||||
'name': result[i].name,
|
||||
'type': result[i].dtype,
|
||||
'value': result[i].value,
|
||||
'name': res_val.name,
|
||||
'type': res_val.dtype,
|
||||
'value': res_val.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, pgBrowser
|
||||
|
||||
erdToolEnabled: function(obj) {
|
||||
/* Same as query tool */
|
||||
var isEnabled = (() => {
|
||||
return (() => {
|
||||
if (!_.isUndefined(obj) && !_.isNull(obj)) {
|
||||
if (_.indexOf(pgAdmin.unsupported_nodes, obj._type) == -1) {
|
||||
if (obj._type == 'database' && obj.allowConn) {
|
||||
@@ -94,7 +94,6 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, pgBrowser
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
return isEnabled;
|
||||
},
|
||||
|
||||
// Callback to draw ERD Tool for objects
|
||||
|
@@ -8,9 +8,8 @@
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import * as React from 'react';
|
||||
import { CanvasWidget } from '@projectstorm/react-canvas-core';
|
||||
import { CanvasWidget, Action, InputType } from '@projectstorm/react-canvas-core';
|
||||
import axios from 'axios';
|
||||
import { Action, InputType } from '@projectstorm/react-canvas-core';
|
||||
import PropTypes from 'prop-types';
|
||||
import _ from 'lodash';
|
||||
import html2canvas from 'html2canvas';
|
||||
@@ -40,8 +39,8 @@ export class KeyboardShortcutAction extends Action {
|
||||
});
|
||||
this.shortcuts = {};
|
||||
|
||||
for(let i=0; i<shortcut_handlers.length; i++){
|
||||
let [key, handler] = shortcut_handlers[i];
|
||||
for(let shortcut_val of shortcut_handlers){
|
||||
let [key, handler] = shortcut_val;
|
||||
if(key) {
|
||||
this.shortcuts[this.shortcutKey(key.alt, key.control, key.shift, false, key.key.key_code)] = handler;
|
||||
}
|
||||
|
@@ -238,8 +238,11 @@ export default function GrantWizard({ sid, did, nodeInfo, nodeData }) {
|
||||
};
|
||||
|
||||
const disableNextCheck = (stepId) => {
|
||||
return selectedObject.length > 0 && stepId === 0 ?
|
||||
false : selectedAcl?.privilege?.length > 0 && stepId === 1 ? validatePrivilege() : true;
|
||||
if (selectedObject.length > 0 && stepId === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return selectedAcl?.privilege?.length > 0 && stepId === 1 ? validatePrivilege() : true;
|
||||
};
|
||||
|
||||
const onDialogHelp= () => {
|
||||
|
@@ -57,10 +57,10 @@ define([
|
||||
}];
|
||||
|
||||
// Add supported menus into the menus list
|
||||
for (var idx = 0; idx < menuUtils.supportedNodes.length; idx++) {
|
||||
for (let mnu_val of menuUtils.supportedNodes) {
|
||||
menus.push({
|
||||
name: 'grant_wizard_schema_context_' + menuUtils.supportedNodes[idx],
|
||||
node: menuUtils.supportedNodes[idx],
|
||||
name: 'grant_wizard_schema_context_' + mnu_val,
|
||||
node: mnu_val,
|
||||
module: this,
|
||||
applies: ['context'],
|
||||
callback: 'start_grant_wizard',
|
||||
|
@@ -55,10 +55,10 @@ define([
|
||||
}];
|
||||
|
||||
// Add supported menus into the menus list
|
||||
for (var idx = 0; idx < menuUtils.maintenanceSupportedNodes.length; idx++) {
|
||||
for (let sup_node_val of menuUtils.maintenanceSupportedNodes) {
|
||||
menus.push({
|
||||
name: 'maintenance_context_' + menuUtils.maintenanceSupportedNodes[idx],
|
||||
node: menuUtils.maintenanceSupportedNodes[idx],
|
||||
name: 'maintenance_context_' + sup_node_val,
|
||||
node: sup_node_val,
|
||||
module: this,
|
||||
applies: ['context'],
|
||||
callback: 'callback_maintenance',
|
||||
@@ -164,7 +164,6 @@ define([
|
||||
gettext('Utility not found'),
|
||||
res.data.errormsg
|
||||
);
|
||||
return;
|
||||
} else{
|
||||
|
||||
pgBrowser.Node.registerUtilityPanel();
|
||||
@@ -196,7 +195,6 @@ define([
|
||||
gettext('Utility not found'),
|
||||
gettext('Failed to fetch Utility information')
|
||||
);
|
||||
return;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
@@ -243,13 +243,11 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, Browser)
|
||||
},
|
||||
psql_terminal: function() {
|
||||
// theme colors
|
||||
var term = new terminal({
|
||||
return new terminal({
|
||||
cursorBlink: true,
|
||||
macOptionIsMeta: true,
|
||||
scrollback: 5000,
|
||||
});
|
||||
|
||||
return term;
|
||||
},
|
||||
psql_Addon: function(term) {
|
||||
const fitAddon = this.psql_fit_screen();
|
||||
|
@@ -52,10 +52,10 @@ define('tools.restore', [
|
||||
},
|
||||
}];
|
||||
|
||||
for (var idx = 0; idx < menuUtils.restoreSupportedNodes.length; idx++) {
|
||||
for (let sup_node_val of menuUtils.restoreSupportedNodes) {
|
||||
menus.push({
|
||||
name: 'restore_' + menuUtils.restoreSupportedNodes[idx],
|
||||
node: menuUtils.restoreSupportedNodes[idx],
|
||||
name: 'restore_' + sup_node_val,
|
||||
node: sup_node_val,
|
||||
module: this,
|
||||
applies: ['context'],
|
||||
callback: 'restoreObjects',
|
||||
@@ -173,7 +173,6 @@ define('tools.restore', [
|
||||
gettext('Utility not found'),
|
||||
gettext('Failed to fetch Utility information')
|
||||
);
|
||||
return;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
@@ -278,8 +278,8 @@ export default class SchemaDiffUI {
|
||||
if (sel_rows.length > 0) {
|
||||
let script_array = {1: [], 2: [], 3: [], 4: [], 5: []},
|
||||
script_body = '';
|
||||
for (var row = 0; row < sel_rows.length; row++) {
|
||||
let data = self.grid.getData().getItem(sel_rows[row]);
|
||||
for (let sel_row_val of sel_rows) {
|
||||
let data = self.grid.getData().getItem(sel_row_val);
|
||||
if(!_.isUndefined(data.diff_ddl)) {
|
||||
if (!(data.dependLevel in script_array)) script_array[data.dependLevel] = [];
|
||||
// Check whether the selected object belongs to source only schema
|
||||
@@ -384,11 +384,11 @@ export default class SchemaDiffUI {
|
||||
formatter: function (g) {
|
||||
let icon = 'icon-coll-' + g.value;
|
||||
let identical=0, different=0, source_only=0, target_only=0;
|
||||
for (var i = 0; i < g.rows.length; i++) {
|
||||
if (g.rows[i]['status'] == self.filters[0]) identical++;
|
||||
else if (g.rows[i]['status'] == self.filters[1]) different++;
|
||||
else if (g.rows[i]['status'] == self.filters[2]) source_only++;
|
||||
else if (g.rows[i]['status'] == self.filters[3]) target_only++;
|
||||
for (let row_val of g.rows) {
|
||||
if (row_val['status'] == self.filters[0]) identical++;
|
||||
else if (row_val['status'] == self.filters[1]) different++;
|
||||
else if (row_val['status'] == self.filters[2]) source_only++;
|
||||
else if (row_val['status'] == self.filters[3]) target_only++;
|
||||
}
|
||||
return '<i class="wcTabIcon '+ icon +'"></i><span>' + g.rows[0].label + ' - ' + gettext('Identical') + ': <strong>' + identical + '</strong> ' + gettext('Different') + ': <strong>' + different + '</strong> ' + gettext('Source Only') + ': <strong>' + source_only + '</strong> ' + gettext('Target Only') + ': <strong>' + target_only + '</strong></span>';
|
||||
},
|
||||
@@ -684,9 +684,9 @@ export default class SchemaDiffUI {
|
||||
if (!_.isUndefined(m.get('source_sid')) && !_.isNull(m.get('source_sid'))
|
||||
&& m.get('source_sid') !== '') {
|
||||
setTimeout(function() {
|
||||
for (var i = 0; i < self_local.options.length; i++) {
|
||||
if (self_local.options[i].is_maintenance_db) {
|
||||
m.set('source_did', self_local.options[i].value);
|
||||
for (let opt_val of self_local.options) {
|
||||
if (opt_val.is_maintenance_db) {
|
||||
m.set('source_did', opt_val.value);
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
@@ -768,9 +768,9 @@ export default class SchemaDiffUI {
|
||||
if (!_.isUndefined(m.get('target_sid')) && !_.isNull(m.get('target_sid'))
|
||||
&& m.get('target_sid') !== '') {
|
||||
setTimeout(function() {
|
||||
for (var i = 0; i < self_local.options.length; i++) {
|
||||
if (self_local.options[i].is_maintenance_db) {
|
||||
m.set('target_did', self_local.options[i].value);
|
||||
for (let opt_val of self_local.options) {
|
||||
if (opt_val.is_maintenance_db) {
|
||||
m.set('target_did', opt_val.value);
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
|
@@ -307,7 +307,10 @@ export default class SearchObjectsDialogWrapper extends DialogWrapper {
|
||||
var field = cols[i].sortCol.field;
|
||||
var sign = cols[i].sortAsc ? 1 : -1;
|
||||
var value1 = dataRow1[field], value2 = dataRow2[field];
|
||||
var result = (value1 == value2 ? 0 : (value1 > value2 ? 1 : -1)) * sign;
|
||||
var result = 0;
|
||||
if (value1 != value2) {
|
||||
result = (value1 > value2 ? 1 : -1) * sign;
|
||||
}
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
@@ -676,7 +679,6 @@ export default class SearchObjectsDialogWrapper extends DialogWrapper {
|
||||
null,
|
||||
null,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1523,11 +1523,11 @@ define('tools.querytool', [
|
||||
update_grid_data: function(data) {
|
||||
this.dataView.beginUpdate();
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
for (let data_val of data) {
|
||||
// Convert 2darray to dict.
|
||||
var item = {};
|
||||
for (var j = 1; j < this.grid_columns.length; j++) {
|
||||
item[this.grid_columns[j]['field']] = data[i][this.grid_columns[j]['pos']];
|
||||
item[this.grid_columns[j]['field']] = data_val[this.grid_columns[j]['pos']];
|
||||
}
|
||||
|
||||
item[this.client_primary_key] = (this.client_primary_key_counter++).toString();
|
||||
@@ -3237,13 +3237,12 @@ define('tools.querytool', [
|
||||
var col_type = '',
|
||||
column_label = '',
|
||||
col_cell;
|
||||
var type = pg_types[c.type_code] ?
|
||||
pg_types[c.type_code][0] :
|
||||
// This is the case where user might
|
||||
// have use casting so we will use type
|
||||
// returned by cast function
|
||||
pg_types[pg_types.length - 1][0] ?
|
||||
pg_types[pg_types.length - 1][0] : 'unknown';
|
||||
var type = 'unknown';
|
||||
if (pg_types[c.type_code]) {
|
||||
type = pg_types[c.type_code][0];
|
||||
} else if (pg_types[pg_types.length - 1][0]) {
|
||||
type = pg_types[pg_types.length - 1][0];
|
||||
}
|
||||
|
||||
if (!is_primary_key)
|
||||
col_type += type;
|
||||
@@ -3494,11 +3493,11 @@ define('tools.querytool', [
|
||||
grid.resetActiveCell();
|
||||
|
||||
dataView.beginUpdate();
|
||||
for (var i = 0; i < deleted_keys.length; i++) {
|
||||
delete self.data_store.staged_rows[deleted_keys[i]];
|
||||
delete self.data_store.added[deleted_keys[i]];
|
||||
delete self.data_store.added_index[deleted_keys[i]];
|
||||
dataView.deleteItem(deleted_keys[i]);
|
||||
for (let del_val of deleted_keys) {
|
||||
delete self.data_store.staged_rows[del_val];
|
||||
delete self.data_store.added[del_val];
|
||||
delete self.data_store.added_index[del_val];
|
||||
dataView.deleteItem(del_val);
|
||||
}
|
||||
dataView.endUpdate();
|
||||
self.rows_to_delete.apply(self, [dataView.getItems()]);
|
||||
@@ -3523,7 +3522,6 @@ define('tools.querytool', [
|
||||
_.each(_.keys(self.data_store.staged_rows), function(key) {
|
||||
if(key in self.data_store.deleted) {
|
||||
strikeout = false;
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3685,8 +3683,8 @@ define('tools.querytool', [
|
||||
dataView.setItems(data, self.client_primary_key);
|
||||
} else {
|
||||
dataView.beginUpdate();
|
||||
for (var j = 0; j < rows.length; j++) {
|
||||
var item = grid.getData().getItemById(rows[j]);
|
||||
for (let row_val of rows) {
|
||||
var item = grid.getData().getItemById(row_val);
|
||||
data.push(item);
|
||||
dataView.deleteItem(item[self.client_primary_key]);
|
||||
}
|
||||
|
@@ -72,19 +72,19 @@ describe('layout related functions test', function() {
|
||||
|
||||
describe('lock_layout', function() {
|
||||
let change_checked_test= function(menu_name) {
|
||||
for(let i=0; i<menu_items.length; i++) {
|
||||
if(menu_items[i].name == menu_name) {
|
||||
expect(menu_items[i].change_checked).toHaveBeenCalledWith(true);
|
||||
for(let mnu_val of menu_items) {
|
||||
if(mnu_val.name == menu_name) {
|
||||
expect(mnu_val.change_checked).toHaveBeenCalledWith(true);
|
||||
} else {
|
||||
expect(menu_items[i].change_checked).toHaveBeenCalledWith(false);
|
||||
expect(mnu_val.change_checked).toHaveBeenCalledWith(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function(){
|
||||
spyOn(pgBrowser.docker, 'lockLayout');
|
||||
for(let i=0; i<menu_items.length; i++) {
|
||||
spyOn(menu_items[i], 'change_checked');
|
||||
for(let mnu_val of menu_items) {
|
||||
spyOn(mnu_val, 'change_checked');
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -2,8 +2,8 @@ import React from 'react';
|
||||
import Theme from 'sources/Theme';
|
||||
|
||||
export function withTheme(WrappedComp) {
|
||||
let NewComp = (props)=>{
|
||||
// eslint-disable-next-line react/display-name
|
||||
return (props)=>{
|
||||
return <Theme><WrappedComp {...props}/></Theme>;
|
||||
};
|
||||
return NewComp;
|
||||
}
|
||||
|
@@ -107,8 +107,12 @@ export class TreeFake extends Tree {
|
||||
let idx = 0;
|
||||
let node_cnt = 0;
|
||||
let result = {};
|
||||
let item = TreeNode.prototype.isPrototypeOf(identifier) ? identifier :
|
||||
(identifier.path ? this.findNode(identifier.path) : this.findNodeByDomElement(identifier));
|
||||
let item = null;
|
||||
if (TreeNode.prototype.isPrototypeOf(identifier)) {
|
||||
item = identifier;
|
||||
} else {
|
||||
item = identifier.path ? this.findNode(identifier.path) : this.findNodeByDomElement(identifier);
|
||||
}
|
||||
|
||||
if (item == undefined || item == null) return null;
|
||||
|
||||
|
@@ -95,8 +95,8 @@ function cssToBeSkiped(curr_path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for(let i=0; i< webpackShimConfig.css_bundle_skip.length; i++) {
|
||||
if(path.join(__dirname, webpackShimConfig.css_bundle_skip[i]) === curr_path){
|
||||
for(let value of webpackShimConfig.css_bundle_skip) {
|
||||
if(path.join(__dirname, value) === curr_path){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -133,11 +133,11 @@ let pgadminScssStyles = [];
|
||||
let pgadminCssStyles = [];
|
||||
|
||||
/* Include what is given in shim config */
|
||||
for(let i=0; i<webpackShimConfig.css_bundle_include.length; i++) {
|
||||
if(webpackShimConfig.css_bundle_include[i].endsWith('.scss')) {
|
||||
pgadminScssStyles.push(path.join(__dirname, webpackShimConfig.css_bundle_include[i]));
|
||||
} else if(webpackShimConfig.css_bundle_include[i].endsWith('.css')){
|
||||
pgadminCssStyles.push(path.join(__dirname, webpackShimConfig.css_bundle_include[i]));
|
||||
for(let value of webpackShimConfig.css_bundle_include) {
|
||||
if(value.endsWith('.scss')) {
|
||||
pgadminScssStyles.push(path.join(__dirname, value));
|
||||
} else if(value.endsWith('.css')){
|
||||
pgadminCssStyles.push(path.join(__dirname, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -358,8 +358,8 @@ var webpackShimConfig = {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<match_modules.length; i++) {
|
||||
if(module.rawRequest.indexOf(match_modules[i]) >= 0) {
|
||||
for(let value of match_modules) {
|
||||
if(module.rawRequest.indexOf(value) >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user