Updated the misc module javascripts to work with latest wcDocker.

This commit is contained in:
Neel Patel 2016-02-29 19:34:06 +05:30 committed by Ashesh Vashi
parent 18d767b107
commit 000c76871f
2 changed files with 79 additions and 21 deletions

View File

@ -25,26 +25,12 @@ define(
'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
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);
// 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.
var Model = Backbone.Model.extend({
defaults: {
@ -85,7 +71,7 @@ define(
* panel only once.
*/
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'),
grid = new Backgrid.Grid({
columns: [
@ -127,16 +113,71 @@ define(
self.dependenciesGrid = grid;
$gridContainer.append(grid.render().el);
return true;
};
appendGridToPanel(this.dependentCollection, this.dependentsPanels, true);
appendGridToPanel(this.dependenciesCollection, this.dependenciesPanels, false);
// We will listened to the visibility change of the Dependencies and Dependents panel
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
__updateCollection: function(collection, panel, url, messages, node) {
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'),
$gridContainer = $container.find('.pg-panel-depends-container');

View File

@ -19,13 +19,30 @@ function(_, $, pgBrowser) {
var sqlPanels = pgBrowser.docker.findPanels('sql');
// 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)?
// If that is the case - we need to listen the browser tree selection
// events.
if ((sqlPanels.length == 1 && sqlPanels[0].isVisible()) || sqlPanels.length != 1) {
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showSQL);
if (sqlPanels.length == 0) {
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) {