Add lndhub info to admin user page
This commit is contained in:
parent
27dd4163f0
commit
6d20ac9a1c
@ -15,7 +15,9 @@ class Admin::UsersController < Admin::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -10,6 +10,18 @@ class LndhubUser < LndhubBase
|
|||||||
foreign_key: "login"
|
foreign_key: "login"
|
||||||
|
|
||||||
def balance
|
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
|
||||||
end
|
end
|
||||||
|
@ -56,7 +56,34 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</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>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<% else %>
|
||||||
|
<p>No LndHub user found for account <strong class="font-mono"><%= @user.ln_account %></strong>.
|
||||||
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user