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:
|
try:
|
||||||
server = Server(
|
server = Server(
|
||||||
user_id=current_user.id,
|
user_id=current_user.id,
|
||||||
|
@ -596,8 +598,10 @@ class ServerNode(PGChildNodeView):
|
||||||
manager.update(server)
|
manager.update(server)
|
||||||
conn = manager.connection()
|
conn = manager.connection()
|
||||||
|
|
||||||
|
have_password = False
|
||||||
if 'password' in data and data["password"] != '':
|
if 'password' in data and data["password"] != '':
|
||||||
# login with password
|
# login with password
|
||||||
|
have_password = True
|
||||||
password = data['password']
|
password = data['password']
|
||||||
password = encrypt(password, current_user.password)
|
password = encrypt(password, current_user.password)
|
||||||
else:
|
else:
|
||||||
|
@ -618,6 +622,10 @@ class ServerNode(PGChildNodeView):
|
||||||
errormsg=gettext("Unable to connect to server:\n\n%s" % errmsg)
|
errormsg=gettext("Unable to connect to server:\n\n%s" % errmsg)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
if 'save_password' in data and data['save_password'] and have_password:
|
||||||
|
setattr(server, 'password', password)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
user = manager.user_info
|
user = manager.user_info
|
||||||
connected = True
|
connected = True
|
||||||
icon = "icon-pg"
|
icon = "icon-pg"
|
||||||
|
|
|
@ -580,7 +580,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
username: '{{ username }}',
|
username: '{{ username }}',
|
||||||
role: null,
|
role: null,
|
||||||
connect_now: true,
|
connect_now: true,
|
||||||
password: undefined
|
password: undefined,
|
||||||
|
save_password: false
|
||||||
},
|
},
|
||||||
// Default values!
|
// Default values!
|
||||||
initialize: function(attrs, args) {
|
initialize: function(attrs, args) {
|
||||||
|
@ -593,22 +594,22 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
},
|
},
|
||||||
schema: [{
|
schema: [{
|
||||||
id: 'id', label: '{{ _('ID') }}', type: 'int', mode: ['properties']
|
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',
|
id: 'name', label:'{{ _('Name') }}', type: 'text',
|
||||||
mode: ['properties', 'edit', 'create']
|
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',
|
mode: ['properties'], visible: 'isConnected',
|
||||||
'options': [{% for st in server_types %}
|
'options': [{% for st in server_types %}
|
||||||
{label: '{{ st.description }}', value: '{{ st.server_type }}'},{% endfor %}
|
{label: '{{ st.description }}', value: '{{ st.server_type }}'},{% endfor %}
|
||||||
{label: '{{ _('Unknown') }}', value: ''}
|
{label: '{{ _('Unknown') }}', value: ''}
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
id: 'connected', label:'{{ _('Connected') }}', type: 'switch',
|
id: 'connected', label:'{{ _('Connected?') }}', type: 'switch',
|
||||||
mode: ['properties'], group: "{{ 'Connection' }}", 'options': {
|
mode: ['properties'], group: "{{ 'Connection' }}", 'options': {
|
||||||
'onText': 'True', 'offText': 'False', 'onColor': 'success',
|
'onText': 'True', 'offText': 'False', 'onColor': 'success',
|
||||||
'offColor': 'danger', 'size': 'small'
|
'offColor': 'danger', 'size': 'small'
|
||||||
|
@ -623,16 +624,16 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
id: 'comment', label:'{{ _('Comments') }}', type: 'multiline', group: null,
|
id: 'comment', label:'{{ _('Comments') }}', type: 'multiline', group: null,
|
||||||
mode: ['properties', 'edit', 'create']
|
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'
|
mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
|
||||||
},{
|
},{
|
||||||
id: 'port', label:'{{ _('Port') }}', type: 'int', group: "{{ 'Connection' }}",
|
id: 'port', label:'{{ _('Port') }}', type: 'int', group: "{{ 'Connection' }}",
|
||||||
mode: ['properties', 'edit', 'create'], disabled: 'isConnected', min: 1024, max: 65535
|
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'
|
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'
|
mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
|
||||||
},{
|
},{
|
||||||
id: 'password', label:'{{ _('Password') }}', type: 'password',
|
id: 'password', label:'{{ _('Password') }}', type: 'password',
|
||||||
|
@ -640,11 +641,17 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
visible: function(m) {
|
visible: function(m) {
|
||||||
return m.get('connect_now') && m.isNew();
|
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' }}",
|
id: 'role', label:'{{ _('Role') }}', type: 'text', group: "{{ 'Connection' }}",
|
||||||
mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
|
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',
|
mode: ['properties', 'edit', 'create'], disabled: 'isConnected',
|
||||||
'options': [
|
'options': [
|
||||||
{label: 'Allow', value: 'allow'},
|
{label: 'Allow', value: 'allow'},
|
||||||
|
|
Loading…
Reference in New Issue