Fixed issues related to About dialog:

1) On resizing, the server configuration text area should be resized.
2) Any password should not be visible in the configuration.
3) Configurations are not properly quoted.
4) Added the "Copy" button so that the user can copy the configuration directly.

refs #6231
This commit is contained in:
Pradip Parkale 2021-06-11 19:30:32 +05:30 committed by Akshay Joshi
parent e3190b86ab
commit e0d094b2aa
3 changed files with 33 additions and 6 deletions

View File

@ -84,16 +84,25 @@ def index():
info['current_user'] = current_user.email
settings = ''
settings = ""
for setting in dir(config):
if not setting.startswith('_') and setting.isupper() and \
setting not in ['CSRF_SESSION_KEY',
'SECRET_KEY',
'SECURITY_PASSWORD_SALT',
'SECURITY_PASSWORD_HASH',
'ALLOWED_HOSTS']:
settings = settings + '{} = {}\n'.format(setting,
getattr(config, setting))
'ALLOWED_HOSTS'
'MAIL_PASSWORD',
'LDAP_BIND_PASSWORD',
'SECURITY_PASSWORD_HASH']:
if isinstance(getattr(config, setting), str):
settings = \
settings + '{} = "{}"\n'.format(
setting, gettext(getattr(config, setting)))
else:
settings = \
settings + '{} = {}\n'.format(
setting, gettext(getattr(config, setting)))
info['settings'] = settings

View File

@ -45,11 +45,26 @@ define(
},
hooks:{
onshow:function(){
var self = this;
var container = $(this.elements.footer).find('button:not([disabled])');
commonUtils.findAndSetFocus(container);
$('#copy_textarea').on('click', function(){
//Copy the server configuration details
let textarea = document.getElementById('about-textarea');
textarea.select();
document.execCommand('copy');
$('#copy_textarea').text('Copied');
});
$(this.elements.resizeHandle).on('click', function(){
// Set the height of the Textarea
var height = self.elements.dialog.scrollHeight - 300;
if (height < 0)
height = self.elements.dialog.scrollHeight - 150;
$('#about-textarea').css({'height':height});
});
},
},
prepare:function() {
this.setContent(this.message);
},

View File

@ -38,7 +38,10 @@
<div class="col-sm-3"><b>{{ _('Server Configuration') }}</b></div>
</div>
<div class="row">
<div class="col-sm-9"><textarea rows="7" cols="85" style="width:120%; height: auto; white-space: pre-wrap;" readonly>{{ info.settings|safe }}</textarea></div>
<div class="col-sm-9">
<textarea id="about-textarea" rows="7" cols="150" style="position: relative;width:101%; white-space: pre-wrap;" readonly>{{ info.settings|safe }}</textarea>
<button class="btn btn-secondary about-copy" id="copy_textarea" style="position:absolute;top:0;right:0;z-index:20;padding:0px;">Copy</button>
</div>
</div>
{% endif %}
</div>