mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-16 09:45:57 +08:00
流水线节点管理和模板管理
This commit is contained in:
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