Feature: Rewamp super admin dashboard (#882)
This commit is contained in:
@@ -12,7 +12,10 @@ class AccountDashboard < Administrate::BaseDashboard
|
||||
name: Field::String,
|
||||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
locale: Field::String.with_options(searchable: false)
|
||||
users: CountField,
|
||||
conversations: CountField,
|
||||
locale: Field::Select.with_options(collection: LANGUAGES_CONFIG.map { |_x, y| y[:iso_639_1_code] }),
|
||||
account_users: Field::HasMany
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
@@ -21,8 +24,11 @@ class AccountDashboard < Administrate::BaseDashboard
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
id
|
||||
name
|
||||
locale
|
||||
users
|
||||
conversations
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
@@ -33,6 +39,8 @@ class AccountDashboard < Administrate::BaseDashboard
|
||||
created_at
|
||||
updated_at
|
||||
locale
|
||||
conversations
|
||||
account_users
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
@@ -58,7 +66,7 @@ class AccountDashboard < Administrate::BaseDashboard
|
||||
# Overwrite this method to customize how accounts are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
#
|
||||
# def display_resource(account)
|
||||
# "Account ##{account.id}"
|
||||
# end
|
||||
def display_resource(account)
|
||||
"##{account.id} #{account.name}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,12 +8,11 @@ class AccountUserDashboard < Administrate::BaseDashboard
|
||||
# which determines how the attribute is displayed
|
||||
# on pages throughout the dashboard.
|
||||
ATTRIBUTE_TYPES = {
|
||||
account: Field::BelongsTo,
|
||||
user: Field::BelongsTo,
|
||||
inviter: Field::BelongsTo.with_options(class_name: 'User'),
|
||||
account: Field::BelongsTo.with_options(searchable: true, searchable_field: 'name'),
|
||||
user: Field::BelongsTo.with_options(searchable: true, searchable_field: 'name'),
|
||||
inviter: Field::BelongsTo.with_options(class_name: 'User', searchable: true, searchable_field: 'name'),
|
||||
id: Field::Number,
|
||||
role: Field::String.with_options(searchable: false),
|
||||
inviter_id: Field::Number,
|
||||
role: Field::Select.with_options(collection: AccountUser.roles.keys),
|
||||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime
|
||||
}.freeze
|
||||
@@ -27,7 +26,7 @@ class AccountUserDashboard < Administrate::BaseDashboard
|
||||
account
|
||||
user
|
||||
inviter
|
||||
id
|
||||
role
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
@@ -38,7 +37,6 @@ class AccountUserDashboard < Administrate::BaseDashboard
|
||||
inviter
|
||||
id
|
||||
role
|
||||
inviter_id
|
||||
created_at
|
||||
updated_at
|
||||
].freeze
|
||||
@@ -49,9 +47,7 @@ class AccountUserDashboard < Administrate::BaseDashboard
|
||||
FORM_ATTRIBUTES = %i[
|
||||
account
|
||||
user
|
||||
inviter
|
||||
role
|
||||
inviter_id
|
||||
].freeze
|
||||
|
||||
# COLLECTION_FILTERS
|
||||
@@ -69,7 +65,7 @@ class AccountUserDashboard < Administrate::BaseDashboard
|
||||
# Overwrite this method to customize how account users are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
#
|
||||
# def display_resource(account_user)
|
||||
# "AccountUser ##{account_user.id}"
|
||||
# end
|
||||
def display_resource(account_user)
|
||||
"AccountUser ##{account_user.id}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,6 +10,7 @@ class SuperAdminDashboard < Administrate::BaseDashboard
|
||||
ATTRIBUTE_TYPES = {
|
||||
id: Field::Number,
|
||||
email: Field::String,
|
||||
password: Field::Password,
|
||||
access_token: Field::HasOne,
|
||||
remember_created_at: Field::DateTime,
|
||||
sign_in_count: Field::Number,
|
||||
@@ -52,12 +53,7 @@ class SuperAdminDashboard < Administrate::BaseDashboard
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = %i[
|
||||
email
|
||||
remember_created_at
|
||||
sign_in_count
|
||||
current_sign_in_at
|
||||
last_sign_in_at
|
||||
current_sign_in_ip
|
||||
last_sign_in_ip
|
||||
password
|
||||
].freeze
|
||||
|
||||
# COLLECTION_FILTERS
|
||||
|
||||
@@ -9,14 +9,11 @@ class UserDashboard < Administrate::BaseDashboard
|
||||
# on pages throughout the dashboard.
|
||||
ATTRIBUTE_TYPES = {
|
||||
account_users: Field::HasMany,
|
||||
accounts: Field::HasMany,
|
||||
invitees: Field::HasMany.with_options(class_name: 'User'),
|
||||
id: Field::Number,
|
||||
avatar_url: AvatarField,
|
||||
provider: Field::String,
|
||||
uid: Field::String,
|
||||
reset_password_token: Field::String,
|
||||
reset_password_sent_at: Field::DateTime,
|
||||
remember_created_at: Field::DateTime,
|
||||
password: Field::Password,
|
||||
sign_in_count: Field::Number,
|
||||
current_sign_in_at: Field::DateTime,
|
||||
last_sign_in_at: Field::DateTime,
|
||||
@@ -32,7 +29,8 @@ class UserDashboard < Administrate::BaseDashboard
|
||||
tokens: Field::String.with_options(searchable: false),
|
||||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
pubsub_token: Field::String
|
||||
pubsub_token: Field::String,
|
||||
accounts: CountField
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
@@ -41,21 +39,25 @@ class UserDashboard < Administrate::BaseDashboard
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
id
|
||||
avatar_url
|
||||
name
|
||||
email
|
||||
accounts
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
accounts
|
||||
id
|
||||
avatar_url
|
||||
unconfirmed_email
|
||||
name
|
||||
nickname
|
||||
email
|
||||
created_at
|
||||
updated_at
|
||||
account_users
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
@@ -65,6 +67,7 @@ class UserDashboard < Administrate::BaseDashboard
|
||||
name
|
||||
nickname
|
||||
email
|
||||
password
|
||||
].freeze
|
||||
|
||||
# COLLECTION_FILTERS
|
||||
@@ -82,7 +85,7 @@ class UserDashboard < Administrate::BaseDashboard
|
||||
# Overwrite this method to customize how users are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
#
|
||||
# def display_resource(user)
|
||||
# "User ##{user.id}"
|
||||
# end
|
||||
def display_resource(user)
|
||||
"##{user.id} #{user.name}"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user