| @@ -61,9 +61,9 @@ 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, :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 | 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 | end | ||||
| end | end | ||||
| @@ -36,6 +36,11 @@ class Action::Node < ApplicationRecord | |||||
| attr_accessor :cust_name, :run_values, :input_values | 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 | def content_yaml | ||||
| "foo".to_yaml | "foo".to_yaml | ||||
| @@ -24,4 +24,7 @@ class Action::NodeInput < ApplicationRecord | |||||
| default_scope { order(sort_no: :asc) } | default_scope { order(sort_no: :asc) } | ||||
| belongs_to :action_node, :class_name => 'Action::Node', foreign_key: "action_nodes_id" | 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 | end | ||||
| @@ -29,6 +29,9 @@ class Action::NodeSelect < ApplicationRecord | |||||
| belongs_to :action_node, :class_name => 'Action::Node', foreign_key: "action_nodes_id" | belongs_to :action_node, :class_name => 'Action::Node', foreign_key: "action_nodes_id" | ||||
| belongs_to :user, optional: true | belongs_to :user, optional: true | ||||
| validates :name, presence: { message: "不能为空" } | |||||
| validates :description, length: { maximum: 65535, too_long: "不能超过65535个字符"} | |||||
| def value | def value | ||||
| if self.val_ext.blank? | if self.val_ext.blank? | ||||
| self.val | self.val | ||||
| @@ -15,4 +15,7 @@ class Action::NodeType < ApplicationRecord | |||||
| default_scope { order(sort_no: :asc) } | default_scope { order(sort_no: :asc) } | ||||
| has_many :action_nodes, :class_name => 'Action::Node', foreign_key: "action_node_types_id" | 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 | end | ||||
| @@ -33,5 +33,7 @@ class Action::Pipeline < ApplicationRecord | |||||
| belongs_to :user, optional: true | belongs_to :user, optional: true | ||||
| belongs_to :project | belongs_to :project | ||||
| validates :name, presence: { message: "不能为空" } | |||||
| validates :json, length: { maximum: 65535, too_long: "不能超过65535个字符"} | |||||
| validates :yaml, length: { maximum: 65535, too_long: "不能超过65535个字符"} | |||||
| end | end | ||||
| @@ -17,4 +17,7 @@ class Action::Template < ApplicationRecord | |||||
| self.table_name = 'action_templates' | self.table_name = 'action_templates' | ||||
| default_scope { order(sort_no: :asc) } | default_scope { order(sort_no: :asc) } | ||||
| validates :name, presence: { message: "不能为空" } | |||||
| validates :description, length: { maximum: 65535, too_long: "不能超过65535个字符"} | |||||
| end | end | ||||
| @@ -39,7 +39,7 @@ | |||||
| <div class="actions" style="margin-top:10px;"> | <div class="actions" style="margin-top:10px;"> | ||||
| <!-- <a href="/managements/competition/customize" style="font-size: 28px;">>>前往节点管理页面</a>--> | <!-- <a href="/managements/competition/customize" style="font-size: 28px;">>>前往节点管理页面</a>--> | ||||
| <%= form.submit("保存赛事") %> | |||||
| <%= form.submit("保存") %> | |||||
| </div> | </div> | ||||
| <% end %> | <% end %> | ||||
| @@ -2,7 +2,7 @@ json.types @node_types.each do |node_type| | |||||
| if node_type.name.to_s == "未分类" | if node_type.name.to_s == "未分类" | ||||
| json.extract! node_type, :id, :name | json.extract! node_type, :id, :name | ||||
| json.nodes @no_type_nodes do |node| | 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.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 | ||||
| @@ -10,7 +10,7 @@ json.types @node_types.each do |node_type| | |||||
| else | else | ||||
| json.extract! node_type, :id, :name | json.extract! node_type, :id, :name | ||||
| json.nodes node_type.action_nodes do |node| | 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.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 | ||||
| @@ -20,7 +20,11 @@ | |||||
| <%= form.text_field :name %> | <%= form.text_field :name %> | ||||
| </div> | </div> | ||||
| <div class="field"> | <div class="field"> | ||||
| <%= form.label :full_name, "节点全称" %> | |||||
| <%= form.label :label, "节点标识" %> | |||||
| <%= form.text_field :label %> | |||||
| </div> | |||||
| <div class="field"> | |||||
| <%= form.label :full_name, "节点全名" %> | |||||
| <%= form.text_field :full_name %> | <%= form.text_field :full_name %> | ||||
| </div> | </div> | ||||
| @@ -10,6 +10,7 @@ | |||||
| <tr> | <tr> | ||||
| <th>ID</th> | <th>ID</th> | ||||
| <th width="15%">节点名称</th> | <th width="15%">节点名称</th> | ||||
| <th width="15%">节点标识</th> | |||||
| <th width="20%">节点全称</th> | <th width="20%">节点全称</th> | ||||
| <th width="20%">节点描述</th> | <th width="20%">节点描述</th> | ||||
| <th width="10%">分类</th> | <th width="10%">分类</th> | ||||
| @@ -27,6 +28,7 @@ | |||||
| <% @nodes.each do |info| %> | <% @nodes.each do |info| %> | ||||
| <tr> | <tr> | ||||
| <td><%= info.id %></td> | <td><%= info.id %></td> | ||||
| <td><%= info.label %></td> | |||||
| <td><%= info.name %></td> | <td><%= info.name %></td> | ||||
| <td><%= info.full_name %></td> | <td><%= info.full_name %></td> | ||||
| <td><%= info.description %></td> | <td><%= info.description %></td> | ||||
| @@ -2,7 +2,7 @@ json.types @node_types.each do |node_type| | |||||
| if node_type.name.to_s == "未分类" | if node_type.name.to_s == "未分类" | ||||
| json.extract! node_type, :id, :name | json.extract! node_type, :id, :name | ||||
| json.nodes @no_type_nodes do |node| | 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.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 | ||||
| @@ -10,7 +10,7 @@ json.types @node_types.each do |node_type| | |||||
| else | else | ||||
| json.extract! node_type, :id, :name | json.extract! node_type, :id, :name | ||||
| json.nodes node_type.action_nodes do |node| | 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.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 | ||||
| @@ -0,0 +1,5 @@ | |||||
| class AddActionNodesLabel < ActiveRecord::Migration[5.2] | |||||
| def change | |||||
| add_column :action_nodes, :label, :string | |||||
| end | |||||
| end | |||||