瀏覽代碼

HUE-7218 [editor] Offer links if row values are pure http links in the record popup

Romain Rigaux 8 年之前
父節點
當前提交
1edda2f
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      desktop/core/src/desktop/templates/common_header_footer_components.mako

+ 4 - 2
desktop/core/src/desktop/templates/common_header_footer_components.mako

@@ -528,8 +528,10 @@ from metadata.conf import has_optimizer, OPTIMIZER
       $t.html('');
       var html = '';
       $el.find('thead th').each(function (colIdx, col) {
-        if (colIdx > 0){
-          html += '<tr><th width="10%">' + $(col).text() + '</th><td>' + $el.data('data')[data.idx][colIdx] + '</td></tr>';
+        if (colIdx > 0) {
+          var value = $el.data('data')[data.idx][colIdx];
+          var link = typeof value == 'string' && value.match(/^https?:\/\//i) ? '<a href="' + escapeOutput(value) + '" target="_blank">' + value + ' <i class="fa fa-external-link"></i></a>' : value;
+          html += '<tr><th width="10%">' + $(col).text() + '</th><td>' + link + '</td></tr>';
         }
       });
       $t.html(html);