diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/Account.scala | 17 | ||||
-rw-r--r-- | app/views/fragments/accountInfos.scala.html | 2 | ||||
-rw-r--r-- | app/views/pages/accountSummary.scala.html | 89 |
3 files changed, 106 insertions, 2 deletions
diff --git a/app/controllers/Account.scala b/app/controllers/Account.scala index ff1d44d..7557ef1 100644 --- a/app/controllers/Account.scala +++ b/app/controllers/Account.scala | |||
@@ -14,6 +14,21 @@ import scala.concurrent.Future | |||
14 | import models._ | 14 | import models._ |
15 | 15 | ||
16 | 16 | ||
17 | object Account { | 17 | object Account extends Controller { |
18 | |||
19 | def summary = Auth { implicit request => | ||
20 | if (request.account.isEmpty) { | ||
21 | Redirect(routes.Authentication.login()) | ||
22 | .flashing("error" -> "Authentication required") | ||
23 | } else { | ||
24 | |||
25 | DB.withSession { implicit session => | ||
26 | val userUuid = request.account.get.userUuid | ||
27 | val transactions = Tables.Transactions.filter(_.userUuid === userUuid).sortBy(_.transactionDate.desc).run | ||
28 | |||
29 | Ok(views.html.pages.accountSummary(transactions)) | ||
30 | } | ||
31 | } | ||
32 | } | ||
18 | 33 | ||
19 | } | 34 | } |
diff --git a/app/views/fragments/accountInfos.scala.html b/app/views/fragments/accountInfos.scala.html index 887e485..60c3583 100644 --- a/app/views/fragments/accountInfos.scala.html +++ b/app/views/fragments/accountInfos.scala.html | |||
@@ -7,7 +7,7 @@ | |||
7 | Logout | 7 | Logout |
8 | </a> | 8 | </a> |
9 | 9 | ||
10 | <a class="pure-button" href="#"> | 10 | <a class="pure-button" href="@routes.Account.summary()"> |
11 | <i class="fa fa-money fa-lg"></i> | 11 | <i class="fa fa-money fa-lg"></i> |
12 | @account.equity € | 12 | @account.equity € |
13 | </a> | 13 | </a> |
diff --git a/app/views/pages/accountSummary.scala.html b/app/views/pages/accountSummary.scala.html new file mode 100644 index 0000000..3a10d3d --- /dev/null +++ b/app/views/pages/accountSummary.scala.html | |||
@@ -0,0 +1,89 @@ | |||
1 | @(transactions: Seq[Tables.Transaction])(implicit request: AuthRequest[AnyContent], flash: Flash, token: play.filters.csrf.CSRF.Token) | ||
2 | |||
3 | @templates.pepal("Account summary")(request.account) { | ||
4 | |||
5 | <div class="action-buttons pure-g"> | ||
6 | @fragments.pepalMainActions() | ||
7 | </div> | ||
8 | |||
9 | <br> | ||
10 | |||
11 | <div class="pure-g"> | ||
12 | <div class="pure-u-1 pure-u-lg-1-4"> | ||
13 | <div class="l-box"> | ||
14 | <h2>My wallet</h2> | ||
15 | |||
16 | <table class="pure-table pure-table-horizontal"> | ||
17 | <thead> | ||
18 | <tr> | ||
19 | <td colspan="2">Account summary</td> | ||
20 | </tr> | ||
21 | </thead> | ||
22 | |||
23 | <tbody> | ||
24 | <tr class="dark-blue"> | ||
25 | <td>Balance</td> | ||
26 | <td>@request.account.get.balance €</td> | ||
27 | </tr> | ||
28 | |||
29 | <tr class="light-blue"> | ||
30 | <td>Available funds</td> | ||
31 | <td>@request.account.get.equity €</td> | ||
32 | </tr> | ||
33 | </tbody> | ||
34 | </table> | ||
35 | |||
36 | <br> | ||
37 | |||
38 | <div class="pure-g wallet-actions"> | ||
39 | <div class="pure-u-1 pure-u-lg-1-1"> | ||
40 | <a class="pure-button" href="#"> | ||
41 | <i class="fa fa-download"></i> | ||
42 | Deposit | ||
43 | </a> | ||
44 | </div> | ||
45 | |||
46 | <br><br> | ||
47 | |||
48 | <div class="pure-u-1 pure-u-lg-1-1"> | ||
49 | <a class="pure-button" href="#HAHAHAHA"> | ||
50 | <i class="fa fa-upload"></i> | ||
51 | Withdraw | ||
52 | </a> | ||
53 | </div> | ||
54 | </div> | ||
55 | </div> | ||
56 | </div> | ||
57 | |||
58 | <div class="pure-u-1 pure-u-lg-3-4"> | ||
59 | <div class="l-box"> | ||
60 | <h2>Transaction history</h2> | ||
61 | |||
62 | <table class="pure-table pure-table-horizontal"> | ||
63 | |||
64 | <thead> | ||
65 | <tr> | ||
66 | <td>Date</td> | ||
67 | <td>Amount</td> | ||
68 | <td>Label</td> | ||
69 | </tr> | ||
70 | </thead> | ||
71 | |||
72 | <tbody> | ||
73 | @for(transaction <- transactions) { | ||
74 | <tr> | ||
75 | <td>@transaction.transactionDate</td> | ||
76 | <td class="align-right @if(transaction.amount >= 0) {income} else {outcome}">@transaction.amount | ||
77 | €</td> | ||
78 | <td>@transaction.label</td> | ||
79 | </tr> | ||
80 | } | ||
81 | </tbody> | ||
82 | |||
83 | |||
84 | </table> | ||
85 | </div> | ||
86 | </div> | ||
87 | </div> | ||
88 | |||
89 | } | ||