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

HUE-8990 [oozie] Fix issue with missing global viewModel variable in the workflow editor

Johan Ahlen 6 жил өмнө
parent
commit
997bdf6064

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

@@ -184,7 +184,6 @@ var Node = function (node, vm) {
 
 
 var Workflow = function (vm, workflow) {
-
   var self = this;
 
   self.id = ko.observable(typeof workflow.id != "undefined" && workflow.id != null ? workflow.id : null);
@@ -276,13 +275,13 @@ var Workflow = function (vm, workflow) {
       },
       success: function (data) {
         if (data.status == 0) {
-          viewModel.addActionProperties.removeAll();
+          window.workflowEditorViewModel.addActionProperties.removeAll();
           $.each(data.properties, function (i, prop) {
-            viewModel.addActionProperties.push(ko.mapping.fromJS(prop));
+            window.workflowEditorViewModel.addActionProperties.push(ko.mapping.fromJS(prop));
           });
 
           if (data.workflows.length > 0) {
-            viewModel.subworkflows(getOtherSubworkflows(viewModel, data.workflows));
+            window.workflowEditorViewModel.subworkflows(getOtherSubworkflows(window.workflowEditorViewModel, data.workflows));
           }
 
           if (callback) {
@@ -297,7 +296,7 @@ var Workflow = function (vm, workflow) {
   self.addNode = function (widget, copiedNode) {
     $.post("/oozie/editor/workflow/add_node/", {
       "node": ko.mapping.toJSON(widget),
-      "properties": ko.mapping.toJSON(viewModel.addActionProperties()),
+      "properties": ko.mapping.toJSON(window.workflowEditorViewModel.addActionProperties()),
       "copiedProperties": copiedNode ? ko.mapping.toJSON(copiedNode.properties) : "{}"
     }, function (data) {
       if (data.status == 0) {

+ 1 - 1
apps/oozie/src/oozie/templates/editor2/common_workflow.mako

@@ -246,7 +246,7 @@
       <!-- /ko -->
 
       <div class="inline pull-right" data-bind="visible: (typeof $root.isViewer == 'undefined' || ! $root.isViewer()) && !$root.isEditing()" style="margin-right: 4px">
-        <a href="javascript:void(0)" data-bind="click: function(w) { viewModel.showSubmitActionPopup(w); }"><i class="fa fa-play-circle-o"></i></a>
+        <a href="javascript:void(0)" data-bind="click: function(w) { window.workflowEditorViewModel.showSubmitActionPopup(w); }"><i class="fa fa-play-circle-o"></i></a>
       </div>
 
       <!-- ko if: widgetType() == 'decision-widget' -->

+ 31 - 31
apps/oozie/src/oozie/templates/editor2/workflow_editor.mako

@@ -622,8 +622,8 @@ ${ utils.submit_popup_event() }
 
   var apiHelper = window.apiHelper;
 
-  var workflowEditorViewModel = new WorkflowEditorViewModel(${ layout_json | n,unicode }, ${ workflow_json | n,unicode }, ${ credentials_json | n,unicode }, ${ workflow_properties_json | n,unicode }, ${ subworkflows_json | n,unicode }, ${ can_edit_json | n,unicode });
-  ko.applyBindings(workflowEditorViewModel, $("#oozie_workflowComponents")[0]);
+  window.workflowEditorViewModel = new WorkflowEditorViewModel(${ layout_json | n,unicode }, ${ workflow_json | n,unicode }, ${ credentials_json | n,unicode }, ${ workflow_properties_json | n,unicode }, ${ subworkflows_json | n,unicode }, ${ can_edit_json | n,unicode });
+  ko.applyBindings(window.workflowEditorViewModel, $("#oozie_workflowComponents")[0]);
 
   % if not is_embeddable:
   var shareViewModel = initSharing("#documentShareModal");
@@ -637,10 +637,10 @@ ${ utils.submit_popup_event() }
   var defaultSection = 'actions';
   % endif
 
-  workflowEditorViewModel.currentDraggableSection(defaultSection);
+  window.workflowEditorViewModel.currentDraggableSection(defaultSection);
 
-  workflowEditorViewModel.init();
-  fullLayout(workflowEditorViewModel);
+  window.workflowEditorViewModel.init();
+  fullLayout(window.workflowEditorViewModel);
 
   var globalFilechooserOptions = {
     skipInitialPathIfEmpty: true,
@@ -650,9 +650,9 @@ ${ utils.submit_popup_event() }
     extraHomeProperties: {
       label: '${ _('Workspace') }',
       icon: 'fa-folder-open',
-      path: workflowEditorViewModel.workflow.properties.deployment_dir()
+      path: window.workflowEditorViewModel.workflow.properties.deployment_dir()
     },
-    deploymentDir: workflowEditorViewModel.workflow.properties.deployment_dir()
+    deploymentDir: window.workflowEditorViewModel.workflow.properties.deployment_dir()
   }
 
   function columnDropAdditionalHandler(widget) {
@@ -661,25 +661,25 @@ ${ utils.submit_popup_event() }
 
   function widgetDraggedAdditionalHandler(widget) {
     $("canvas").remove();
-    if (workflowEditorViewModel.currentlyDraggedWidget() && workflowEditorViewModel.currentlyDraggedWidget().id() == ""){
-      workflowEditorViewModel.workflow.newNode(widget, function() {
+    if (window.workflowEditorViewModel.currentlyDraggedWidget() && window.workflowEditorViewModel.currentlyDraggedWidget().id() == ""){
+      window.workflowEditorViewModel.workflow.newNode(widget, function() {
         showAddActionDemiModal(widget);
       });
     }
     else {
-      if (workflowEditorViewModel.currentlyDraggedOp() == "move"){
-        workflowEditorViewModel.workflow.moveNode(widget);
+      if (window.workflowEditorViewModel.currentlyDraggedOp() == "move"){
+        window.workflowEditorViewModel.workflow.moveNode(widget);
       }
       else { // Copy
-        var _sourceNode = workflowEditorViewModel.workflow.getNodeById(workflowEditorViewModel.currentlyDraggedWidget().id());
-        workflowEditorViewModel.workflow.newNode(widget, workflowEditorViewModel.workflow.addNode, _sourceNode);
+        var _sourceNode = window.workflowEditorViewModel.workflow.getNodeById(window.workflowEditorViewModel.currentlyDraggedWidget().id());
+        window.workflowEditorViewModel.workflow.newNode(widget, window.workflowEditorViewModel.workflow.addNode, _sourceNode);
       }
       $(document).trigger("drawArrows");
     }
   }
 
   function showAddActionDemiModal(widget) {
-    workflowEditorViewModel.newAction(widget);
+    window.workflowEditorViewModel.newAction(widget);
     $("#exposeOverlay").fadeIn(300);
     var _el = $("#wdg_" + widget.id());
     _el.css("zIndex", "1032");
@@ -708,25 +708,25 @@ ${ utils.submit_popup_event() }
   }
 
   function addActionDemiModalFieldPreview(field) {
-    if (workflowEditorViewModel.newAction() != null) {
-      var _el = $("#wdg_" + workflowEditorViewModel.newAction().id());
+    if (window.workflowEditorViewModel.newAction() != null) {
+      var _el = $("#wdg_" + window.workflowEditorViewModel.newAction().id());
       _el.css("position", "static");
       _el.css("width", "");
-      workflowEditorViewModel.workflow.addNode(workflowEditorViewModel.newAction());
+      window.workflowEditorViewModel.workflow.addNode(window.workflowEditorViewModel.newAction());
       $("#addActionDemiModal").modal("hide");
-      $("#wdg_" + workflowEditorViewModel.newAction().id()).css("zIndex", "0");
+      $("#wdg_" + window.workflowEditorViewModel.newAction().id()).css("zIndex", "0");
       $("#exposeOverlay").fadeOut(300);
-      workflowEditorViewModel.newAction(null);
+      window.workflowEditorViewModel.newAction(null);
     }
   }
 
   function addActionDemiModalFieldCancel() {
     $("#exposeOverlay").fadeOut(300);
     $("#addActionDemiModal").modal("hide");
-    if (workflowEditorViewModel.newAction()){
-      workflowEditorViewModel.removeWidgetById(workflowEditorViewModel.newAction().id());
+    if (window.workflowEditorViewModel.newAction()){
+      window.workflowEditorViewModel.removeWidgetById(window.workflowEditorViewModel.newAction().id());
     }
-    workflowEditorViewModel.newAction(null);
+    window.workflowEditorViewModel.newAction(null);
   }
 
   function resizeDrops() {
@@ -741,8 +741,8 @@ ${ utils.submit_popup_event() }
 
   function renderChangeables() {
     resizeDrops();
-    if (workflowEditorViewModel.workflow && workflowEditorViewModel.workflow.properties && workflowEditorViewModel.workflow.properties.show_arrows()){
-      workflowEditorViewModel.drawArrows();
+    if (window.workflowEditorViewModel.workflow && window.workflowEditorViewModel.workflow.properties && window.workflowEditorViewModel.workflow.properties.show_arrows()){
+      window.workflowEditorViewModel.drawArrows();
     }
     $("#oozie_workflowComponents .widget-main-section").removeClass("zoom-in");
     $("#oozie_workflowComponents .widget-main-section").each(function(){
@@ -767,7 +767,7 @@ ${ utils.submit_popup_event() }
         _el.css("z-index", "1032");
         lastSeenPosition = _el.position();
         var _width = _el.width();
-        _el.parent().css("height", workflowEditorViewModel.isEditing() ? _el.height() : (_el.height() + 17) + "px");
+        _el.parent().css("height", window.workflowEditorViewModel.isEditing() ? _el.height() : (_el.height() + 17) + "px");
         _el.css("position", "absolute");
         _el.css({
           "width": _width,
@@ -802,11 +802,11 @@ ${ utils.submit_popup_event() }
 
   function validateAndSave() {
     validateFields();
-    if (workflowEditorViewModel.isInvalid() && workflowEditorViewModel.isEditing()) {
+    if (window.workflowEditorViewModel.isInvalid() && window.workflowEditorViewModel.isEditing()) {
       var $firstElWithErrors = $("[validate].with-errors").eq(0);
       if (!$firstElWithErrors.is(":visible")) {
         var widgetId = $firstElWithErrors.parents(".card-widget").attr("id").substr(4);
-        workflowEditorViewModel.getWidgetById(widgetId).ooziePropertiesExpanded(true);
+        window.workflowEditorViewModel.getWidgetById(widgetId).ooziePropertiesExpanded(true);
       }
       window.setTimeout(function () {
         $("html,body").animate({
@@ -815,7 +815,7 @@ ${ utils.submit_popup_event() }
       }, 200);
     }
 
-    workflowEditorViewModel.save();
+    window.workflowEditorViewModel.save();
   }
 
   function validateFields() {
@@ -833,7 +833,7 @@ ${ utils.submit_popup_event() }
         $(this).removeClass("with-errors");
       }
     });
-    workflowEditorViewModel.isInvalid(_hasErrors);
+    window.workflowEditorViewModel.isInvalid(_hasErrors);
   }
 
   $(document).ready(function(){
@@ -843,7 +843,7 @@ ${ utils.submit_popup_event() }
       if (window.location.pathname.indexOf('/oozie/editor/workflow') > -1) {
         $("canvas").remove();
         exposeOverlayClickHandler();
-        if (workflowEditorViewModel.isEditing()) {
+        if (window.workflowEditorViewModel.isEditing()) {
           hueUtils.waitForRendered('#oozie_workflowComponents .card-toolbar-content', function (el) {
             return el.height() > 40 && el.height() < 200
           }, function () {
@@ -918,7 +918,7 @@ ${ utils.submit_popup_event() }
       if (clusterConfig['cluster_type'] != 'dataeng') {
         interpreters = interpreters.concat(['subworkflow', 'fs', 'email', 'ssh', 'streaming', 'generic', 'stop']);
       }
-      workflowEditorViewModel.availableActions(interpreters);
+      window.workflowEditorViewModel.availableActions(interpreters);
     }, 'oozie');
 
     huePubSub.publish('cluster.config.get.config');