Browse Source

[oozie] Added generic kill node

Enrico Berti 11 năm trước cách đây
mục cha
commit
a46b824

+ 3 - 2
apps/oozie/src/oozie/models2.py

@@ -69,8 +69,9 @@ class Workflow():
           'layout': [{
               "size":12, "rows":[
                   {"widgets":[{"size":12, "name":"Start", "id":"3f107997-04cc-8733-60a9-a4bb62cebffc", "widgetType":"start-widget", "properties":{}, "offset":0, "isLoading":False, "klass":"card card-widget span12"}]},
-                  {"widgets":[{"size":12, "name":"End", "id":"33430f0f-ebfa-c3ec-f237-3e77efa03d0a", "widgetType":"end-widget", "properties":{}, "offset":0, "isLoading":False, "klass":"card card-widget span12"}]}
-              ], 
+                  {"widgets":[{"size":12, "name":"End", "id":"33430f0f-ebfa-c3ec-f237-3e77efa03d0a", "widgetType":"end-widget", "properties":{}, "offset":0, "isLoading":False, "klass":"card card-widget span12"}]},
+                  {"widgets":[{"size":12, "name":"Kill", "id":"17c9c895-5a16-7443-bb81-f34b30b21548", "widgetType":"kill-widget", "properties":{}, "offset":0, "isLoading":False, "klass":"card card-widget span12"}]}
+              ],
               "drops":[ "temp"],
               "klass":"card card-home card-column span12"
           }],

+ 36 - 23
apps/oozie/src/oozie/templates/editor/workflow_editor.mako

@@ -225,6 +225,7 @@ ${ commonheader(_("Workflow Editor"), "Oozie", user, "40px") | n,unicode }
   </div>
 </div>
 
+
 <script type="text/html" id="column-template">
   <div data-bind="css: klass()" style="min-height: 50px !important;">
     <div data-bind="template: { name: 'row-template', data: oozieStartRow }" style="margin-top: 50px"></div>
@@ -239,12 +240,16 @@ ${ commonheader(_("Workflow Editor"), "Oozie", user, "40px") | n,unicode }
     </div>
     <div class="container-fluid" data-bind="visible: $root.isEditing() && rows().length > 0">
       <div class="row-fluid">
-        <div data-bind="visible: enableOozieDropOnAfter, css: {'span4 offset4': true, 'drop-target': true, 'is-editing': $root.isEditing}, droppable: {enabled: $root.isEditing, onDrop: function(){ var _w = $root.addDraggedWidget($data, false); widgetDraggedAdditionalHandler(_w); } }"></div>
+        <div data-bind="visible: enableOozieDropOnAfter, css: {'span4 offset4': true, 'drop-target': true, 'is-editing': $root.isEditing}, droppable: {enabled: $root.isEditing, onDrop: function(){ var _w = $root.addDraggedWidget($data, false); widgetDraggedAdditionalHandler(_w); } }">
+          <span data-bind="visible: oozieRows().length == 0">${ _('Drop your action here.') }</span>
+        </div>
         <div data-bind="visible: ! enableOozieDropOnAfter(), css: {'drop-target drop-target-disabled': true, 'is-editing': $root.isEditing}"></div>
       </div>
     </div>
 
     <div data-bind="template: { name: 'row-template', data: oozieEndRow }"></div>
+
+    <div data-bind="template: { name: 'row-template', data: oozieKillRow }" style="margin-top: 60px"></div>
   </div>
 </script>
 
@@ -320,7 +325,7 @@ ${ commonheader(_("Workflow Editor"), "Oozie", user, "40px") | n,unicode }
 
 <script type="text/html" id="widget-template">
   <div data-bind="attr: {'id': 'wdg_'+ id(),}, css: klass() + (oozieExpanded()?' expanded-widget':''), draggable: {data: $data, isEnabled: true, options: {'handle': '.move-widget', 'opacity': 0.7, 'refreshPositions': true, 'start': function(event, ui){ $root.setCurrentlyDraggedWidget($data, event.toElement); }, 'stop': function(event, ui){ $root.enableSideDrop($data); }, 'helper': function(event){lastWindowScrollPosition = $(window).scrollTop();  var _par = $('<div>');_par.addClass('card card-widget');var _title = $('<h2>');_title.addClass('card-heading simple');_title.text($(event.currentTarget).find('h2').text());_title.appendTo(_par);_par.css('minHeight', '10px');_par.width(120);return _par;}}}">
-    <h2 class="card-heading simple">
+    <h2 class="card-heading simple" data-bind="visible: widgetType() != 'start-widget' && widgetType() != 'end-widget'  && id() != '17c9c895-5a16-7443-bb81-f34b30b21548'">
       <span data-bind="visible: $root.isEditing() && oozieMovable() && ! oozieExpanded()">
         <a href="javascript:void(0)" class="move-widget"><i class="fa fa-arrows"></i></a>
         &nbsp;
@@ -478,12 +483,11 @@ ${ commonheader(_("Workflow Editor"), "Oozie", user, "40px") | n,unicode }
 
 <script type="text/html" id="kill-widget">
   <!-- ko if: $root.workflow.getNodeById(id()) -->
