diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..2f973a61b55ac6c23142fba22e434e53d1ee0383 --- /dev/null +++ b/app/controllers/groups_controller.rb @@ -0,0 +1,2 @@ +class GroupsController < ApplicationController +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 330e9abea298468fcb95e3c24a321fea3996093f..8b1291954b3c3b8b0738ae35949e57ca4e43f10e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,4 +4,8 @@ class UsersController < ApplicationController def index @users = User.find :all, '*' end + + def show + @u = User.find :first, params[:id] + end end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 3c8a863f1f4d86bcfa2172565693f75db425782e..a56283d75b0f193fd65984cef94ba120455bfee6 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,7 +2,7 @@ %html %head %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ - %title Usermanager + %title UserManager = csrf_meta_tags = csp_meta_tag = stylesheet_link_tag 'application', media: 'all' diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 86db76854dd77745c4b118f6963bfe15d834f299..217d0bdf9a0fcdf714dc765ee3ab3f869c65867c 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -1,21 +1,26 @@ +%h1 User list +.btn-group + %a.btn.btn-primary{role: 'button', href: new_user_path} Create user %table.table.table-striped#dttb %caption List of users %thead %tr %th User ID - %th First Name - %th Last Name - %th Primary Group + %th Given name + %th Surame + %th Primary group %th Groups %th Status %tbody - @users.each do |u| %tr - %td= u.cn + %td= link_to u.cn, user_path(u) %td= u.givenname %td= u.sn - %td= u.primary_group.cn if u.primary_group.exists? - %td= u.groups.map {|g| g.cn}.join(', ') %td + - if u.primary_group.exists? + = link_to u.primary_group.cn, group_path(u.primary_group) + %td!= u.groups.map {|g| link_to g.cn, group_path(g)}.join(', ') + %td{class: u.active? ? 'table-success' : 'table-warning'} %span{class: [:fas, u.active? ? 'fa-check' : 'fa-lock'], aria: {hidden: :true}, title: u.active? ? 'Enabled' : 'Disabled'} %span.sr-only= u.active? ? 'Enabled' : 'Disabled' diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..55af8de0d651a4d6bb0281f3b70b4e7910685381 --- /dev/null +++ b/app/views/users/show.html.haml @@ -0,0 +1,35 @@ +%h1 User details +.btn-group + %a.btn.btn-danger{role: 'button'} Disable user + %a.btn.btn-primary{role: 'button'} Change group(s) +%table.table.table-hover + %tbody + %tr + %td User ID + %td= @u.cn + %tr + %td Given name + %td= @u.givenname + %tr + %td Surname + %td= @u.sn + %tr + %td Status + %td{class: @u.active? ? 'table-success' : 'table-warning'} + %span{class: [:fas, @u.active? ? 'fa-check' : 'fa-lock'], aria: {hidden: :true}, title: @u.active? ? 'Enabled' : 'Disabled'} + = @u.active? ? 'Enabled' : 'Disabled' + %tr + %td Primary group + - if @u.primary_group.exists? + %td= link_to @u.primary_group.cn, group_path(@u.primary_group) + - else + %td.table-warning No primary group + %tr + %td Groups + %td{class: @u.groups.empty? && 'table-warning'} + - if @u.groups.empty? + No groups + - else + %ul.list-group + - @u.groups.each do |g| + %li.list-group-item= link_to g.cn, group_path(g) diff --git a/config/routes.rb b/config/routes.rb index 5091501b3d1f633f969a5cec889cb1d469690105..f39bc031bc678bfdbbd4f773a49a55bb1a8b72fc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,4 +3,5 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html resources :users + resources :groups end diff --git a/test/controllers/groups_controller_test.rb b/test/controllers/groups_controller_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..23aba76b38190e6336fd1a9977703b5a20ec4cda --- /dev/null +++ b/test/controllers/groups_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class GroupsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end