|
|
@@ -964,7 +964,6 @@ var CURRENT_CODEMIRROR_SIZE = 100;
|
|
|
|
|
|
// Navigator, recent queries
|
|
|
$(document).ready(function () {
|
|
|
-
|
|
|
var INITIAL_RESIZE_POSITION = 299;
|
|
|
$("#resizePanel a").draggable({
|
|
|
axis: "y",
|
|
|
@@ -1087,80 +1086,85 @@ $(document).ready(function () {
|
|
|
renderNavigator = function () {
|
|
|
$("#navigatorTables").empty();
|
|
|
$("#navigatorLoader").show();
|
|
|
- hac_getTables(viewModel.database(), function (data) { //preload tables for the default db
|
|
|
- $(data.split(" ")).each(function (cnt, table) {
|
|
|
- if ($.trim(table) != "") {
|
|
|
- var _table = $("<li>");
|
|
|
- var _metastoreLink = "";
|
|
|
- % if has_metastore:
|
|
|
- _metastoreLink = "<i class='fa fa-eye' title='" + "${ _('View in Metastore Browser') }" + "'></i>";
|
|
|
- % endif
|
|
|
- _table.html("<a href='javascript:void(0)' class='pull-right' style='padding-right:5px'><i class='fa fa-list' title='" + "${ _('Preview Sample data') }" + "' style='margin-left:5px'></i></a><a href='/metastore/table/" + viewModel.database() + "/" + table + "' target='_blank' class='pull-right hide'>" + _metastoreLink + "</a><div><a href='javascript:void(0)' title='" + table + "'><i class='fa fa-table'></i> " + table + "</a><ul class='unstyled'></ul></div>");
|
|
|
-
|
|
|
- _table.data("table", table).attr("id", "navigatorTables_" + table);
|
|
|
- _table.find("a:eq(2)").on("click", function () {
|
|
|
- _table.find(".fa-table").removeClass("fa-table").addClass("fa-spin").addClass("fa-spinner");
|
|
|
- hac_getTableColumns(viewModel.database(), table, "", function (plain_columns, extended_columns) {
|
|
|
- _table.find("a:eq(1)").removeClass("hide");
|
|
|
- _table.find("ul").empty();
|
|
|
- _table.find(".fa-spinner").removeClass("fa-spinner").removeClass("fa-spin").addClass("fa-table");
|
|
|
- $(extended_columns).each(function (iCnt, col) {
|
|
|
- var _column = $("<li>");
|
|
|
- _column.html("<a href='javascript:void(0)' style='padding-left:10px'" + (col.comment != null && col.comment != "" ? " title='" + col.comment + "'" : "") + "><i class='fa fa-columns'></i> " + col.name + ($.trim(col.type) != "" ? " (" + $.trim(col.type) + ")" : "") + "</a>");
|
|
|
- _column.appendTo(_table.find("ul"));
|
|
|
- _column.on("dblclick", function () {
|
|
|
- codeMirror.replaceSelection($.trim(col.name) + ', ');
|
|
|
- codeMirror.setSelection(codeMirror.getCursor());
|
|
|
- codeMirror.focus();
|
|
|
+
|
|
|
+ if (! viewModel.database()) {
|
|
|
+ $("#navigatorLoader").html("${_('No databases or tables found.')}");
|
|
|
+ } else {
|
|
|
+ hac_getTables(viewModel.database(), function (data) { //preload tables for the default db
|
|
|
+ $(data.split(" ")).each(function (cnt, table) {
|
|
|
+ if ($.trim(table) != "") {
|
|
|
+ var _table = $("<li>");
|
|
|
+ var _metastoreLink = "";
|
|
|
+ % if has_metastore:
|
|
|
+ _metastoreLink = "<i class='fa fa-eye' title='" + "${ _('View in Metastore Browser') }" + "'></i>";
|
|
|
+ % endif
|
|
|
+ _table.html("<a href='javascript:void(0)' class='pull-right' style='padding-right:5px'><i class='fa fa-list' title='" + "${ _('Preview Sample data') }" + "' style='margin-left:5px'></i></a><a href='/metastore/table/" + viewModel.database() + "/" + table + "' target='_blank' class='pull-right hide'>" + _metastoreLink + "</a><div><a href='javascript:void(0)' title='" + table + "'><i class='fa fa-table'></i> " + table + "</a><ul class='unstyled'></ul></div>");
|
|
|
+
|
|
|
+ _table.data("table", table).attr("id", "navigatorTables_" + table);
|
|
|
+ _table.find("a:eq(2)").on("click", function () {
|
|
|
+ _table.find(".fa-table").removeClass("fa-table").addClass("fa-spin").addClass("fa-spinner");
|
|
|
+ hac_getTableColumns(viewModel.database(), table, "", function (plain_columns, extended_columns) {
|
|
|
+ _table.find("a:eq(1)").removeClass("hide");
|
|
|
+ _table.find("ul").empty();
|
|
|
+ _table.find(".fa-spinner").removeClass("fa-spinner").removeClass("fa-spin").addClass("fa-table");
|
|
|
+ $(extended_columns).each(function (iCnt, col) {
|
|
|
+ var _column = $("<li>");
|
|
|
+ _column.html("<a href='javascript:void(0)' style='padding-left:10px'" + (col.comment != null && col.comment != "" ? " title='" + col.comment + "'" : "") + "><i class='fa fa-columns'></i> " + col.name + ($.trim(col.type) != "" ? " (" + $.trim(col.type) + ")" : "") + "</a>");
|
|
|
+ _column.appendTo(_table.find("ul"));
|
|
|
+ _column.on("dblclick", function () {
|
|
|
+ codeMirror.replaceSelection($.trim(col.name) + ', ');
|
|
|
+ codeMirror.setSelection(codeMirror.getCursor());
|
|
|
+ codeMirror.focus();
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
- });
|
|
|
- _table.find("a:eq(2)").on("dblclick", function () {
|
|
|
- codeMirror.replaceSelection($.trim(table) + ' ');
|
|
|
- codeMirror.setSelection(codeMirror.getCursor());
|
|
|
- codeMirror.focus();
|
|
|
- });
|
|
|
- _table.find("a:eq(0)").on("click", function () {
|
|
|
- var tableUrl = "/${ app_name }/api/table/" + viewModel.database() + "/" + _table.data("table");
|
|
|
- $("#navigatorQuicklook").find(".tableName").text(table);
|
|
|
- $("#navigatorQuicklook").find(".tableLink").attr("href", "/metastore/table/" + viewModel.database() + "/" + table);
|
|
|
- $("#navigatorQuicklook").find(".sample").empty("");
|
|
|
- $("#navigatorQuicklook").attr("style", "width: " + ($(window).width() - 120) + "px;margin-left:-" + (($(window).width() - 80) / 2) + "px!important;");
|
|
|
- $.ajax({
|
|
|
- url: tableUrl,
|
|
|
- data: {"sample": true},
|
|
|
- beforeSend: function (xhr) {
|
|
|
- xhr.setRequestHeader("X-Requested-With", "Hue");
|
|
|
- },
|
|
|
- dataType: "html",
|
|
|
- success: function (data) {
|
|
|
- $("#navigatorQuicklook").find(".loader").hide();
|
|
|
- $("#navigatorQuicklook").find(".sample").html(data);
|
|
|
- },
|
|
|
- error: function (e) {
|
|
|
- if (e.status == 500) {
|
|
|
- resetNavigator();
|
|
|
- $(document).trigger("error", "${ _('There was a problem loading the table preview.') }");
|
|
|
- $("#navigatorQuicklook").modal("hide");
|
|
|
+ _table.find("a:eq(2)").on("dblclick", function () {
|
|
|
+ codeMirror.replaceSelection($.trim(table) + ' ');
|
|
|
+ codeMirror.setSelection(codeMirror.getCursor());
|
|
|
+ codeMirror.focus();
|
|
|
+ });
|
|
|
+ _table.find("a:eq(0)").on("click", function () {
|
|
|
+ var tableUrl = "/${ app_name }/api/table/" + viewModel.database() + "/" + _table.data("table");
|
|
|
+ $("#navigatorQuicklook").find(".tableName").text(table);
|
|
|
+ $("#navigatorQuicklook").find(".tableLink").attr("href", "/metastore/table/" + viewModel.database() + "/" + table);
|
|
|
+ $("#navigatorQuicklook").find(".sample").empty("");
|
|
|
+ $("#navigatorQuicklook").attr("style", "width: " + ($(window).width() - 120) + "px;margin-left:-" + (($(window).width() - 80) / 2) + "px!important;");
|
|
|
+ $.ajax({
|
|
|
+ url: tableUrl,
|
|
|
+ data: {"sample": true},
|
|
|
+ beforeSend: function (xhr) {
|
|
|
+ xhr.setRequestHeader("X-Requested-With", "Hue");
|
|
|
+ },
|
|
|
+ dataType: "html",
|
|
|
+ success: function (data) {
|
|
|
+ $("#navigatorQuicklook").find(".loader").hide();
|
|
|
+ $("#navigatorQuicklook").find(".sample").html(data);
|
|
|
+ },
|
|
|
+ error: function (e) {
|
|
|
+ if (e.status == 500) {
|
|
|
+ resetNavigator();
|
|
|
+ $(document).trigger("error", "${ _('There was a problem loading the table preview.') }");
|
|
|
+ $("#navigatorQuicklook").modal("hide");
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
+ $("#navigatorQuicklook").modal("show");
|
|
|
});
|
|
|
- $("#navigatorQuicklook").modal("show");
|
|
|
- });
|
|
|
- _table.appendTo($("#navigatorTables"));
|
|
|
+ _table.appendTo($("#navigatorTables"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $("#navigatorLoader").hide();
|
|
|
+ if ($("#navigatorTables li").length > 0) {
|
|
|
+ $("#navigatorSearch").show();
|
|
|
+ $("#navigatorNoTables").hide();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $("#navigatorSearch").hide();
|
|
|
+ $("#navigatorNoTables").show();
|
|
|
}
|
|
|
});
|
|
|
- $("#navigatorLoader").hide();
|
|
|
- if ($("#navigatorTables li").length > 0) {
|
|
|
- $("#navigatorSearch").show();
|
|
|
- $("#navigatorNoTables").hide();
|
|
|
- }
|
|
|
- else {
|
|
|
- $("#navigatorSearch").hide();
|
|
|
- $("#navigatorNoTables").show();
|
|
|
- }
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$("#expandResults").on("click", function(){
|