///////////////////////////////////////////////////////////// // // pgAdmin 4 - PostgreSQL Tools // // Copyright (C) 2013 - 2020, The pgAdmin Development Team // This software is released under the PostgreSQL Licence // ////////////////////////////////////////////////////////////// import gettext from 'sources/gettext'; import url_for from 'sources/url_for'; import $ from 'jquery'; import Alertify from 'pgadmin.alertifyjs'; import pgAdmin from 'sources/pgadmin'; import Backform from 'pgadmin.backform'; import newConnectionDialogModel from 'sources/sqleditor/new_connection_dialog_model'; let NewConnectionDialog = { 'dialog': function(handler, reconnect, preferences) { let url = url_for('sqleditor.get_new_connection_data', { 'sid': handler.url_params.sid, 'sgid': handler.url_params.sgid, }); if(reconnect) { url += '?connect=1'; } let title = gettext('Connect to server'); $.ajax({ url: url, headers: { 'Cache-Control' : 'no-cache', }, }).done(function (res) { let response = res.data.result; response.database_list = []; response.user_list = []; if (Alertify.newConnectionDialog) { delete Alertify.newConnectionDialog; } // Create Dialog Alertify.dialog('newConnectionDialog', function factory() { let $container = $('
'); return { main: function(message) { this.msg = message; }, build: function() { this.elements.content.appendChild($container.get(0)); Alertify.pgDialogBuild.apply(this); }, setup: function(){ return { buttons: [ { text: '', key: 112, className: 'btn btn-primary-icon pull-left fa fa-question pg-alertify-icon-button', attrs: { name: 'dialog_help', type: 'button', label: gettext('Help'), 'aria-label': gettext('Help'), url: url_for('help.static', { 'filename': 'query_tool.html', }), }, }, { text: gettext('Cancel'), key: 27, className: 'btn btn-secondary fa fa-times pg-alertify-button', 'data-btn-name': 'cancel', }, { text: gettext('OK'), key: 13, className: 'btn btn-primary fa fa-check pg-alertify-button', 'data-btn-name': 'ok', }, ], // Set options for dialog options: { title: title, //disable both padding and overflow control. padding: !1, overflow: !1, model: 0, resizable: true, maximizable: false, pinnable: false, closableByDimmer: false, modal: false, autoReset: false, closable: false, }, }; }, prepare: function() { let self = this; $container.html(''); // Disable Ok button this.__internal.buttons[2].element.disabled = true; // Status bar this.statusBar = $( '').appendTo($container); // To show progress on filter Saving/Updating on AJAX this.showNewConnectionProgress = $( `