mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Improved the functionality of enable/disable the auto-collection of
the graph data. - Dashboard is intereseted only on the current selected object in the browser tree. And, not the one, which was got disconnected. - Disable the auto-collection of data selectively, and only when the selected object got disconnected, and not when changing back to the Dashboard panel (as per Aditya).
This commit is contained in:
parent
35862b94a9
commit
5ff2942b4d
@ -243,14 +243,32 @@ define('pgadmin.dashboard', [
|
|||||||
|
|
||||||
// Handle Server Disconnect
|
// Handle Server Disconnect
|
||||||
object_disconnected: function(obj) {
|
object_disconnected: function(obj) {
|
||||||
this.object_selected(obj.item, obj.data, pgBrowser.Nodes[obj.data._type]);
|
let item = pgBrowser.tree.selected(),
|
||||||
|
itemData = item && pgBrowser.tree.itemData(item);
|
||||||
|
|
||||||
|
// The server connected may not be the same one, which was selected, and
|
||||||
|
// we do care out the current selected one only.
|
||||||
|
if (item.length != 0) {
|
||||||
|
this.object_selected(item, itemData, pgBrowser.Nodes[itemData._type]);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Handle treeview clicks
|
// Handle treeview clicks
|
||||||
object_selected: function(item, itemData, node) {
|
object_selected: function(item, itemData, node) {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
if (itemData && itemData._type && dashboardVisible) {
|
if (dashboardVisible === false) {
|
||||||
|
/*
|
||||||
|
* Clear all the interval functions, even when dashboard is not
|
||||||
|
* visible (in case of connection of the object got disconnected).
|
||||||
|
*/
|
||||||
|
if (
|
||||||
|
!_.isUndefined(itemData.connected) &&
|
||||||
|
itemData.connected !== true
|
||||||
|
) {
|
||||||
|
self.clearIntervalId();
|
||||||
|
}
|
||||||
|
} else if (itemData && itemData._type) {
|
||||||
var treeHierarchy = node.getTreeNodeHierarchy(item),
|
var treeHierarchy = node.getTreeNodeHierarchy(item),
|
||||||
url = NodesDashboard.url(itemData, item, treeHierarchy);
|
url = NodesDashboard.url(itemData, item, treeHierarchy);
|
||||||
|
|
||||||
@ -301,17 +319,19 @@ define('pgadmin.dashboard', [
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (div) {
|
if (div) {
|
||||||
|
if (itemData.connected || _.isUndefined(itemData.connected)) {
|
||||||
|
// Avoid unnecessary reloads
|
||||||
|
if (
|
||||||
|
url !== $(dashboardPanel).data('dashboard_url') || (
|
||||||
|
url === $(dashboardPanel).data('dashboard_url') &&
|
||||||
|
$(dashboardPanel).data('server_status') == false
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
$(div).empty();
|
||||||
|
|
||||||
/* Clear all the interval functions of previous dashboards */
|
/* Clear all the interval functions of previous dashboards */
|
||||||
self.clearIntervalId();
|
self.clearIntervalId();
|
||||||
|
|
||||||
if (itemData.connected || _.isUndefined(itemData.connected)) {
|
|
||||||
// Avoid unnecessary reloads
|
|
||||||
if (url !== $(dashboardPanel).data('dashboard_url') || (
|
|
||||||
url === $(dashboardPanel).data('dashboard_url') &&
|
|
||||||
$(dashboardPanel).data('server_status') == false)) {
|
|
||||||
$(div).empty();
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
@ -330,6 +350,13 @@ define('pgadmin.dashboard', [
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$(div).empty();
|
$(div).empty();
|
||||||
|
if (
|
||||||
|
!_.isUndefined(itemData.connected) &&
|
||||||
|
itemData.connected !== true
|
||||||
|
) {
|
||||||
|
/* Clear all the interval functions of previous dashboards */
|
||||||
|
self.clearIntervalId();
|
||||||
|
}
|
||||||
$(div).html(
|
$(div).html(
|
||||||
'<div class="alert alert-info pg-panel-message" role="alert">' + gettext('Please connect to the selected server to view the dashboard.') + '</div>'
|
'<div class="alert alert-info pg-panel-message" role="alert">' + gettext('Please connect to the selected server to view the dashboard.') + '</div>'
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user