WIP Add admin settings pages, reserved username config
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Prototyping settings forms
This commit is contained in:
parent
cd7b05e2ff
commit
084835f06a
@ -1,6 +1,6 @@
|
|||||||
@layer components {
|
@layer components {
|
||||||
input[type=text], input[type=email], input[type=password],
|
input[type=text], input[type=email], input[type=password],
|
||||||
input[type=number], select {
|
input[type=number], select, textarea {
|
||||||
@apply mt-1 rounded-md bg-gray-100 focus:bg-white
|
@apply mt-1 rounded-md bg-gray-100 focus:bg-white
|
||||||
border-transparent focus:border-transparent focus:ring-2
|
border-transparent focus:border-transparent focus:ring-2
|
||||||
focus:ring-blue-600 focus:ring-opacity-75;
|
focus:ring-blue-600 focus:ring-opacity-75;
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
class Admin::Settings::RegistrationsController < Admin::SettingsController
|
||||||
|
|
||||||
|
def index
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
9
app/controllers/admin/settings/services_controller.rb
Normal file
9
app/controllers/admin/settings/services_controller.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
class Admin::Settings::ServicesController < Admin::SettingsController
|
||||||
|
|
||||||
|
def index
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
12
app/controllers/admin/settings_controller.rb
Normal file
12
app/controllers/admin/settings_controller.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
class Admin::SettingsController < Admin::BaseController
|
||||||
|
before_action :set_current_section
|
||||||
|
|
||||||
|
def index
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_current_section
|
||||||
|
@current_section = :settings
|
||||||
|
end
|
||||||
|
end
|
@ -2,6 +2,16 @@
|
|||||||
class Setting < RailsSettings::Base
|
class Setting < RailsSettings::Base
|
||||||
cache_prefix { "v1" }
|
cache_prefix { "v1" }
|
||||||
|
|
||||||
|
field :reserved_usernames, type: :array, default: %w[
|
||||||
|
account
|
||||||
|
accounts
|
||||||
|
admin
|
||||||
|
donations
|
||||||
|
mail
|
||||||
|
webmaster
|
||||||
|
support
|
||||||
|
]
|
||||||
|
|
||||||
field :lndhub_enabled, default: (ENV["LNDHUB_API_URL"].present?.to_s || "false"), type: :boolean
|
field :lndhub_enabled, default: (ENV["LNDHUB_API_URL"].present?.to_s || "false"), type: :boolean
|
||||||
field :lndhub_admin_enabled, default: (ENV["LNDHUB_ADMIN_UI"] || "false"), type: :boolean
|
field :lndhub_admin_enabled, default: (ENV["LNDHUB_ADMIN_UI"] || "false"), type: :boolean
|
||||||
end
|
end
|
||||||
|
31
app/views/admin/settings/registrations/index.html.erb
Normal file
31
app/views/admin/settings/registrations/index.html.erb
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<%= render HeaderComponent.new(title: "Settings") %>
|
||||||
|
|
||||||
|
<%= render MainWithSidenavComponent.new(sidenav_partial: 'shared/admin_sidenav_settings') do %>
|
||||||
|
<section>
|
||||||
|
<h3>Registrations</h3>
|
||||||
|
<%= form_for(Setting.new, url: admin_settings_services_path) do |f| %>
|
||||||
|
<% if @errors && @errors.any? %>
|
||||||
|
<div>
|
||||||
|
<ul>
|
||||||
|
<% @errors.full_messages.each do |msg| %>
|
||||||
|
<li><%= msg %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<p class="font-bold mb-1">Reserved usernames</p>
|
||||||
|
<p class="text-gray-500">
|
||||||
|
These usernames cannot be registered as accounts:
|
||||||
|
</p>
|
||||||
|
<%= f.text_area :reserved_usernames,
|
||||||
|
value: Setting.reserved_usernames.join("\n"),
|
||||||
|
class: "h-44 mb-2" %>
|
||||||
|
<p class="text-sm text-gray-500">
|
||||||
|
One username per line
|
||||||
|
</p>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
</section>
|
||||||
|
<% end %>
|
39
app/views/admin/settings/services/index.html.erb
Normal file
39
app/views/admin/settings/services/index.html.erb
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<%= render HeaderComponent.new(title: "Settings") %>
|
||||||
|
|
||||||
|
<%= render MainWithSidenavComponent.new(sidenav_partial: 'shared/admin_sidenav_settings') do %>
|
||||||
|
<section>
|
||||||
|
<h3>Lightning Network</h3>
|
||||||
|
<%= form_for(Setting.new, url: admin_settings_services_path) do |f| %>
|
||||||
|
<% if @errors && @errors.any? %>
|
||||||
|
<div>
|
||||||
|
<ul>
|
||||||
|
<% @errors.full_messages.each do |msg| %>
|
||||||
|
<li><%= msg %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<ul role="list" class="mt-2 divide-y divide-gray-200">
|
||||||
|
<li class="flex items-center justify-between py-6">
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<label class="font-bold mb-1">Enable LNDHub integration</label>
|
||||||
|
<p class="text-gray-500 mb-0">LNDHub configuration present and wallet features enabled</p>
|
||||||
|
</div>
|
||||||
|
<%= f.check_box :lndhub_enabled, checked: Setting.lndhub_enabled?,
|
||||||
|
disabled: true,
|
||||||
|
class: "relative ml-4 inline-flex flex-shrink-0" %>
|
||||||
|
</li>
|
||||||
|
<li class="flex items-center justify-between py-6">
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<label class="font-bold mb-1">Enable LNDHub admin panel</label>
|
||||||
|
<p class="text-gray-500 mb-0">LNDHub database configuration present and admin panel enabled</p>
|
||||||
|
</div>
|
||||||
|
<%= f.check_box :lndhub_admin_enabled, checked: Setting.lndhub_admin_enabled?,
|
||||||
|
disabled: true,
|
||||||
|
class: "relative ml-4 inline-flex flex-shrink-0" %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
</section>
|
||||||
|
<% end %>
|
@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-grid"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-grid <%= custom_class %>"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>
|
||||||
|
Before Width: | Height: | Size: 404 B After Width: | Height: | Size: 425 B |
@ -10,3 +10,5 @@
|
|||||||
<%= link_to "Lightning", admin_lightning_path,
|
<%= link_to "Lightning", admin_lightning_path,
|
||||||
class: main_nav_class(@current_section, :lightning) %>
|
class: main_nav_class(@current_section, :lightning) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%= link_to "Settings", admin_settings_registrations_path,
|
||||||
|
class: main_nav_class(@current_section, :settings) %>
|
||||||
|
11
app/views/shared/_admin_sidenav_settings.html.erb
Normal file
11
app/views/shared/_admin_sidenav_settings.html.erb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<%= render SidenavLinkComponent.new(
|
||||||
|
name: "Registrations", path: admin_settings_registrations_path, icon: "user",
|
||||||
|
active: current_page?(admin_settings_registrations_path)
|
||||||
|
) %>
|
||||||
|
<%= render SidenavLinkComponent.new(
|
||||||
|
name: "Services", path: admin_settings_services_path, icon: "grid",
|
||||||
|
active: current_page?(admin_settings_services_path)
|
||||||
|
) %>
|
||||||
|
<%= render SidenavLinkComponent.new(
|
||||||
|
name: "Security", path: "#", icon: "shield", disabled: true
|
||||||
|
) %>
|
@ -43,6 +43,11 @@ Rails.application.routes.draw do
|
|||||||
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 :settings do
|
||||||
|
resources 'registrations', only: ['index', 'update']
|
||||||
|
resources 'services', only: ['index', 'update']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
authenticate :user, ->(user) { user.is_admin? } do
|
authenticate :user, ->(user) { user.is_admin? } do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user