mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 08:46:39 -06:00
Fixed some SonarQube issues.
This commit is contained in:
parent
faa66f1636
commit
008bc6da28
@ -941,14 +941,14 @@ def set_master_password():
|
||||
if not config.SERVER_MODE and config.MASTER_PASSWORD_REQUIRED:
|
||||
|
||||
# if master pass is set previously
|
||||
if current_user.masterpass_check is not None:
|
||||
if data.get('button_click') and \
|
||||
not validate_master_password(data.get('password')):
|
||||
return form_master_password_response(
|
||||
existing=True,
|
||||
present=False,
|
||||
errmsg=gettext("Incorrect master password")
|
||||
)
|
||||
if current_user.masterpass_check is not None and \
|
||||
data.get('button_click') and \
|
||||
not validate_master_password(data.get('password')):
|
||||
return form_master_password_response(
|
||||
existing=True,
|
||||
present=False,
|
||||
errmsg=gettext("Incorrect master password")
|
||||
)
|
||||
|
||||
if data != '' and data.get('password', '') != '':
|
||||
|
||||
|
@ -17,8 +17,6 @@ export function Search() {
|
||||
const wrapperRef = useRef(null);
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
const [isShowMinLengthMsg, setIsShowMinLengthMsg] = useState(false);
|
||||
let helpLinkTitles = [];
|
||||
let helpLinks = [];
|
||||
const [isMenuLoading, setIsMenuLoading] = useState(false);
|
||||
const [isHelpLoading, setIsHelpLoading] = useState(false);
|
||||
const [menuSearchResult, setMenuSearchResult] = useState({
|
||||
@ -51,11 +49,6 @@ export function Search() {
|
||||
|
||||
// Below will be called when any changes has been made to state
|
||||
useEffect(() => {
|
||||
helpLinkTitles = Object.keys(helpSearchResult.data);
|
||||
for(let i = 0; i<helpLinkTitles.length;i++){
|
||||
helpLinks.push(<a href={''} target='_blank' rel='noreferrer'>helpLinkTitles[i]</a>);
|
||||
}
|
||||
|
||||
if(menuSearchResult.fetched == true){
|
||||
setIsMenuLoading(false);
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ define('pgadmin.dashboard', [
|
||||
// Check if user is super user
|
||||
var server = treeHierarchy['server'];
|
||||
maintenance_database = (server && server.db) || null;
|
||||
can_signal_backend = server.user.can_signal_backend;
|
||||
can_signal_backend = (server && server.user) ? server.user.can_signal_backend : false;
|
||||
|
||||
if (server && server.user && server.user.is_superuser) {
|
||||
is_super_user = true;
|
||||
|
@ -1474,7 +1474,7 @@ define('pgadmin.misc.explain', [
|
||||
ctx.totalDownloadedNodes++;
|
||||
if (!ctx.isDownloaded && ctx.totalNodes === ctx.totalDownloadedNodes) {
|
||||
ctx.isDownloaded = true;
|
||||
var s = Snap('.pgadmin-explain-container svg');
|
||||
s = Snap('.pgadmin-explain-container svg');
|
||||
var today = new Date();
|
||||
var filename = 'explain_plan_' + today.getTime() + '.svg';
|
||||
svgDownloader.downloadSVG(s.toString(), filename);
|
||||
|
@ -557,10 +557,9 @@ define([
|
||||
this.updateInvalid();
|
||||
|
||||
this.$el.find('.btn').on('keyup', (e)=>{
|
||||
switch(e.keyCode) {
|
||||
case 32: /* Spacebar click */
|
||||
/* Spacebar click */
|
||||
if (e.keyCode == 32) {
|
||||
$(e.currentTarget).trigger('click');
|
||||
break;
|
||||
}
|
||||
});
|
||||
return this;
|
||||
|
@ -118,7 +118,7 @@ export class ModelValidation {
|
||||
} catch(e) {
|
||||
try {
|
||||
new Address6(ipAddress);
|
||||
} catch(e) {
|
||||
} catch(ex) {
|
||||
this.err['hostaddr'] = msg;
|
||||
this.errmsg = msg;
|
||||
}
|
||||
|
@ -447,8 +447,8 @@ _.extend(DatetimeFormatter.prototype, {
|
||||
if ((data + '').trim() === '') return null;
|
||||
|
||||
var date, time = null;
|
||||
var jsDate = new Date(data);
|
||||
if (_.isNumber(data)) {
|
||||
var jsDate = new Date(data);
|
||||
date = lpad(jsDate.getUTCFullYear(), 4, 0) + '-' + lpad(jsDate.getUTCMonth() + 1, 2, 0) + '-' + lpad(jsDate.getUTCDate(), 2, 0);
|
||||
time = lpad(jsDate.getUTCHours(), 2, 0) + ':' + lpad(jsDate.getUTCMinutes(), 2, 0) + ':' + lpad(jsDate.getUTCSeconds(), 2, 0);
|
||||
}
|
||||
@ -469,7 +469,7 @@ _.extend(DatetimeFormatter.prototype, {
|
||||
if (!this.includeTime && time) return;
|
||||
}
|
||||
|
||||
var jsDate = new Date(Date.UTC(YYYYMMDD[1] * 1 || 0,
|
||||
jsDate = new Date(Date.UTC(YYYYMMDD[1] * 1 || 0,
|
||||
YYYYMMDD[2] * 1 - 1 || 0,
|
||||
YYYYMMDD[3] * 1 || 0,
|
||||
HHmmssSSS[1] * 1 || null,
|
||||
@ -1348,16 +1348,17 @@ var BooleanCellEditor = Backgrid.BooleanCellEditor = CellEditor.extend({
|
||||
}
|
||||
|
||||
var $el = this.$el;
|
||||
var val = null;
|
||||
if (command.save() || command.moveLeft() || command.moveRight() || command.moveUp() ||
|
||||
command.moveDown()) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var val = formatter.toRaw($el.prop("checked"), model);
|
||||
val = formatter.toRaw($el.prop("checked"), model);
|
||||
model.set(column.get("name"), val);
|
||||
model.trigger("backgrid:edited", model, column, command);
|
||||
}
|
||||
else if (e.type == "change") {
|
||||
var val = formatter.toRaw($el.prop("checked"), model);
|
||||
val = formatter.toRaw($el.prop("checked"), model);
|
||||
model.set(column.get("name"), val);
|
||||
$el.focus();
|
||||
}
|
||||
|
@ -188,7 +188,8 @@ class Driver(BaseDriver):
|
||||
"""
|
||||
manager = self.connection_manager(sid)
|
||||
|
||||
return manager.connection(database, conn_id, auto_reconnect)
|
||||
return manager.connection(database=database, conn_id=conn_id,
|
||||
auto_reconnect=auto_reconnect)
|
||||
|
||||
def release_connection(self, sid, database=None, conn_id=None):
|
||||
"""
|
||||
|
@ -145,11 +145,15 @@ class Connection(BaseConnection):
|
||||
gettext("Cursor could not be found for the async connection.")
|
||||
ARGS_STR = "{0}#{1}"
|
||||
|
||||
def __init__(self, manager, conn_id, db, auto_reconnect=True, async_=0,
|
||||
use_binary_placeholder=False, array_to_string=False):
|
||||
def __init__(self, manager, conn_id, db, **kwargs):
|
||||
assert (manager is not None)
|
||||
assert (conn_id is not None)
|
||||
|
||||
auto_reconnect = kwargs.get('auto_reconnect', True)
|
||||
async_ = kwargs.get('async_', 0)
|
||||
use_binary_placeholder = kwargs.get('use_binary_placeholder', False)
|
||||
array_to_string = kwargs.get('array_to_string', False)
|
||||
|
||||
self.conn_id = conn_id
|
||||
self.manager = manager
|
||||
self.db = db if db is not None else manager.db
|
||||
|
@ -182,10 +182,15 @@ class ServerManager(object):
|
||||
return int(int(self.sversion / 100) / 100)
|
||||
raise InternalServerError(self._INFORMATION_MSG)
|
||||
|
||||
def connection(
|
||||
self, database=None, conn_id=None, auto_reconnect=True, did=None,
|
||||
async_=None, use_binary_placeholder=False, array_to_string=False
|
||||
):
|
||||
def connection(self, **kwargs):
|
||||
database = kwargs.get('database', None)
|
||||
conn_id = kwargs.get('conn_id', None)
|
||||
auto_reconnect = kwargs.get('auto_reconnect', True)
|
||||
did = kwargs.get('did', None)
|
||||
async_ = kwargs.get('async_', None)
|
||||
use_binary_placeholder = kwargs.get('use_binary_placeholder', False)
|
||||
array_to_string = kwargs.get('array_to_string', False)
|
||||
|
||||
if database is not None:
|
||||
if did is not None and did in self.db_info:
|
||||
self.db_info[did]['datname'] = database
|
||||
@ -247,7 +252,8 @@ WHERE db.oid = {0}""".format(did))
|
||||
else:
|
||||
async_ = 1 if async_ is True else 0
|
||||
self.connections[my_id] = Connection(
|
||||
self, my_id, database, auto_reconnect, async_,
|
||||
self, my_id, database, auto_reconnect=auto_reconnect,
|
||||
async_=async_,
|
||||
use_binary_placeholder=use_binary_placeholder,
|
||||
array_to_string=array_to_string
|
||||
)
|
||||
|
@ -475,7 +475,7 @@ class Preferences(object):
|
||||
|
||||
@classmethod
|
||||
def register_preference(
|
||||
cls, module, category, name, label, _type, default, **kwargs
|
||||
cls, module, category, name, label, _type, **kwargs
|
||||
):
|
||||
"""
|
||||
register
|
||||
@ -489,8 +489,8 @@ class Preferences(object):
|
||||
Allowed type of options are as below:
|
||||
boolean, integer, numeric, date, datetime,
|
||||
options, multiline, switch, node
|
||||
:param default: Default value for the preference/option
|
||||
"""
|
||||
default = kwargs.get('default')
|
||||
min_val = kwargs.get('min_val', None)
|
||||
max_val = kwargs.get('max_val', None)
|
||||
options = kwargs.get('options', None)
|
||||
@ -498,7 +498,6 @@ class Preferences(object):
|
||||
module_label = kwargs.get('module_label', None)
|
||||
category_label = kwargs.get('category_label', None)
|
||||
|
||||
m = None
|
||||
if module in Preferences.modules:
|
||||
m = Preferences.modules[module]
|
||||
# Update the label (if not defined yet)
|
||||
|
14
web/setup.py
14
web/setup.py
@ -19,6 +19,8 @@ import os
|
||||
import sys
|
||||
import builtins
|
||||
|
||||
USER_NOT_FOUND = "The specified user ID (%s) could not be found."
|
||||
|
||||
# Grab the SERVER_MODE if it's been set by the runtime
|
||||
if 'SERVER_MODE' in globals():
|
||||
builtins.SERVER_MODE = globals()['SERVER_MODE']
|
||||
@ -77,8 +79,7 @@ def dump_servers(args):
|
||||
user = User.query.filter_by(email=dump_user).first()
|
||||
|
||||
if user is None:
|
||||
print("The specified user ID (%s) could not be found." %
|
||||
dump_user)
|
||||
print(USER_NOT_FOUND % dump_user)
|
||||
sys.exit(1)
|
||||
|
||||
user_id = user.id
|
||||
@ -242,8 +243,7 @@ def load_servers(args):
|
||||
user = User.query.filter_by(email=load_user).first()
|
||||
|
||||
if user is None:
|
||||
print("The specified user ID (%s) could not be found." %
|
||||
load_user)
|
||||
print(USER_NOT_FOUND % load_user)
|
||||
sys.exit(1)
|
||||
|
||||
user_id = user.id
|
||||
@ -416,8 +416,7 @@ def clear_servers():
|
||||
user = User.query.filter_by(email=load_user).first()
|
||||
|
||||
if user is None:
|
||||
print("The specified user ID (%s) could not be found." %
|
||||
load_user)
|
||||
print(USER_NOT_FOUND % load_user)
|
||||
sys.exit(1)
|
||||
|
||||
user_id = user.id
|
||||
@ -439,7 +438,8 @@ def clear_servers():
|
||||
try:
|
||||
db.session.commit()
|
||||
except Exception as e:
|
||||
print("Error clearing server configuration")
|
||||
print("Error clearing server configuration with error (%s)" %
|
||||
str(e))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user