Эх сурвалжийг харах

HUE-8687 [frontend] Refactor and modularize hue.utils.js

Johan Ahlen 6 жил өмнө
parent
commit
339c922
35 өөрчлөгдсөн 1618 нэмэгдсэн , 1261 устгасан
  1. 1 10
      .babelrc
  2. 2 6
      apps/beeswax/src/beeswax/templates/execute.mako
  3. 1 1
      apps/oozie/src/oozie/static/oozie/js/bundle-editor.ko.js
  4. 2 2
      apps/oozie/src/oozie/static/oozie/js/coordinator-editor.ko.js
  5. 6 6
      apps/oozie/src/oozie/static/oozie/js/workflow-editor.ko.js
  6. 0 1
      apps/oozie/src/oozie/templates/editor2/bundle_editor.mako
  7. 0 1
      apps/oozie/src/oozie/templates/editor2/coordinator_editor.mako
  8. 1 1
      apps/security/src/security/static/security/js/hive.ko.js
  9. 1 1
      apps/security/src/security/static/security/js/sentry.ko.js
  10. 40 0
      desktop/core/src/desktop/js/hue.js
  11. 14 11
      desktop/core/src/desktop/js/utils/hueAnalytics.js
  12. 35 0
      desktop/core/src/desktop/js/utils/hueDebug.js
  13. 111 0
      desktop/core/src/desktop/js/utils/hueDrop.js
  14. 95 0
      desktop/core/src/desktop/js/utils/huePubSub.js
  15. 403 0
      desktop/core/src/desktop/js/utils/hueUtils.js
  16. 1 1
      desktop/core/src/desktop/static/desktop/js/apiHelper.js
  17. 22 3
      desktop/core/src/desktop/static/desktop/js/hue-bundle-9f109ed3929449756ec4.js
  18. 0 0
      desktop/core/src/desktop/static/desktop/js/hue-bundle-9f109ed3929449756ec4.js.map
  19. 0 0
      desktop/core/src/desktop/static/desktop/js/hue-bundle-f32ebc5a2ae9c17ad586.js.map
  20. 15 94
      desktop/core/src/desktop/static/desktop/js/hue.utils.js
  21. 1 1
      desktop/core/src/desktop/static/desktop/js/jquery.hdfsautocomplete.js
  22. 3 13
      desktop/core/src/desktop/static/desktop/js/ko.common-dashboard.js
  23. 1 1
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js
  24. 205 0
      desktop/core/src/desktop/static/desktop/js/polyfills.js
  25. 1 1
      desktop/core/src/desktop/templates/common_header_footer_components.mako
  26. 1 1
      desktop/core/src/desktop/templates/hue.mako
  27. 1 1
      desktop/core/src/desktop/templates/ko_components/ko_sentry_privileges.mako
  28. 1 1
      desktop/core/src/desktop/templates/ko_components/ko_simple_ace_editor.mako
  29. 9 9
      desktop/libs/dashboard/src/dashboard/static/dashboard/js/search.ko.js
  30. 4 4
      desktop/libs/dashboard/src/dashboard/templates/common_search.mako
  31. 5 5
      desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js
  32. 631 1074
      package-lock.json
  33. 1 2
      package.json
  34. 1 1
      webpack-stats.json
  35. 3 9
      webpack.config.js

+ 1 - 10
.babelrc

@@ -1,12 +1,3 @@
 {
-  "presets": [
-    [
-      "env",
-      {
-        "targets": {
-          "browsers": ["last 2 versions", "safari >= 7"]
-        }
-      }
-    ]
-  ]
+  "presets": ["@babel/preset-env"]
 }

+ 2 - 6
apps/beeswax/src/beeswax/templates/execute.mako

@@ -1204,10 +1204,6 @@ var autocompleter = new Autocompleter({
 
 var totalStorageUserPrefix = apiHelper.getTotalStorageUserPrefix(snippetType);
 
-var escapeOutput = function (str) {
-  return $('<span>').text(str).html().trim();
-};
-
 var truncateOutput = function (obj) {
   //default to 20 characters (column output displays first 21 chars so we need to consider the length of both column name and type
   var chars = obj.chars || 20,
@@ -1221,7 +1217,7 @@ var truncateOutput = function (obj) {
     type = type.slice(0, Math.abs(type.length - trim));
     suffix = '&hellip;';
   }
-  return escapeOutput(type) + suffix;
+  return hueUtils.escapeOutput(type) + suffix;
 };
 
 var reinitTimeout = -1;
@@ -2480,7 +2476,7 @@ function updateSidebarTooltips(selector) {
     $(this).tooltip({
       placement: "right",
       title: $(this).val()
-    }).attr('data-original-title', escapeOutput($(this).val())).tooltip('fixTitle');
+    }).attr('data-original-title', hueUtils.escapeOutput($(this).val())).tooltip('fixTitle');
   });
 }
 

+ 1 - 1
apps/oozie/src/oozie/static/oozie/js/bundle-editor.ko.js

