Mattias Bodlund 1 year ago
parent
commit
999772b2b5
5 changed files with 86 additions and 58 deletions
  1. +63
    -57
      Gemfile.lock
  2. +8
    -0
      app/controllers/admin/admin_controller.rb
  3. +1
    -0
      app/views/admin/admin/clear_cache.turbo_stream.erb
  4. +10
    -1
      app/views/layouts/admin.html.erb
  5. +4
    -0
      config/routes.rb

+ 63
- 57
Gemfile.lock View File

@ -1,35 +1,35 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.1.3.3)
actionpack (= 7.1.3.3)
activesupport (= 7.1.3.3)
actioncable (7.1.3.4)
actionpack (= 7.1.3.4)
activesupport (= 7.1.3.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.1.3.3)
actionpack (= 7.1.3.3)
activejob (= 7.1.3.3)
activerecord (= 7.1.3.3)
activestorage (= 7.1.3.3)
activesupport (= 7.1.3.3)
actionmailbox (7.1.3.4)
actionpack (= 7.1.3.4)
activejob (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.1.3.3)
actionpack (= 7.1.3.3)
actionview (= 7.1.3.3)
activejob (= 7.1.3.3)
activesupport (= 7.1.3.3)
actionmailer (7.1.3.4)
actionpack (= 7.1.3.4)
actionview (= 7.1.3.4)
activejob (= 7.1.3.4)
activesupport (= 7.1.3.4)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.2)
actionpack (7.1.3.3)
actionview (= 7.1.3.3)
activesupport (= 7.1.3.3)
actionpack (7.1.3.4)
actionview (= 7.1.3.4)
activesupport (= 7.1.3.4)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
@ -37,35 +37,35 @@ GEM
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actiontext (7.1.3.3)
actionpack (= 7.1.3.3)
activerecord (= 7.1.3.3)
activestorage (= 7.1.3.3)
activesupport (= 7.1.3.3)
actiontext (7.1.3.4)
actionpack (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.1.3.3)
activesupport (= 7.1.3.3)
actionview (7.1.3.4)
activesupport (= 7.1.3.4)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.1.3.3)
activesupport (= 7.1.3.3)
activejob (7.1.3.4)
activesupport (= 7.1.3.4)
globalid (>= 0.3.6)
activemodel (7.1.3.3)
activesupport (= 7.1.3.3)
activerecord (7.1.3.3)
activemodel (= 7.1.3.3)
activesupport (= 7.1.3.3)
activemodel (7.1.3.4)
activesupport (= 7.1.3.4)
activerecord (7.1.3.4)
activemodel (= 7.1.3.4)
activesupport (= 7.1.3.4)
timeout (>= 0.4.0)
activestorage (7.1.3.3)
actionpack (= 7.1.3.3)
activejob (= 7.1.3.3)
activerecord (= 7.1.3.3)
activesupport (= 7.1.3.3)
activestorage (7.1.3.4)
actionpack (= 7.1.3.4)
activejob (= 7.1.3.4)
activerecord (= 7.1.3.4)
activesupport (= 7.1.3.4)
marcel (~> 1.0)
activesupport (7.1.3.3)
activesupport (7.1.3.4)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
@ -75,8 +75,9 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
acts_as_list (1.1.0)
activerecord (>= 4.2)
acts_as_list (1.2.0)
activerecord (>= 6.1)
activesupport (>= 6.1)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ancestry (4.3.3)
@ -104,7 +105,12 @@ GEM
railties (>= 6.1)
drb (2.2.1)
erubi (1.12.0)
ffi (1.16.3)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-arm-linux-gnu)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86-linux-gnu)
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
globalid (1.2.1)
activesupport (>= 6.1)
htmlentities (4.3.4)
@ -153,7 +159,7 @@ GEM
request_store (~> 1.0)
msgpack (1.7.2)
mutex_m (0.2.0)
net-imap (0.4.11)
net-imap (0.4.12)
date
net-protocol
net-pop (0.1.2)
@ -206,20 +212,20 @@ GEM
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails (7.1.3.3)
actioncable (= 7.1.3.3)
actionmailbox (= 7.1.3.3)
actionmailer (= 7.1.3.3)
actionpack (= 7.1.3.3)
actiontext (= 7.1.3.3)
actionview (= 7.1.3.3)
activejob (= 7.1.3.3)
activemodel (= 7.1.3.3)
activerecord (= 7.1.3.3)
activestorage (= 7.1.3.3)
activesupport (= 7.1.3.3)
rails (7.1.3.4)
actioncable (= 7.1.3.4)
actionmailbox (= 7.1.3.4)
actionmailer (= 7.1.3.4)
actionpack (= 7.1.3.4)
actiontext (= 7.1.3.4)
actionview (= 7.1.3.4)
activejob (= 7.1.3.4)
activemodel (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
bundler (>= 1.15.0)
railties (= 7.1.3.3)
railties (= 7.1.3.4)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
@ -227,9 +233,9 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.1.3.3)
actionpack (= 7.1.3.3)
activesupport (= 7.1.3.3)
railties (7.1.3.4)
actionpack (= 7.1.3.4)
activesupport (= 7.1.3.4)
irb
rackup (>= 1.0.0)
rake (>= 12.2)


+ 8
- 0
app/controllers/admin/admin_controller.rb View File

@ -10,6 +10,14 @@ class Admin::AdminController < ApplicationController
helper_method :user_signed_in?
helper_method :form_locale
# DELETE admin/cache/clear
def clear_cache
Rails.cache.clear
respond_to do |format|
format.turbo_stream { flash.now[:notice] = t(:cache_cleared, scope: 'utils') }
end
end
private


+ 1
- 0
app/views/admin/admin/clear_cache.turbo_stream.erb View File

@ -0,0 +1 @@
<%= turbo_stream.append 'flash', partial: 'layouts/flash' %>

+ 10
- 1
app/views/layouts/admin.html.erb View File

@ -43,7 +43,16 @@
<span class="icon"><%= t c, scope: 'icons' %></span>
<% end %>
<% end if current_user.admin_role? %>
<%= link_to admin_cache_clear_path(locale: nil),
class: 'navbar-link',
method: :delete,
data: {
turbo_method: :delete
} do %>
<span class="icon">bolt</span>
<% end %>
<div data-controller="popup">
<button class="navbar-link has-popup-menu open--right" data-action="click->popup#toggle">
<span class="icon">settings</span>


+ 4
- 0
config/routes.rb View File

@ -35,9 +35,13 @@ Rails.application.routes.draw do
# Users
resources :users
# Root
root to: 'nodes#index'
end
# Cache
delete 'cache/clear', to: "admin#clear_cache"
resources :sessions, path: 'login', only: [:index, :create, :destroy]
get "logout", to: 'sessions#destroy', as: "logout"


Loading…
Cancel
Save