Add admin layout with admin navigation
And remove the hacky link list from the dashboard.
This commit is contained in:
parent
9ddd36c414
commit
2bdf08a523
@ -6,5 +6,8 @@ $text-color-discreet: #888;
|
|||||||
|
|
||||||
$background-color-notice: #efffc4;
|
$background-color-notice: #efffc4;
|
||||||
$background-color-alert: #fff4c2;
|
$background-color-alert: #fff4c2;
|
||||||
|
|
||||||
$color-blue: #0d4f99;
|
$color-blue: #0d4f99;
|
||||||
$color-purple: #8955a0;
|
$color-purple: #8955a0;
|
||||||
|
$color-red-bright: #c00;
|
||||||
|
$color-red-dark: #990c0e;
|
||||||
|
22
app/assets/stylesheets/admin.scss
Normal file
22
app/assets/stylesheets/admin.scss
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
@import "variables";
|
||||||
|
|
||||||
|
body#admin-panel {
|
||||||
|
#wrapper {
|
||||||
|
> header {
|
||||||
|
background: $color-red-bright;
|
||||||
|
background: linear-gradient(35deg, $color-purple 0, $color-red-dark 100%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#main-nav {
|
||||||
|
ul {
|
||||||
|
li {
|
||||||
|
a {
|
||||||
|
&.active {
|
||||||
|
border-bottom: 2px solid $color-red-bright;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -170,3 +170,7 @@ main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-centered {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
@ -3,4 +3,6 @@ class Admin::BaseController < ApplicationController
|
|||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
before_action :authorize_admin
|
before_action :authorize_admin
|
||||||
|
|
||||||
|
layout "admin"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class Admin::DashboardController < Admin::BaseController
|
class Admin::DashboardController < Admin::BaseController
|
||||||
def index
|
def index
|
||||||
|
@current_section = :dashboard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
class Admin::DonationsController < Admin::BaseController
|
class Admin::DonationsController < Admin::BaseController
|
||||||
before_action :set_donation, only: [:show, :edit, :update, :destroy]
|
before_action :set_donation, only: [:show, :edit, :update, :destroy]
|
||||||
|
before_action :set_current_section, only: [:index, :show, :new, :edit]
|
||||||
|
|
||||||
# GET /donations
|
# GET /donations
|
||||||
# GET /donations.json
|
# GET /donations.json
|
||||||
@ -71,4 +72,8 @@ class Admin::DonationsController < Admin::BaseController
|
|||||||
def donation_params
|
def donation_params
|
||||||
params.require(:donation).permit(:user_id, :amount_sats, :amount_eur, :amount_usd, :public_name, :paid_at)
|
params.require(:donation).permit(:user_id, :amount_sats, :amount_eur, :amount_usd, :public_name, :paid_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_current_section
|
||||||
|
@current_section = :donations
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
class Admin::LdapUsersController < Admin::BaseController
|
class Admin::LdapUsersController < Admin::BaseController
|
||||||
|
before_action :set_current_section
|
||||||
|
|
||||||
def index
|
def index
|
||||||
attributes = %w{dn cn uid mail admin}
|
attributes = %w{dn cn uid mail admin}
|
||||||
filter = Net::LDAP::Filter.eq("uid", "*")
|
filter = Net::LDAP::Filter.eq("uid", "*")
|
||||||
@ -38,4 +40,8 @@ class Admin::LdapUsersController < Admin::BaseController
|
|||||||
def ldap_config
|
def ldap_config
|
||||||
ldap_config ||= YAML.load(ERB.new(File.read("#{Rails.root}/config/ldap.yml")).result)[Rails.env]
|
ldap_config ||= YAML.load(ERB.new(File.read("#{Rails.root}/config/ldap.yml")).result)[Rails.env]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_current_section
|
||||||
|
@current_section = :ldap_users
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,6 +2,6 @@ class DashboardController < ApplicationController
|
|||||||
before_action :require_user_signed_in
|
before_action :require_user_signed_in
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@current_section = "dashboard"
|
@current_section = :dashboard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,6 @@ class DonationsController < ApplicationController
|
|||||||
# GET /donations.json
|
# GET /donations.json
|
||||||
def index
|
def index
|
||||||
@donations = current_user.donations.completed
|
@donations = current_user.donations.completed
|
||||||
@current_section = "contributions"
|
@current_section = :contributions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,7 @@ class InvitationsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@invitations_unused = current_user.invitations.unused
|
@invitations_unused = current_user.invitations.unused
|
||||||
@invitations_used = current_user.invitations.used
|
@invitations_used = current_user.invitations.used
|
||||||
@current_section = "invitations"
|
@current_section = :invitations
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /invitations/a-random-invitation-token
|
# GET /invitations/a-random-invitation-token
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
<h2>Admin Panel</h2>
|
<p class="text-centered">
|
||||||
<p>
|
With great power comes great responsibility.
|
||||||
Ohai there, admin human.
|
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
|
||||||
<li><%= link_to 'LDAP users', admin_ldap_users_path %></li>
|
|
||||||
<li><%= link_to 'Donations', admin_donations_path %></li>
|
|
||||||
</ul>
|
|
||||||
|
45
app/views/layouts/admin.html.erb
Normal file
45
app/views/layouts/admin.html.erb
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Admin Panel | Kosmos Accounts</title>
|
||||||
|
<%= csrf_meta_tags %>
|
||||||
|
<%= csp_meta_tag %>
|
||||||
|
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||||
|
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body id="admin-panel">
|
||||||
|
<div id="wrapper">
|
||||||
|
<header>
|
||||||
|
<h1>
|
||||||
|
<span class ="project-name">Kosmos</span>
|
||||||
|
<span class ="site-name">Akkounts</span>
|
||||||
|
<span class="beta"><span class="bolt">⚡</span> beta</span>
|
||||||
|
</h1>
|
||||||
|
<% if user_signed_in? %>
|
||||||
|
<p class="current-user">
|
||||||
|
Signed in as <strong><%= current_user.cn %>@kosmos.org</strong>.
|
||||||
|
<%= link_to "Log out", destroy_user_session_path, method: :delete %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<% if user_signed_in? && current_user.confirmed? %>
|
||||||
|
<%= render partial: 'shared/admin_nav' %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% flash.each do |type, msg| %>
|
||||||
|
<div class="flash-msg <%= type %>">
|
||||||
|
<p><%= msg %></p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<%= yield %>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
18
app/views/shared/_admin_nav.html.erb
Normal file
18
app/views/shared/_admin_nav.html.erb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<nav id="main-nav">
|
||||||
|
<div class="wrapper">
|
||||||
|
<ul class="pages">
|
||||||
|
<li>
|
||||||
|
<%= link_to "Dashboard", admin_root_path,
|
||||||
|
class: @current_section == :dashboard ? "active" : nil %>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<%= link_to "Donations", admin_donations_path,
|
||||||
|
class: @current_section == :donations ? "active" : nil %>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<%= link_to "LDAP Users", admin_ldap_users_path,
|
||||||
|
class: @current_section == :ldap_users ? "active" : nil %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
@ -3,15 +3,15 @@
|
|||||||
<ul class="pages">
|
<ul class="pages">
|
||||||
<li>
|
<li>
|
||||||
<%= link_to "Services", root_path,
|
<%= link_to "Services", root_path,
|
||||||
class: @current_section == "dashboard" ? "active" : nil %>
|
class: @current_section == :dashboard ? "active" : nil %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to "Donations", donations_path,
|
<%= link_to "Donations", donations_path,
|
||||||
class: @current_section == "contributions" ? "active" : nil %>
|
class: @current_section == :contributions ? "active" : nil %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to "Invitations", invitations_path,
|
<%= link_to "Invitations", invitations_path,
|
||||||
class: @current_section == "invitations" ? "active" : nil %>
|
class: @current_section == :invitations ? "active" : nil %>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user