Add toggle switch component, service configs, admin profile links
This commit is contained in:
		
							parent
							
								
									f050d010fd
								
							
						
					
					
						commit
						805733939c
					
				@ -1,10 +1,16 @@
 | 
			
		||||
LDAP_HOST=localhost
 | 
			
		||||
LDAP_PORT=389
 | 
			
		||||
LDAP_ADMIN_PASSWORD=passthebutter
 | 
			
		||||
LDAP_SUFFIX="dc=kosmos,dc=org"
 | 
			
		||||
LDAP_SUFFIX='dc=kosmos,dc=org'
 | 
			
		||||
 | 
			
		||||
WEBHOOKS_ALLOWED_IPS='10.1.1.163'
 | 
			
		||||
 | 
			
		||||
DISCOURSE_PUBLIC_URL='https://community.kosmos.org'
 | 
			
		||||
GITEA_PUBLIC_URL='https://gitea.kosmos.org'
 | 
			
		||||
MASTODON_PUBLIC_URL='https://kosmos.social'
 | 
			
		||||
MEDIAWIKI_PUBLIC_URL='https://wiki.kosmos.org'
 | 
			
		||||
 | 
			
		||||
EJABBERD_ADMIN_URL='https://xmpp.kosmos.org/admin'
 | 
			
		||||
EJABBERD_API_URL='https://xmpp.kosmos.org/api'
 | 
			
		||||
 | 
			
		||||
BTCPAY_API_URL='http://localhost:23001/api/v1'
 | 
			
		||||
@ -18,3 +24,4 @@ LNDHUB_PG_PORT=5432
 | 
			
		||||
LNDHUB_PG_DATABASE=lndhub
 | 
			
		||||
LNDHUB_PG_USERNAME=lndhub
 | 
			
		||||
LNDHUB_PG_PASSWORD=''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								app/components/form_elements/toggle_component.html.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								app/components/form_elements/toggle_component.html.erb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
<button type="submit" role="switch" aria-checked="false"
 | 
			
		||||
        class="<%= @enabled ? 'bg-indigo-600' : 'bg-gray-200' %>
 | 
			
		||||
               relative inline-flex h-6 w-11 flex-shrink-0
 | 
			
		||||
               cursor-pointer rounded-full border-2 border-transparent
 | 
			
		||||
               transition-colors duration-200 ease-in-out focus:outline-none
 | 
			
		||||
               focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2">
 | 
			
		||||
  <!-- <span class="sr-only">Enable</span> -->
 | 
			
		||||
  <span aria-hidden="true"
 | 
			
		||||
        class="<%= @enabled ? 'translate-x-5' : 'translate-x-0' %>
 | 
			
		||||
               pointer-events-none inline-block h-5 w-5 transform rounded-full
 | 
			
		||||
               bg-white shadow ring-0 transition duration-200 ease-in-out"></span>
 | 
			
		||||
</button>
 | 
			
		||||
							
								
								
									
										9
									
								
								app/components/form_elements/toggle_component.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								app/components/form_elements/toggle_component.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
module FormElements
 | 
			
		||||
  class ToggleComponent < ViewComponent::Base
 | 
			
		||||
    def initialize(enabled:)
 | 
			
		||||
      @enabled = !!enabled
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
@ -10,6 +10,56 @@ class Setting < RailsSettings::Base
 | 
			
		||||
    account accounts donations mail webmaster support
 | 
			
		||||
  ]
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Discourse
 | 
			
		||||
  #
 | 
			
		||||
 | 
			
		||||
  field :discourse_public_url, type: :string,
 | 
			
		||||
    default: ENV["DISCOURSE_PUBLIC_URL"].presence
 | 
			
		||||
 | 
			
		||||
  field :discourse_enabled, type: :boolean,
 | 
			
		||||
    default: (ENV["DISCOURSE_PUBLIC_URL"].present?.to_s || false)
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # ejabberd
 | 
			
		||||
  #
 | 
			
		||||
 | 
			
		||||
  field :ejabberd_enabled, type: :boolean,
 | 
			
		||||
    default: (ENV["EJABBERD_API_URL"].present?.to_s || false)
 | 
			
		||||
 | 
			
		||||
  field :ejabberd_admin_url, type: :string,
 | 
			
		||||
    default: ENV["EJABBERD_ADMIN_URL"].presence
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Gitea
 | 
			
		||||
  #
 | 
			
		||||
 | 
			
		||||
  field :gitea_public_url, type: :string,
 | 
			
		||||
    default: ENV["GITEA_PUBLIC_URL"].presence
 | 
			
		||||
 | 
			
		||||
  field :gitea_enabled, type: :boolean,
 | 
			
		||||
    default: (ENV["GITEA_PUBLIC_URL"].present?.to_s || false)
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Mastodon
 | 
			
		||||
  #
 | 
			
		||||
 | 
			
		||||
  field :mastodon_public_url, type: :string,
 | 
			
		||||
    default: ENV["MASTODON_PUBLIC_URL"].presence
 | 
			
		||||
 | 
			
		||||
  field :mastodon_enabled, type: :boolean,
 | 
			
		||||
    default: (ENV["MASTODON_PUBLIC_URL"].present?.to_s || false)
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # MediaWiki
 | 
			
		||||
  #
 | 
			
		||||
 | 
			
		||||
  field :mediawiki_public_url, type: :string,
 | 
			
		||||
    default: ENV["MEDIAWIKI_PUBLIC_URL"].presence
 | 
			
		||||
 | 
			
		||||
  field :mediawiki_enabled, type: :boolean,
 | 
			
		||||
    default: (ENV["MEDIAWIKI_PUBLIC_URL"].present?.to_s || false)
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Lightning Network
 | 
			
		||||
  #
 | 
			
		||||
 | 
			
		||||
