Add user page to admin panel, improve other admin pages #88

Merged
raucao merged 15 commits from feature/admin_user_details into master 2023-02-26 14:16:41 +00:00
3 changed files with 43 additions and 2 deletions
Showing only changes of commit 6d20ac9a1c - Show all commits

View File

@@ -15,7 +15,9 @@ class Admin::UsersController < Admin::BaseController
end
def show
@inviter = Invitation.where(invited_user_id: @user.id).first.try(:user)
if Setting.lndhub_admin_enabled?
@lndhub_user = @user.lndhub_user
end
end
private

View File

@@ -10,6 +10,18 @@ class LndhubUser < LndhubBase
foreign_key: "login"
def balance
accounts.current.first.ledgers.sum("account_ledgers.amount")
accounts.current.first.ledgers.sum("account_ledgers.amount").to_i.abs
end
def sum_outgoing
accounts.outgoing.first.ledgers.sum("account_ledgers.amount").to_i.abs
end
def sum_incoming
accounts.incoming.first.ledgers.sum("account_ledgers.amount").to_i.abs
end
def sum_fees
accounts.fees.first.ledgers.sum("account_ledgers.amount").to_i.abs
end
end

View File

@@ -56,7 +56,34 @@
</tbody>
</table>
</section>
<% if Setting.lndhub_admin_enabled? %>
<section>
<h3>LndHub</h3>
<% if @lndhub_user %>
<table>
<thead>
<tr>
<th>Account</th>
<th>Balance</th>
<th>Incoming</th>
<th>Outgoing</th>
<th>Fees</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @user.ln_account %></td>
<td><%= number_with_delimiter @lndhub_user.balance %> sats</td>
<td><%= number_with_delimiter @lndhub_user.sum_incoming %> sats</td>
<td><%= number_with_delimiter @lndhub_user.sum_outgoing %> sats</td>
<td><%= number_with_delimiter @lndhub_user.sum_fees %> sats</td>
</tr>
</tbody>
</table>
<% else %>
<p>No LndHub user found for account <strong class="font-mono"><%= @user.ln_account %></strong>.
<% end %>
</section>
<% end %>
<% end %>