-  <div class="row-fluid" data-bind="with: $root.workflow.getNodeById(id())" style="min-height: 80px">
-    <div data-bind="visible: $root.isEditing" style="margin-bottom: 20px">
-    </div>
+  <div class="row-fluid" data-bind="with: $root.workflow.getNodeById(id())" style="min-height: 40px">
+    <div class="big-icon" data-bind="visible: id() == '17c9c895-5a16-7443-bb81-f34b30b21548'"><i class="fa fa-thumbs-o-down"></i></div>
 
     <div>
-      <input type="text" data-bind="value: properties.message" />
+      <input type="text" class="input-xxlarge" data-bind="value: properties.message" />
     </div>
   </div>
   <!-- /ko -->
@@ -1439,24 +1443,24 @@ ${ commonheader(_("Workflow Editor"), "Oozie", user, "40px") | n,unicode }
 </script>
 
 
-<div id="addActionDemiModal" class="demi-modal hide" data-backdrop="false">
+<div id="addActionDemiModal" class="demi-modal demi-modal-half hide fade" data-backdrop="false">
   <div class="modal-body">
     <a href="javascript: void(0)" data-dismiss="modal" data-bind="click: addActionDemiModalFieldCancel" class="pull-right"><i class="fa fa-times"></i></a>
 
-    <ul data-bind="foreach: addActionProperties">
-      <li>
-        <span data-bind="text: label"></span>
-        <input data-bind="value: value"/>
-      </li>
-    </ul>
+    <table data-bind="foreach: addActionProperties">
+      <tr>
+        <td data-bind="text: label" style="width: 1%; padding-right: 10px" class="no-wrap"></td>
+        <td><input data-bind="value: value"/></td>
+      </tr>
+    </table>
 
     <!-- ko if: addActionWorkflows().length > 0 -->
       <select data-bind="options: addActionWorkflows, optionsText: 'name', value: selectedSubWorkflow"></select>
     <!-- /ko -->
 
     <br/>
-    <a data-bind="click: addActionDemiModalFieldPreview">
-      Add
+    <a class="btn btn-primary disable-feedback" data-bind="click: addActionDemiModalFieldPreview">
+      ${ _('Add') }
     </a>
   </div>
 </div>
@@ -1581,6 +1585,8 @@ ${ dashboard.import_bindings() }
 
   function showAddActionDemiModal(widget) {
     newAction = widget;
+    $("#exposeOverlay").fadeIn(300);
+    $("#wdg_" + widget.id()).css("zIndex", "1032");
     $("#addActionDemiModal").modal("show");
   }
 
@@ -1588,10 +1594,13 @@ ${ dashboard.import_bindings() }
     if (newAction != null) {
       viewModel.workflow.addNode(newAction);
       $("#addActionDemiModal").modal("hide");
+      $("#wdg_" + newAction.id()).css("zIndex", "0");
+      $("#exposeOverlay").fadeOut(300);
     }
   }
 
   function addActionDemiModalFieldCancel() {
+    $("#exposeOverlay").fadeOut(300);
     viewModel.removeWidgetById(newAction.id());
   }
 
@@ -1644,14 +1653,16 @@ ${ dashboard.import_bindings() }
 
   function drawArrows(){
     $("canvas").remove();
-    var _links = viewModel.workflow.linkMapping();
-    Object.keys(_links).forEach(function(id){
-      if (_links[id].length > 0){
-        _links[id].forEach(function(nextId){
-          linkWidgets(id, nextId);
-        });
-      }
-    });
+    if (viewModel.columns()[0].rows().length > 3){
+      var _links = viewModel.workflow.linkMapping();
+      Object.keys(_links).forEach(function(id){
+        if (_links[id].length > 0){
+          _links[id].forEach(function(nextId){
+            linkWidgets(id, nextId);
+          });
+        }
+      });
+    }
   }
 
   var _linkMappingTimeout = -1;
@@ -1740,6 +1751,8 @@ ${ dashboard.import_bindings() }
     $(document).keyup(function(e) {
       if (e.keyCode == 27) {
         $("#exposeOverlay").click();
+        addActionDemiModalFieldCancel();
+        $("#addActionDemiModal").modal("hide");
       }
     });
 

+ 13 - 1
apps/oozie/static/css/workflow-editor.css

@@ -429,4 +429,16 @@ em {
   font-size: 40px;
   text-align: center;
   padding: 5px;
-}
+}
+
+body {
+  background-color: #FFFFFF;
+}
+
+.ui-sortable {
+ min-height: 10px!important;
+}
+
+.row-container {
+ min-height: 10px!important;;
+}

+ 1 - 16
apps/oozie/static/js/workflow-editor.ko.js

@@ -489,7 +489,7 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
             _newRow = _parentCol.addEmptyRow(false, 1);
           }
           else {
-            _newRow = _parentCol.addEmptyRow(false, _parentCol.rows().length - 1);
+            _newRow = _parentCol.addEmptyRow(false, _parentCol.rows().length - 2);
           }
         }
         else {
@@ -622,21 +622,6 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json, credentials_
     }
   }
 
