Compare commits
2 Commits
67689dcce3
...
8747ce4eb0
| Author | SHA1 | Date | |
|---|---|---|---|
|
8747ce4eb0
|
|||
|
fcda3b9c8c
|
@@ -2,13 +2,21 @@
|
|||||||
<div class="relative inline-block">
|
<div class="relative inline-block">
|
||||||
<div role="button" tabindex="0" data-dropdown-target="button"
|
<div role="button" tabindex="0" data-dropdown-target="button"
|
||||||
class="inline-block select-none">
|
class="inline-block select-none">
|
||||||
|
<% if @size == :large %>
|
||||||
<span class="appearance-none flex items-center inline-block">
|
<span class="appearance-none flex items-center inline-block">
|
||||||
<span class="p-2 bg-gray-50 hover:bg-gray-100 rounded-full">
|
<span class="p-2 bg-gray-50 hover:bg-gray-100 rounded-full">
|
||||||
<%= render partial: "icons/kebab-menu", locals: {
|
<%= render partial: "icons/#{@icon_name}",
|
||||||
custom_class: "inline text-gray-500 h-6 w-6"
|
locals: { custom_class: "inline text-gray-500 h-6 w-6" } %>
|
||||||
} %>
|
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
<% elsif @size == :small %>
|
||||||
|
<span class="appearance-none flex items-center inline-block">
|
||||||
|
<span class="text-gray-500 hover:text-blue-600">
|
||||||
|
<%= render partial: "icons/#{@icon_name}",
|
||||||
|
locals: { custom_class: "inline h-4 w-4" } %>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div data-dropdown-target="menu"
|
<div data-dropdown-target="menu"
|
||||||
data-transition-enter="transition ease-out duration-200"
|
data-transition-enter="transition ease-out duration-200"
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class DropdownComponent < ViewComponent::Base
|
class DropdownComponent < ViewComponent::Base
|
||||||
|
def initialize(size: :large, icon_name: "kebap-menu")
|
||||||
|
@size = size.to_sym
|
||||||
|
@icon_name = icon_name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ class Admin::UsersController < Admin::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
ldap = LdapService.new
|
ldap = LdapService.new
|
||||||
@ou = params[:ou] || Setting.primary_domain
|
@ou = Setting.primary_domain
|
||||||
@orgs = ldap.fetch_organizations
|
|
||||||
@pagy, @users = pagy(User.where(ou: @ou).order(cn: :asc))
|
@pagy, @users = pagy(User.where(ou: @ou).order(cn: :asc))
|
||||||
|
|
||||||
@stats = {
|
@stats = {
|
||||||
@@ -27,8 +26,8 @@ class Admin::UsersController < Admin::BaseController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def set_user
|
def set_user
|
||||||
address = params[:address].split("@")
|
@user = User.find_by(cn: params[:username], ou: Setting.primary_domain)
|
||||||
@user = User.where(cn: address.first, ou: address.last).first
|
http_status :not_found unless @user
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_current_section
|
def set_current_section
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= render HeaderComponent.new(title: "Users: #{@ou}") %>
|
<%= render HeaderComponent.new(title: "Users") %>
|
||||||
|
|
||||||
<%= render MainSimpleComponent.new do %>
|
<%= render MainSimpleComponent.new do %>
|
||||||
<section>
|
<section>
|
||||||
@@ -16,19 +16,6 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<% if @orgs.length > 1 %>
|
|
||||||
<section>
|
|
||||||
<h3 class="hidden">Domains</h3>
|
|
||||||
<ul>
|
|
||||||
<% @orgs.each do |org| %>
|
|
||||||
<li class="inline-block">
|
|
||||||
<%= link_to org[:ou], admin_users_path(ou: org[:ou]), class: "ks-text-link" %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<table class="divided mb-8">
|
<table class="divided mb-8">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -36,13 +23,12 @@
|
|||||||
<th>UID</th>
|
<th>UID</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Roles</th>
|
<th>Roles</th>
|
||||||
<!-- <th>Password</th> -->
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @users.each do |user| %>
|
<% @users.each do |user| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to(user.cn, admin_user_path(user.address), class: 'ks-text-link') %></td>
|
<td><%= link_to(user.cn, admin_user_path(user.cn), class: 'ks-text-link') %></td>
|
||||||
<td><%= user.confirmed_at.nil? ? badge("pending", :yellow) : "" %></td>
|
<td><%= user.confirmed_at.nil? ? badge("pending", :yellow) : "" %></td>
|
||||||
<td><%= user.is_admin? ? badge("admin", :red) : "" %></td>
|
<td><%= user.is_admin? ? badge("admin", :red) : "" %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= render HeaderComponent.new(title: "User: #{@user.address}") %>
|
<%= render HeaderComponent.new(title: "User: #{@user.cn}") %>
|
||||||
|
|
||||||
<%= render MainSimpleComponent.new do %>
|
<%= render MainSimpleComponent.new do %>
|
||||||
<div class="mb-12 sm:flex sm:flex-row sm:gap-x-8">
|
<div class="mb-12 sm:flex sm:flex-row sm:gap-x-8">
|
||||||
@@ -43,7 +43,26 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Invitations available</th>
|
<th>Invitations available</th>
|
||||||
<td>
|
<td>
|
||||||
<%= @user.invitations.count %>
|
<div class="flex justify-between">
|
||||||
|
<span>
|
||||||
|
<%= @user.invitations.count %>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<%= render DropdownComponent.new(size: :small, icon_name: "edit") do %>
|
||||||
|
<%= render DropdownLinkComponent.new(
|
||||||
|
href: ""
|
||||||
|
) do %>
|
||||||
|
Add more
|
||||||
|
<% end %>
|
||||||
|
<%= render DropdownLinkComponent.new(
|
||||||
|
href: "",
|
||||||
|
separator: true, add_class: "text-red-700"
|
||||||
|
) do %>
|
||||||
|
Remove all
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -73,9 +73,14 @@ Rails.application.routes.draw do
|
|||||||
namespace :admin do
|
namespace :admin do
|
||||||
root to: 'dashboard#index'
|
root to: 'dashboard#index'
|
||||||
|
|
||||||
resources 'users', param: 'address', only: ['index', 'show'], constraints: { address: /.*/ }
|
resources 'users', param: 'username', only: ['index', 'show'] do
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
get 'invitations', to: 'invitations#index'
|
get 'invitations', to: 'invitations#index'
|
||||||
|
|
||||||
resources :donations
|
resources :donations
|
||||||
|
|
||||||
get 'lightning', to: 'lightning#index'
|
get 'lightning', to: 'lightning#index'
|
||||||
|
|
||||||
namespace :app_catalog do
|
namespace :app_catalog do
|
||||||
|
|||||||
Reference in New Issue
Block a user