@@ -20,7 +20,7 @@ var Bundle = function (vm, bundle) {
   var self = this;
 
   self.id = ko.observable(typeof bundle.id != "undefined" && bundle.id != null ? bundle.id : null);
-  self.uuid = ko.observable(typeof bundle.uuid != "undefined" && bundle.uuid != null ? bundle.uuid : UUID());
+  self.uuid = ko.observable(typeof bundle.uuid != "undefined" && bundle.uuid != null ? bundle.uuid : hueUtils.UUID());
   self.name = ko.observable(typeof bundle.name != "undefined" && bundle.name != null ? bundle.name : "");
 
   self.coordinators = ko.mapping.fromJS(typeof bundle.coordinators != "undefined" && bundle.coordinators != null ? bundle.coordinators : []);

+ 2 - 2
apps/oozie/src/oozie/static/oozie/js/coordinator-editor.ko.js

@@ -26,7 +26,7 @@ var CoordinatorEditorViewModel = (function () {
     var self = this;
 
     self.id = ko.observable(typeof coordinator.id != "undefined" && coordinator.id != null ? coordinator.id : null);
-    self.uuid = ko.observable(typeof coordinator.uuid != "undefined" && coordinator.uuid != null ? coordinator.uuid : UUID());
+    self.uuid = ko.observable(typeof coordinator.uuid != "undefined" && coordinator.uuid != null ? coordinator.uuid : hueUtils.UUID());
     self.name = ko.observable(typeof coordinator.name != "undefined" && coordinator.name != null ? coordinator.name : "").extend({ trackChange: true });
     self.isManaged = ko.observable(typeof coordinator.isManaged != "undefined" && coordinator.isManaged != null ? coordinator.isManaged : false);
 
@@ -147,7 +147,7 @@ var CoordinatorEditorViewModel = (function () {
 
         'dataset_type': 'parameter',
 
-        'uuid': UUID(), // Dataset
+        'uuid': hueUtils.UUID(), // Dataset
         'dataset_variable': '', // Aka property or URI
         'show_advanced': false,
         'use_done_flag': false,

+ 6 - 6
apps/oozie/src/oozie/static/oozie/js/workflow-editor.ko.js

@@ -77,7 +77,7 @@ var Node = function (node, vm) {
 
   var type = typeof node.widgetType != "undefined" ? node.widgetType : node.type;
 
-  self.id = ko.observable(typeof node.id != "undefined" && node.id != null ? node.id : UUID());
+  self.id = ko.observable(typeof node.id != "undefined" && node.id != null ? node.id : hueUtils.UUID());
   self.name = ko.observable(typeof node.name != "undefined" && node.name != null ? node.name : "");
   self.type = ko.observable(typeof type != "undefined" && type != null ? type : "");
 
@@ -188,7 +188,7 @@ var Workflow = function (vm, workflow) {
   var self = this;
 
   self.id = ko.observable(typeof workflow.id != "undefined" && workflow.id != null ? workflow.id : null);
-  self.uuid = ko.observable(typeof workflow.uuid != "undefined" && workflow.uuid != null ? workflow.uuid : UUID());
+  self.uuid = ko.observable(typeof workflow.uuid != "undefined" && workflow.uuid != null ? workflow.uuid : hueUtils.UUID());
   self.name = ko.observable(typeof workflow.name != "undefined" && workflow.name != null ? workflow.name : "");
 
   self.tracker = new ChangeTracker(self, ko, {
@@ -693,7 +693,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
 
       var _w = new ExtendedWidget({
         size: self.currentlyDraggedWidget().size(),
-        id: UUID(),
+        id: hueUtils.UUID(),
         name: self.currentlyDraggedWidget().name(),
         widgetType: self.currentlyDraggedWidget().widgetType(),
         properties: self.currentlyDraggedWidget().properties(),
@@ -727,7 +727,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
 
       if (_addForkAndJoin) {
         var _forkRow = _parentCol.addEmptyRow(false, _rowIdx);
-        var _id = UUID();
+        var _id = hueUtils.UUID();
         var _fork = new ExtendedWidget({
           size: 12,
           id: _id,
@@ -744,7 +744,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
 
       var _w = new ExtendedWidget({
         size: self.currentlyDraggedWidget().size(),
-        id: UUID(),
+        id: hueUtils.UUID(),
         name: self.currentlyDraggedWidget().name(),
         widgetType: self.currentlyDraggedWidget().widgetType(),
         properties: self.currentlyDraggedWidget().properties(),
@@ -783,7 +783,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
 
       if (_addForkAndJoin) {
         var _joinRow = _parentCol.addEmptyRow(false, _rowIdx + 2);
-        var _id = UUID();
+        var _id = hueUtils.UUID();
         var _join = new ExtendedWidget({
           size: 12,
           id: _id,

+ 0 - 1
apps/oozie/src/oozie/templates/editor2/bundle_editor.mako

@@ -270,7 +270,6 @@ ${ commonshare() | n,unicode }
 %endif
 
 <script src="${ static('desktop/ext/js/bootstrap-editable.min.js') }" type="text/javascript" charset="utf-8"></script>
-<script src="${ static('desktop/js/hue.utils.js') }"></script>
 <script src="${ static('desktop/js/ko.editable.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/ext/chosen/chosen.jquery.min.js') }" type="text/javascript" charset="utf-8"></script>
 % if not is_embeddable:

+ 0 - 1
apps/oozie/src/oozie/templates/editor2/coordinator_editor.mako

@@ -128,7 +128,6 @@ ${ commonshare() | n,unicode }
 %endif
 
 <script src="${ static('desktop/ext/js/bootstrap-editable.min.js') }" type="text/javascript" charset="utf-8"></script>
-<script src="${ static('desktop/js/hue.utils.js') }"></script>
 <script src="${ static('desktop/js/ko.editable.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/ext/chosen/chosen.jquery.min.js') }" type="text/javascript" charset="utf-8"></script>
 % if not is_embeddable:

+ 1 - 1
apps/security/src/security/static/security/js/hive.ko.js

@@ -1096,7 +1096,7 @@ var HiveViewModel = (function () {
         'timestamp': privilege.timestamp,
         'roleName': privilege.roleName,
         'grantOption': privilege.grantOption,
-        'id': UUID()
+        'id': hueUtils.UUID()
       });
       return _privilege;
     }

+ 1 - 1
apps/security/src/security/static/security/js/sentry.ko.js

@@ -1143,7 +1143,7 @@ var SentryViewModel = (function () {
         'timestamp': privilege.timestamp,
         'grantorPrincipal': privilege.grantorPrincipal,
         'grantOption': privilege.grantOption,
-        'id': UUID()
+        'id': hueUtils.UUID()
       });
       return _privilege;
     }

+ 40 - 0
desktop/core/src/desktop/js/hue.js

@@ -0,0 +1,40 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+var locale = 'en-US';
+
+import $ from 'jquery';
+import _ from 'lodash';
+import ko from 'knockout';
+import komapping from 'komapping';
+import page from 'page';
+import hueUtils from 'utils/hueUtils';
+import hueAnalytics from 'utils/hueAnalytics';
+import hueDebug from 'utils/hueDebug';
+import huePubSub from 'utils/huePubSub';
+import hueDrop from 'utils/hueDrop';
+
+// TODO: Migrate away
+window._ = _;
+window.$ = $;
+window.ko = ko;
+window.ko.mapping = komapping;
+window.page = page;
+window.hueUtils = hueUtils;
+window.hueAnalytics = hueAnalytics;
+window.hueDebug = hueDebug;
+window.huePubSub = huePubSub;
+window.hueDrop = hueDrop;

+ 14 - 11
desktop/core/src/desktop/static/desktop/js/hue.js → desktop/core/src/desktop/js/utils/hueAnalytics.js

@@ -14,16 +14,19 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-var locale = 'en-US';
-
 import $ from 'jquery';
-import _ from 'lodash';
-import ko from 'knockout';
-import komapping from 'komapping';
-import page from 'page';
 
-window._ = _;
-window.$ = $;
-window.ko = ko;
-window.ko.mapping = komapping;
-window.page = page;
+let hueAnalytics = {
+  log: function (app, page) {
+    if (typeof trackOnGA == 'function') {
+      trackOnGA(app + '/' + page);
+    }
+  },
+  convert: function (app, page) {
+    $.post('/desktop/log_analytics', {
+      page: app + '/' + page,
+    });
+  }
+};
+
+export default hueAnalytics;

+ 35 - 0
desktop/core/src/desktop/js/utils/hueDebug.js

@@ -0,0 +1,35 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+let hueDebug = {
+  clearCaches: function () {
+    var promises = [];
+    var clearInstance = function (prefix) {
+      promises.push(localforage.createInstance({name: prefix + LOGGED_USERNAME}).clear());
+    };
+    clearInstance('HueContextCatalog_');
+    clearInstance('HueDataCatalog_');
+    clearInstance('HueDataCatalog_hive_');
+    clearInstance('HueDataCatalog_hive_multiTable_');
+    clearInstance('HueDataCatalog_impala_');
+    clearInstance('HueDataCatalog_impala_multiTable_');
+    Promise.all(promises).then(function () {
+      console.log('Done! Refresh the browser.');
+    })
+  }
+};
+
+export default hueDebug;

+ 111 - 0
desktop/core/src/desktop/js/utils/hueDrop.js

@@ -0,0 +1,111 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import huePubSub from './huePubSub';
+import $ from 'jquery';
+
+let jQuery = $;
+
+const hueDrop = () => {
+  var draggableMeta = {};
+
+  huePubSub.subscribe('draggable.text.meta', function (meta) {
+    draggableMeta = meta;
+  });
+
+  return {
+    fromAssist: function (element, callback) {
+      if (typeof element === 'function' && !(element instanceof jQuery)) {
+        callback = element;
+      }
+      if (typeof element === 'string') {
+        element = $(element);
+      }
+      if (element.length > 0) {
+        element.droppable({
+          accept: '.draggableText',
+          drop: function (e, ui) {
+            var droppedText = ui.helper.text();
+            if (callback) {
+              callback({
+                text: ui.helper.text(),
+                meta: draggableMeta
+              });
+            }
+          }
+        });
+      }
+      else {
+        console.warn('hueDrop.fromAssist could not be attached to the element');
+      }
+    },
+    fromDesktop: function (element, callback, method) {
+      if (window.FileReader) {
+        if (typeof element === 'function' && !(element instanceof jQuery)) {
+          callback = element;
+        }
+        if (typeof element === 'string') {
+          element = $(element);
+        }
+
+        let handleFileSelect = (e) => {
+          e.stopPropagation();
+          e.preventDefault();
+          var dt = e.dataTransfer;
+          var files = dt.files;
+          for (var i = 0, f; f = files[i]; i++) {
+            var reader = new FileReader();
+            reader.onload = (function (file) {
+              return function (e) {
+                callback(e.target.result);
+              };
+            })(f);
+            switch (method) {
+              case 'arrayBuffer':
+                reader.readAsArrayBuffer(f);
+                break;
+              case 'binaryString':
+                reader.readAsBinaryString(f);
+                break;
+              case 'dataURL':
+                reader.readAsDataURL(f);
+                break;
+              default:
+                reader.readAsText(f);
+            }
+          }
+        };
+
+        let handleDragOver = (e) => {
+          e.stopPropagation();
+          e.preventDefault();
+          e.dataTransfer.dropEffect = 'copy';
+        };
+
+        if (element.length > 0) {
+          element[0].addEventListener('dragover', handleDragOver, false);
+          element[0].addEventListener('drop', handleFileSelect, false);
+        } else {
+          console.warn('hueDrop.fromDesktop could not be attached to the element');
+        }
+      }  else {
+        console.warn('FileReader is not supported by your browser. Please consider upgrading to fully experience Hue!')
+      }
+    }
+  };
+};
+
+export default hueDrop;

+ 95 - 0
desktop/core/src/desktop/js/utils/huePubSub.js

@@ -0,0 +1,95 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Based on original pub/sub implementation from http://davidwalsh.name/pubsub-javascript
+
+let topics = {};
+let hOP = topics.hasOwnProperty;
+
+const huePubSub = {
+  subscribe: function (topic, listener, app) {
+    if (!hOP.call(topics, topic)) {
+      topics[topic] = [];
+    }
+
+    let index = topics[topic].push({
+      listener: listener,
+      app: app,
+      status: 'running'
+    }) - 1;
+
+    return {
+      remove: function () {
+        delete topics[topic][index];
+      }
+    };
+  },
+  removeAll: function (topic) {
+    topics[topic] = [];
+  },
+  subscribeOnce: function (topic, listener, app) {
+    let ephemeral = this.subscribe(topic, function () {
+      listener.apply(listener, arguments);
+      ephemeral.remove();
+    }, app);
+
+  },
+  publish: function (topic, info) {
+    if (!hOP.call(topics, topic)) {
+      return;
+    }
+
+    topics[topic].forEach(function (item) {
+      if (item.status === 'running') {
+        item.listener(info);
+      }
+    });
+  },
+  getTopics: function () {
+    return topics;
+  },
+  pauseAppSubscribers: function (app) {
+    if (app) {
+      Object.keys(topics).forEach(function (topicName) {
+        topics[topicName].forEach(function (topic) {
+          if (typeof topic.app !== 'undefined' && topic.app !== null && (topic.app === app || topic.app.split('-')[0] === app)) {
+            topic.status = 'paused';
+          }
+        });
+      });
+    }
+  },
+  resumeAppSubscribers: function (app) {
+    if (app) {
+      Object.keys(topics).forEach(function (topicName) {
+        topics[topicName].forEach(function (topic) {
+          if (typeof topic.app !== 'undefined' && topic.app !== null && (topic.app === app || topic.app.split('-')[0] === app)) {
+            topic.status = 'running';
+          }
+        });
+      });
+    }
+  },
+  clearAppSubscribers: function (app) {
+    if (app) {
+      Object.keys(topics).forEach(function (topicName) {
+        topics[topicName] = topics[topicName].filter(function(obj){ return obj.app !== app });
+      });
+    }
+  }
+};
+
+export default huePubSub

+ 403 - 0
desktop/core/src/desktop/js/utils/hueUtils.js

@@ -0,0 +1,403 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import $ from 'jquery'
+
+const bootstrapRatios = {
+  span3() {
+    var windowWidth = $(window).width();
+    if (windowWidth >= 1200) {
+    return 23.07692308;
+  } else if (windowWidth >= 768 && windowWidth <= 979) {
+    return 22.9281768;
+  } else {
+    return 23.17073171;
+  }
+  },
+  span9() {
+    var windowWidth = $(window).width();
+    if (windowWidth >= 1200) {
+      return 74.35897436;
+    } else if (windowWidth >= 768 && windowWidth <= 979) {
+      return 74.30939227;
+    } else {
+      return 74.3902439;
+    }
+  },
+  margin() {
+    return 2.56410256;
+  }
+};
+
+/**
+ * Convert text to URLs
+ * Selector arg can be jQuery or document.querySelectorAll()
+ *
+ * @param selectors
+ * @return {default}
+ */
+const text2Url = (selectors) => {
+  var i = 0,
+    len = selectors.length;
+
+  for (i; i < len; i++) {
+    var arr = [],
+      selector = selectors[i],
+      val = selector.innerHTML.replace(/&nbsp;/g, ' ').split(' ');
+
+    val.forEach(function(word) {
+      var matched = null,
+        re = /(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/gi;
+
+      if (re.test(word)) {
+        matched = word.match(re);
+        word = word.replace(matched, '<a href="' + matched + '">' + matched + '</a>')
+        arr.push(word);
+      } else {
+        arr.push(word);
+      }
+    });
+
+    selector.innerHTML = arr.join(' ');
+  }
+  return this;
+};
+
+/**
+ * Create a in-memory div, set it's inner text(which jQuery automatically encodes)
+ * then grab the encoded contents back out.
+ *
+ * @param value
+ * @return {*|jQuery}
+ */
+const htmlEncode = (value) => {
+  return $('<div/>').text(value).html();
+};
+
+const html2text = (value) => {
+  return $('<div/>').html(value).text().replace(/\u00A0/g, ' ');
+};
+
+const goFullScreen = () => {
+  if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {
+    if (document.documentElement.requestFullscreen) {
+      document.documentElement.requestFullscreen();
+    } else if (document.documentElement.msRequestFullscreen) {
+      document.documentElement.msRequestFullscreen();
+    } else if (document.documentElement.mozRequestFullScreen) {
+      document.documentElement.mozRequestFullScreen();
+    } else if (document.documentElement.webkitRequestFullscreen) {
+      document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
+    }
+  }
+};
+
+const exitFullScreen = () => {
+  if (document.fullscreenElement ||
+    document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement) {
+    if (document.exitFullscreen) {
+      document.exitFullscreen();
+    } else if (document.msExitFullscreen) {
+      document.msExitFullscreen();
+    } else if (document.mozCancelFullScreen) {
+      document.mozCancelFullScreen();
+    } else if (document.webkitExitFullscreen) {
+      document.webkitExitFullscreen();
+    }
+  }
+};
+
+const changeURL = (newURL, params) => {
+  var extraSearch = '';
+  if (params) {
+    var newSearchKeys = Object.keys(params);
+    if (newSearchKeys.length) {
+      while (newSearchKeys.length) {
+        var newKey = newSearchKeys.pop();
+        extraSearch += newKey + '=' + params[newKey];
+        if (newSearchKeys.length) {
+          extraSearch += '&';
+        }
+      }
+    }
+  }
+
+  if (typeof IS_EMBEDDED !== 'undefined' && IS_EMBEDDED) {
+    var search = window.location.search;
+    if (extraSearch) {
+      search += (search ? '&' : '?') + extraSearch
+    }
+    newURL = window.location.pathname + search + '#!' + newURL.replace('/hue', '');
+    window.history.pushState(null, null, newURL);
+    return;
+  }
+
+  var hashSplit = newURL.split('#');
+  var url = hashSplit[0];
+  if (extraSearch) {
+    url += (url.indexOf('?') === -1 ? '?' : '&') + extraSearch;
+  }
+  if (hashSplit.length > 1) {
+    url += '#' + hashSplit[1];
+  } else if (window.location.hash) {
+    url += window.location.hash;
+  }
+  window.history.pushState(null, null, url);
+};
+
+const replaceURL = (newURL) => {
+  window.history.replaceState(null, null, newURL);
+};
+
+const changeURLParameter = (param, value) => {
+  if (typeof IS_EMBEDDED !== 'undefined' && IS_EMBEDDED) {
+    var currentUrl = window.location.hash.replace('#!', '');
+    var parts = currentUrl.split('?');
+    var path = parts[0];
+    var search = parts.length > 1 ? parts[1] : '';
+    if (~search.indexOf(param + '=' + value)) {
+      return;
+    }
+    if (~search.indexOf(param + '=')) {
+      if (!value) {
+        search = search.replace(new RegExp(param + '=[^&]*&?'), '');
+      } else {
+        search = search.replace(new RegExp(param + '=[^&]*'), param + '=' + value);
+      }
+    } else if (value) {
+      if (search) {
+        search += '&';
+      }
+      search += param + '=' + value;
+    } else {
+      return;
+    }
+
+    changeURL(search ? path + '?' + search : path);
+  } else {
+    var newSearch = '';
+    if (window.location.getParameter(param, true) !== null) {
+      newSearch += '?';
+      window.location.search.replace(/\?/gi, '').split('&').forEach(function (p) {
+        if (p.split('=')[0] !== param) {
+          newSearch += p;
+        }
+      });
+      if (value){
+        newSearch += (newSearch !== '?' ? '&' : '') + param + '=' + value;
+      }
+    } else {
+      newSearch = window.location.search + (value ? (window.location.search.indexOf('?') > -1 ? '&' : '?') + param + '=' + value : '' );
+    }
+
+    if (newSearch === '?') {
+      newSearch = '';
+    }
+
+    changeURL(window.location.pathname + newSearch);
+  }
+};
+
+const removeURLParameter = (param) => {
+  changeURLParameter(param, null);
+};
+
+const parseHivePseudoJson = (pseudoJson) => {
+  // Hive returns a pseudo-json with parameters, like
+  // "{Lead Developer=John Foo, Lead Developer Email=jfoo@somewhere.com, date=2013-07-11 }"
+  var parsedParams = {};
+  if (pseudoJson && pseudoJson.length > 2){
+    var splits = pseudoJson.substring(1, pseudoJson.length-1).split(', ');
+    splits.forEach(function(part){
+      if (part.indexOf('=') > -1){
+        parsedParams[part.split('=')[0]] = part.split('=')[1];
+      }
+    });
+  }
+  return parsedParams;
+};
+
+const isOverflowing = (element) => {
+  if (element instanceof jQuery) {
+    element = element[0];
+  }
+  return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
+};
+
+const waitForRendered = (selector, condition, callback, timeout) => {
+  var $el = selector instanceof jQuery ? selector: $(selector);
+  if (condition($el)) {
+    callback($el);
+  } else {
+    window.clearTimeout($el.data('waitForRenderTimeout'));
+    var waitForRenderTimeout = window.setTimeout(function () {
+      waitForRendered(selector, condition, callback);
+    }, timeout || 100);
+    $el.data('waitForRenderTimeout', waitForRenderTimeout);
+  }
+};
+
+const waitForObservable = (observable, callback) => {
+  if (observable()) {
+    callback(observable);
+  }
+  else {
+    var subscription = observable.subscribe(function(newValue) {
+      if (newValue) {
+        subscription.dispose();
+        callback(observable);
+      }
+    });
+  }
+};
+
+const waitForVariable = (variable, callback, timeout) => {
+  if (variable) {
+    callback(variable);
+  }
+  else {
+    window.setTimeout(function () {
+      waitForVariable(variable, callback);
+    }, timeout || 100)
+  }
+};
+
+const scrollbarWidth = () => {
+  var $parent, $children, width;
+  $parent = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo(HUE_CONTAINER);
+  $children = $parent.children();
+  width = $children.innerWidth() - $children.height(99).innerWidth();
+  $parent.remove();
+  return width;
+};
+
+const getSearchParameter = (search, name, returnNull) => {
+  name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
+  var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
+    results = regex.exec(search);
+  if (returnNull && results === null){
+    return null;
+  }
+  return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
+};
+
+const logError = (error) => {
+  if (typeof window.console !== 'undefined' && typeof window.console.error !== 'undefined') {
+    if (typeof error !== 'undefined') {
+      console.error(error);
+    }
+    console.error(new Error().stack);
+  }
+};
+
+const equalIgnoreCase = (a, b) => a && b && a.toLowerCase() === b.toLowerCase();
+
+const deXSS = (str) => {
+  if (typeof str !== 'undefined' && str !== null && typeof str === 'string') {
+    return str.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
+  }
+  return str;
+};
+
+const getStyleFromCSSClass = (cssClass) => {
+  for (var i = 0; i < document.styleSheets.length; i++) {
+    var cssClasses = document.styleSheets[i].rules || document.styleSheets[i].cssRules;
+    for (var x = 0; x < cssClasses.length; x++) {
+      if (cssClasses[x].selectorText == cssClass) {
+        return (cssClasses[x].style) ? cssClasses[x].style : cssClasses[x];
+      }
+    }
+  }
+};
+
+const highlight = (text, searchTerm) => {
+  if (searchTerm === '' || text === '') {
+    return text;
+  }
+
+  var remText = text;
+  var highLightedText = '';
+  searchTerm = searchTerm.toLowerCase();
+
+  do {
+    var remLowerText = remText.toLowerCase();
+    var startIndex = remLowerText.indexOf(searchTerm);
+    if(startIndex >= 0) {
+      highLightedText += remText.substring(0, startIndex) + '<strong>' + remText.substring(startIndex, startIndex + searchTerm.length) + '</strong>';
+      remText = remText.substring(startIndex + searchTerm.length);
+    } else {
+      highLightedText += remText;
+    }
+  } while (startIndex >= 0);
+
+  return highLightedText;
+};
+
+const dfs = (node, callback) => {
+  if (!node || typeof(node) !== 'object') {
+    return;
+  }
+  Object.keys(node).forEach(function(key) {
+    callback(node, key);
+    dfs(node[key], callback);
+  });
+};
+
+const deleteAllEmptyStringKey = (node) => {
+  var fDeleteEmptyStringKey = function (node, key) {
+    if (node[key] || typeof(node[key]) !== 'string') {
+      return;
+    }
+    delete node[key];
+  };
+  dfs(node, fDeleteEmptyStringKey);
+};
+
+
+const s4 = () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
+
+const UUID = () =>  s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
+
+const escapeOutput = (str) =>  $('<span>').text(str).html().trim();
+
+export default {
+  bootstrapRatios: bootstrapRatios,
+  text2Url: text2Url,
+  htmlEncode: htmlEncode,
+  html2text: html2text,
+  goFullScreen: goFullScreen,
+  exitFullScreen: exitFullScreen,
+  changeURL: changeURL,
+  replaceURL: replaceURL,
+  changeURLParameter: changeURLParameter,
+  removeURLParameter: removeURLParameter,
+  parseHivePseudoJson: parseHivePseudoJson,
+  isOverflowing: isOverflowing,
+  waitForRendered: waitForRendered,
+  waitForObservable: waitForObservable,
+  waitForVariable: waitForVariable,
+  scrollbarWidth: scrollbarWidth,
+  getSearchParameter: getSearchParameter,
+  logError: logError,
+  equalIgnoreCase: equalIgnoreCase,
+  deXSS: deXSS,
+  getStyleFromCSSClass: getStyleFromCSSClass,
+  highlight: highlight,
+  dfs: dfs,
+  deleteAllEmptyStringKey: deleteAllEmptyStringKey,
+  UUID: UUID,
+  escapeOutput: escapeOutput
+}

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/apiHelper.js

@@ -1669,7 +1669,7 @@ var ApiHelper = (function () {
    */
   var QueryResult = function (sourceType, compute, response) {
     var self = this;
-    self.id = UUID();
+    self.id = hueUtils.UUID();
     self.type = response.result.type || sourceType;
     self.compute = compute;
     self.status = response.status || 'running';

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 22 - 3
desktop/core/src/desktop/static/desktop/js/hue-bundle-9f109ed3929449756ec4.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/hue-bundle-9f109ed3929449756ec4.js.map


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/hue-bundle-f32ebc5a2ae9c17ad586.js.map


+ 15 - 94
desktop/core/src/desktop/static/desktop/js/hue.utils.js

@@ -494,6 +494,21 @@ window.hueUtils = window.hueUtils || (function () {
     hueUtils.dfs(node, fDeleteEmptyStringKey);
   };
 
+  function s4() {
+    return Math.floor((1 + Math.random()) * 0x10000)
+      .toString(16)
+      .substring(1);
+  }
+
+  hueUtils.UUID = function() {
+    return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
+  };
+
+
+  hueUtils.escapeOutput = function (str) {
+    return $('<span>').text(str).html().trim();
+  };
+
   return hueUtils;
 
 })();
@@ -540,96 +555,6 @@ if (!Object.keys) {
   }());
 }
 
-
-function s4() {
-  return Math.floor((1 + Math.random()) * 0x10000)
-      .toString(16)
-      .substring(1);
-}
-
-function UUID() {
-  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
-}
-
-// Based on original pub/sub implementation from http://davidwalsh.name/pubsub-javascript
-var huePubSub = (function () {
-  var topics = {};
-  var hOP = topics.hasOwnProperty;
-
-  return {
-    subscribe: function (topic, listener, app) {
-      if (!hOP.call(topics, topic)) {
-        topics[topic] = [];
-      }
-
-      var index = topics[topic].push({
-        listener: listener,
-        app: app,
-        status: 'running'
-      }) - 1;
-
-      return {
-        remove: function () {
-          delete topics[topic][index];
-        }
-      };
-    },
-    removeAll: function (topic) {
-      topics[topic] = [];
-    },
-    subscribeOnce: function (topic, listener, app) {
-      var ephemeral = this.subscribe(topic, function () {
-        listener.apply(listener, arguments);
-        ephemeral.remove();
-      }, app);
-
-    },
-    publish: function (topic, info) {
-      if (!hOP.call(topics, topic)) {
-        return;
-      }
-
-      topics[topic].forEach(function (item) {
-        if (item.status === 'running') {
-          item.listener(info);
-        }
-      });
-    },
-    getTopics: function () {
-      return topics;
-    },
-    pauseAppSubscribers: function (app) {
-      if (app) {
-        Object.keys(topics).forEach(function (topicName) {
-          topics[topicName].forEach(function (topic) {
-            if (typeof topic.app !== 'undefined' && topic.app !== null && (topic.app === app || topic.app.split('-')[0] === app)) {
-              topic.status = 'paused';
-            }
-          });
-        });
-      }
-    },
-    resumeAppSubscribers: function (app) {
-      if (app) {
-        Object.keys(topics).forEach(function (topicName) {
-          topics[topicName].forEach(function (topic) {
-            if (typeof topic.app !== 'undefined' && topic.app !== null && (topic.app === app || topic.app.split('-')[0] === app)) {
-              topic.status = 'running';
-            }
-          });
-        });
-      }
-    },
-    clearAppSubscribers: function (app) {
-      if (app) {
-        Object.keys(topics).forEach(function (topicName) {
-          topics[topicName] = topics[topicName].filter(function(obj){ return obj.app !== app });
-        });
-      }
-    }
-  };
-})();
-
 var hueDrop = (function () {
   var draggableMeta = {};
   huePubSub.subscribe('draggable.text.meta', function (meta) {
@@ -838,7 +763,3 @@ if (!('getParameter' in window.location)) {
     return hueUtils.getSearchParameter(window.location.search, name, returnNull);
   };
 }
-
-var escapeOutput = function (str) {
-  return $('<span>').text(str).html().trim();
-};

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/jquery.hdfsautocomplete.js

@@ -238,7 +238,7 @@
               if (item.type == "dir") {
                 ico = "fa-folder";
               }
-              _currentFiles.push('<li class="hdfsAutocompleteItem" data-value="' + escapeOutput(item.name) + '"><i class="fa ' + ico + '"></i> ' + escapeOutput(item.name) + '</li>');
+              _currentFiles.push('<li class="hdfsAutocompleteItem" data-value="' + hueUtils.escapeOutput(item.name) + '"><i class="fa ' + ico + '"></i> ' + escapeOutput(item.name) + '</li>');
             }
           });
           window.setTimeout(function () {

+ 3 - 13
desktop/core/src/desktop/static/desktop/js/ko.common-dashboard.js

@@ -14,21 +14,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-function s4() {
-  return Math.floor((1 + Math.random()) * 0x10000)
-      .toString(16)
-      .substring(1);
-}
-
-function UUID() {
-  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
-}
-
 var Column = function (size, rows, vm) {
   var self = this;
 
   self.rowPrototype = Row;
-  self.id = ko.observable(UUID());
+  self.id = ko.observable(hueUtils.UUID());
   self.size = ko.observable(size);
   self.rows = ko.observableArray(rows);
 
@@ -128,7 +118,7 @@ var Row = function (widgets, vm, columns) {
   var self = this;
 
   self.columnPrototype = Column;
-  self.id = ko.observable(UUID());
+  self.id = ko.observable(hueUtils.UUID());
   self.widgets = ko.observableArray(widgets);
   self.columns = ko.observableArray(columns ? columns : []);
   self.columns.subscribe(function (val) {
@@ -272,7 +262,7 @@ var Widget = function (params) {
 Widget.prototype.clone = function () {
   return new Widget({
     size: this.size(),
-    id: UUID(),
+    id: hueUtils.UUID(),
     name: this.name(),
     widgetType: this.widgetType()
   });

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -3220,7 +3220,7 @@
       if (options.title) {
         var title = ko.unwrap(options.title); // Not always an observable
         if (typeof title === 'string' && !options.html) {
-          options.title = escapeOutput(title);
+          options.title = hueUtils.escapeOutput(title);
         }
       }
 

+ 205 - 0
desktop/core/src/desktop/static/desktop/js/polyfills.js

@@ -0,0 +1,205 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+if (!Array.prototype.clean) {
+  Array.prototype.clean = function (deleteValue) {
+    for (var i = 0; i < this.length; i++) {
+      if (this[i] == deleteValue) {
+        this.splice(i, 1);
+        i--;
+      }
+    }
+    return this;
+  };
+}
+
+if (!Array.prototype.move) {
+  Array.prototype.move = function (old_index, new_index) {
+    if (new_index >= this.length) {
+      var k = new_index - this.length;
+      while ((k--) + 1) {
+        this.push(undefined);
+      }
+    }
+    this.splice(new_index, 0, this.splice(old_index, 1)[0]);
+    return this;
+  };
+}
+
+if (!Array.prototype.indexOf) {
+  Array.prototype.indexOf = function (needle) {
+    for (var i = 0; i < this.length; i++) {
+      if (this[i] === needle) {
+        return i;
+      }
+    }
+    return -1;
+  };
+}
+
+if (!Array.prototype.filter) {
+  Array.prototype.filter = function (filter, that /*opt*/) {
+    var other = [], v;
+    for (var i = 0, n = this.length; i < n; i++) {
+      if (i in this && filter.call(that, v = this[i], i, this)) {
+        other.push(v);
+      }
+    }
+    return other;
+  };
+}
+
+if (!Array.prototype.diff) {
+  Array.prototype.diff = function (a) {
+    return this.filter(function (i) {
+      return a.indexOf(i) < 0;
+    });
+  };
+}
+
+if (!String.prototype.startsWith) {
+  String.prototype.startsWith = function (searchString, position) {
+    position = position || 0;
+    return this.substr(position, searchString.length) === searchString;
+  };
+}
+
+if (!String.prototype.endsWith) {
+  String.prototype.endsWith = function (searchString, position) {
+    var subjectString = this.toString();
+    if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
+      position = subjectString.length;
+    }
+    position -= searchString.length;
+    var lastIndex = subjectString.lastIndexOf(searchString, position);
+    return lastIndex !== -1 && lastIndex === position;
+  };
+}
+
+if (!String.prototype.includes) {
+  String.prototype.includes = function (search, start) {
+    'use strict';
+    if (typeof start !== 'number') {
+      start = 0;
+    }
+
+    if (start + search.length > this.length) {
+      return false;
+    } else {
+      return this.indexOf(search, start) !== -1;
+    }
+  };
+}
+
+if (!CSSStyleSheet.prototype.addRule) {
+  CSSStyleSheet.prototype.addRule = function (selector, rule, idx) {
+    return this.insertRule(selector + "{" + rule + "}", idx || 0);
+  }
+}
+
+
+if (!Object.keys) {
+  Object.keys = (function () {
+    'use strict';
+    var hasOwnProperty = Object.prototype.hasOwnProperty,
+        hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
+        dontEnums = [
+          'toString',
+          'toLocaleString',
+          'valueOf',
+          'hasOwnProperty',
+          'isPrototypeOf',
+          'propertyIsEnumerable',
+          'constructor'
+        ],
+        dontEnumsLength = dontEnums.length;
+
+    return function (obj) {
+      if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
+        throw new TypeError('Object.keys called on non-object');
+      }
+
+      var result = [], prop, i;
+
+      for (prop in obj) {
+        if (hasOwnProperty.call(obj, prop)) {
+          result.push(prop);
+        }
+      }
+
+      if (hasDontEnumBug) {
+        for (i = 0; i < dontEnumsLength; i++) {
+          if (hasOwnProperty.call(obj, dontEnums[i])) {
+            result.push(dontEnums[i]);
+          }
+        }
+      }
+      return result;
+    };
+  }());
+}
+
+Number.prototype.toHHMMSS = function (skipZeroSeconds) {
+  var n = this;
+  var millis = n % 1000;
+  n = (n - millis) / 1000;
+  millis = +(millis/10).toFixed();
+  var seconds = n % 60;
+  n = (n - seconds) / 60;
+  var minutes = n % 60;
+  n = (n - minutes) / 60;
+  var hours = n % 24;
+  var days = (n - hours) / 24;
+  var val = $.trim((days > 0 ? days + "d, " : "") + (hours > 0 ? hours + "h, " : "") + (minutes > 0 ? minutes + "m, " : "") + ((skipZeroSeconds && seconds === 0) ? '' : (seconds + (millis > 0 && minutes == 0 && hours == 0 && days == 0 ? "." + millis : "") + "s")));
+  if (val[val.length - 1] === ',') {
+    val = val.substr(0, val.length - 1);
+  }
+  return val;
+};
+
+String.prototype.hashCode = function() {
+  var hash = 0, i, chr, len;
+  if (this.length === 0) return hash;
+  for (i = 0, len = this.length; i < len; i++) {
+    chr   = this.charCodeAt(i);
+    hash  = ((hash << 5) - hash) + chr;
+    hash |= 0; // Convert to 32bit integer
+  }
+  return hash;
+};
+
+String.prototype.regexLastIndexOf = function (regex, startpos) {
+  regex = (regex.global) ? regex : new RegExp(regex.source, "g" + (regex.ignoreCase ? "i" : "") + (regex.multiLine ? "m" : ""));
+  if (typeof (startpos) == "undefined") {
+    startpos = this.length;
+  } else if (startpos < 0) {
+    startpos = 0;
+  }
+  var stringToWorkWith = this.substring(0, startpos + 1);
+  var lastIndexOf = -1;
+  var nextStop = 0;
+  while ((result = regex.exec(stringToWorkWith)) != null) {
+    lastIndexOf = result.index;
+    regex.lastIndex = ++nextStop;
+  }
+  return lastIndexOf;
+};
+
+if (!window.location.getParameter) {
+  window.location.getParameter = function (name, returnNull) {
+    return hueUtils.getSearchParameter(window.location.search, name, returnNull);
+  };
+}

+ 1 - 1
desktop/core/src/desktop/templates/common_header_footer_components.mako

@@ -345,7 +345,7 @@ from metadata.conf import has_optimizer, OPTIMIZER
           else {
             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;
+          var link = typeof value == 'string' && value.match(/^https?:\/\//i) ? '<a href="' + hueUtils.escapeOutput(value) + '" target="_blank">' + value + ' <i class="fa fa-external-link"></i></a>' : value;
           html += '<tr><th width="10%" title="' + $(col).attr("title") + '">' + hueUtils.deXSS($(col).text()) + '</th><td class="multi-line-ellipsis" style="word-break: break-all"><div style="position: relative">' + $('<span>').text(hueUtils.deXSS(link)).html() + '</div></td></tr>';
         }
       });

+ 1 - 1
desktop/core/src/desktop/templates/hue.mako

@@ -459,7 +459,7 @@ ${ render_bundle('hue') | n,unicode }
 % endif
 
 <script src="${ static('desktop/js/jquery.migration.js') }"></script>
-<script src="${ static('desktop/js/hue.utils.js') }"></script>
+<script src="${ static('desktop/js/polyfills.js') }"></script>
 <script src="${ static('desktop/ext/js/bootstrap.min.js') }"></script>
 <script src="${ static('desktop/ext/js/tether.js') }"></script>
 <script src="${ static('desktop/ext/js/shepherd.min.js') }"></script>

+ 1 - 1
desktop/core/src/desktop/templates/ko_components/ko_sentry_privileges.mako

@@ -516,7 +516,7 @@ from desktop.views import _ko
           'timestamp': privilege.timestamp,
           'roleName': privilege.roleName,
           'grantOption': privilege.grantOption,
-          'id': UUID()
+          'id': hueUtils.UUID()
         });
         return _privilege;
       }

+ 1 - 1
desktop/core/src/desktop/templates/ko_components/ko_simple_ace_editor.mako

@@ -793,7 +793,7 @@ from desktop.views import _ko
         var aceOptions = params.aceOptions || {};
 
         if (!$element.attr('id')) {
-          $element.attr('id', UUID());
+          $element.attr('id', hueUtils.UUID());
         }
 
         var editor = ace.edit($element.find('.ace-editor')[0]);

+ 9 - 9
desktop/libs/dashboard/src/dashboard/static/dashboard/js/search.ko.js

@@ -138,7 +138,7 @@ var EmptyGridsterWidget = function (vm) {
 var Query = function (vm, query) {
   var self = this;
 
-  self.uuid = ko.observable(typeof query.uuid != "undefined" && query.uuid != null ? query.uuid : UUID());
+  self.uuid = ko.observable(typeof query.uuid != "undefined" && query.uuid != null ? query.uuid : hueUtils.UUID());
   self.qs = ko.mapping.fromJS(query.qs);
   self.qs.subscribe(function(){
     if (vm.selectedQDefinition() != null){
@@ -270,7 +270,7 @@ var Query = function (vm, query) {
     if (fq) {
       id = fq.id();
     } else {
-      id = UUID();
+      id = hueUtils.UUID();
     }
     self.toggleFacet({'widget_id': id, 'facet': {'cat': data.val.cat, 'value': data.val.value}, 'exclude': exclude});
     vm.search();
@@ -551,7 +551,7 @@ var Collection = function (vm, collection) {
   var self = this;
 
   self.id = ko.mapping.fromJS(collection.id);
-  self.uuid = ko.observable(typeof collection.uuid != "undefined" && collection.uuid != null ? collection.uuid : UUID());
+  self.uuid = ko.observable(typeof collection.uuid != "undefined" && collection.uuid != null ? collection.uuid : hueUtils.UUID());
   self.name = ko.mapping.fromJS(collection.name);
   self.label = ko.mapping.fromJS(collection.label);
   self.description = ko.observable(typeof collection.description != "undefined" && collection.description != null ? collection.description : "");
@@ -1106,7 +1106,7 @@ var Collection = function (vm, collection) {
     if ($.trim(self.newQDefinitionName()) != "") {
       var _def = ko.mapping.fromJS({
         'name': $.trim(self.newQDefinitionName()),
-        'id': UUID(),
+        'id': hueUtils.UUID(),
         'data': ko.mapping.toJSON(vm.query)
       });
       self.qdefinitions.push(_def);
@@ -1957,7 +1957,7 @@ var NewTemplate = function (vm, initial) {
 var QueryResult = function (vm, initial) { // Similar to to Notebook Snippet
   var self = this; // TODO remove 'vm'
 
-  self.id = ko.observable(UUID());
+  self.id = ko.observable(hueUtils.UUID());
   self.type = ko.mapping.fromJS(initial.type);
   self.status = ko.observable(initial.status || 'running');
   self.progress = ko.mapping.fromJS(initial.progress || 0);
@@ -2156,7 +2156,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json, has_g
       var w = new Widget({
         size: 12,
         gridsterHeight: gridsterHeight,
-        id: UUID(),
+        id: hueUtils.UUID(),
         name: name,
         widgetType: type,
         isEditing: false
@@ -2962,7 +2962,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json, has_g
 
     self.saveAs = function() {
       self.collection.id(null);
-      self.collection.uuid(UUID());
+      self.collection.uuid(hueUtils.UUID());
       self.save();
     };
 
@@ -2992,7 +2992,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json, has_g
 
     var c = self.collectionJson.collection;
     ko.mapping.fromJS(c.id, self.collection.id);
-    self.collection.uuid(typeof c.uuid != "undefined" && c.uuid != null ? c.uuid : UUID());
+    self.collection.uuid(typeof c.uuid != "undefined" && c.uuid != null ? c.uuid : hueUtils.UUID());
     ko.mapping.fromJS(c.name, self.collection.name);
     ko.mapping.fromJS(c.label, self.collection.label);
     self.collection.description(typeof c.description != "undefined" && c.description != null ? c.description : '');
@@ -3089,7 +3089,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json, has_g
     self.collection.template.filteredAttributeFieldsAll(true);
 
     var q = self.queryJson;
-    self.query.uuid(typeof q.uuid != "undefined" && q.uuid != null ? q.uuid : UUID());
+    self.query.uuid(typeof q.uuid != "undefined" && q.uuid != null ? q.uuid : hueUtils.UUID());
     ko.mapping.fromJS(q.qs, self.query.qs);
     ko.mapping.fromJS(q.fqs, self.query.fqs);
     ko.mapping.fromJS(q.start, self.query.start);

+ 4 - 4
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -1109,7 +1109,7 @@ ${ dashboard.layout_skeleton(suffix='search') }
              <th class="grid-th" data-bind="text: key"></th>
              <td width="100%">
                <!-- ko if: typeof value() == 'string' && value().match(/^https?:\/\//i) -->
-               <a data-bind="attr: { href: escapeOutput(value()) }" target="_blank">
+               <a data-bind="attr: { href: hueUtils.escapeOutput(value()) }" target="_blank">
                  <span data-bind="text: value, visible: !$parent.showEdit()"></span>
                </a>
                <!-- /ko -->
@@ -4568,7 +4568,7 @@ $(document).ready(function () {
     else {
       tempDraggableGridsterWidget = null;
       var widgetClone = ko.mapping.toJS(options.widget);
-      widgetClone.id = UUID();
+      widgetClone.id = hueUtils.UUID();
       tempDraggable = new Widget(widgetClone);
     }
     addPreviewHolder();
@@ -4623,7 +4623,7 @@ $(document).ready(function () {
   huePubSub.subscribe('gridster.empty.add', function (options) {
     var fakeRow = searchViewModel.columns()[0].addEmptyRow(true);
     var widgetClone = ko.mapping.toJS(options.widget);
-    widgetClone.id = UUID();
+    widgetClone.id = hueUtils.UUID();
     selectedWidget = new Widget(widgetClone);
     fakeRow.addWidget(selectedWidget);
     selectedGridster = options.target;
@@ -5344,7 +5344,7 @@ $(document).ready(function () {
         }
         var fakeRow = searchViewModel.columns()[0].addEmptyRow(true);
         var widgetClone = ko.mapping.toJS(selectedWidget);
-        widgetClone.id = UUID();
+        widgetClone.id = hueUtils.UUID();
         selectedWidget = new Widget(widgetClone);
         fakeRow.addWidget(selectedWidget);
         addFacetDemiModalFieldPreview({

+ 5 - 5
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -56,7 +56,7 @@ var EditorViewModel = (function() {
         chartType: 'bars',
         chartTimelineType: 'line'
     });
-    self.id = ko.observable(typeof result.id != "undefined" && result.id != null ? result.id : UUID());
+    self.id = ko.observable(typeof result.id != "undefined" && result.id != null ? result.id : hueUtils.UUID());
     self.type = ko.observable(typeof result.type != "undefined" && result.type != null ? result.type : 'table');
     self.hasResultset = ko.observable(typeof result.hasResultset != "undefined" && result.hasResultset != null ? result.hasResultset : true)
       .extend("throttle", 100);
@@ -351,7 +351,7 @@ var EditorViewModel = (function() {
   var Snippet = function (vm, notebook, snippet) {
     var self = this;
 
-    self.id = ko.observable(typeof snippet.id != "undefined" && snippet.id != null ? snippet.id : UUID());
+    self.id = ko.observable(typeof snippet.id != "undefined" && snippet.id != null ? snippet.id : hueUtils.UUID());
     self.name = ko.observable(typeof snippet.name != "undefined" && snippet.name != null ? snippet.name : '');
     self.type = ko.observable(typeof snippet.type != "undefined" && snippet.type != null ? snippet.type : 'hive');
     self.type.subscribe(function(newVal) {
@@ -2353,7 +2353,7 @@ var EditorViewModel = (function() {
     var self = this;
 
     self.id = ko.observable(typeof notebook.id != "undefined" && notebook.id != null ? notebook.id : null);
-    self.uuid = ko.observable(typeof notebook.uuid != "undefined" && notebook.uuid != null ? notebook.uuid : UUID());
+    self.uuid = ko.observable(typeof notebook.uuid != "undefined" && notebook.uuid != null ? notebook.uuid : hueUtils.UUID());
     self.name = ko.observable(typeof notebook.name != "undefined" && notebook.name != null ? notebook.name : 'My Notebook');
     self.description = ko.observable(typeof notebook.description != "undefined" && notebook.description != null ? notebook.description: '');
     self.type = ko.observable(typeof notebook.type != "undefined" && notebook.type != null ? notebook.type : 'notebook');
@@ -2907,7 +2907,7 @@ var EditorViewModel = (function() {
         self.history.removeAll();
         if (self.isHistory()) {
           self.id(null);
-          self.uuid(UUID());
+          self.uuid(hueUtils.UUID());
           if (vm.isHue4()) {
             vm.changeURL(vm.URLS.hue4 + '?type=' + vm.editorType());
           }
@@ -3592,7 +3592,7 @@ var EditorViewModel = (function() {
 
     self.saveAsNotebook = function () {
       self.selectedNotebook().id(null);
-      self.selectedNotebook().uuid(UUID());
+      self.selectedNotebook().uuid(hueUtils.UUID());
       self.selectedNotebook().parentSavedQueryUuid(null);
       self.selectedNotebook().save(function () {
         huePubSub.publish('assist.document.refresh');

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 631 - 1074
package-lock.json


+ 1 - 2
package.json

@@ -32,8 +32,7 @@
     "babel-cli": "6.26.0",
     "babel-jscs": "3.0.0-beta1",
     "babel-loader": "8.0.5",
-    "babel-preset-env": "1.7.0",
-    "babel-preset-es2015": "7.0.0-beta.3",
+    "@babel/preset-env": "7.3.1",
     "expose-loader": "0.7.5",
     "dryice": "0.4.11", // For building Ace "make ace"
     "grunt": "1.0.3",

+ 1 - 1
webpack-stats.json

@@ -1 +1 @@
-{"status":"done","chunks":{"hue":[{"name":"hue-bundle-f32ebc5a2ae9c17ad586.js","path":"/Users/jahlen/dev/hue/desktop/core/src/desktop/static/desktop/js/hue-bundle-f32ebc5a2ae9c17ad586.js"},{"name":"hue-bundle-f32ebc5a2ae9c17ad586.js.map","path":"/Users/jahlen/dev/hue/desktop/core/src/desktop/static/desktop/js/hue-bundle-f32ebc5a2ae9c17ad586.js.map"}]}}
+{"status":"done","chunks":{"hue":[{"name":"hue-bundle-9f109ed3929449756ec4.js","path":"/Users/jahlen/dev/hue/desktop/core/src/desktop/static/desktop/js/hue-bundle-9f109ed3929449756ec4.js"},{"name":"hue-bundle-9f109ed3929449756ec4.js.map","path":"/Users/jahlen/dev/hue/desktop/core/src/desktop/static/desktop/js/hue-bundle-9f109ed3929449756ec4.js.map"}]}}

+ 3 - 9
webpack.config.js

@@ -22,11 +22,9 @@ module.exports = {
     extensions: ['.json', '.jsx', '.js'],
     modules: [
       'node_modules',
-      'js',
-      'desktop/core/src/desktop/static/desktop/js/cui'
+      'js'
     ],
     alias: {
-      // any bootstrap modules should really resolve to node_modules/bootstrap/js
       bootstrap: 'bootstrap/js',
       'cloudera-ui': 'cui',
       _: 'lodash',
@@ -36,7 +34,7 @@ module.exports = {
     }
   },
   entry: {
-    hue: ['./desktop/core/src/desktop/static/desktop/js/hue.js']
+    hue: ['./desktop/core/src/desktop/js/hue.js']
   },
   output: {
     path:  __dirname + '/desktop/core/src/desktop/static/desktop/js',
@@ -51,12 +49,8 @@ module.exports = {
       {
         test: /\.jsx?$/,
         exclude: /node_modules/,
-        loader: 'babel-loader',
-        query: {
-          presets: ['es2015']
-        }
+        loader: 'babel-loader'
       },
-
       // expose lodash and jquery for knockout templates to access
       { test: /lodash$/, loader: 'expose-loader?_' },
       { test: /jquery/, loader: 'expose-loader?$!expose-loader?jQuery' },

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно