Feature: Rewamp super admin dashboard (#882)
This commit is contained in:
@@ -2,10 +2,32 @@ class SuperAdmin::AccountUsersController < SuperAdmin::ApplicationController
|
||||
# Overwrite any of the RESTful controller actions to implement custom behavior
|
||||
# For example, you may want to send an email after a foo is updated.
|
||||
#
|
||||
# def update
|
||||
# super
|
||||
# send_foo_updated_email(requested_resource)
|
||||
# end
|
||||
def create
|
||||
resource = resource_class.new(resource_params)
|
||||
authorize_resource(resource)
|
||||
|
||||
redirect_resource = params[:redirect_to] == 'user' ? resource.user : resource.account
|
||||
if resource.save
|
||||
redirect_to(
|
||||
[namespace, redirect_resource],
|
||||
notice: translate_with_resource('create.success')
|
||||
)
|
||||
else
|
||||
redirect_to(
|
||||
[namespace, redirect_resource],
|
||||
notice: resource.errors.full_messages.first
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if requested_resource.destroy
|
||||
flash[:notice] = translate_with_resource('destroy.success')
|
||||
else
|
||||
flash[:error] = requested_resource.errors.full_messages.join('<br/>')
|
||||
end
|
||||
redirect_to([namespace, requested_resource.account])
|
||||
end
|
||||
|
||||
# Override this method to specify custom lookup behavior.
|
||||
# This will be used to set the resource for the `show`, `edit`, and `update`
|
||||
|
||||
@@ -13,4 +13,11 @@ class SuperAdmin::ApplicationController < Administrate::ApplicationController
|
||||
# def records_per_page
|
||||
# params[:per_page] || 20
|
||||
# end
|
||||
|
||||
def order
|
||||
@order ||= Administrate::Order.new(
|
||||
params.fetch(resource_name, {}).fetch(:order, 'id'),
|
||||
params.fetch(resource_name, {}).fetch(:direction, 'desc')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
12
app/controllers/super_admin/dashboard_controller.rb
Normal file
12
app/controllers/super_admin/dashboard_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class SuperAdmin::DashboardController < SuperAdmin::ApplicationController
|
||||
include ActionView::Helpers::NumberHelper
|
||||
|
||||
def index
|
||||
@data = Conversation.unscoped.group_by_day(:created_at, range: 30.days.ago..2.seconds.ago).count.to_a
|
||||
@accounts_count = number_with_delimiter(Account.all.length)
|
||||
@users_count = number_with_delimiter(User.all.length)
|
||||
@inboxes_count = number_with_delimiter(Inbox.all.length)
|
||||
@conversations_count = number_with_delimiter(Conversation.all.length)
|
||||
@messages_count = number_with_delimiter(Message.all.length)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user