Skip to content

Commit

Permalink
Add system info.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Jan 20, 2025
1 parent fe72bbc commit 5808187
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 14 deletions.
9 changes: 9 additions & 0 deletions app/controllers/system_info_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class SystemInfoController < ApplicationController
before_action :authenticate_user!
after_action :verify_authorized

def show
authorize :SystemInfo

end
end
5 changes: 5 additions & 0 deletions app/policies/system_info_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class SystemInfoPolicy < ApplicationPolicy
def show?
user&.admin?
end
end
14 changes: 0 additions & 14 deletions app/views/employees/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,8 @@
<div class="col-md-12">
<div class="tile">
<div class="tile-body">
<table id="users-datatable" class="table table-hover table-bordered" data-source="<%= employees_path(format: :json) -%>">
<thead>
<tr>
<th>ID</th>
<th><%= t('user.username') -%></th>
<th><%= t('user.email') -%></th>
<th><%= t('ui.admin_action') -%></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</main>

<div id="employee-modal" class="modal" tabindex="-1" role="dialog"></div>
5 changes: 5 additions & 0 deletions app/views/shared/_sidebar_menu.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
</li>
</ul>
</li>
<li>
<%= link_to system_info_path, class: "app-menu__item #{params[:controller] == 'system_info' && params[:action] == 'show' ? 'active' : ''}" do %>
<i class="app-menu__icon fa fa-microchip"></i><span class="app-menu__label"><%= t('ui.system_info') -%></span>
<% end %>
</li>
<% end -%>
<% allow_department_index = policy(Department).index? %>
<% allow_position_index = policy(Position).index? %>
Expand Down
19 changes: 19 additions & 0 deletions app/views/system_info/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<main class="app-content">
<div class="app-title">
<div>
<h1><i class="fa fa-dashboard"></i> <%= t('ui.system_info') -%></h1>
</div>
<ul class="app-breadcrumb breadcrumb">
<li class="breadcrumb-item"><i class="fa fa-microchip fa-lg"></i></li>
<li class="breadcrumb-item"><a href="<%= system_info_path -%>"><%= t('ui.system_info') -%></a></li>
</ul>
</div>
<div class="row">
<div class="col-md-12">
<div class="tile">
<div class="tile-body">
</div>
</div>
</div>
</div>
</main>
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ en:
can_grant_applications: "Applications can grant to access"
can_not_grant_applications: "Can not grant applications to access"
allow_access: "Allow Access"
system_info: "System Info"
system_administrator: "System Administrator"
settings: "Settings"
profile: "Profile"
Expand Down
1 change: 1 addition & 0 deletions config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ zh-CN:
can_grant_applications: "可以授予访问权限的应用程序"
can_not_grant_applications: "无法授予应用程序访问权限"
allow_access: "允许访问"
system_info: "系统信息"
system_administrator: "系统管理员"
settings: "设置"
profile: "详细资料"
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
get :report
end
end
resource :system_info, controller: 'system_info', only: [:show]

resource :setting, only: :update do
member do
Expand Down

0 comments on commit 5808187

Please sign in to comment.