Просмотр исходного кода

HUE-2727 [spark] Fix namespace for JVM memory input

(cherry picked from commit 1e4436a3d39d74888ef408229e15f33366d845fd)
Johan Ahlen 10 лет назад
Родитель
Сommit
2f6c7db
1 измененных файлов с 30 добавлено и 28 удалено
  1. 30 28
      apps/spark/src/spark/templates/editor.mako

+ 30 - 28
apps/spark/src/spark/templates/editor.mako

@@ -762,37 +762,39 @@ ${ commonheader(_('Query'), app_name, user, "68px") | n,unicode }
 </template>
 
 <script type="text/javascript" charset="utf-8">
-  var JVM_MEM_PATTERN = /([0-9]+)([MG])$/;
-  var UNITS = { 'MB' : 'M', 'GB' : 'G'};
-
-  function JvmMemoryInputViewModel(params) {
-    this.valueObservable = params.value;
-    this.units = Object.keys(UNITS);
-    this.selectedUnit = ko.observable();
-    this.value = ko.observable().extend({ 'numeric' : 0 });
-
-    var match = JVM_MEM_PATTERN.exec(this.valueObservable());
-    if (match.length === 3) {
-      this.value(match[1]);
-      this.selectedUnit(match[2] === 'M' ? 'MB' : 'GB');
-    }
-
-    this.value.subscribe(this.updateValueObservable, this);
-    this.selectedUnit.subscribe(this.updateValueObservable, this);
-  }
+  (function() {
+    var JVM_MEM_PATTERN = /([0-9]+)([MG])$/;
+    var UNITS = { 'MB' : 'M', 'GB' : 'G' };
+
+    function JvmMemoryInputViewModel(params) {
+      this.valueObservable = params.value;
+      this.units = Object.keys(UNITS);
+      this.selectedUnit = ko.observable();
+      this.value = ko.observable().extend({ 'numeric' : 0 });
+
+      var match = JVM_MEM_PATTERN.exec(this.valueObservable());
+      if (match.length === 3) {
+        this.value(match[1]);
+        this.selectedUnit(match[2] === 'M' ? 'MB' : 'GB');
+      }
 
-  JvmMemoryInputViewModel.prototype.updateValueObservable = function() {
-    if (isNaN(this.value()) || this.value() === '') {
-      this.valueObservable(undefined);
-    } else {
-      this.valueObservable(this.value() + UNITS[this.selectedUnit()]);
+      this.value.subscribe(this.updateValueObservable, this);
+      this.selectedUnit.subscribe(this.updateValueObservable, this);
     }
-  };
 
-  ko.components.register('jvm-memory-input', {
-    viewModel: JvmMemoryInputViewModel,
-    template: { element: 'jvm-memory-input-template' }
-  });
+    JvmMemoryInputViewModel.prototype.updateValueObservable = function() {
+      if (isNaN(this.value()) || this.value() === '') {
+        this.valueObservable(undefined);
+      } else {
+        this.valueObservable(this.value() + UNITS[this.selectedUnit()]);
+      }
+    };
+
+    ko.components.register('jvm-memory-input', {
+      viewModel: JvmMemoryInputViewModel,
+      template: { element: 'jvm-memory-input-template' }
+    });
+  }());
 </script>