浏览代码

[oozie] Create a new workflow

Romain Rigaux 11 年之前
父节点
当前提交
44b085d440

+ 13 - 3
apps/oozie/src/oozie/templates/editor/workflow_editor.mako

@@ -63,10 +63,20 @@ ${ commonheader(_("Workflow Editor"), "Oozie", user) | n,unicode }
 <div class="search-bar">
   <div class="pull-right" style="padding-right:50px">
     % if user.is_superuser:
-      <a title="${ _('Edit') }" rel="tooltip" data-placement="bottom" data-bind="click: toggleEditing, css: {'btn': true, 'btn-inverse': isEditing}"><i class="fa fa-pencil"></i></a>
+      <a title="${ _('Edit') }" rel="tooltip" data-placement="bottom" data-bind="click: toggleEditing, css: {'btn': true, 'btn-inverse': isEditing}">
+        <i class="fa fa-pencil"></i>
+      </a>
+      &nbsp;
+      <button type="button" title="${ _('Settings') }" rel="tooltip" data-placement="bottom" data-toggle="modal" data-target="#settingsDemiModal" data-bind="css: {'btn': true}">
+        <i class="fa fa-cog"></i>
+      </button>
+      <button type="button" title="${ _('Save') }" rel="tooltip" data-placement="bottom" data-loading-text="${ _("Saving...") }" data-bind="click: $root.save, css: {'btn': true}">
+        <i class="fa fa-save"></i>
+      </button>
       &nbsp;&nbsp;&nbsp;
-      <button type="button" title="${ _('Save') }" rel="tooltip" data-placement="bottom" data-loading-text="${ _("Saving...") }" data-bind="click: $root.save, css: {'btn': true}"><i class="fa fa-save"></i></button>
-      <a class="btn" href="${ url('impala:new_search') }" title="${ _('New') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}"><i class="fa fa-file-o"></i></a>
+      <a class="btn" href="${ url('oozie:new_workflow') }" title="${ _('New') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}">
+        <i class="fa fa-file-o"></i>
+      </a>
     % endif
   </div>
 </div>

+ 3 - 1
apps/oozie/src/oozie/urls.py

@@ -70,7 +70,9 @@ urlpatterns = patterns(
 urlpatterns += patterns(
   'oozie.views.editor2',
 
-  url(r'^editor/workflow$', 'workflow_editor', name='workflow_editor'),
+  url(r'^editor/workflow$', 'edit_workflow', name='edit_workflow'),
+  url(r'^editor/workflow/new$', 'new_workflow', name='new_workflow'),
+  url(r'^editor/workflow/save$', 'save_workflow', name='save_workflow'),
 )
 
 

+ 15 - 8
apps/oozie/static/js/workflow-editor.ko.js

@@ -49,11 +49,18 @@ function loadLayout(viewModel, json_layout) {
 
 // End dashboard lib
 
-var Node = function (node_json) {
+var Node = function (node) {
   var self = this;
 
-  self.id = ko.observable(typeof node_json.id != "undefined" && node_json.id != null ? node_json.id : UUID());
-  self.name = ko.observable(typeof node_json.name != "undefined" && node_json.name != null ? node_json.name : "");
+  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.name = ko.observable(typeof node.name != "undefined" && node.name != null ? node.name : "");
+  self.type = ko.observable(typeof type != "undefined" && type != null ? type : "");
+
+  self.properties = ko.mapping.fromJS(typeof node.properties != "undefined" && node.properties != null ? node.properties : {});
+  
+  self.childreen = ko.observable(typeof node.childreen != "undefined" && node.childreen != null ? node.childreen : []);
 }
 
 var Workflow = function (vm, workflow) {
@@ -115,15 +122,15 @@ var WorkflowEditorViewModel = function (layout_json, workflow_json) {
   }
 
   self.save = function () {
-    $.post("/impala/dashboard/save", {
-        "dashboard": ko.mapping.toJSON(self.dashboard),
-        "layout": ko.mapping.toJSON(self.columns)
+    $.post("/oozie/editor/workflow/save", {        
+        "layout": ko.mapping.toJSON(self.columns),
+        "workflow": ko.mapping.toJSON(self.workflow)
     }, function (data) {
       if (data.status == 0) {
         self.dashboard.id(data.id);
         $(document).trigger("info", data.message);
-        if (window.location.search.indexOf("dashboard") == -1) {
-          window.location.hash = '#dashboard=' + data.id;
+        if (window.location.search.indexOf("workflow") == -1) {
+          window.location.hash = '#workflow=' + data.id;
         }
       }
       else {