#encoding
module RailsAdmin
  module Config
    module Actions

        class PushXcxTmplRedirect < RailsAdmin::Config::Actions::Base
            register_instance_option :visible?  do
          authorized?
            end

            register_instance_option :member do
                true
            end

            register_instance_option :link_icon do
                'icon-share'
            end

            register_instance_option :pjax? do
                false
            end

            register_instance_option :controller do
                Proc.new do
                    n = "已推送！"
                    begin
                        url = "#{CONFIG_FILE["api_host"]}/railsadmin/push/xcx_template/#{@object.id}"
                        open(url)
                    rescue Exception => e
                        p "************ push/xcx_template fail . #{e.to_s}"
                        n = "推送失败！"
                    end
                    redirect_to :back, notice: "#{n}"
                end
            end

        end

    end
  end
end