Feature: Rewamp super admin dashboard (#882)

This commit is contained in:
Sojan Jose
2020-05-24 22:44:26 +05:30
committed by GitHub
parent e49a200ee0
commit d8d14fc4a4
63 changed files with 2190 additions and 79 deletions

View File

@@ -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`

View File

@@ -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

View 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