fixed 节点增加属性,节点名称带上id
This commit is contained in:
parent
35c0ac4eec
commit
28f3395b05
|
@ -13,6 +13,9 @@ class Action::NodesController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@node = Action::Node.new(node_params)
|
@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|
|
respond_to do |format|
|
||||||
if @node.save
|
if @node.save
|
||||||
format.html { redirect_to action_nodes_path, notice: '创建成功.' }
|
format.html { redirect_to action_nodes_path, notice: '创建成功.' }
|
||||||
|
@ -33,10 +36,15 @@ class Action::NodesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
if @node.link_type.present?
|
||||||
|
@node.link_type_array = @node.link_type.to_s.split(",")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
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)
|
@node.update(node_params)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to action_nodes_path, notice: '更新成功.' }
|
format.html { redirect_to action_nodes_path, notice: '更新成功.' }
|
||||||
|
@ -62,10 +70,10 @@ class Action::NodesController < ApplicationController
|
||||||
def node_params
|
def node_params
|
||||||
if params.require(:action_node)
|
if params.require(:action_node)
|
||||||
params.require(:action_node).permit(:name, :label, :full_name, :description, :icon, :action_node_types_id,
|
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
|
else
|
||||||
params.permit(:name, :label, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url,
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -101,6 +101,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
|
||||||
job_nodes.each do |job|
|
job_nodes.each do |job|
|
||||||
node = Action::Node.find_by(name: job["data"]["name"])
|
node = Action::Node.find_by(name: job["data"]["name"])
|
||||||
node.label = job["data"]["label"] if job["data"]["label"].present?
|
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 if node.blank?
|
||||||
next_edge_nodes = JSON.parse(demo2.to_json)["edges"].select { |edge| edge["source"]["cell"].include?(job["id"]) }
|
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"] }
|
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"])
|
node = Action::Node.find_by(name: input_node["data"]["name"])
|
||||||
next if node.blank?
|
next if node.blank?
|
||||||
node.label = input_node["data"]["label"] if input_node["data"]["label"].present?
|
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 = {}
|
run_values = {}
|
||||||
input_values = {}
|
input_values = {}
|
||||||
if input_node["data"]["inputs"].present?
|
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"])
|
node = Action::Node.find_by(name: input_node["data"]["name"])
|
||||||
return nil if node.blank?
|
return nil if node.blank?
|
||||||
node.label = input_node["data"]["label"] if input_node["data"]["label"].present?
|
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 = {}
|
run_values = {}
|
||||||
input_values = {}
|
input_values = {}
|
||||||
if input_node["data"]["inputs"].present?
|
if input_node["data"]["inputs"].present?
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Action::Node < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :user, optional: true
|
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 :name, presence: { message: "不能为空" }
|
||||||
validates :full_name, length: { maximum: 200, too_long: "不能超过200个字符" }
|
validates :full_name, length: { maximum: 200, too_long: "不能超过200个字符" }
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
<%# end %>
|
<%# end %>
|
||||||
<div class="form-group ">
|
<div class="form-group ">
|
||||||
<label for="status">类型:</label>
|
<label for="status">节点分类:</label>
|
||||||
<%= 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" %>
|
<%= 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" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
@ -26,6 +26,22 @@
|
||||||
<%= form.label :full_name, "节点全名" %>
|
<%= form.label :full_name, "节点全名" %>
|
||||||
<%= form.text_field :full_name %>
|
<%= form.text_field :full_name %>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group ">
|
||||||
|
<label for="status">类型:</label>
|
||||||
|
<% node_type_options = [['action节点', 'step' ], ['启动', 'start' ], ['任务', 'job']] %>
|
||||||
|
<%= form.select :node_type, options_for_select(node_type_options, node.node_type), {}, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
<div class="form-group ">
|
||||||
|
<label for="status">是否支持分支:</label>
|
||||||
|
<% 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" %>
|
||||||
|
</div>
|
||||||
|
<div class="form-group ">
|
||||||
|
<label for="status">可连接到类型:</label>
|
||||||
|
<% 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) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<%= form.label :description, "描述" %>
|
<%= form.label :description, "描述" %>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
json.status 0
|
json.status 0
|
||||||
json.message "success"
|
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.inputs @node.action_node_inputs do |node_input|
|
||||||
json.partial! "node_input", locals: { node_input: node_input, node: @node }
|
json.partial! "node_input", locals: { node_input: node_input, node: @node }
|
||||||
end
|
end
|
Loading…
Reference in New Issue