@ -53,7 +53,7 @@ class User < ApplicationRecord
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def devise_after_confirmation
 | 
			
		||||
    enable_service %w[discourse gitea wiki xmpp]
 | 
			
		||||
    enable_service %w[discourse gitea mediawiki ejabberd]
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def reset_password(new_password, new_password_confirmation)
 | 
			
		||||
 | 
			
		||||
@ -65,28 +65,72 @@
 | 
			
		||||
 | 
			
		||||
  <section>
 | 
			
		||||
    <h3>Services</h3>
 | 
			
		||||
    <table class="sm:w-1/4">
 | 
			
		||||
    <table class="divided">
 | 
			
		||||
      <thead>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <th>Name</th>
 | 
			
		||||
          <th>Enabled</th>
 | 
			
		||||
          <th></th>
 | 
			
		||||
        </tr>
 | 
			
		||||
      </thead>
 | 
			
		||||
      <tbody>
 | 
			
		||||
        <% if Setting.discourse_enabled %>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <td>Discourse</td>
 | 
			
		||||
          <td><%= check_box_tag 'service_discourse', 'enabled', @services_enabled.include?("discourse"), disabled: true %></td>
 | 
			
		||||
          <td>
 | 
			
		||||
            <%= render FormElements::ToggleComponent.new(enabled: @services_enabled.include?("discourse")) %>
 | 
			
		||||
          </td>
 | 
			
		||||
          <td class="text-right">
 | 
			
		||||
            <%= link_to "Open profile", "#{Setting.discourse_public_url}/u/#{@user.cn}/summary", class: "btn-sm btn-gray" %>
 | 
			
		||||
          </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <% end %>
 | 
			
		||||
        <% if Setting.gitea_enabled %>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <td>Gitea</td>
 | 
			
		||||
          <td><%= check_box_tag 'service_gitea', 'enabled', @services_enabled.include?("gitea"), disabled: true %></td>
 | 
			
		||||
          <td>
 | 
			
		||||
            <%= render FormElements::ToggleComponent.new(enabled: @services_enabled.include?("gitea")) %>
 | 
			
		||||
          </td>
 | 
			
		||||
          <td class="text-right">
 | 
			
		||||
            <%= link_to "Open profile", "#{Setting.gitea_public_url}/#{@user.cn}", class: "btn-sm btn-gray" %>
 | 
			
		||||
          </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <% end %>
 | 
			
		||||
        <% if Setting.mastodon_enabled %>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <td>Mastodon</td>
 | 
			
		||||
          <td><%= check_box_tag 'service_mastodon', 'enabled', @services_enabled.include?("mastodon"), disabled: true %></td>
 | 
			
		||||
          <td>
 | 
			
		||||
            <%= render FormElements::ToggleComponent.new(enabled: @services_enabled.include?("mastodon")) %>
 | 
			
		||||
          </td>
 | 
			
		||||
          <td class="text-right">
 | 
			
		||||
            <%= link_to "Open profile", "#{Setting.mastodon_public_url}/@#{@user.cn}", class: "btn-sm btn-gray" %>
 | 
			
		||||
          </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <% end %>
 | 
			
		||||
        <% if Setting.mediawiki_enabled %>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <td>Wiki</td>
 | 
			
		||||
          <td><%= check_box_tag 'service_wiki', 'enabled', @services_enabled.include?("wiki"), disabled: true %></td>
 | 
			
		||||
          <td>MediaWiki</td>
 | 
			
		||||
          <td>
 | 
			
		||||
            <%= render FormElements::ToggleComponent.new(enabled: @services_enabled.include?("mediawiki")) %>
 | 
			
		||||
          </td>
 | 
			
		||||
          <td class="text-right">
 | 
			
		||||
            <%= link_to "Open profile", "#{Setting.mediawiki_public_url}/Special:Contributions/#{@user.cn}", class: "btn-sm btn-gray" %>
 | 
			
		||||
          </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <% end %>
 | 
			
		||||
        <% if Setting.ejabberd_enabled %>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <td>XMPP</td>
 | 
			
		||||
          <td><%= check_box_tag 'service_xmpp', 'enabled', @services_enabled.include?("xmpp"), disabled: true %></td>
 | 
			
		||||
          <td>XMPP (ejabberd)</td>
 | 
			
		||||
          <td>
 | 
			
		||||
            <%= render FormElements::ToggleComponent.new(enabled: @services_enabled.include?("ejabberd")) %>
 | 
			
		||||
          </td>
 | 
			
		||||
          <td class="text-right">
 | 
			
		||||
            <% if Setting.ejabberd_admin_url.present? %>
 | 
			
		||||
            <%= link_to "Open profile", "#{Setting.ejabberd_admin_url}/server/#{@user.ou}/user/#{@user.cn}/", class: "btn-sm btn-gray" %>
 | 
			
		||||
            <% end %>
 | 
			
		||||
          </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <% end %>
 | 
			
		||||
      </tbody>
 | 
			
		||||
    </table>
 | 
			
		||||
  </section>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user