From b96d52a84dbb089a4e6fe07d4fc28e8f3e9778ef Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 31 May 2024 10:56:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=90=8D=E7=A7=B0=EF=BC=8C=E5=92=8C=E6=A0=87?= =?UTF-8?q?=E8=AF=86=E5=8C=BA=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/action/nodes_controller.rb | 4 ++-- app/models/action/node.rb | 5 +++++ app/models/action/node_input.rb | 3 +++ app/models/action/node_select.rb | 3 +++ app/models/action/node_type.rb | 3 +++ app/models/action/pipeline.rb | 4 +++- app/models/action/template.rb | 3 +++ app/views/action/node_inputs/edit.html.erb | 2 +- app/views/action/node_inputs/index.json.jbuilder | 4 ++-- app/views/action/nodes/_form.html.erb | 6 +++++- app/views/action/nodes/index.html.erb | 2 ++ app/views/action/nodes/index.json.jbuilder | 4 ++-- db/migrate/20240408010103_add_action_nodes_label.rb | 5 +++++ 13 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20240408010103_add_action_nodes_label.rb diff --git a/app/controllers/action/nodes_controller.rb b/app/controllers/action/nodes_controller.rb index e1e7799f4..d85a6094a 100644 --- a/app/controllers/action/nodes_controller.rb +++ b/app/controllers/action/nodes_controller.rb @@ -61,9 +61,9 @@ class Action::NodesController < ApplicationController def node_params if params.require(:action_node) - params.require(:action_node).permit(:name, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no) + params.require(:action_node).permit(:name, :label, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no) else - params.permit(:name, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no) + params.permit(:name, :label, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no) end end end diff --git a/app/models/action/node.rb b/app/models/action/node.rb index 07d3be134..a761a0216 100644 --- a/app/models/action/node.rb +++ b/app/models/action/node.rb @@ -36,6 +36,11 @@ class Action::Node < ApplicationRecord attr_accessor :cust_name, :run_values, :input_values + validates :name, presence: { message: "不能为空" } + validates :full_name, length: { maximum: 200, too_long: "不能超过200个字符" } + validates :label, length: { maximum: 200, too_long: "不能超过200个字符" } + validates :description, length: { maximum: 65535, too_long: "不能超过65535个字符"} + def content_yaml "foo".to_yaml diff --git a/app/models/action/node_input.rb b/app/models/action/node_input.rb index 4f3825170..7dc475a2e 100644 --- a/app/models/action/node_input.rb +++ b/app/models/action/node_input.rb @@ -24,4 +24,7 @@ class Action::NodeInput < ApplicationRecord default_scope { order(sort_no: :asc) } belongs_to :action_node, :class_name => 'Action::Node', foreign_key: "action_nodes_id" + + validates :name, presence: { message: "不能为空" } + validates :description, length: { maximum: 65535, too_long: "不能超过65535个字符"} end diff --git a/app/models/action/node_select.rb b/app/models/action/node_select.rb index 25be51f99..23cd87bb8 100644 --- a/app/models/action/node_select.rb +++ b/app/models/action/node_select.rb @@ -29,6 +29,9 @@ class Action::NodeSelect < ApplicationRecord belongs_to :action_node, :class_name => 'Action::Node', foreign_key: "action_nodes_id" belongs_to :user, optional: true + validates :name, presence: { message: "不能为空" } + validates :description, length: { maximum: 65535, too_long: "不能超过65535个字符"} + def value if self.val_ext.blank? self.val diff --git a/app/models/action/node_type.rb b/app/models/action/node_type.rb index 7ce78b0fb..59f4ab9de 100644 --- a/app/models/action/node_type.rb +++ b/app/models/action/node_type.rb @@ -15,4 +15,7 @@ class Action::NodeType < ApplicationRecord default_scope { order(sort_no: :asc) } has_many :action_nodes, :class_name => 'Action::Node', foreign_key: "action_node_types_id" + + validates :name, presence: { message: "不能为空" } + validates :description, length: { maximum: 65535, too_long: "不能超过65535个字符"} end diff --git a/app/models/action/pipeline.rb b/app/models/action/pipeline.rb index 1dfbd0f24..227fa4aa8 100644 --- a/app/models/action/pipeline.rb +++ b/app/models/action/pipeline.rb @@ -33,5 +33,7 @@ class Action::Pipeline < ApplicationRecord belongs_to :user, optional: true belongs_to :project - + validates :name, presence: { message: "不能为空" } + validates :json, length: { maximum: 65535, too_long: "不能超过65535个字符"} + validates :yaml, length: { maximum: 65535, too_long: "不能超过65535个字符"} end diff --git a/app/models/action/template.rb b/app/models/action/template.rb index 34b669f66..d854e8854 100644 --- a/app/models/action/template.rb +++ b/app/models/action/template.rb @@ -17,4 +17,7 @@ class Action::Template < ApplicationRecord self.table_name = 'action_templates' default_scope { order(sort_no: :asc) } + validates :name, presence: { message: "不能为空" } + validates :description, length: { maximum: 65535, too_long: "不能超过65535个字符"} + end diff --git a/app/views/action/node_inputs/edit.html.erb b/app/views/action/node_inputs/edit.html.erb index 6ae9f8a78..6139eb73f 100644 --- a/app/views/action/node_inputs/edit.html.erb +++ b/app/views/action/node_inputs/edit.html.erb @@ -39,7 +39,7 @@
- <%= form.submit("保存赛事") %> + <%= form.submit("保存") %>
<% end %> diff --git a/app/views/action/node_inputs/index.json.jbuilder b/app/views/action/node_inputs/index.json.jbuilder index 3909639ce..059a647e4 100644 --- a/app/views/action/node_inputs/index.json.jbuilder +++ b/app/views/action/node_inputs/index.json.jbuilder @@ -2,7 +2,7 @@ json.types @node_types.each do |node_type| if node_type.name.to_s == "未分类" json.extract! node_type, :id, :name json.nodes @no_type_nodes do |node| - json.extract! node, :id, :name, :full_name, :description, :action_node_types_id, :yaml, :sort_no, :use_count + json.extract! node, :id, :label, :name, :full_name, :description, :action_node_types_id, :yaml, :sort_no, :use_count json.inputs node.action_node_inputs do |node_input| json.partial! "node_input", locals: { node_input: node_input, node: node } end @@ -10,7 +10,7 @@ json.types @node_types.each do |node_type| else json.extract! node_type, :id, :name json.nodes node_type.action_nodes do |node| - json.extract! node, :id, :name, :full_name, :description, :action_node_types_id, :yaml, :sort_no, :use_count + json.extract! node, :id, :label, :name, :full_name, :description, :action_node_types_id, :yaml, :sort_no, :use_count json.inputs node.action_node_inputs do |node_input| json.partial! "node_input", locals: { node_input: node_input, node: node } end diff --git a/app/views/action/nodes/_form.html.erb b/app/views/action/nodes/_form.html.erb index 4e40f0ff0..f80395809 100644 --- a/app/views/action/nodes/_form.html.erb +++ b/app/views/action/nodes/_form.html.erb @@ -20,7 +20,11 @@ <%= form.text_field :name %>
- <%= form.label :full_name, "节点全称" %> + <%= form.label :label, "节点标识" %> + <%= form.text_field :label %> +
+
+ <%= form.label :full_name, "节点全名" %> <%= form.text_field :full_name %>
diff --git a/app/views/action/nodes/index.html.erb b/app/views/action/nodes/index.html.erb index 763a8e467..ce603590b 100644 --- a/app/views/action/nodes/index.html.erb +++ b/app/views/action/nodes/index.html.erb @@ -10,6 +10,7 @@ ID 节点名称 + 节点标识 节点全称 节点描述 分类 @@ -27,6 +28,7 @@ <% @nodes.each do |info| %> <%= info.id %> + <%= info.label %> <%= info.name %> <%= info.full_name %> <%= info.description %> diff --git a/app/views/action/nodes/index.json.jbuilder b/app/views/action/nodes/index.json.jbuilder index b81879e20..fc8a38505 100644 --- a/app/views/action/nodes/index.json.jbuilder +++ b/app/views/action/nodes/index.json.jbuilder @@ -2,7 +2,7 @@ json.types @node_types.each do |node_type| if node_type.name.to_s == "未分类" json.extract! node_type, :id, :name json.nodes @no_type_nodes do |node| - json.extract! node, :id, :name, :full_name, :description, :icon, :action_node_types_id, :yaml, :sort_no, :use_count + json.extract! node, :id, :label, :name, :full_name, :description, :icon, :action_node_types_id, :yaml, :sort_no, :use_count json.inputs node.action_node_inputs do |node_input| json.partial! "node_input", locals: { node_input: node_input, node: node } end @@ -10,7 +10,7 @@ json.types @node_types.each do |node_type| else json.extract! node_type, :id, :name json.nodes node_type.action_nodes do |node| - json.extract! node, :id, :name, :full_name, :description, :icon, :action_node_types_id, :yaml, :sort_no, :use_count + json.extract! node, :id, :label, :name, :full_name, :description, :icon, :action_node_types_id, :yaml, :sort_no, :use_count json.inputs node.action_node_inputs do |node_input| json.partial! "node_input", locals: { node_input: node_input, node: node } end diff --git a/db/migrate/20240408010103_add_action_nodes_label.rb b/db/migrate/20240408010103_add_action_nodes_label.rb new file mode 100644 index 000000000..fe88fb4fc --- /dev/null +++ b/db/migrate/20240408010103_add_action_nodes_label.rb @@ -0,0 +1,5 @@ +class AddActionNodesLabel < ActiveRecord::Migration[5.2] + def change + add_column :action_nodes, :label, :string + end +end