mirror of
https://github.com/System-End/highway.git
synced 2026-04-19 22:05:13 +00:00
Add admin dashboard
This commit is contained in:
parent
097e567042
commit
ff99f9df09
3 changed files with 35 additions and 0 deletions
19
site/app/controllers/admin_controller.rb
Normal file
19
site/app/controllers/admin_controller.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class AdminController < ApplicationController
|
||||
before_action :require_authentication
|
||||
before_action :authenticate_user
|
||||
|
||||
def dashboard
|
||||
@users = User.all
|
||||
@posts = Post.all
|
||||
@projects = Project.all
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def authenticate_user
|
||||
unless current_user && current_user.admin?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
10
site/app/views/admin/dashboard.html.erb
Normal file
10
site/app/views/admin/dashboard.html.erb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<h1 class="text-3xl font-bold mb-4">Admin Dashboard</h1>
|
||||
|
||||
<h1 class="text-2xl font-bold mb-4">Projects</h1>
|
||||
<%= (ap @projects).html_safe %>
|
||||
|
||||
<h1 class="text-2xl font-bold mb-4">Users</h1>
|
||||
<%= (ap @users).html_safe %>
|
||||
|
||||
<h1 class="text-2xl font-bold mb-4">Posts</h1>
|
||||
<%= (ap @posts).html_safe %>
|
||||
|
|
@ -20,6 +20,12 @@ Rails.application.routes.draw do
|
|||
get "/dashboard", to: "landing#dashboard", as: :dashboard
|
||||
get "/leaderboards", to: "landing#leaderboards", as: :leaderboards
|
||||
|
||||
resources :admin, only: [] do
|
||||
collection do
|
||||
get "/dashboard", to: "admin#dashboard", as: :dashboard
|
||||
end
|
||||
end
|
||||
|
||||
# otp auth + session
|
||||
# resources :sessions
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue