Explorar o código

[assist] Support json and html response type when fetching table samples

Johan Ahlen %!s(int64=10) %!d(string=hai) anos
pai
achega
301324c

+ 2 - 1
desktop/core/src/desktop/static/desktop/js/assist/assistEntry.js

@@ -280,10 +280,11 @@
     $assistQuickLook.find(".sample").empty("");
     $assistQuickLook.attr("style", "width: " + ($(window).width() - 120) + "px;margin-left:-" + (($(window).width() - 80) / 2) + "px!important;");
 
-    self.assistSource.assistHelper.fetchTableHtmlPreview({
+    self.assistSource.assistHelper.fetchTableSample({
       sourceType: self.assistSource.type === "hive" ? "beeswax" : self.assistSource.type,
       databaseName: databaseName,
       tableName: tableName,
+      dataType: "html",
       successCallback: function(data) {
         $assistQuickLook.find(".loader").hide();
         $assistQuickLook.find(".sample").html(data);

+ 7 - 4
desktop/core/src/desktop/static/desktop/js/assist/assistHelper.js

@@ -122,17 +122,20 @@
    * @param {string} options.sourceType
    * @param {string} options.databaseName
    * @param {string} options.tableName
+   * @param {string} options.dataType - html or json
    * @param {function} options.successCallback
    * @param {function} options.errorCallback
    */
-  AssistHelper.prototype.fetchTableHtmlPreview = function (options) {
+  AssistHelper.prototype.fetchTableSample = function (options) {
     $.ajax({
-      url: "/" + options.sourceType + "/api/table/" + options.databaseName + "/" + options.tableName,
-      data: { "sample": true },
+      url: "/" + (options.sourceType == "hive" ? "beeswax" : options.sourceType) + "/api/table/" + options.databaseName + "/" + options.tableName,
+      data: {
+        "sample": true,
+        "format" : options.dataType
+      },
       beforeSend: function (xhr) {
         xhr.setRequestHeader("X-Requested-With", "Hue");
       },
-      dataType: "html",
       success: options.successCallback,
       error: options.errorCallback
     });