mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Moved the javascripts of different modules from 'templates' to 'static' directory.
Moving the javascripts for the following modules: - About - Browser nodes - Dashboard - FileManager - Vendor/snap.svg - Preferences - Settings - Backup - Datagrid - Debugger - Sqleditor - Grant Wizard - Import & Export - Maintenance - Restore and - User Management
This commit is contained in:
committed by
Ashesh Vashi
parent
831c614a60
commit
6d5417709c
2004
web/pgadmin/browser/static/js/browser.js
Normal file
2004
web/pgadmin/browser/static/js/browser.js
Normal file
File diff suppressed because it is too large
Load Diff
176
web/pgadmin/browser/static/js/collection.js
Normal file
176
web/pgadmin/browser/static/js/collection.js
Normal file
@@ -0,0 +1,176 @@
|
||||
define([
|
||||
'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'pgadmin',
|
||||
'backbone', 'alertify', 'backform', 'backgrid', 'pgadmin.backform', 'pgadmin.backgrid',
|
||||
'pgadmin.browser.node'
|
||||
], function(gettext, $, _, S, pgAdmin, Backbone, Alertify, Backform, Backgrid) {
|
||||
|
||||
var pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
|
||||
// It has already been defined.
|
||||
// Avoid running this script again.
|
||||
if (pgBrowser.Collection)
|
||||
return pgBrowser.Collection;
|
||||
|
||||
pgBrowser.Collection = function() {};
|
||||
|
||||
_.extend(
|
||||
pgBrowser.Collection,
|
||||
_.clone(pgBrowser.Node), {
|
||||
///////
|
||||
// Initialization function
|
||||
// Generally - used to register the menus for this type of node.
|
||||
//
|
||||
// Also, look at pgAdmin.Browser.add_menus(...) function.
|
||||
//
|
||||
// Collection will not have 'Properties' menu.
|
||||
//
|
||||
// NOTE: Override this for each node for initialization purpose
|
||||
Init: function() {
|
||||
if (this.node_initialized)
|
||||
return;
|
||||
this.node_initialized = true;
|
||||
pgAdmin.Browser.add_menus([{
|
||||
name: 'refresh', node: this.type, module: this,
|
||||
applies: ['object', 'context'], callback: 'refresh',
|
||||
priority: 1, label: gettext('Refresh...'),
|
||||
icon: 'fa fa-refresh'
|
||||
}]);
|
||||
|
||||
// show query tool only in context menu of supported nodes.
|
||||
if (pgAdmin.DataGrid && pgAdmin.unsupported_nodes) {
|
||||
if (_.indexOf(pgAdmin.unsupported_nodes, this.type) == -1) {
|
||||
pgAdmin.Browser.add_menus([{
|
||||
name: 'show_query_tool', node: this.type, module: this,
|
||||
applies: ['context'], callback: 'show_query_tool',
|
||||
priority: 998, label: gettext('Query Tool...'),
|
||||
icon: 'fa fa-bolt'
|
||||
}]);
|
||||
}
|
||||
}
|
||||
},
|
||||
hasId: false,
|
||||
is_collection: true,
|
||||
collection_node: true,
|
||||
// A collection will always have a collection of statistics, when the node
|
||||
// it represent will have some statistics.
|
||||
hasCollectiveStatistics: true,
|
||||
showProperties: function(item, data, panel) {
|
||||
var that = this,
|
||||
j = panel.$container.find('.obj_properties').first(),
|
||||
view = j.data('obj-view'),
|
||||
content = $('<div></div>')
|
||||
.addClass('pg-prop-content col-xs-12'),
|
||||
node = pgBrowser.Nodes[that.node],
|
||||
// This will be the URL, used for object manipulation.
|
||||
urlBase = this.generate_url(item, 'properties', data),
|
||||
collection = new (node.Collection.extend({
|
||||
url: urlBase,
|
||||
model: node.model
|
||||
}))(),
|
||||
info = this.getTreeNodeHierarchy.apply(this, [item]),
|
||||
gridSchema = Backform.generateGridColumnsFromModel(
|
||||
info, node.model, 'properties', that.columns
|
||||
),
|
||||
// Initialize a new Grid instance
|
||||
grid = new Backgrid.Grid({
|
||||
columns: gridSchema.columns,
|
||||
collection: collection,
|
||||
className: "backgrid table-bordered"
|
||||
}),
|
||||
gridView = {
|
||||
'remove': function() {
|
||||
if (this.grid) {
|
||||
if (this.grid.collection) {
|
||||
this.grid.collection.reset(null, {silent: true});
|
||||
delete (this.grid.collection);
|
||||
}
|
||||
delete (this.grid);
|
||||
this.grid = null;
|
||||
}
|
||||
},
|
||||
grid: grid
|
||||
};
|
||||
|
||||
if (view) {
|
||||
// Avoid unnecessary reloads
|
||||
if (_.isEqual($(panel).data('node-prop'), urlBase)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cache the current IDs for next time
|
||||
$(panel).data('node-prop', urlBase);
|
||||
|
||||
// Reset the data object
|
||||
j.data('obj-view', null);
|
||||
}
|
||||
|
||||
// Make sure the HTML element is empty.
|
||||
j.empty();
|
||||
j.data('obj-view', gridView);
|
||||
|
||||
// Render subNode grid
|
||||
content.append(grid.render().$el);
|
||||
j.append(content);
|
||||
|
||||
// Fetch Data
|
||||
collection.fetch({
|
||||
reset: true,
|
||||
error: function(xhr, error, message) {
|
||||
pgBrowser.Events.trigger(
|
||||
'pgadmin:collection:retrieval:error', 'properties', xhr, error, message, item, that
|
||||
);
|
||||
if (
|
||||
!Alertify.pgHandleItemError(xhr, error, message, {item: item, info: info})
|
||||
) {
|
||||
Alertify.pgNotifier(
|
||||
error, xhr,
|
||||
S(
|
||||
gettext("Error retrieving properties - %s.")
|
||||
).sprintf(message || that.label).value(),
|
||||
function() {
|
||||
console.log(arguments);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
generate_url: function(item, type, d) {
|
||||
var url = pgAdmin.Browser.URL + '{TYPE}/{REDIRECT}{REF}',
|
||||
/*
|
||||
* Using list, and collection functions of a node to get the nodes
|
||||
* under the collection, and properties of the collection respectively.
|
||||
*/
|
||||
opURL = {
|
||||
'properties': 'obj', 'children': 'nodes'
|
||||
},
|
||||
ref = '', self = this;
|
||||
|
||||
_.each(
|
||||
_.sortBy(
|
||||
_.values(
|
||||
_.pick(
|
||||
this.getTreeNodeHierarchy(item), function(v, k, o) {
|
||||
return (k != self.type);
|
||||
})
|
||||
),
|
||||
function(o) { return o.priority; }
|
||||
),
|
||||
function(o) {
|
||||
ref = S('%s/%s').sprintf(ref, encodeURI(o._id)).value();
|
||||
});
|
||||
|
||||
var args = {
|
||||
'TYPE': self.node,
|
||||
'REDIRECT': (type in opURL ? opURL[type] : type),
|
||||
'REF': S('%s/').sprintf(ref).value()
|
||||
};
|
||||
|
||||
return url.replace(/{(\w+)}/g, function(match, arg) {
|
||||
return args[arg];
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return pgBrowser.Collection;
|
||||
});
|
||||
45
web/pgadmin/browser/static/js/error.js
Normal file
45
web/pgadmin/browser/static/js/error.js
Normal file
@@ -0,0 +1,45 @@
|
||||
define(
|
||||
['sources/gettext', 'underscore', 'alertify', 'pgadmin'],
|
||||
function(gettext, _, alertify, pgAdmin) {
|
||||
pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
|
||||
_.extend(pgAdmin.Browser, {
|
||||
report_error: function(title, message, info) {
|
||||
var text = '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">\
|
||||
<div class="panel panel-default">\
|
||||
<div class="panel-heading" role="tab" id="headingOne">\
|
||||
<h4 class="panel-title">\
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">\
|
||||
' + gettext("Error message") + '</a>\
|
||||
</h4>\
|
||||
</div>\
|
||||
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">\
|
||||
<div class="panel-body" style="overflow: auto;">' + unescape(message) + '</div>\
|
||||
</div>\
|
||||
</div>';
|
||||
|
||||
if (info != null && info != '') {
|
||||
text += '<div class="panel panel-default">\
|
||||
<div class="panel-heading" role="tab" id="headingTwo">\
|
||||
<h4 class="panel-title">\
|
||||
<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">\
|
||||
' + gettext("Additional info") + '</a>\
|
||||
</h4>\
|
||||
</div>\
|
||||
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">\
|
||||
<div class="panel-body" style="overflow: auto;">' + unescape(info) + '</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>'
|
||||
}
|
||||
|
||||
text += '</div>';
|
||||
alertify.alert(
|
||||
title,
|
||||
text
|
||||
)
|
||||
},
|
||||
});
|
||||
|
||||
return pgAdmin.Browser.report_error;
|
||||
});
|
||||
1578
web/pgadmin/browser/static/js/node.js
Normal file
1578
web/pgadmin/browser/static/js/node.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user