Add transactions view
This commit is contained in:
parent
d388226d32
commit
546d918700
11 changed files with 108 additions and 35 deletions
|
@ -20,3 +20,7 @@
|
|||
*/
|
||||
@import "bootstrap-sprockets";
|
||||
@import "bootstrap";
|
||||
|
||||
.clear-both {
|
||||
clear: both;
|
||||
}
|
||||
|
|
9
app/assets/stylesheets/card.scss
Normal file
9
app/assets/stylesheets/card.scss
Normal file
|
@ -0,0 +1,9 @@
|
|||
.card-wrapper {
|
||||
padding: 0 20px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.card {
|
||||
box-shadow: 0 1px 3px rgba(0,0,0, 0.12), 0 1px 2px rgba(0,0,0, 0.24);
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
|
@ -42,3 +42,51 @@ a.login-button {
|
|||
.shame-percentage {
|
||||
text-align: right
|
||||
}
|
||||
|
||||
.transaction {
|
||||
border-bottom: 1px solid #c7d0d5;
|
||||
padding: 15px 10px;
|
||||
font-size: 16px;
|
||||
color: rgb(45, 54, 59);
|
||||
|
||||
.transaction-calendar {
|
||||
float: left;
|
||||
text-align: center;
|
||||
color: #adbac2;
|
||||
line-height: 1.1;
|
||||
margin-top: 0.125em;
|
||||
|
||||
.transaction-day {
|
||||
font-size: 1.125em;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.transaction-month {
|
||||
font-size: 0.750em;
|
||||
text-transform: uppercase;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.transaction-block {
|
||||
padding-left: 3.500em;
|
||||
|
||||
.transaction-block-l {
|
||||
width: 75%;
|
||||
float: left;
|
||||
|
||||
.transaction-message {
|
||||
margin: 0;
|
||||
color: #0072ae;
|
||||
font-size: 1em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
}
|
||||
|
||||
.transaction-block-r {
|
||||
width: 25%;
|
||||
float: left;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
3
app/assets/stylesheets/layout.scss
Normal file
3
app/assets/stylesheets/layout.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
#content {
|
||||
padding: 30px;
|
||||
}
|
|
@ -22,6 +22,7 @@ $color: #777;
|
|||
|
||||
.menu-heading {
|
||||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.menu-list {
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
class PagesController < ApplicationController
|
||||
|
||||
require 'statistics'
|
||||
|
||||
def landing
|
||||
query = TransactionsQuery.new(current_user)
|
||||
@transactions = ActiveRecord::Base.connection.exec_query(query.query.order(query.arel_table[:time].desc).take(10).project(Arel.star).to_sql)
|
||||
end
|
||||
|
||||
def sign_in
|
||||
@statistics = Statistics.new
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ module BaseTransaction
|
|||
end
|
||||
|
||||
def amount_f
|
||||
number_to_currency amount/100.0, unit: '€'
|
||||
euro_from_cents amount
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
%body
|
||||
.pure-g
|
||||
= render 'menu' if current_user
|
||||
.pure-u-1
|
||||
#content.pure-u-1
|
||||
= render 'flash'
|
||||
= yield
|
||||
|
|
18
app/views/pages/_transactions.html.haml
Normal file
18
app/views/pages/_transactions.html.haml
Normal file
|
@ -0,0 +1,18 @@
|
|||
.card-wrapper
|
||||
.card
|
||||
- @transactions.each do |t|
|
||||
- t.symbolize_keys!
|
||||
- date = Date.parse t[:time]
|
||||
.transaction
|
||||
.transaction-calendar
|
||||
%span.transaction-day= date.strftime('%d')
|
||||
%span.transaction-month= Date::MONTHNAMES[date.month][0..2]
|
||||
.transaction-block
|
||||
.transaction-block-l
|
||||
%h4.transaction-message
|
||||
= t[:message]
|
||||
.transaction-peer
|
||||
= t[:peer]
|
||||
.transaction-block-r
|
||||
= euro_from_cents t[:amount]
|
||||
.clear-both
|
|
@ -1,32 +1,14 @@
|
|||
%h1.columns-title Tab
|
||||
= javascript_include_tag "//www.google.com/jsapi", "chartkick"
|
||||
%h2.columns-title Cute Little Statistics
|
||||
.pure-g
|
||||
.pure-u-1.pure-u-md-1-2.landing-column
|
||||
%h3.columns-title Pie of Shame
|
||||
= pie_chart @statistics.shamehash
|
||||
%h3.columns-title Table of Shame
|
||||
%table.pure-table.full-table
|
||||
%thead
|
||||
%th Shame on
|
||||
%th Contribution to Zeus' lack of money
|
||||
%tbody
|
||||
- @statistics.shameful_users.each do |user|
|
||||
%tr
|
||||
%td.shameful-person= user.name
|
||||
// Won't divide by zero because there won't be any users with
|
||||
// a shameful debt if the total debt is zero.
|
||||
%td.shame-percentage= "#{-100 * user.balance / @statistics.total_debt}%"
|
||||
.pure-u-1.pure-u-md-1-2.landing-column
|
||||
%h3.columns-title Distribution of Debt Sources
|
||||
= pie_chart @statistics.by_issuer
|
||||
%h3.columns-title Top Debt Creators
|
||||
%table.pure-table.full-table
|
||||
%thead
|
||||
%th Issuer
|
||||
%th Number of Transactions issued
|
||||
%tbody
|
||||
- @statistics.creation_counts.each do |name, count|
|
||||
%tr
|
||||
%td.shameful-person= name
|
||||
%td.shame-percentage= count
|
||||
.pure-u-7-12
|
||||
= render 'transactions'
|
||||
.pure-u-5-12
|
||||
.card-wrapper
|
||||
.card
|
||||
nieuwe transactie
|
||||
.card-wrapper
|
||||
.card
|
||||
requests
|
||||
.card-wrapper
|
||||
.card
|
||||
notifications
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@ Rails.application.routes.draw do
|
|||
omniauth_callbacks: 'callbacks'
|
||||
}
|
||||
|
||||
root to: 'pages#landing'
|
||||
authenticated :user do
|
||||
root 'pages#landing', as: :authenticated_root
|
||||
end
|
||||
|
||||
root to: 'pages#sign_in'
|
||||
|
||||
resources :transactions, only: [:index, :create]
|
||||
resources :users, only: [:index, :show] do
|
||||
|
|
Loading…
Reference in a new issue