diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
new file mode 100644
index 0000000..ef99f6e
--- /dev/null
+++ b/app/controllers/admin/users_controller.rb
@@ -0,0 +1,29 @@
+class Admin::UsersController < ApplicationController
+ before_action :authorize!
+ before_action :set_user, only: [ :show, :edit ]
+
+ def index
+ @users = User.all.order(:lastname, :firstname)
+ end
+
+ def edit
+ end
+
+ def show
+ end
+
+ def new
+ end
+
+ def create
+ end
+
+ def update
+ end
+
+ private
+
+ def set_user
+ @user = User.find(params[:id])
+ end
+end
diff --git a/app/helpers/admin/users_helper.rb b/app/helpers/admin/users_helper.rb
new file mode 100644
index 0000000..5995c2a
--- /dev/null
+++ b/app/helpers/admin/users_helper.rb
@@ -0,0 +1,2 @@
+module Admin::UsersHelper
+end
diff --git a/app/policies/admin/user_policy.rb b/app/policies/admin/user_policy.rb
new file mode 100644
index 0000000..5738f78
--- /dev/null
+++ b/app/policies/admin/user_policy.rb
@@ -0,0 +1,4 @@
+class Admin::UserPolicy < ApplicationPolicy
+ def index
+ end
+end
diff --git a/app/views/admin/users/_user.html.erb b/app/views/admin/users/_user.html.erb
new file mode 100644
index 0000000..36b7d01
--- /dev/null
+++ b/app/views/admin/users/_user.html.erb
@@ -0,0 +1,11 @@
+
+ <%= icon "user", class: "size-10" %>
+
+ <%= user.name %>
+ <%= user.role %>
+
+
<%= user.email %>
+
E-Mail Verifiziert:
+ <%= icon bool_icon(user.verified), class: "icon #{user.verified ? "text-green-600" : "text-red-600"}" %>
+
<%= user.created_at %>
+
diff --git a/app/views/admin/users/_user_tr.html.erb b/app/views/admin/users/_user_tr.html.erb
new file mode 100644
index 0000000..6aed004
--- /dev/null
+++ b/app/views/admin/users/_user_tr.html.erb
@@ -0,0 +1,34 @@
+<%= turbo_frame_tag dom_id(user) do %>
+
+ |
+ <%= link_to admin_user_path(user) do %>
+
+ <%= user.id %>
+
+ <% end %>
+ |
+
+ <%= user.name %>
+ |
+
+ <%= icon bool_icon(user.verified), class: "icon #{user.verified ? "text-green-600" : "text-red-600"}", title: "E-Mail-Adresse verifiziert" %>
+ <%= user.email %>
+ |
+
+
+ <%= user.role %>
+
+ |
+
+ <%= link_to do %>
+ User
+ <% end unless user.user? %>
+ <%= link_to do %>
+ Operator
+ <% end unless user.operator? %>
+ <%= link_to do %>
+ Admin
+ <% end unless user.admin? %>
+ |
+
+<% end %>
diff --git a/app/views/admin/users/create.html.erb b/app/views/admin/users/create.html.erb
new file mode 100644
index 0000000..f34ca11
--- /dev/null
+++ b/app/views/admin/users/create.html.erb
@@ -0,0 +1,4 @@
+
+
Admin::Users#create
+
Find me in app/views/admin/users/create.html.erb
+
diff --git a/app/views/admin/users/edit.html.erb b/app/views/admin/users/edit.html.erb
new file mode 100644
index 0000000..d3cce1e
--- /dev/null
+++ b/app/views/admin/users/edit.html.erb
@@ -0,0 +1,4 @@
+
+
Admin::Users#edit
+
Find me in app/views/admin/users/edit.html.erb
+
diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb
new file mode 100644
index 0000000..dc99bb6
--- /dev/null
+++ b/app/views/admin/users/index.html.erb
@@ -0,0 +1,23 @@
+
+ <% content_for :title, "Current Print Jobs" %>
+
+
Benutzerliste
+ <%= link_to "Filter", "#", class: "px-3 py-2 bg-hsrm-red drop-shadow-lg transition-colors hover:bg-hsrm-red-light text-white block font-medium" %>
+
+
+
+
+
+ | ID |
+ Name |
+ E-Mail-Adresse |
+ Rolle |
+ Rolle ändern zu |
+
+
+
+ <%= render partial: "user_tr", collection: @users, as: :user %>
+
+
+
+
diff --git a/app/views/admin/users/new.html.erb b/app/views/admin/users/new.html.erb
new file mode 100644
index 0000000..593c8c1
--- /dev/null
+++ b/app/views/admin/users/new.html.erb
@@ -0,0 +1,4 @@
+
+
Admin::Users#new
+
Find me in app/views/admin/users/new.html.erb
+
diff --git a/app/views/admin/users/show.html.erb b/app/views/admin/users/show.html.erb
new file mode 100644
index 0000000..cb702dc
--- /dev/null
+++ b/app/views/admin/users/show.html.erb
@@ -0,0 +1,33 @@
+
+
Benutzer Details
+ <%= render partial: 'user', locals: { user: @user } %>
+
+Some Stats:
+
+ - Druckaufträge insgesammt: <%= @user.jobs_as_costumer.count %>
+ - davon abgebrochen: <%= @user.jobs_as_costumer.canceled.count %>
+ - letzten 5 Druckaufträge
+
+
+
+
+
+
+ | ID |
+ Vorschau |
+ Auftraggeber |
+ PDF |
+ A0 |
+ A1 |
+ A2 |
+ A3 |
+ no DIN |
+ Kosten |
+ Status |
+
+
+
+ <%= render partial: "jobs/job_tr", collection: @user.jobs_as_costumer.limit(5), as: :job, locals: { no_actions: true } %>
+
+
+
diff --git a/app/views/admin/users/update.html.erb b/app/views/admin/users/update.html.erb
new file mode 100644
index 0000000..6fb3919
--- /dev/null
+++ b/app/views/admin/users/update.html.erb
@@ -0,0 +1,4 @@
+
+
Admin::Users#update
+
Find me in app/views/admin/users/update.html.erb
+
diff --git a/app/views/jobs/_job_tr.html.erb b/app/views/jobs/_job_tr.html.erb
index 0471d2c..d14dccc 100644
--- a/app/views/jobs/_job_tr.html.erb
+++ b/app/views/jobs/_job_tr.html.erb
@@ -53,15 +53,17 @@
<%= job.status %>
-
- <% # TODO: Refactor to helper function %>
- <% if defined?(no_turbo_stream) && no_turbo_stream %>
- <%= turbo_frame_tag dom_id(job, :cancel_button) do %>
- <%= render partial: "jobs/cancel_button", locals: { job: job } %>
- <% end %>
- <% else %>
- <%= turbo_frame_tag dom_id(job, :cancel_button), src: cancel_button_job_path(job), loading: 'lazy' do %>
- <%= icon("ellipsis-horizontal-circle", class: "icon icon-disabled size-10", title: "Loading...") %>
+ <% unless defined?(no_actions) && no_actions %>
+ |
+ <% # TODO: Refactor to helper function %>
+ <% if defined?(no_turbo_stream) && no_turbo_stream %>
+ <%= turbo_frame_tag dom_id(job, :cancel_button) do %>
+ <%= render partial: "jobs/cancel_button", locals: { job: job } %>
+ <% end %>
+ <% else %>
+ <%= turbo_frame_tag dom_id(job, :cancel_button), src: cancel_button_job_path(job), loading: 'lazy' do %>
+ <%= icon("ellipsis-horizontal-circle", class: "icon icon-disabled size-10", title: "Loading...") %>
+ <% end %>
<% end %>
<% end %>
|
diff --git a/config/routes.rb b/config/routes.rb
index 3f29325..a0c9492 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -18,7 +18,7 @@ Rails.application.routes.draw do
end
resource :profile, only: [ :show, :edit, :destroy ]
namespace :admin do
- resources :users
+ resources :users, only: [ :index, :show ]
resources :jobs
resource :dashboard, only: [ :show ]
end
diff --git a/config/tailwind.config.js b/config/tailwind.config.js
index 6d37afe..9c4a323 100644
--- a/config/tailwind.config.js
+++ b/config/tailwind.config.js
@@ -29,6 +29,12 @@ module.exports = {
"status-paid-light": "#86efac", // green-300
"status-canceled": "#7f1d1d", // red-900
"status-canceled-light": "#fca5a5", // red-300
+ "role-user": "#14532d", // green
+ "role-user-light": "#86efac",
+ "role-operator": "#713f12", // yellow
+ "role-operator-light": "#fde047",
+ "role-admin": "#7f1d1d", // red
+ "role-admin-light": "#fca5a5",
},
},
},
@@ -48,6 +54,12 @@ module.exports = {
"text-status-canceled",
"bg-status-canceled-light",
"border-status-canceled-light",
+ "text-role-user",
+ "bg-role-user-light",
+ "text-role-operator",
+ "bg-role-operator-light",
+ "text-role-admin",
+ "bg-role-admin-light",
],
plugins: [
require("@tailwindcss/forms"),
diff --git a/test/controllers/admin/users_controller_test.rb b/test/controllers/admin/users_controller_test.rb
new file mode 100644
index 0000000..6173b2a
--- /dev/null
+++ b/test/controllers/admin/users_controller_test.rb
@@ -0,0 +1,33 @@
+require "test_helper"
+
+class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
+ test "should get index" do
+ get admin_users_index_url
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get admin_users_edit_url
+ assert_response :success
+ end
+
+ test "should get show" do
+ get admin_users_show_url
+ assert_response :success
+ end
+
+ test "should get new" do
+ get admin_users_new_url
+ assert_response :success
+ end
+
+ test "should get create" do
+ get admin_users_create_url
+ assert_response :success
+ end
+
+ test "should get update" do
+ get admin_users_update_url
+ assert_response :success
+ end
+end
diff --git a/test/policies/admin/user_policy_test.rb b/test/policies/admin/user_policy_test.rb
new file mode 100644
index 0000000..0bd74c0
--- /dev/null
+++ b/test/policies/admin/user_policy_test.rb
@@ -0,0 +1,13 @@
+require "test_helper"
+
+# See https://actionpolicy.evilmartians.io/#/testing?id=testing-policies
+class Admin::UserPolicyTest < ActiveSupport::TestCase
+ def test_index
+ end
+
+ def test_create
+ end
+
+ def test_manage
+ end
+end