Add new user settings pages for Chat and Wallet
This commit is contained in:
parent
23821f9e65
commit
f19baaf22a
@ -12,6 +12,13 @@ class SettingsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@user = current_user
|
||||||
|
@user.preferences.merge! user_params[:preferences]
|
||||||
|
@user.save!
|
||||||
|
|
||||||
|
redirect_to setting_path(@settings_section), flash: {
|
||||||
|
success: 'Settings saved.'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_password
|
def reset_password
|
||||||
@ -29,10 +36,17 @@ class SettingsController < ApplicationController
|
|||||||
|
|
||||||
def set_settings_section
|
def set_settings_section
|
||||||
@settings_section = params[:section]
|
@settings_section = params[:section]
|
||||||
allowed_sections = [:profile, :account, :notifications]
|
allowed_sections = [:profile, :account, :lightning, :xmpp]
|
||||||
|
|
||||||
unless allowed_sections.include?(@settings_section.to_sym)
|
unless allowed_sections.include?(@settings_section.to_sym)
|
||||||
redirect_to setting_path(:profile)
|
redirect_to setting_path(:profile)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_params
|
||||||
|
params.require(:user).permit(preferences: [
|
||||||
|
lightning: [:notify_sats_received],
|
||||||
|
xmpp: [:exchange_contacts_with_invitees]
|
||||||
|
])
|
||||||
|
end
|
||||||
end
|
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-message-circle"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></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-message-circle <%= custom_class %>"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg>
|
||||||
|
Before Width: | Height: | Size: 428 B After Width: | Height: | Size: 449 B |
27
app/views/settings/_lightning.html.erb
Normal file
27
app/views/settings/_lightning.html.erb
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<%= form_for @user, url: setting_path(:lightning), html: { :method => :put } do |f| %>
|
||||||
|
<section>
|
||||||
|
<h3>Notifications</h3>
|
||||||
|
<ul role="list">
|
||||||
|
<%= render FormElements::FieldsetComponent.new(
|
||||||
|
positioning: :horizontal,
|
||||||
|
title: "Sats received",
|
||||||
|
description: "Notify me when sats are sent to my Lightning Address"
|
||||||
|
) do %>
|
||||||
|
<% f.fields_for :preferences do |p| %>
|
||||||
|
<% p.fields_for :lightning do |l| %>
|
||||||
|
<%= l.select :notify_sats_received, options_for_select([
|
||||||
|
["off", "off"],
|
||||||
|
["Chat (Jabber)", "xmpp"],
|
||||||
|
["E-Mail", "email"]
|
||||||
|
], selected: @user.preferences.dig('lightning', 'notify_sats_received')) %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<p class="pt-6 border-t border-gray-200 text-right">
|
||||||
|
<%= f.submit 'Save', class: "btn-md btn-blue w-full md:w-auto" %>
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
<% end %>
|
18
app/views/settings/_xmpp.html.erb
Normal file
18
app/views/settings/_xmpp.html.erb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<%= form_for @user, url: setting_path(:xmpp), html: { :method => :put } do |f| %>
|
||||||
|
<section>
|
||||||
|
<h3>Contacts</h3>
|
||||||
|
<ul role="list">
|
||||||
|
<%= render FormElements::FieldsetToggleComponent.new(
|
||||||
|
field_name: "user[preferences][xmpp][exchange_contacts_with_invitees]",
|
||||||
|
enabled: @user.pref_enabled?("xmpp:exchange_contacts_with_invitees"),
|
||||||
|
title: "Exchange contacts when invited user signs up",
|
||||||
|
description: "Add each others contacts, so you can chat with them immediately"
|
||||||
|
) %>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<p class="pt-6 border-t border-gray-200 text-right">
|
||||||
|
<%= f.submit 'Save', class: "btn-md btn-blue w-full md:w-auto" %>
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
<% end %>
|
@ -6,7 +6,15 @@
|
|||||||
name: "Account", path: setting_path(:account), icon: "key",
|
name: "Account", path: setting_path(:account), icon: "key",
|
||||||
active: current_page?(setting_path(:account))
|
active: current_page?(setting_path(:account))
|
||||||
) %>
|
) %>
|
||||||
|
<% if Setting.ejabberd_enabled %>
|
||||||
<%= render SidenavLinkComponent.new(
|
<%= render SidenavLinkComponent.new(
|
||||||
name: "Notifications", path: setting_path(:notifications), icon: "bell",
|
name: "Chat", path: setting_path(:xmpp), icon: "message-circle",
|
||||||
active: current_page?(setting_path(:notifications))
|
active: current_page?(setting_path(:xmpp))
|
||||||
) %>
|
) %>
|
||||||
|
<% end %>
|
||||||
|
<% if Setting.lndhub_enabled %>
|
||||||
|
<%= render SidenavLinkComponent.new(
|
||||||
|
name: "Wallet", path: setting_path(:lightning), icon: "zap",
|
||||||
|
active: current_page?(setting_path(:lightning))
|
||||||
|
) %>
|
||||||
|
<% end %>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user