mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
流水线节点管理和模板管理
This commit is contained in:
75
app/controllers/action/node_inputs_controller.rb
Normal file
75
app/controllers/action/node_inputs_controller.rb
Normal file
@@ -0,0 +1,75 @@
|
||||
class Action::NodeInputsController < ApplicationController
|
||||
before_action :require_admin, except: [:index]
|
||||
before_action :find_action_node
|
||||
|
||||
def index
|
||||
@node_inputs = @node.action_node_inputs
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@node_input = Action::NodeInput.new(node_input_params)
|
||||
@node_input.action_node = @node
|
||||
respond_to do |format|
|
||||
if @node_input.save
|
||||
format.html { redirect_to action_node_node_inputs_path(@node), notice: '创建成功.' }
|
||||
format.json { render_ok(data: @node_input.as_json) }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @node_input.errors, status: -1 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@node_input.update(node_input_params)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to action_node_node_inputs_path(@node), notice: '更新成功.' }
|
||||
format.json { render_ok(data: @node_input.as_json) }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @node_input.destroy!
|
||||
flash[:success] = '删除成功'
|
||||
else
|
||||
flash[:danger] = '删除失败'
|
||||
end
|
||||
redirect_to "api/actions/nodes"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_action_node
|
||||
@node = Action::Node.find(params[:node_id])
|
||||
if params[:id].present?
|
||||
@node_input = @node.action_node_inputs.find(params[:id])
|
||||
else
|
||||
@node_input = Action::NodeInput.new
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def node_input_params
|
||||
if params.require(:action_node_input)
|
||||
params.require(:action_node_input).permit(:name, :input_type, :description, :is_required, :sort_no)
|
||||
else
|
||||
params.permit(:name, :input_type, :description, :is_required, :sort_no)
|
||||
end
|
||||
end
|
||||
end
|
||||
76
app/controllers/action/node_selects_controller.rb
Normal file
76
app/controllers/action/node_selects_controller.rb
Normal file
@@ -0,0 +1,76 @@
|
||||
class Action::NodeSelectsController < ApplicationController
|
||||
|
||||
before_action :require_admin, except: [:index]
|
||||
before_action :find_action_node
|
||||
|
||||
def index
|
||||
@node_selects = @node.action_node_selects
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@node_select = Action::NodeSelect.new(node_select_params)
|
||||
@node_select.action_node = @node
|
||||
respond_to do |format|
|
||||
if @node_select.save
|
||||
format.html { redirect_to action_node_node_selects_path(@node), notice: '创建成功.' }
|
||||
format.json { render_ok(data: @node_select.as_json) }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @node_select.errors, status: -1 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@node_select.update(node_select_params)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to action_node_node_selects_path(@node), notice: '更新成功.' }
|
||||
format.json { render_ok(data: @node_select.as_json) }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @node_select.destroy!
|
||||
flash[:success] = '删除成功'
|
||||
else
|
||||
flash[:danger] = '删除失败'
|
||||
end
|
||||
redirect_to "api/actions/nodes"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_action_node
|
||||
@node = Action::Node.find(params[:node_id])
|
||||
if params[:id].present?
|
||||
@node_select = @node.action_node_selects.find(params[:id])
|
||||
else
|
||||
@node_select = Action::NodeSelect.new
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def node_select_params
|
||||
if params.require(:action_node_select)
|
||||
params.require(:action_node_select).permit(:name, :val, :val_ext, :description, :sort_no)
|
||||
else
|
||||
params.permit(:name, :val, :val_ext, :description, :sort_no)
|
||||
end
|
||||
end
|
||||
end
|
||||
64
app/controllers/action/node_types_controller.rb
Normal file
64
app/controllers/action/node_types_controller.rb
Normal file
@@ -0,0 +1,64 @@
|
||||
class Action::NodeTypesController < ApplicationController
|
||||
before_action :require_admin, except: [:index]
|
||||
before_action :find_node_type, except: [:index, :create, :new]
|
||||
|
||||
def index
|
||||
@node_types = Action::NodeType.all
|
||||
end
|
||||
|
||||
def create
|
||||
@node_type = Action::NodeType.new(node_types_params)
|
||||
respond_to do |format|
|
||||
if @node_type.save
|
||||
format.html { redirect_to action_node_types_path, notice: '创建成功.' }
|
||||
format.json { render_ok(data: @node_type.as_json) }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @node_type.errors, status: -1 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@node_type = Action::NodeType.new
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@node_type.update(node_types_params)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to action_node_types_path, notice: '更新成功.' }
|
||||
format.json { render_ok(data: @node_type.as_json) }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @node_type.destroy!
|
||||
flash[:success] = '删除成功'
|
||||
else
|
||||
flash[:danger] = '删除失败'
|
||||
end
|
||||
redirect_to action_node_types_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_node_type
|
||||
@node_type = Action::NodeType.find(params[:id])
|
||||
end
|
||||
|
||||
def node_types_params
|
||||
if params.require(:action_node_type)
|
||||
params.require(:action_node_type).permit(:name, :description, :sort_no)
|
||||
else
|
||||
params.permit(:name, :description, :sort_no)
|
||||
end
|
||||
end
|
||||
end
|
||||
69
app/controllers/action/nodes_controller.rb
Normal file
69
app/controllers/action/nodes_controller.rb
Normal file
@@ -0,0 +1,69 @@
|
||||
class Action::NodesController < ApplicationController
|
||||
before_action :require_admin, except: [:index]
|
||||
before_action :find_action_node, except: [:index, :create, :new]
|
||||
|
||||
def index
|
||||
@node_types = Action::NodeType.all
|
||||
@no_type_nodes = Action::Node.where(action_node_types_id: nil)
|
||||
respond_to do |format|
|
||||
format.html { @nodes = Action::Node.all }
|
||||
format.json
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@node = Action::Node.new(node_params)
|
||||
respond_to do |format|
|
||||
if @node.save
|
||||
format.html { redirect_to action_nodes_path, notice: '创建成功.' }
|
||||
format.json { render_ok(data: @node.as_json) }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @node.errors, status: -1 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@node = Action::Node.new
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@node.update(node_params)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to action_nodes_path, notice: '更新成功.' }
|
||||
format.json { render_ok(data: @node.as_json) }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @node.destroy!
|
||||
flash[:success] = '删除成功'
|
||||
else
|
||||
flash[:danger] = '删除失败'
|
||||
end
|
||||
redirect_to action_nodes_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_action_node
|
||||
@node = Action::Node.find(params[:id])
|
||||
end
|
||||
|
||||
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)
|
||||
else
|
||||
params.permit(:name, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no)
|
||||
end
|
||||
end
|
||||
end
|
||||
68
app/controllers/action/templates_controller.rb
Normal file
68
app/controllers/action/templates_controller.rb
Normal file
@@ -0,0 +1,68 @@
|
||||
class Action::TemplatesController < ApplicationController
|
||||
before_action :require_admin, except: [:index]
|
||||
before_action :find_action_template, except: [:index, :create, :new]
|
||||
|
||||
def index
|
||||
@templates = Action::Template.all
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@template = Action::Template.new(templates_params)
|
||||
respond_to do |format|
|
||||
if @template.save
|
||||
format.html { redirect_to action_templates_path, notice: '创建成功.' }
|
||||
format.json { render_ok(data: @template.as_json) }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @template.errors, status: -1 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@template = Action::Template.new
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@template.update(templates_params)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to action_templates_path, notice: '更新成功.' }
|
||||
format.json { render_ok(data: @template.as_json) }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @template.destroy!
|
||||
flash[:success] = '删除成功'
|
||||
else
|
||||
flash[:danger] = '删除失败'
|
||||
end
|
||||
redirect_to action_templates_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_action_template
|
||||
@template = Action::Template.find(params[:id])
|
||||
end
|
||||
|
||||
def templates_params
|
||||
if params.require(:action_template)
|
||||
params.require(:action_template).permit(:name, :description, :img, :sort_no, :json, :yaml)
|
||||
else
|
||||
params.permit(:name, :description, :img, :sort_no, :json, :yaml)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user