2019-01-02 04:24:12 -06:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2020-01-02 08:43:50 -06:00
|
|
|
// Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
2019-01-02 04:24:12 -06:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2015-06-30 00:51:55 -05:00
|
|
|
define(
|
2018-01-12 01:29:51 -06:00
|
|
|
['underscore', 'sources/pgadmin', 'jquery', 'wcdocker'],
|
|
|
|
function(_, pgAdmin, $) {
|
|
|
|
|
|
|
|
var pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {},
|
|
|
|
wcDocker = window.wcDocker;
|
|
|
|
|
|
|
|
pgAdmin.Browser.Panel = function(options) {
|
|
|
|
var defaults = [
|
|
|
|
'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
|
2019-03-26 10:08:45 -05:00
|
|
|
'isPrivate', 'isLayoutMember', 'content', 'icon', 'events', 'onCreate', 'elContainer',
|
2019-02-27 04:59:58 -06:00
|
|
|
'canHide', 'limit', 'extraClasses',
|
2018-01-12 01:29:51 -06:00
|
|
|
];
|
|
|
|
_.extend(this, _.pick(options, defaults));
|
|
|
|
};
|
|
|
|
|
|
|
|
_.extend(pgAdmin.Browser.Panel.prototype, {
|
|
|
|
name: '',
|
|
|
|
title: '',
|
|
|
|
width: 300,
|
|
|
|
height: 600,
|
|
|
|
showTitle: true,
|
|
|
|
isCloseable: true,
|
|
|
|
isPrivate: false,
|
2019-03-26 10:08:45 -05:00
|
|
|
isLayoutMember: true,
|
2018-01-12 01:29:51 -06:00
|
|
|
content: '',
|
|
|
|
icon: '',
|
|
|
|
panel: null,
|
|
|
|
onCreate: null,
|
|
|
|
elContainer: false,
|
|
|
|
limit: null,
|
2019-02-27 04:59:58 -06:00
|
|
|
extraClasses: null,
|
2018-01-12 01:29:51 -06:00
|
|
|
load: function(docker, title) {
|
|
|
|
var that = this;
|
|
|
|
if (!that.panel) {
|
|
|
|
docker.registerPanelType(that.name, {
|
|
|
|
title: that.title,
|
|
|
|
isPrivate: that.isPrivate,
|
|
|
|
limit: that.limit,
|
2019-03-26 10:08:45 -05:00
|
|
|
isLayoutMember: that.isLayoutMember,
|
2018-01-12 01:29:51 -06:00
|
|
|
onCreate: function(myPanel) {
|
|
|
|
$(myPanel).data('pgAdminName', that.name);
|
|
|
|
myPanel.initSize(that.width, that.height);
|
|
|
|
|
|
|
|
if (!that.showTitle)
|
|
|
|
myPanel.title(false);
|
|
|
|
else {
|
2019-05-15 07:12:07 -05:00
|
|
|
var title_elem = '<a href="#" tabindex="-1" class="panel-link-heading">' + (title || that.title) + '</a>';
|
2018-02-02 07:28:37 -06:00
|
|
|
myPanel.title(title_elem);
|
2018-01-12 01:29:51 -06:00
|
|
|
if (that.icon != '')
|
|
|
|
myPanel.icon(that.icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
var $container = $('<div>', {
|
|
|
|
'class': 'pg-panel-content',
|
|
|
|
}).append($(that.content));
|
|
|
|
|
2019-02-27 04:59:58 -06:00
|
|
|
// Add extra classes
|
|
|
|
if (!_.isNull('extraClasses')) {
|
|
|
|
$container.addClass(that.extraClasses);
|
|
|
|
}
|
|
|
|
|
2018-01-12 01:29:51 -06:00
|
|
|
myPanel.closeable(!!that.isCloseable);
|
|
|
|
myPanel.layout().addItem($container);
|
|
|
|
that.panel = myPanel;
|
|
|
|
if (that.events && _.isObject(that.events)) {
|
|
|
|
_.each(that.events, function(v, k) {
|
|
|
|
if (v && _.isFunction(v)) {
|
|
|
|
myPanel.on(k, v);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_.each([
|
2016-01-19 06:31:14 -06:00
|
|
|
wcDocker.EVENT.UPDATED, wcDocker.EVENT.VISIBILITY_CHANGED,
|
|
|
|
wcDocker.EVENT.BEGIN_DOCK, wcDocker.EVENT.END_DOCK,
|
|
|
|
wcDocker.EVENT.GAIN_FOCUS, wcDocker.EVENT.LOST_FOCUS,
|
|
|
|
wcDocker.EVENT.CLOSED, wcDocker.EVENT.BUTTON,
|
|
|
|
wcDocker.EVENT.ATTACHED, wcDocker.EVENT.DETACHED,
|
|
|
|
wcDocker.EVENT.MOVE_STARTED, wcDocker.EVENT.MOVE_ENDED,
|
|
|
|
wcDocker.EVENT.MOVED, wcDocker.EVENT.RESIZE_STARTED,
|
|
|
|
wcDocker.EVENT.RESIZE_ENDED, wcDocker.EVENT.RESIZED,
|
2018-01-12 01:29:51 -06:00
|
|
|
wcDocker.EVENT.SCROLLED,
|
2016-05-25 05:17:56 -05:00
|
|
|
], function(ev) {
|
2018-01-12 01:29:51 -06:00
|
|
|
myPanel.on(ev, that.eventFunc.bind(myPanel, ev));
|
2016-05-25 05:17:56 -05:00
|
|
|
});
|
2018-01-12 01:29:51 -06:00
|
|
|
|
|
|
|
if (that.onCreate && _.isFunction(that.onCreate)) {
|
|
|
|
that.onCreate.apply(that, [myPanel, $container]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (that.elContainer) {
|
|
|
|
myPanel.pgElContainer = $container;
|
|
|
|
$container.addClass('pg-el-container');
|
|
|
|
_.each([
|
|
|
|
wcDocker.EVENT.RESIZED, wcDocker.EVENT.ATTACHED,
|
|
|
|
wcDocker.EVENT.DETACHED, wcDocker.EVENT.VISIBILITY_CHANGED,
|
|
|
|
], function(ev) {
|
|
|
|
myPanel.on(ev, that.resizedContainer.bind(myPanel));
|
2017-06-30 04:11:34 -05:00
|
|
|
});
|
2018-01-12 01:29:51 -06:00
|
|
|
that.resizedContainer.apply(myPanel);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bind events only if they are configurable
|
|
|
|
if (that.canHide) {
|
|
|
|
_.each([wcDocker.EVENT.CLOSED, wcDocker.EVENT.VISIBILITY_CHANGED],
|
|
|
|
function(ev) {
|
|
|
|
myPanel.on(ev, that.handleVisibility.bind(myPanel, ev));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
eventFunc: function(eventName) {
|
|
|
|
var name = $(this).data('pgAdminName');
|
|
|
|
|
|
|
|
try {
|
|
|
|
pgBrowser.Events.trigger(
|
|
|
|
'pgadmin-browser:panel', eventName, this, arguments
|
|
|
|
);
|
|
|
|
pgBrowser.Events.trigger(
|
|
|
|
'pgadmin-browser:panel:' + eventName, this, arguments
|
|
|
|
);
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
pgBrowser.Events.trigger(
|
|
|
|
'pgadmin-browser:panel-' + name, eventName, this, arguments
|
|
|
|
);
|
|
|
|
pgBrowser.Events.trigger(
|
|
|
|
'pgadmin-browser:panel-' + name + ':' + eventName, this, arguments
|
|
|
|
);
|
2015-06-30 00:51:55 -05:00
|
|
|
}
|
2018-01-12 01:29:51 -06:00
|
|
|
} catch (e) {
|
|
|
|
console.warn(e.stack || e);
|
2016-01-19 06:31:14 -06:00
|
|
|
}
|
2018-01-12 01:29:51 -06:00
|
|
|
},
|
|
|
|
resizedContainer: function() {
|
|
|
|
var p = this;
|
2016-05-25 05:17:56 -05:00
|
|
|
|
2018-01-12 01:29:51 -06:00
|
|
|
if (p.pgElContainer && !p.pgResizeTimeout) {
|
|
|
|
if (!p.isVisible()) {
|
|
|
|
clearTimeout(p.pgResizeTimeout);
|
2016-05-25 05:17:56 -05:00
|
|
|
p.pgResizeTimeout = null;
|
|
|
|
|
2018-01-12 01:29:51 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
p.pgResizeTimeout = setTimeout(
|
|
|
|
function() {
|
2019-01-17 06:50:12 -06:00
|
|
|
var w = p.width(),
|
|
|
|
elAttr = 'xs';
|
2018-01-12 01:29:51 -06:00
|
|
|
p.pgResizeTimeout = null;
|
|
|
|
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 05:44:55 -06:00
|
|
|
/** Calculations based on https://getbootstrap.com/docs/4.1/layout/grid/#grid-options **/
|
2019-01-02 03:35:15 -06:00
|
|
|
if (w < 480) {
|
2019-01-17 06:50:12 -06:00
|
|
|
elAttr = 'xs';
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 05:44:55 -06:00
|
|
|
}
|
2019-01-02 03:35:15 -06:00
|
|
|
if (w >= 480) {
|
2019-01-17 06:50:12 -06:00
|
|
|
elAttr = 'sm';
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 05:44:55 -06:00
|
|
|
}
|
|
|
|
if (w >= 768) {
|
2019-01-17 06:50:12 -06:00
|
|
|
elAttr = 'md';
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 05:44:55 -06:00
|
|
|
}
|
|
|
|
if (w >= 992) {
|
2019-01-17 06:50:12 -06:00
|
|
|
elAttr = 'lg';
|
2018-01-12 01:29:51 -06:00
|
|
|
}
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 05:44:55 -06:00
|
|
|
if (w >=1200) {
|
2019-01-17 06:50:12 -06:00
|
|
|
elAttr = 'xl';
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 05:44:55 -06:00
|
|
|
}
|
2018-01-12 01:29:51 -06:00
|
|
|
|
2019-01-17 06:50:12 -06:00
|
|
|
p.pgElContainer.attr('el', elAttr);
|
2018-01-12 01:29:51 -06:00
|
|
|
},
|
|
|
|
100
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handleVisibility: function(eventName) {
|
|
|
|
// Currently this function only works with dashboard panel but
|
|
|
|
// as per need it can be extended
|
|
|
|
if (this._type != 'dashboard' || _.isUndefined(pgAdmin.Dashboard))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (eventName == 'panelClosed') {
|
2018-09-05 11:25:11 -05:00
|
|
|
/* Pass the closed flag also */
|
|
|
|
pgAdmin.Dashboard.toggleVisibility(false, true);
|
2018-01-12 01:29:51 -06:00
|
|
|
} else if (eventName == 'panelVisibilityChanged') {
|
|
|
|
if (pgBrowser.tree) {
|
|
|
|
var selectedNode = pgBrowser.tree.selected();
|
2018-07-24 10:31:44 -05:00
|
|
|
if (!_.isUndefined(pgAdmin.Dashboard)) {
|
|
|
|
pgAdmin.Dashboard.toggleVisibility(pgBrowser.panels.dashboard.panel.isVisible());
|
|
|
|
}
|
2018-01-12 01:29:51 -06:00
|
|
|
// Explicitly trigger tree selected event when we add the tab.
|
2018-09-05 11:25:11 -05:00
|
|
|
if(selectedNode.length) {
|
|
|
|
pgBrowser.Events.trigger('pgadmin-browser:tree:selected', selectedNode,
|
|
|
|
pgBrowser.tree.itemData(selectedNode), pgBrowser.Node);
|
|
|
|
}
|
2018-01-12 01:29:51 -06:00
|
|
|
}
|
2017-06-30 04:11:34 -05:00
|
|
|
}
|
2018-01-12 01:29:51 -06:00
|
|
|
},
|
2017-06-30 04:11:34 -05:00
|
|
|
|
2018-01-12 01:29:51 -06:00
|
|
|
});
|
2015-06-30 00:51:55 -05:00
|
|
|
|
2018-01-12 01:29:51 -06:00
|
|
|
return pgAdmin.Browser.Panel;
|
|
|
|
});
|