Add save password option in sever create mode. Fixes #1450
Do a little string/layout cleanup whilst passing.pull/3/head
parent
68497b00f6
commit
dfceb63986
|
@ -570,6 +570,8 @@ class ServerNode(PGChildNodeView):
|
|||
)
|
||||
)
|
||||
|
||||
server = None
|
||||
|
||||
try:
|
||||
server = Server(
|
||||
user_id=current_user.id,
|
||||
|
@ -596,8 +598,10 @@ class ServerNode(PGChildNodeView):
|
|||
manager.update(server)
|
||||
conn = manager.connection()
|
||||
|
||||
have_password = False
|
||||
if 'password' in data and data["password"] != '':
|
||||
# login with password
|
||||
have_password = True
|
||||
password = data['password']
|
||||
password = encrypt(password, current_user.password)
|
||||
else:
|
||||
|
@ -618,6 +622,10 @@ class ServerNode(PGChildNodeView):
|
|||
errormsg=gettext("Unable to connect to server:\n\n%s" % errmsg)
|
||||
)
|
||||
else:
|
||||
if 'save_password' in data and data['save_password'] and have_password:
|
||||
setattr(server, 'password', password)
|
||||
db.session.commit()
|
||||
|
||||
user = manager.user_info
|
||||
connected = True
|
||||
icon = "icon-pg"
|
||||
|
|
|
@ -580,7 +580,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
|||
username: '{{ username }}',
|
||||
role: null,
|
||||
connect_now: true,
|
||||
password: undefined
|
||||
password: undefined,
|
||||
save_password: false
|
||||
},
|
||||
// Default values!
|
||||
initialize: function(attrs, args) {
|
||||
|
@ -593,22 +594,22 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
|||
},
|
||||
schema: [{
|
||||
id: 'id', label: '{{ _('ID') }}', type: 'int', mode: ['properties']
|
||||
},{
|
||||
id: 'gid', label: '{{ _('Server Group') }}', type: 'int',
|
||||
control: 'node-list-by-id', node: 'server-group',
|
||||
mode: ['create', 'edit'], select2: {allowClear: false}
|
||||
},{
|
||||
id: 'name', label:'{{ _('Name') }}', type: 'text',
|
||||
mode: ['properties', 'edit', 'create']
|
||||
},{
|
||||
id: 'server_type', label: '{{ _('Server Type') }}', type: 'options',
|
||||
id: 'gid', label: '{{ _('Server group') }}', type: 'int',
|
||||
control: 'node-list-by-id', node: 'server-group',
|
||||
mode: ['create', 'edit'], select2: {allowClear: false}
|
||||
},{
|
||||
id: 'server_type', label: '{{ _('Server type') }}', type: 'options',
|
||||
mode: ['properties'], visible: 'isConnected',
|
||||
'options': [{% for st in server_types %}
|
||||
{label: '{{ st.description }}', value: '{{ st.server_type }}'},{% endfor %}
|
||||
{label: '{{ _('Unknown') }}', value: ''}
|
||||
]
|
||||
},{
|
||||
id: 'connected', label:'{{ _('Connected') }}', type: 'switch',
|
||||
id: 'connected', label:'{{ _('Connected?') }}', type: 'switch',
|
||||
mode: ['properties'], group: "{{ 'Connection' }}", 'options': {
|
||||
'onText': 'True', 'offText': 'False', 'onColor': 'success',
|
||||
'offColor': 'danger', 'size': 'small'
|
||||
|
@ -623,16 +624,16 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
|||
id: 'comment', label:'{{ _('Comments') }}', type: 'multiline', group: null,
|
||||
mode: ['properties', 'edit', 'create']
|
||||
},{
|
||||
id: 'host', label:'{{ _('Host Name/Address') }}', type: 'text', group: "{{ 'Connection' }}",
|
||||
id: 'host', label:'{{ _('Host name/address') }}', type: 'text', group: "{{ 'Connection' }}",
|
||||
mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
|
||||
},{
|
||||
id: 'port', label:'{{ _('Port') }}', type: 'int', group: "{{ 'Connection' }}",
|
||||
mode: ['properties', 'edit', 'create'], disabled: 'isConnected', min: 1024, max: 65535
|
||||
},{
|
||||
id: 'db', label:'{{ _('Maintenance Database') }}', type: 'text', group: "{{ 'Connection' }}",
|
||||
id: 'db', label:'{{ _('Maintenance database') }}', type: 'text', group: "{{ 'Connection' }}",
|
||||
mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
|
||||
},{
|
||||
id: 'username', label:'{{ _('User Name') }}', type: 'text', group: "{{ 'Connection' }}",
|
||||
id: 'username', label:'{{ _('User name') }}', type: 'text', group: "{{ 'Connection' }}",
|
||||
mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
|
||||
},{
|
||||
id: 'password', label:'{{ _('Password') }}', type: 'password',
|
||||
|
@ -640,11 +641,17 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
|||
visible: function(m) {
|
||||
return m.get('connect_now') && m.isNew();
|
||||
}
|
||||
},{
|
||||
id: 'save_password', controlLabel:'{{ _('Save password?') }}', type: 'checkbox',
|
||||
group: "{{ 'Connection' }}", mode: ['create'], deps: ['connect_now'],
|
||||
visible: function(m) {
|
||||
return m.get('connect_now') && m.isNew();
|
||||
}
|
||||
},{
|
||||
id: 'role', label:'{{ _('Role') }}', type: 'text', group: "{{ 'Connection' }}",
|
||||
mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
|
||||
},{
|
||||
id: 'sslmode', label:'{{ _('SSL Mode') }}', type: 'options', group: "{{ 'Connection' }}",
|
||||
id: 'sslmode', label:'{{ _('SSL mode') }}', type: 'options', group: "{{ 'Connection' }}",
|
||||
mode: ['properties', 'edit', 'create'], disabled: 'isConnected',
|
||||
'options': [
|
||||
{label: 'Allow', value: 'allow'},
|
||||
|
|
Loading…
Reference in New Issue