add ActiveAdmin
This commit is contained in:
25
app/admin/channel.rb
Normal file
25
app/admin/channel.rb
Normal file
@ -0,0 +1,25 @@
|
||||
ActiveAdmin.register Channel do
|
||||
|
||||
filter :name
|
||||
filter :description
|
||||
filter :created_at
|
||||
|
||||
permit_params :name, :public_flag
|
||||
|
||||
index do
|
||||
column :id
|
||||
column(:name) { |channel| link_to channel.name, channel }
|
||||
column(:user) { |channel| link_to channel.user.login, admin_user_path(channel.user) if channel.user.present? }
|
||||
column :public_flag
|
||||
column :created_at
|
||||
default_actions
|
||||
end
|
||||
|
||||
form do |f|
|
||||
f.semantic_errors *f.object.errors.keys
|
||||
f.inputs :name, :public_flag
|
||||
f.actions
|
||||
end
|
||||
|
||||
end
|
||||
|
28
app/admin/dashboard.rb
Normal file
28
app/admin/dashboard.rb
Normal file
@ -0,0 +1,28 @@
|
||||
ActiveAdmin.register_page "Dashboard" do
|
||||
|
||||
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
|
||||
|
||||
content title: proc{ I18n.t("active_admin.dashboard") } do
|
||||
columns do
|
||||
|
||||
column do
|
||||
panel "Stats" do
|
||||
para "Total Users: #{User.all.count}"
|
||||
para "Total Channels: #{Channel.all.count}"
|
||||
end
|
||||
end
|
||||
|
||||
column do
|
||||
panel "Recent Channels" do
|
||||
ul do
|
||||
Channel.all.order("created_at desc").limit(5).map do |channel|
|
||||
li link_to(channel.name, admin_channel_path(channel))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end # content
|
||||
end
|
||||
|
19
app/admin/failedlogin.rb
Normal file
19
app/admin/failedlogin.rb
Normal file
@ -0,0 +1,19 @@
|
||||
ActiveAdmin.register Failedlogin do
|
||||
menu :parent => "Others"
|
||||
actions :all, :except => [:edit]
|
||||
|
||||
filter :login
|
||||
filter :password
|
||||
filter :created_at
|
||||
|
||||
index do
|
||||
column :id
|
||||
column :login
|
||||
column :password
|
||||
column :ip_address
|
||||
column :created_at
|
||||
default_actions
|
||||
end
|
||||
|
||||
end
|
||||
|
23
app/admin/plugin.rb
Normal file
23
app/admin/plugin.rb
Normal file
@ -0,0 +1,23 @@
|
||||
ActiveAdmin.register Plugin do
|
||||
|
||||
filter :name
|
||||
filter :created_at
|
||||
|
||||
permit_params :name, :html, :css, :js, :private_flag
|
||||
|
||||
index do
|
||||
column :id
|
||||
column(:user) { |object| link_to object.user.login, admin_user_path(object.user) if object.user.present? }
|
||||
column :name
|
||||
column :private_flag
|
||||
default_actions
|
||||
end
|
||||
|
||||
form do |f|
|
||||
f.semantic_errors *f.object.errors.keys
|
||||
f.inputs :name, :html, :css, :js, :private_flag
|
||||
f.actions
|
||||
end
|
||||
|
||||
end
|
||||
|
9
app/admin/useful_links.rb
Normal file
9
app/admin/useful_links.rb
Normal file
@ -0,0 +1,9 @@
|
||||
ActiveAdmin.register_page "Useful Links" do
|
||||
menu :parent => "Others"
|
||||
|
||||
content do
|
||||
render "index"
|
||||
end
|
||||
|
||||
end
|
||||
|
48
app/admin/user.rb
Normal file
48
app/admin/user.rb
Normal file
@ -0,0 +1,48 @@
|
||||
ActiveAdmin.register User do
|
||||
require 'csv'
|
||||
|
||||
filter :email
|
||||
filter :login
|
||||
filter :created_at
|
||||
|
||||
permit_params :email, :login, :bio, :website
|
||||
|
||||
index do
|
||||
column :id
|
||||
column :email
|
||||
column :login
|
||||
column :created_at
|
||||
default_actions
|
||||
end
|
||||
|
||||
show do
|
||||
attributes_table do
|
||||
rows :id, :email, :login, :time_zone, :bio, :website, :created_at, :sign_in_count, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip, :last_sign_in_ip
|
||||
end
|
||||
panel 'Channels' do
|
||||
table_for user.channels do
|
||||
column :id
|
||||
column(:name) { |channel| link_to channel.name, channel }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
form do |f|
|
||||
f.semantic_errors *f.object.errors.keys
|
||||
f.inputs :email, :login
|
||||
f.actions
|
||||
end
|
||||
|
||||
# custom action for signups per day
|
||||
collection_action :signups, :method => :get, :format => :csv do
|
||||
@csv_headers = [:day, :signups]
|
||||
@days = User.signups_per_day
|
||||
end
|
||||
|
||||
# custom action for emails list
|
||||
collection_action :emails, :method => :get do
|
||||
@users = User.all
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user