diff --git a/app/controllers/action/nodes_controller.rb b/app/controllers/action/nodes_controller.rb index ebccf8efe..2664ff95a 100644 --- a/app/controllers/action/nodes_controller.rb +++ b/app/controllers/action/nodes_controller.rb @@ -13,6 +13,9 @@ class Action::NodesController < ApplicationController def create @node = Action::Node.new(node_params) + if params.require(:node).present? && params.require(:node)[:link_type_array].present? + @node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",") + end respond_to do |format| if @node.save format.html { redirect_to action_nodes_path, notice: '创建成功.' } @@ -33,10 +36,15 @@ class Action::NodesController < ApplicationController end def edit - + if @node.link_type.present? + @node.link_type_array = @node.link_type.to_s.split(",") + end end def update + if params.require(:node).present? && params.require(:node)[:link_type_array].present? + @node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",") + end @node.update(node_params) respond_to do |format| format.html { redirect_to action_nodes_path, notice: '更新成功.' } @@ -62,10 +70,10 @@ class Action::NodesController < ApplicationController def node_params if params.require(:action_node) params.require(:action_node).permit(:name, :label, :full_name, :description, :icon, :action_node_types_id, - :is_local, :local_url, :yaml, :sort_no, :type, :is_mutil_link, :link_type) + :is_local, :local_url, :yaml, :sort_no, :node_type, :is_mutil_link, :link_type, :link_type_array) else params.permit(:name, :label, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, - :yaml, :sort_no, :type, :is_mutil_link, :link_type) + :yaml, :sort_no, :node_type, :is_mutil_link, :link_type, :link_type_array) end end end diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 68f15d152..532b33d7e 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -101,6 +101,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController job_nodes.each do |job| node = Action::Node.find_by(name: job["data"]["name"]) node.label = job["data"]["label"] if job["data"]["label"].present? + node.node_id = job["data"]["id"] if job["data"]["id"].present? next if node.blank? next_edge_nodes = JSON.parse(demo2.to_json)["edges"].select { |edge| edge["source"]["cell"].include?(job["id"]) } node_ids = next_edge_nodes.map { |t| t["target"]["cell"] } @@ -150,6 +151,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController node = Action::Node.find_by(name: input_node["data"]["name"]) next if node.blank? node.label = input_node["data"]["label"] if input_node["data"]["label"].present? + node.node_id = input_node["data"]["id"] if input_node["data"]["id"].present? run_values = {} input_values = {} if input_node["data"]["inputs"].present? @@ -182,6 +184,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController node = Action::Node.find_by(name: input_node["data"]["name"]) return nil if node.blank? node.label = input_node["data"]["label"] if input_node["data"]["label"].present? + node.node_id = input_node["data"]["id"] if input_node["data"]["id"].present? run_values = {} input_values = {} if input_node["data"]["inputs"].present? diff --git a/app/models/action/node.rb b/app/models/action/node.rb index 8d2620d06..b92837b7b 100644 --- a/app/models/action/node.rb +++ b/app/models/action/node.rb @@ -38,7 +38,7 @@ class Action::Node < ApplicationRecord belongs_to :user, optional: true - attr_accessor :cust_name, :run_values, :input_values, :sub_nodes + attr_accessor :cust_name, :run_values, :input_values, :sub_nodes, :link_type_array, :node_id validates :name, presence: { message: "不能为空" } validates :full_name, length: { maximum: 200, too_long: "不能超过200个字符" } diff --git a/app/views/action/nodes/_form.html.erb b/app/views/action/nodes/_form.html.erb index 0ecee56ed..7b21bb20f 100644 --- a/app/views/action/nodes/_form.html.erb +++ b/app/views/action/nodes/_form.html.erb @@ -11,7 +11,7 @@ <%# end %>
- + <%= form.select :action_node_types_id, options_for_select(Action::NodeType.all.map { |key| [key.name, key.id]}, node.action_node_types_id), {}, class: "form-control" %>
@@ -26,6 +26,22 @@ <%= form.label :full_name, "节点全名" %> <%= form.text_field :full_name %>
+
+ + <% node_type_options = [['action节点', 'step' ], ['启动', 'start' ], ['任务', 'job']] %> + <%= form.select :node_type, options_for_select(node_type_options, node.node_type), {}, class: "form-control" %> +
+
+ + <% is_mutil_link_options = [['否', false ], ['是', true]] %> + <%= form.select :is_mutil_link, options_for_select(is_mutil_link_options, node.is_mutil_link), {}, class: "form-control" %> +
+
+ + <% link_type_options = [Action::Node.new(name: "job", label: "任务"), Action::Node.new(name: "step", label: "action节点")] %> + <%= collection_check_boxes(:node, :link_type_array, link_type_options, :name, :label) %> +
+
<%= form.label :description, "描述" %> diff --git a/app/views/action/nodes/show.json.jbuilder b/app/views/action/nodes/show.json.jbuilder index 64548544d..4bf73bef3 100644 --- a/app/views/action/nodes/show.json.jbuilder +++ b/app/views/action/nodes/show.json.jbuilder @@ -1,7 +1,7 @@ json.status 0 json.message "success" -json.extract! @node, :id, :name, :full_name, :description, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no, :use_count +json.extract! @node, :id, :name, :full_name, :description, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no, :use_count, :node_type, :is_mutil_link, :link_type json.inputs @node.action_node_inputs do |node_input| json.partial! "node_input", locals: { node_input: node_input, node: @node } end \ No newline at end of file