-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(users): Adds ability to view all users and admins (#216)
* feat(users): Adds ability to view all users and admins refactor(admins): Moves hard-coded strings to en.yml * style(users): Removes whitespace for style Co-authored-by: Peter Kos <pkos91@icloud.com>
- Loading branch information
1 parent
1a31861
commit c119c9a
Showing
20 changed files
with
302 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class UserDatatable < ApplicationDatatable | ||
def_delegators :@view, :link_to, :manage_user_path, :manage_questionnaire_path, :bold, :display_datetime | ||
|
||
def view_columns | ||
@view_columns ||= { | ||
id: { source: "User.id" }, | ||
email: { source: "User.email" }, | ||
role: { source: "User.role", searchable: false }, | ||
active: { source: "User.is_active", searchable: false }, | ||
created_at: { source: "User.created_at", searchable: false }, | ||
current_sign_in_at: { source: "User.current_sign_in_at", searchable: false }, | ||
last_sign_in_at: { source: "User.last_sign_in_at", searchable: false }, | ||
current_sign_in_ip: { source: "User.current_sign_in_ip" }, | ||
last_sign_in_ip: { source: "User.last_sign_in_ip" }, | ||
sign_in_count: { source: "User.sign_in_count", searchable: false }, | ||
} | ||
end | ||
|
||
private | ||
|
||
def data | ||
records.map do |record| | ||
{ | ||
id: record.id, | ||
email: link_to(bold(record.email), manage_user_path(record)), | ||
role: record.role.titleize, | ||
questionnaire: record.questionnaire.present? ? link_to(bold("View »".html_safe), manage_questionnaire_path(record.questionnaire.id)) : 'None', | ||
active: record.is_active ? '<span class="badge badge-secondary">Active</span>'.html_safe : '<span class="badge badge-danger">Inactive<span>'.html_safe, | ||
created_at: display_datetime(record.created_at), | ||
current_sign_in_at: display_datetime(record.current_sign_in_at), | ||
last_sign_in_at: display_datetime(record.last_sign_in_at), | ||
current_sign_in_ip: record.current_sign_in_ip == "::1" ? "127.0.0.1" : record.current_sign_in_ip, | ||
last_sign_in_ip: record.last_sign_in_ip == "::1" ? "127.0.0.1" : record.last_sign_in_ip, | ||
sign_in_count: record.sign_in_count, | ||
} | ||
end | ||
end | ||
|
||
def get_raw_records | ||
User.all | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.form-container | ||
= bs_horizontal_simple_form_for @user, url: url_for(action: "update", controller: "users"), html: { "data-validate" => "form" } do |f| | ||
|
||
- if f.error_notification.present? | ||
#disclaimer | ||
= f.error_notification | ||
|
||
.form-inputs | ||
= f.input :email, input_html: { "data-validate" => "presence" }, required: true | ||
= f.input :role, collection: User.roles.to_a.collect{|c| [c[0].titleize, c[0]]}, include_blank: false | ||
= f.input :is_active, collection: [[t(:active, scope: "pages.manage.users.edit.form"), true], [t(:inactive, scope: "pages.manage.users.edit.form"), false]], as: :radio_buttons | ||
= f.input :receive_weekly_report, collection: [[t(:yes, scope: "pages.manage.users.edit.form"), true], [t(:no, scope: "pages.manage.users.edit.form"), false]], as: :radio_buttons | ||
|
||
.center | ||
= f.button :submit, value: ( t(:save, scope: "pages.manage.users.edit.form") ), class: 'btn-primary' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
= render "layouts/manage/page_title", title: t(:title, scope: "pages.manage.users.edit", user_email: @user.email), subtitle: @user.email do | ||
.btn-group | ||
= link_to t(:cancel, scope: "pages.manage.users.edit"), manage_user_path(@user), class: 'btn btn-sm btn-outline-secondary' | ||
= link_to t(:delete, scope: "pages.manage.users.edit"), manage_user_path(@user), method: :delete, data: { confirm: "Are you sure? #{@user.email} will be permanently deleted. This action is irreversible." }, class: 'btn btn-sm btn-outline-secondary' | ||
|
||
= render 'form' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
= render "layouts/manage/page_title", title: t(:title, scope: 'pages.manage.users') | ||
|
||
.row | ||
.col | ||
%h5.dashboard-container-title | ||
= t(:users, scope: 'pages.manage.users') | ||
%table.users.datatable.table.table-striped.table-hover{ "data-source" => user_datatable_manage_users_path(format: :json) } | ||
%thead | ||
%tr | ||
%th= t(:id, scope: 'pages.manage.users.table') | ||
%th= t(:email, scope: 'pages.manage.users.table') | ||
%th= t(:role, scope: 'pages.manage.users.table') | ||
%th= t(:questionnaire, scope: 'pages.manage.users.table') | ||
%th= t(:login_access, scope: 'pages.manage.users.table') | ||
%th= t(:registered_on, scope: 'pages.manage.users.table') | ||
%th= t(:signed_in_on, scope: 'pages.manage.users.table') | ||
%th= t(:previous_signed_in_on, scope: 'pages.manage.users.table') | ||
%th= t(:signed_in_ip, scope: 'pages.manage.users.table') | ||
%th= t(:previous_signed_in_ip, scope: 'pages.manage.users.table') | ||
%th= t(:sign_in_count, scope: 'pages.manage.users.table') | ||
%tbody | ||
.row | ||
.col | ||
%h5.dashboard-container-title | ||
= t(:staff, scope: 'pages.manage.users', hackathon_name: HackathonConfig['name']) | ||
%table.admins.datatable.table.table-striped.table-hover{ "data-source" => admin_datatable_manage_users_path(format: :json) } | ||
%thead | ||
%tr | ||
%th= t(:id, scope: 'pages.manage.users.table') | ||
%th= t(:email, scope: 'pages.manage.users.table') | ||
%th= t(:role, scope: 'pages.manage.users.table') | ||
%th= t(:login_access, scope: 'pages.manage.users.table') | ||
%th= t(:weekly_report, scope: 'pages.manage.users.table') | ||
%th= t(:registered_on, scope: 'pages.manage.users.table') | ||
%th= t(:signed_in_on, scope: 'pages.manage.users.table') | ||
%th= t(:previous_signed_in_on, scope: 'pages.manage.users.table') | ||
%th= t(:signed_in_ip, scope: 'pages.manage.users.table') | ||
%th= t(:previous_signed_in_ip, scope: 'pages.manage.users.table') | ||
%th= t(:sign_in_count, scope: 'pages.manage.users.table') | ||
%tbody |
Oops, something went wrong.