2015-06-30 00:51:55 -05:00
|
|
|
define(
|
2015-10-20 02:03:18 -05:00
|
|
|
['jquery', 'underscore', 'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify'],
|
|
|
|
function($, _, S, pgAdmin, pgBrowser, alertify) {
|
2015-06-30 00:51:55 -05:00
|
|
|
|
|
|
|
if (!pgBrowser.Nodes['server']) {
|
|
|
|
pgAdmin.Browser.Nodes['server'] = pgAdmin.Browser.Node.extend({
|
|
|
|
parent_type: 'server-group',
|
|
|
|
type: 'server',
|
2015-07-20 05:36:17 -05:00
|
|
|
label: '{{ _('Server') }}',
|
2016-01-07 07:21:56 -06:00
|
|
|
canDrop: true,
|
2016-04-14 06:15:32 -05:00
|
|
|
hasStatistics: true,
|
|
|
|
hasCollectiveStatistics: true,
|
2015-06-30 00:51:55 -05:00
|
|
|
Init: function() {
|
|
|
|
|
|
|
|
/* Avoid multiple registration of same menus */
|
|
|
|
if (this.initialized)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.initialized = true;
|
|
|
|
|
|
|
|
pgBrowser.add_menus([{
|
|
|
|
name: 'create_server_on_sg', node: 'server-group', module: this,
|
|
|
|
applies: ['object', 'context'], callback: 'show_obj_properties',
|
|
|
|
category: 'create', priority: 1, label: '{{ _('Server...') }}',
|
|
|
|
data: {action: 'create'}, icon: 'wcTabIcon icon-server'
|
|
|
|
}, {
|
|
|
|
name: 'create_server', node: 'server', module: this,
|
|
|
|
applies: ['object', 'context'], callback: 'show_obj_properties',
|
|
|
|
category: 'create', priority: 3, label: '{{ _('Server...') }}',
|
|
|
|
data: {action: 'create'}, icon: 'wcTabIcon icon-server'
|
2015-10-20 02:03:18 -05:00
|
|
|
},{
|
|
|
|
name: 'connect_server', node: 'server', module: this,
|
|
|
|
applies: ['object', 'context'], callback: 'connect_server',
|
|
|
|
category: 'connect', priority: 4, label: '{{ _('Connect Server...') }}',
|
|
|
|
icon: 'fa fa-link', enable : 'is_not_connected'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'disconnect_server', node: 'server', module: this,
|
|
|
|
applies: ['object', 'context'], callback: 'disconnect_server',
|
|
|
|
category: 'drop', priority: 5, label: '{{ _('Disconnect Server...') }}',
|
|
|
|
icon: 'fa fa-chain-broken', enable : 'is_connected'
|
2016-05-06 09:08:22 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'reload_configuration', node: 'server', module: this,
|
|
|
|
applies: ['tools', 'context'], callback: 'reload_configuration',
|
|
|
|
category: 'reload', priority: 6, label: '{{ _('Reload Configuration...') }}',
|
|
|
|
icon: 'fa fa-repeat', enable : 'is_connected'
|
2015-06-30 00:51:55 -05:00
|
|
|
}]);
|
2016-03-15 08:30:58 -05:00
|
|
|
|
|
|
|
pgBrowser.messages['PRIV_GRANTEE_NOT_SPECIFIED'] =
|
2016-05-06 07:53:48 -05:00
|
|
|
'{{ _('A grantee must be selected.') }}';
|
2016-03-15 08:30:58 -05:00
|
|
|
pgBrowser.messages['NO_PRIV_SELECTED'] =
|
2016-05-06 07:53:48 -05:00
|
|
|
'{{ _('At least one privilege should be selected.') }}';
|
2015-06-30 00:51:55 -05:00
|
|
|
},
|
2015-10-20 02:03:18 -05:00
|
|
|
is_not_connected: function(node) {
|
|
|
|
return (node && node.connected != true);
|
|
|
|
},
|
|
|
|
is_connected: function(node) {
|
|
|
|
return (node && node.connected == true);
|
|
|
|
},
|
2015-06-30 00:51:55 -05:00
|
|
|
callbacks: {
|
2015-10-20 02:03:18 -05:00
|
|
|
/* Connect the server */
|
|
|
|
connect_server: function(args){
|
|
|
|
var input = args || {};
|
|
|
|
obj = this,
|
|
|
|
t = pgBrowser.tree,
|
|
|
|
i = input.item || t.selected(),
|
|
|
|
d = i && i.length == 1 ? t.itemData(i) : undefined;
|
|
|
|
|
|
|
|
if (!d)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
connect_to_server(obj, d, t, i);
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
/* Disconnect the server */
|
|
|
|
disconnect_server: function(args) {
|
|
|
|
var input = args || {};
|
|
|
|
obj = this,
|
|
|
|
t = pgBrowser.tree,
|
2015-11-19 11:45:48 -06:00
|
|
|
i = 'item' in input ? input.item : t.selected(),
|
2015-10-20 02:03:18 -05:00
|
|
|
d = i && i.length == 1 ? t.itemData(i) : undefined;
|
|
|
|
|
|
|
|
if (!d)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
alertify.confirm(
|
|
|
|
'{{ _('Disconnect the server') }}',
|
|
|
|
S('{{ _('Are you sure you want to disconnect the server - %%s ?') }}').sprintf(d.label).value(),
|
|
|
|
function(evt) {
|
|
|
|
$.ajax({
|
2015-11-19 11:45:48 -06:00
|
|
|
url: obj.generate_url(i, 'connect', d, true),
|
2015-10-20 02:03:18 -05:00
|
|
|
type:'DELETE',
|
|
|
|
success: function(res) {
|
|
|
|
if (res.success == 1) {
|
2016-04-18 07:39:25 -05:00
|
|
|
alertify.success(res.info);
|
2015-11-19 11:45:48 -06:00
|
|
|
d = t.itemData(i);
|
2015-10-20 02:03:18 -05:00
|
|
|
t.removeIcon(i);
|
|
|
|
d.connected = false;
|
|
|
|
d.icon = 'icon-server-not-connected';
|
|
|
|
t.addIcon(i, {icon: d.icon});
|
2016-03-23 06:21:08 -05:00
|
|
|
obj.callbacks.refresh.apply(obj, [null, i]);
|
2015-11-19 11:45:48 -06:00
|
|
|
if (pgBrowser.serverInfo && d._id in pgBrowser.serverInfo) {
|
|
|
|
delete pgBrowser.serverInfo[d._id]
|
|
|
|
}
|
2015-11-19 12:11:58 -06:00
|
|
|
obj.trigger('server-disconnected', obj, i, d);
|
2015-06-30 00:51:55 -05:00
|
|
|
}
|
2016-04-18 07:39:25 -05:00
|
|
|
else {
|
|
|
|
try {
|
|
|
|
alertify.error(res.errormsg);
|
|
|
|
} catch (e) {}
|
|
|
|
t.unload(i);
|
|
|
|
}
|
2015-10-20 02:03:18 -05:00
|
|
|
},
|
|
|
|
error: function(xhr, status, error) {
|
|
|
|
try {
|
|
|
|
var err = $.parseJSON(xhr.responseText);
|
|
|
|
if (err.success == 0) {
|
2016-04-18 07:39:25 -05:00
|
|
|
alertify.error(err.errormsg);
|
2015-10-20 02:03:18 -05:00
|
|
|
}
|
|
|
|
} catch (e) {}
|
|
|
|
t.unload(i);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
function(evt) {
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
2015-02-18 21:06:12 -06:00
|
|
|
},
|
2015-06-30 00:51:55 -05:00
|
|
|
/* Connect the server (if not connected), before opening this node */
|
2015-11-19 11:45:48 -06:00
|
|
|
beforeopen: function(item, data) {
|
2016-01-11 11:22:13 -06:00
|
|
|
|
2015-06-30 00:51:55 -05:00
|
|
|
if(!data || data._type != 'server') {
|
|
|
|
return false;
|
|
|
|
}
|
2015-10-20 02:03:18 -05:00
|
|
|
|
2015-11-19 11:45:48 -06:00
|
|
|
pgBrowser.tree.addIcon(item, {icon: data.icon});
|
2015-06-30 00:51:55 -05:00
|
|
|
if (!data.connected) {
|
2015-11-19 11:45:48 -06:00
|
|
|
connect_to_server(this, data, pgBrowser.tree, item);
|
2016-01-11 11:22:13 -06:00
|
|
|
|
2015-06-30 00:51:55 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2015-11-19 11:45:48 -06:00
|
|
|
},
|
2016-01-11 11:22:13 -06:00
|
|
|
added: function(item, data) {
|
|
|
|
|
2015-11-19 11:45:48 -06:00
|
|
|
pgBrowser.serverInfo = pgBrowser.serverInfo || {};
|
|
|
|
pgBrowser.serverInfo[data._id] = _.extend({}, data);
|
2016-01-11 11:22:13 -06:00
|
|
|
|
|
|
|
return true;
|
2016-05-06 09:08:22 -05:00
|
|
|
},
|
|
|
|
/* Reload configuration */
|
|
|
|
reload_configuration: function(args){
|
|
|
|
var input = args || {};
|
|
|
|
obj = this,
|
|
|
|
t = pgBrowser.tree,
|
|
|
|
i = input.item || t.selected(),
|
|
|
|
d = i && i.length == 1 ? t.itemData(i) : undefined;
|
|
|
|
|
|
|
|
if (!d)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
alertify.confirm(
|
|
|
|
'{{ _('Reload server configuration') }}',
|
|
|
|
S('{{ _('Are you sure you want to reload the server configuration on %%s?') }}').sprintf(d.label).value(),
|
|
|
|
function(evt) {
|
|
|
|
$.ajax({
|
|
|
|
url: obj.generate_url(i, 'reload', d, true),
|
|
|
|
method:'GET',
|
|
|
|
success: function(res) {
|
|
|
|
if (res.data.status) {
|
|
|
|
alertify.success(res.data.result);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
alertify.error(res.data.result);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: function(xhr, status, error) {
|
|
|
|
try {
|
|
|
|
var err = $.parseJSON(xhr.responseText);
|
|
|
|
if (err.success == 0) {
|
|
|
|
alertify.error(err.errormsg);
|
|
|
|
}
|
|
|
|
} catch (e) {}
|
|
|
|
t.unload(i);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
function(evt) {
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
2015-06-30 00:51:55 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
model: pgAdmin.Browser.Node.Model.extend({
|
|
|
|
defaults: {
|
2016-05-05 10:42:16 -05:00
|
|
|
gid: undefined,
|
2015-06-30 00:51:55 -05:00
|
|
|
id: undefined,
|
2015-10-20 02:03:18 -05:00
|
|
|
name: null,
|
|
|
|
sslmode: 'prefer',
|
|
|
|
host: null,
|
|
|
|
port: 5432,
|
2016-03-10 09:58:17 -06:00
|
|
|
db: 'postgres',
|
|
|
|
username: '{{ username }}',
|
2015-10-20 02:03:18 -05:00
|
|
|
role: null
|
2015-02-18 21:06:12 -06:00
|
|
|
},
|
2016-05-05 10:42:16 -05:00
|
|
|
// Default values!
|
|
|
|
initialize: function(attrs, args) {
|
|
|
|
var isNew = (_.size(attrs) === 0);
|
|
|
|
|
|
|
|
if (isNew) {
|
|
|
|
this.set({'gid': args.node_info['server-group']._id});
|
|
|
|
}
|
|
|
|
pgAdmin.Browser.Node.Model.prototype.initialize.apply(this, arguments);
|
|
|
|
},
|
2015-06-30 00:51:55 -05:00
|
|
|
schema: [{
|
2015-12-21 23:20:30 -06:00
|
|
|
id: 'id', label: '{{ _('ID') }}', type: 'int', mode: ['properties']
|
2016-05-05 10:42:16 -05:00
|
|
|
},{
|
|
|
|
id: 'gid', label: '{{ _('Server Group') }}', type: 'int',
|
|
|
|
control: 'node-list-by-id', node: 'server-group',
|
|
|
|
mode: ['create', 'edit'], select2: {allowClear: false}
|
2015-06-30 00:51:55 -05:00
|
|
|
},{
|
2015-12-21 23:20:30 -06:00
|
|
|
id: 'name', label:'{{ _('Name') }}', type: 'text',
|
2015-06-30 00:51:55 -05:00
|
|
|
mode: ['properties', 'edit', 'create']
|
2016-03-16 04:58:14 -05:00
|
|
|
},{
|
|
|
|
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: ''}
|
|
|
|
]
|
2015-06-30 00:51:55 -05:00
|
|
|
},{
|
2015-12-21 23:20:30 -06:00
|
|
|
id: 'connected', label:'{{ _('Connected') }}', type: 'switch',
|
2016-03-16 04:58:14 -05:00
|
|
|
mode: ['properties'], group: "{{ 'Connection' }}", 'options': {
|
2015-12-21 23:20:30 -06:00
|
|
|
'onText': 'True', 'offText': 'False', 'onColor': 'success',
|
|
|
|
'offColor': 'danger', 'size': 'small'
|
2015-12-04 04:19:08 -06:00
|
|
|
}
|
2015-06-30 00:51:55 -05:00
|
|
|
},{
|
2015-10-20 02:03:18 -05:00
|
|
|
id: 'version', label:'{{ _('Version') }}', type: 'text', group: null,
|
2016-01-15 07:55:45 -06:00
|
|
|
mode: ['properties'], visible: 'isConnected'
|
2015-06-30 00:51:55 -05:00
|
|
|
},{
|
2015-12-04 04:19:08 -06:00
|
|
|
id: 'comment', label:'{{ _('Comments') }}', type: 'multiline', group: null,
|
2015-12-21 23:20:30 -06:00
|
|
|
mode: ['properties', 'edit', 'create']
|
2015-06-30 00:51:55 -05:00
|
|
|
},{
|
2016-01-17 10:51:55 -06:00
|
|
|
id: 'host', label:'{{ _('Host Name/Address') }}', type: 'text', group: "{{ 'Connection' }}",
|
2015-10-20 02:03:18 -05:00
|
|
|
mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
|
2015-06-30 00:51:55 -05:00
|
|
|
},{
|
2016-01-17 10:51:55 -06:00
|
|
|
id: 'port', label:'{{ _('Port') }}', type: 'int', group: "{{ 'Connection' }}",
|
2016-01-07 07:21:56 -06:00
|
|
|
mode: ['properties', 'edit', 'create'], disabled: 'isConnected', min: 1024, max: 65534
|
2015-06-30 00:51:55 -05:00
|
|
|
},{
|
2016-01-17 10:51:55 -06:00
|
|
|
id: 'db', label:'{{ _('Maintenance Database') }}', type: 'text', group: "{{ 'Connection' }}",
|
2015-10-20 02:03:18 -05:00
|
|
|
mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
|
2015-06-30 00:51:55 -05:00
|
|
|
},{
|
2016-01-17 10:51:55 -06:00
|
|
|
id: 'username', label:'{{ _('User Name') }}', type: 'text', group: "{{ 'Connection' }}",
|
2015-10-20 02:03:18 -05:00
|
|
|
mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
|
2015-06-30 00:51:55 -05:00
|
|
|
},{
|
2016-01-17 10:51:55 -06:00
|
|
|
id: 'role', label:'{{ _('Role') }}', type: 'text', group: "{{ 'Connection' }}",
|
2015-10-20 02:03:18 -05:00
|
|
|
mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
|
|
|
|
},{
|
2016-01-17 10:51:55 -06:00
|
|
|
id: 'sslmode', label:'{{ _('SSL Mode') }}', type: 'options', group: "{{ 'Connection' }}",
|
2015-10-20 02:03:18 -05:00
|
|
|
mode: ['properties', 'edit', 'create'], disabled: 'isConnected',
|
|
|
|
'options': [
|
|
|
|
{label: 'Allow', value: 'allow'},
|
|
|
|
{label: 'Prefer', value: 'prefer'},
|
|
|
|
{label: 'Require', value: 'require'},
|
|
|
|
{label: 'Disable', value: 'disable'},
|
|
|
|
{label: 'Verify-CA', value: 'verify-ca'},
|
|
|
|
{label: 'Verify-Full', value: 'verify-full'}
|
|
|
|
]
|
2015-06-30 00:51:55 -05:00
|
|
|
}],
|
2015-12-04 04:03:16 -06:00
|
|
|
validate: function() {
|
|
|
|
var err = {},
|
|
|
|
errmsg;
|
|
|
|
|
|
|
|
if (!this.isNew() && 'id' in this.sessAttrs) {
|
2016-05-06 07:53:48 -05:00
|
|
|
err['id'] = '{{ _('The ID can not be changed.') }}';;
|
2016-01-12 10:51:24 -06:00
|
|
|
errmsg = err['id'];
|
2015-12-04 04:03:16 -06:00
|
|
|
}
|
|
|
|
if (_.isUndefined(this.get('name')) || String(this.get('name')).replace(/^\s+|\s+$/g, '') == '') {
|
2016-05-06 07:53:48 -05:00
|
|
|
err['name'] = '{{ _('Name must be specified.') }}';
|
2016-01-12 10:51:24 -06:00
|
|
|
errmsg = errmsg || err['name'];
|
2015-06-30 00:51:55 -05:00
|
|
|
}
|
2016-04-14 15:46:01 -05:00
|
|
|
if (_.isUndefined(this.get('host')) || this.get('host') == null || String(this.get('host')).replace(/^\s+|\s+$/g, '') == '') {
|
2016-05-06 07:53:48 -05:00
|
|
|
err['host'] = '{{ _('Hostname or address must be specified.') }}';
|
2016-04-14 15:46:01 -05:00
|
|
|
errmsg = errmsg || err['host'];
|
|
|
|
}
|
|
|
|
|
2015-12-04 04:03:16 -06:00
|
|
|
this.errorModel.set(err);
|
|
|
|
|
|
|
|
if (_.size(err)) {
|
2015-12-21 23:20:30 -06:00
|
|
|
return errmsg;
|
2015-06-30 00:51:55 -05:00
|
|
|
}
|
2015-12-04 04:03:16 -06:00
|
|
|
|
2015-06-30 00:51:55 -05:00
|
|
|
return null;
|
|
|
|
},
|
2015-10-20 02:03:18 -05:00
|
|
|
isConnected: function(model) {
|
|
|
|
return model.get('connected');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
function connect_to_server(obj, data, tree, item) {
|
|
|
|
var onFailure = function(xhr, status, error, _model, _data, _tree, _item) {
|
|
|
|
|
|
|
|
tree.setInode(_item);
|
|
|
|
tree.addIcon(_item, {icon: 'icon-server-not-connected'});
|
|
|
|
|
|
|
|
alertify.pgNotifier('error', xhr, error, function(msg) {
|
|
|
|
setTimeout(function() {
|
|
|
|
alertify.dlgServerPass(
|
|
|
|
'{{ _('Connect to Server') }}',
|
|
|
|
msg, _model, _data, _tree, _item
|
|
|
|
).resizeTo();
|
|
|
|
}, 100);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onSuccess = function(res, model, data, tree, item) {
|
|
|
|
tree.deselect(item);
|
|
|
|
tree.setInode(item);
|
|
|
|
|
|
|
|
if (res && res.data) {
|
2015-11-19 11:45:48 -06:00
|
|
|
|
2015-10-20 02:03:18 -05:00
|
|
|
if (typeof res.data.icon == 'string') {
|
|
|
|
tree.removeIcon(item);
|
|
|
|
data.icon = res.data.icon;
|
|
|
|
tree.addIcon(item, {icon: data.icon});
|
|
|
|
}
|
2015-11-19 11:45:48 -06:00
|
|
|
_.extend(data, res.data);
|
2015-10-20 02:03:18 -05:00
|
|
|
|
2016-01-11 11:22:13 -06:00
|
|
|
var serverInfo = pgBrowser.serverInfo = pgBrowser.serverInfo || {};
|
|
|
|
serverInfo[data._id] = _.extend({}, data);
|
|
|
|
|
2015-10-20 02:03:18 -05:00
|
|
|
alertify.success(res.info);
|
2015-11-19 12:11:58 -06:00
|
|
|
obj.trigger('server-connected', obj, item, data);
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
tree.select(item);
|
|
|
|
tree.open(item);
|
|
|
|
}, 10);
|
2016-03-15 08:30:58 -05:00
|
|
|
|
2015-10-20 02:03:18 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Ask Password and send it back to the connect server
|
|
|
|
if (!alertify.dlgServerPass) {
|
|
|
|
alertify.dialog('dlgServerPass', function factory() {
|
|
|
|
return {
|
|
|
|
main: function(title, message, model, data, tree, item) {
|
|
|
|
this.set('title', title);
|
|
|
|
this.message = message;
|
|
|
|
this.tree = tree;
|
|
|
|
this.nodeData = data;
|
|
|
|
this.nodeItem = item;
|
|
|
|
this.nodeModel = model;
|
|
|
|
},
|
|
|
|
setup:function() {
|
|
|
|
return {
|
|
|
|
buttons:[
|
|
|
|
{
|
|
|
|
text: "{{ _('OK') }}", key: 13, className: "btn btn-primary"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "{{ _('Cancel') }}", className: "btn btn-danger"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
focus: { element: '#password', select: true },
|
|
|
|
options: {
|
|
|
|
modal: 0, resizable: false, maximizable: false, pinnable: false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
build:function() {},
|
|
|
|
prepare:function() {
|
|
|
|
this.setContent(this.message);
|
|
|
|
},
|
|
|
|
callback: function(closeEvent) {
|
|
|
|
var _sdata = this.nodeData,
|
|
|
|
_tree = this.tree,
|
|
|
|
_item = this.nodeItem,
|
|
|
|
_model = this.nodeModel;
|
|
|
|
|
|
|
|
if (closeEvent.button.text == "{{ _('OK') }}") {
|
|
|
|
|
2015-11-19 11:45:48 -06:00
|
|
|
var _url = _model.generate_url(_item, 'connect', _sdata, true);
|
2015-10-20 02:03:18 -05:00
|
|
|
|
|
|
|
_tree.setLeaf(_item);
|
|
|
|
_tree.removeIcon(_item);
|
|
|
|
_tree.addIcon(_item, {icon: 'icon-server-connecting'});
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
timeout: 30000,
|
|
|
|
url: _url,
|
|
|
|
data: $('#frmPassword').serialize(),
|
|
|
|
success: function(res) {
|
|
|
|
return onSuccess(
|
|
|
|
res, _model, _sdata, _tree, _item
|
|
|
|
);
|
|
|
|
},
|
|
|
|
error: function(xhr, status, error) {
|
|
|
|
return onFailure(
|
|
|
|
xhr, status, error, _model, _sdata, _tree, _item
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
_tree.setInode(_item);
|
|
|
|
_tree.removeIcon(_item);
|
|
|
|
_tree.addIcon(_item, {icon: 'icon-server-not-connected'});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-02-12 10:46:56 -06:00
|
|
|
url = obj.generate_url(item, "connect", data, true);
|
|
|
|
$.post(url)
|
|
|
|
.done(
|
|
|
|
function(res) {
|
|
|
|
if (res.success == 1) {
|
|
|
|
return onSuccess(res, obj, data, tree, item);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.fail(
|
|
|
|
function(xhr, status, error) {
|
|
|
|
return onFailure(xhr, status, error, obj, data, tree, item);
|
|
|
|
});
|
2015-10-20 02:03:18 -05:00
|
|
|
}
|
2016-03-15 08:30:58 -05:00
|
|
|
|
2015-10-20 02:03:18 -05:00
|
|
|
/* Send PING to indicate that session is alive */
|
|
|
|
function server_status(server_id)
|
|
|
|
{
|
|
|
|
url = "/ping";
|
|
|
|
$.post(url)
|
|
|
|
.done(function(data) { return true})
|
|
|
|
.fail(function(xhr, status, error) { return false})
|
|
|
|
}
|
2015-06-30 00:51:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return pgBrowser.Nodes['server'];
|
|
|
|
});
|