-//  self.getWidgetById = function (widget_id) {
-//    var _widget = null;
-//    $.each(self.columns(), function (i, col) {
-//      $.each(col.rows(), function (j, row) {
-//        $.each(row.widgets(), function (z, widget) {
-//          if (widget.id() == widget_id) {
-//            _widget = widget;
-//            return false;
-//          }
-//        });
-//      });
-//    });
-//    return _widget;
-//  }
-
   self.removeWidget = function (widget_json) {
     self.workflow.removeNode(widget_json.id());
     self.removeWidgetById(widget_json.id());

+ 20 - 14
desktop/core/static/css/hue3.css

@@ -128,7 +128,7 @@
   text-align: left !important;
 }
 
-.nowrap {
+.nowrap, .no-wrap {
   white-space: nowrap;
 }
 
@@ -1622,26 +1622,32 @@ body.modal-open {
   border: 1px solid rgba(0, 0, 0, 0.3);
   *border: 1px solid #999;
   -webkit-border-bottom-right-radius: 0px;
--webkit-border-bottom-left-radius: 0px;
--moz-border-radius-bottomright: 0px;
--moz-border-radius-bottomleft: 0px;
-border-bottom-right-radius: 0px;
-border-bottom-left-radius: 0px;
+  -webkit-border-bottom-left-radius: 0px;
+  -moz-border-radius-bottomright: 0px;
+  -moz-border-radius-bottomleft: 0px;
+  border-bottom-right-radius: 0px;
+  border-bottom-left-radius: 0px;
   outline: none;
   -webkit-box-shadow: none;
-     -moz-box-shadow: none;
-          box-shadow: none;
+  -moz-box-shadow: none;
+  box-shadow: none;
   -webkit-background-clip: padding-box;
-     -moz-background-clip: padding-box;
-          background-clip: padding-box;
+  -moz-background-clip: padding-box;
+  background-clip: padding-box;
+}
+
+.demi-modal-half {
+  width: 500px;
+  left: 50%;
+  margin-left: -250px;
 }
 
 .demi-modal.fade {
   top: -25%;
   -webkit-transition: opacity 0.3s linear, top 0.3s ease-out;
-     -moz-transition: opacity 0.3s linear, top 0.3s ease-out;
-       -o-transition: opacity 0.3s linear, top 0.3s ease-out;
-          transition: opacity 0.3s linear, top 0.3s ease-out;
+  -moz-transition: opacity 0.3s linear, top 0.3s ease-out;
+  -o-transition: opacity 0.3s linear, top 0.3s ease-out;
+  transition: opacity 0.3s linear, top 0.3s ease-out;
 }
 
 .demi-modal.fade.in {
@@ -1669,7 +1675,7 @@ border-bottom-left-radius: 0px;
 }
 
 .control-group.error .input-prepend .add-on i, .control-group.error .input-append .add-on i {
-    color: #fff;
+  color: #fff;
 }
 
 .app-icon {

+ 13 - 3
desktop/core/static/js/ko.layout.js

@@ -32,7 +32,7 @@ var Column = function (size, rows) {
   self.oozieStartRow = ko.computed(function () {
     var _row = null;
     ko.utils.arrayForEach(self.rows(), function (row) {
-      if ((row.widgets().length > 0 && row.widgets()[0].widgetType() == "start-widget")) {
+      if ((row.widgets().length > 0 && row.widgets()[0].id() == "3f107997-04cc-8733-60a9-a4bb62cebffc")) {
         _row = row;
       }
     });
@@ -42,7 +42,17 @@ var Column = function (size, rows) {
   self.oozieEndRow = ko.computed(function () {
     var _row = null;
     ko.utils.arrayForEach(self.rows(), function (row) {
-      if ((row.widgets().length > 0 && row.widgets()[0].widgetType() == "end-widget")) {
+      if ((row.widgets().length > 0 && row.widgets()[0].id() == "33430f0f-ebfa-c3ec-f237-3e77efa03d0a")) {
+        _row = row;
+      }
+    });
+    return _row;
+  }, self);
+
+  self.oozieKillRow = ko.computed(function () {
+    var _row = null;
+    ko.utils.arrayForEach(self.rows(), function (row) {
+      if ((row.widgets().length > 0 && row.widgets()[0].id() == "17c9c895-5a16-7443-bb81-f34b30b21548")) {
         _row = row;
       }
     });
@@ -53,7 +63,7 @@ var Column = function (size, rows) {
   self.oozieRows = ko.computed(function () {
     var _rows = [];
     ko.utils.arrayForEach(self.rows(), function (row) {
-      if ((row.widgets().length > 0 && row.widgets()[0].widgetType() != "start-widget" && row.widgets()[0].widgetType() != "end-widget") || row.widgets().length == 0) {
+      if ((row.widgets().length > 0 && ["3f107997-04cc-8733-60a9-a4bb62cebffc", "33430f0f-ebfa-c3ec-f237-3e77efa03d0a", "17c9c895-5a16-7443-bb81-f34b30b21548"].indexOf(row.widgets()[0].id()) == -1) || row.widgets().length == 0) {
         _rows.push(row);
       }
     });