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