浏览代码

HUE-7710 [search] Prettify facet dimension humane description

Romain Rigaux 8 年之前
父节点
当前提交
e986e8e
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      desktop/libs/dashboard/src/dashboard/templates/common_search.mako

+ 8 - 2
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -2076,7 +2076,7 @@ ${ dashboard.layout_skeleton(suffix='search') }
 
     <!-- ko if: !$root.isEditing() -->
     <div class="content" style="border: 1px solid #d8d8d8;">
-      <div data-bind="text: getPrettyMetric(aggregate)" class="muted"></div>
+      <div data-bind="text: getPrettyMetric($data)" class="muted"></div>
       <!-- ko if: aggregate.function() != 'field' && aggregate.metrics -->
       <i class="fa" data-bind="css: { 'fa-long-arrow-down': sort() == 'desc', 'fa-long-arrow-up': sort() == 'asc' }"></i>
       <!-- /ko -->
@@ -2846,7 +2846,13 @@ function getHitOption(value) {
 }
 
 function getPrettyMetric(facet) {
-  return getHitOption(facet.function());
+  if (facet.field() == 'formula') {
+    return facet.aggregate.plain_formula()
+  } else if (facet.aggregate.function() == 'percentile') {
+    return 'percentile(' + facet.aggregate.percentiles()[0]['value']() + ')';
+  } else {
+    return getHitOption(facet.aggregate.function());
+  }
 }
 
 function prettifyDate(from, widget, to) {