admin: dashboard instead of the invoice list
/admin redirected to the invoice list, which stopped making sense once the admin also ran the bingo. Make it a dashboard with one tile per area: invoice totals, outstanding amount per currency, overdue count and the five latest invoices; the bingo score, reserve size, latest incident and card cells still missing a photo. A shared nav links the sections. Tiles are per area so they can follow user permissions later. Assisted-by: Claude:opus-5
This commit is contained in:
parent
e5bd1c1ac7
commit
c2020bf903
8 changed files with 134 additions and 5 deletions
22
asxpio.rb
22
asxpio.rb
|
|
@ -130,8 +130,28 @@ class AsxpioWeb < Sinatra::Base
|
|||
halt 503, 'Invoicing not configured (DATABASE_URL missing).' unless defined?(Invoice)
|
||||
end
|
||||
|
||||
# Overview of every admin area; each tile links into its section.
|
||||
get '/admin' do
|
||||
redirect '/admin/invoices'
|
||||
@page_title = 'Dashboard · admin'
|
||||
@noindex = true
|
||||
unpaid = Invoice.where(paid_at: nil).all
|
||||
@inv = {
|
||||
count: Invoice.count,
|
||||
unpaid: unpaid,
|
||||
overdue: unpaid.count { |i| i.due_on < Date.today },
|
||||
unpaid_totals: unpaid.group_by(&:currency).transform_values { |l| l.sum(&:total) },
|
||||
recent: Invoice.order(Sequel.desc(:created_at)).limit(5).all
|
||||
}
|
||||
board = Bingo::Board.load
|
||||
@bingo = {
|
||||
cells: board.cells.size,
|
||||
hit: board.hit.count(true),
|
||||
lines: board.wins.size,
|
||||
reserve: [Bingo::Datacenter.count - board.cells.size, 0].max,
|
||||
last_incident: board.incidents.first,
|
||||
no_photo: board.cells.reject(&:photo_key)
|
||||
}
|
||||
erb :'admin/dashboard'
|
||||
end
|
||||
|
||||
get '/admin/invoices' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue