diff --git a/Gemfile b/Gemfile index d885523..cd6bb7b 100644 --- a/Gemfile +++ b/Gemfile @@ -93,3 +93,7 @@ gem "view_component", "~> 3.7" gem "dry-initializer-rails" gem "dry-types", "~> 1.7" + +# Avo admin +gem "avo", ">= 3.2" +gem "ransack", "~> 4.1" diff --git a/Gemfile.lock b/Gemfile.lock index 2bc6455..8c69c30 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,6 +62,9 @@ GEM erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) + active_link_to (1.0.5) + actionpack + addressable activejob (7.1.2) activesupport (= 7.1.2) globalid (>= 0.3.6) @@ -94,6 +97,22 @@ GEM rake (>= 10.4, < 14.0) ast (2.4.2) authentication-zero (3.0.2) + avo (3.3.0) + actionview (>= 6.1) + active_link_to + activerecord (>= 6.1) + activesupport (>= 6.1) + addressable + docile + dry-initializer + httparty + inline_svg + meta-tags + pagy + turbo-rails + turbo_power (>= 0.6.0) + view_component (>= 3.7.0) + zeitwerk (>= 2.6.12) base64 (0.2.0) bcrypt (3.1.20) bcrypt_pbkdf (1.1.0) @@ -132,6 +151,7 @@ GEM irb (~> 1.10) reline (>= 0.3.8) debug_inspector (1.2.0) + docile (1.4.0) dotenv (2.8.1) drb (2.2.0) ruby2_keywords @@ -174,6 +194,9 @@ GEM actioncable (>= 6.0.0) listen (>= 3.0.0) railties (>= 6.0.0) + httparty (0.21.0) + mini_mime (>= 1.0.0) + multi_xml (>= 0.5.2) i18n (1.14.1) concurrent-ruby (~> 1.0) i18n-tasks (1.0.13) @@ -190,6 +213,9 @@ GEM i18n_generators (2.2.2) activerecord (>= 3.0.0) railties (>= 3.0.0) + inline_svg (1.9.0) + activesupport (>= 3.0) + nokogiri (>= 1.6) io-console (0.7.1) irb (1.11.1) rdoc @@ -230,10 +256,13 @@ GEM net-smtp marcel (1.0.2) matrix (0.4.2) + meta-tags (2.20.0) + actionpack (>= 6.0.0, < 7.2) method_source (1.0.0) mini_mime (1.1.5) minitest (5.20.0) msgpack (1.7.2) + multi_xml (0.6.0) mutex_m (0.2.0) net-imap (0.4.9.1) date @@ -262,6 +291,7 @@ GEM racc (~> 1.4) nokogiri (1.16.0-x86_64-linux) racc (~> 1.4) + pagy (6.4.1) parallel (1.24.0) parser (3.3.0.2) ast (~> 2.4.1) @@ -326,6 +356,10 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.1.0) + ransack (4.1.1) + activerecord (>= 6.1.5) + activesupport (>= 6.1.5) + i18n rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) @@ -410,6 +444,8 @@ GEM actionpack (>= 6.0.0) activejob (>= 6.0.0) railties (>= 6.0.0) + turbo_power (0.6.1) + turbo-rails (>= 1.3.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) @@ -442,6 +478,7 @@ PLATFORMS DEPENDENCIES annotate authentication-zero (~> 3.0) + avo (>= 3.2) bcrypt (~> 3.1.7) bootsnap byebug @@ -463,6 +500,7 @@ DEPENDENCIES propshaft puma (>= 5.0) rails (~> 7.1.1) + ransack (~> 4.1) redis (>= 4.0.1) ruby-lsp ruby-lsp-rails diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index 69f12e1..5a80a42 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -2,4 +2,5 @@ @import "tailwindcss/components"; @import "tailwindcss/utilities"; +@import "reset"; @import "components/typography"; diff --git a/app/assets/stylesheets/reset.css b/app/assets/stylesheets/reset.css new file mode 100644 index 0000000..f93d2d2 --- /dev/null +++ b/app/assets/stylesheets/reset.css @@ -0,0 +1,22 @@ +/* from https://x.com/souporserious/status/1746311121949356469?s=20 */ + +* { + box-sizing: border-box; + position: relative; + min-width: 0; +} + +body { + min-height: 100dvh; +} + +h1, +h2, +h3, +h4 { + text-wrap: balance; +} + +p { + text-wrap: pretty; +} diff --git a/app/avo/resources/session.rb b/app/avo/resources/session.rb new file mode 100644 index 0000000..2f0cfc5 --- /dev/null +++ b/app/avo/resources/session.rb @@ -0,0 +1,14 @@ +class Avo::Resources::Session < Avo::BaseResource + self.includes = [] + # self.search = { + # query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) } + # } + + def fields + field :id, as: :id + field :user, as: :belongs_to + field :user_id, as: :number + field :user_agent, as: :text, hide_on: [:index] + field :ip_address, as: :text, hide_on: [:index] + end +end diff --git a/app/avo/resources/user.rb b/app/avo/resources/user.rb new file mode 100644 index 0000000..56a5b48 --- /dev/null +++ b/app/avo/resources/user.rb @@ -0,0 +1,17 @@ +class Avo::Resources::User < Avo::BaseResource + self.title = :admin_title + self.includes = [] + self.search = { + query: -> { query.ransack(email_cont: params[:q], id_eq: params[:q], m: "or").result(distinct: true) } + } + + def fields + field :id, as: :id, link_to_record: true + field :email, as: :text, link_to_record: true + field :first_name, as: :text + field :last_name, as: :text + field :admin, as: :boolean, link_to_record: true + field :verified, as: :boolean, hide_on: [:index] + field :sessions, as: :has_many + end +end diff --git a/app/components/ui/dropdown_component.html.erb b/app/components/ui/dropdown_component.html.erb index 467db05..9d0d1de 100644 --- a/app/components/ui/dropdown_component.html.erb +++ b/app/components/ui/dropdown_component.html.erb @@ -1,5 +1,5 @@ <%= content_tag :details, class: classes, **attributes do %> - + <% if toggle_open? && toggle_close? %>
<%= toggle_open %>
diff --git a/app/controllers/avo/sessions_controller.rb b/app/controllers/avo/sessions_controller.rb new file mode 100644 index 0000000..3a7b165 --- /dev/null +++ b/app/controllers/avo/sessions_controller.rb @@ -0,0 +1,4 @@ +# This controller has been generated to enable Rails' resource routes. +# More information on https://docs.avohq.io/2.0/controllers.html +class Avo::SessionsController < Avo::ResourcesController +end diff --git a/app/controllers/avo/users_controller.rb b/app/controllers/avo/users_controller.rb new file mode 100644 index 0000000..774b502 --- /dev/null +++ b/app/controllers/avo/users_controller.rb @@ -0,0 +1,4 @@ +# This controller has been generated to enable Rails' resource routes. +# More information on https://docs.avohq.io/2.0/controllers.html +class Avo::UsersController < Avo::ResourcesController +end diff --git a/app/views/shared/_authenticated.html.erb b/app/views/shared/_authenticated.html.erb index 5d5b43a..f8c2a17 100644 --- a/app/views/shared/_authenticated.html.erb +++ b/app/views/shared/_authenticated.html.erb @@ -10,9 +10,9 @@