mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Updated the misc module javascripts to work with latest wcDocker.
This commit is contained in:
parent
18d767b107
commit
000c76871f
@ -25,26 +25,12 @@ define(
|
|||||||
'showDependencies', 'dependenciesPanelVisibilityChanged', '__updateCollection'
|
'showDependencies', 'dependenciesPanelVisibilityChanged', '__updateCollection'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Find the panels to render the grid.
|
|
||||||
var dependenciesPanels = this.dependenciesPanels = pgBrowser.docker.findPanels('dependencies');
|
|
||||||
var dependentsPanels = this.dependentsPanels = pgBrowser.docker.findPanels('dependents');
|
|
||||||
|
|
||||||
// We will listened to the visibility change of the Dependencies and Dependents panel
|
// We will listened to the visibility change of the Dependencies and Dependents panel
|
||||||
pgBrowser.Events.on('pgadmin-browser:panel-dependencies:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
pgBrowser.Events.on('pgadmin-browser:panel-dependencies:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
||||||
this.dependenciesPanelVisibilityChanged);
|
this.dependenciesPanelVisibilityChanged);
|
||||||
pgBrowser.Events.on('pgadmin-browser:panel-dependents:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
pgBrowser.Events.on('pgadmin-browser:panel-dependents:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
||||||
this.dependentsPanelVisibilityChanged);
|
this.dependentsPanelVisibilityChanged);
|
||||||
|
|
||||||
// If Dependencies panel exists and is focused then we need to listen the browser tree selection events.
|
|
||||||
if ((dependenciesPanels.length == 1 && dependenciesPanels[0].isVisible()) || dependenciesPanels.length != 1) {
|
|
||||||
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependencies);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If Dependents panel exists and is focused then we need to listen the browser tree selection events.
|
|
||||||
if ((dependentsPanels.length == 1 && dependentsPanels[0].isVisible()) || dependentsPanels.length != 1) {
|
|
||||||
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependents);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defining Backbone Model for Dependencies and Dependents.
|
// Defining Backbone Model for Dependencies and Dependents.
|
||||||
var Model = Backbone.Model.extend({
|
var Model = Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
@ -85,7 +71,7 @@ define(
|
|||||||
* panel only once.
|
* panel only once.
|
||||||
*/
|
*/
|
||||||
var appendGridToPanel = function(collection, panel, is_dependent) {
|
var appendGridToPanel = function(collection, panel, is_dependent) {
|
||||||
var $container = panel[0].layout().$table.find('.pg-panel-content'),
|
var $container = panel[0].layout().scene().find('.pg-panel-content'),
|
||||||
$gridContainer = $container.find('.pg-panel-depends-container'),
|
$gridContainer = $container.find('.pg-panel-depends-container'),
|
||||||
grid = new Backgrid.Grid({
|
grid = new Backgrid.Grid({
|
||||||
columns: [
|
columns: [
|
||||||
@ -127,16 +113,71 @@ define(
|
|||||||
self.dependenciesGrid = grid;
|
self.dependenciesGrid = grid;
|
||||||
|
|
||||||
$gridContainer.append(grid.render().el);
|
$gridContainer.append(grid.render().el);
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
appendGridToPanel(this.dependentCollection, this.dependentsPanels, true);
|
// We will listened to the visibility change of the Dependencies and Dependents panel
|
||||||
appendGridToPanel(this.dependenciesCollection, this.dependenciesPanels, false);
|
pgBrowser.Events.on('pgadmin-browser:panel-dependencies:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
||||||
|
this.dependenciesPanelVisibilityChanged);
|
||||||
|
pgBrowser.Events.on('pgadmin-browser:panel-dependents:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
||||||
|
this.dependentsPanelVisibilityChanged);
|
||||||
|
|
||||||
|
// We will render the grid objects in the panel after some time, because -
|
||||||
|
// it is possible, it is not yet available.
|
||||||
|
// Find the panels to render the grid.
|
||||||
|
var dependenciesPanels = this.dependenciesPanels = pgBrowser.docker.findPanels('dependencies');
|
||||||
|
var dependentsPanels = this.dependentsPanels = pgBrowser.docker.findPanels('dependents');
|
||||||
|
|
||||||
|
if (dependenciesPanels.length == 0) {
|
||||||
|
pgBrowser.Events.on(
|
||||||
|
'pgadmin-browser:panel-dependencies:' + wcDocker.EVENT.INIT,
|
||||||
|
function() {
|
||||||
|
this.dependenciesPanels = pgBrowser.docker.findPanels('dependencies');
|
||||||
|
appendGridToPanel(this.dependenciesCollection, this.dependenciesPanels, false);
|
||||||
|
|
||||||
|
// If Dependencies panel exists and is focused then we need to listen the browser tree selection events.
|
||||||
|
if ((dependenciesPanels[0].isVisible()) || dependenciesPanels.length != 1) {
|
||||||
|
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependencies);
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
appendGridToPanel(this.dependenciesCollection, this.dependenciesPanels, false);
|
||||||
|
|
||||||
|
// If Dependencies panel exists and is focused then we need to listen the browser tree selection events.
|
||||||
|
if ((dependenciesPanels[0].isVisible()) || dependenciesPanels.length != 1) {
|
||||||
|
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependencies);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dependentsPanels.length == 0) {
|
||||||
|
pgBrowser.Events.on(
|
||||||
|
'pgadmin-browser:panel-dependents:' + wcDocker.EVENT.INIT,
|
||||||
|
function() {
|
||||||
|
this.dependentsPanels = pgBrowser.docker.findPanels('dependents');
|
||||||
|
appendGridToPanel(this.dependentCollection, this.dependentsPanels, true);
|
||||||
|
|
||||||
|
// If Dependents panel exists and is focused then we need to listen the browser tree selection events.
|
||||||
|
if ((dependentsPanels[0].isVisible()) || dependentsPanels.length != 1) {
|
||||||
|
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependents);
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
appendGridToPanel(this.dependentCollection, this.dependentsPanels, true);
|
||||||
|
|
||||||
|
// If Dependents panel exists and is focused then we need to listen the browser tree selection events.
|
||||||
|
if ((dependentsPanels[0].isVisible()) || dependentsPanels.length != 1) {
|
||||||
|
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependents);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Fetch the actual data and update the collection
|
// Fetch the actual data and update the collection
|
||||||
__updateCollection: function(collection, panel, url, messages, node) {
|
__updateCollection: function(collection, panel, url, messages, node) {
|
||||||
var msg = messages[0],
|
var msg = messages[0],
|
||||||
$container = panel[0].layout().$table.find('.pg-panel-content'),
|
$container = panel[0].layout().scene().find('.pg-panel-content'),
|
||||||
$msgContainer = $container.find('.pg-panel-depends-message'),
|
$msgContainer = $container.find('.pg-panel-depends-message'),
|
||||||
$gridContainer = $container.find('.pg-panel-depends-container');
|
$gridContainer = $container.find('.pg-panel-depends-container');
|
||||||
|
|
||||||
|
@ -19,13 +19,30 @@ function(_, $, pgBrowser) {
|
|||||||
var sqlPanels = pgBrowser.docker.findPanels('sql');
|
var sqlPanels = pgBrowser.docker.findPanels('sql');
|
||||||
|
|
||||||
// We will listend to the visibility change of the SQL panel
|
// We will listend to the visibility change of the SQL panel
|
||||||
pgBrowser.Events.on('pgadmin-browser:panel-sql:' + wcDocker.EVENT.VISIBILITY_CHANGED, this.sqlPanelVisibilityChanged);
|
pgBrowser.Events.on(
|
||||||
|
'pgadmin-browser:panel-sql:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
||||||
|
this.sqlPanelVisibilityChanged
|
||||||
|
);
|
||||||
|
|
||||||
// Hmm.. Did we find the SQL panel, and is it visible (openned)?
|
// Hmm.. Did we find the SQL panel, and is it visible (openned)?
|
||||||
// If that is the case - we need to listen the browser tree selection
|
// If that is the case - we need to listen the browser tree selection
|
||||||
// events.
|
// events.
|
||||||
if ((sqlPanels.length == 1 && sqlPanels[0].isVisible()) || sqlPanels.length != 1) {
|
if (sqlPanels.length == 0) {
|
||||||
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showSQL);
|
pgBrowser.Events.on(
|
||||||
|
'pgadmin-browser:panel-sql:' + wcDocker.EVENT.INIT,
|
||||||
|
function() {
|
||||||
|
if ((sqlPanels[0].isVisible()) || sqlPanels.length != 1) {
|
||||||
|
pgBrowser.Events.on(
|
||||||
|
'pgadmin-browser:tree:selected', this.showSQL
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ((sqlPanels[0].isVisible()) || sqlPanels.length != 1) {
|
||||||
|
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showSQL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showSQL: function(item, data, node) {
|
showSQL: function(item, data, node) {
|
||||||
|
Loading…
Reference in New Issue
Block a user