diff options
| author | Adam Soltys <[email protected]> | 2012-11-12 23:25:09 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2012-11-12 23:25:09 -0800 |
| commit | 54c28a395db853c601d3592c967f322c7f09e1d4 (patch) | |
| tree | 5e5ccd511daa0eabe82b5591298918c015d2eb14 | |
| parent | 5bba3395bc0bb84dcd24a7ade0c855a6beb6dbef (diff) | |
| download | coinos-server-54c28a395db853c601d3592c967f322c7f09e1d4.tar.gz coinos-server-54c28a395db853c601d3592c967f322c7f09e1d4.zip | |
Making progress on transactions report
| -rw-r--r-- | app.coffee | 20 | ||||
| -rw-r--r-- | public/js/report.coffee | 29 | ||||
| -rw-r--r-- | views/report.html | 8 |
3 files changed, 31 insertions, 26 deletions
@@ -20,8 +20,8 @@ app.get('/', (req, res) -> res.render('index', js: (-> global.js), css: (-> global.css)) ) -app.get('/report', (req, res) -> - res.render('report', js: (-> global.js), css: (-> global.css)) +app.get('/:user/report', (req, res) -> + res.render('report', user: req.params.user, js: (-> global.js), css: (-> global.css)) ) app.get('/:user.json', (req, res) -> @@ -35,16 +35,24 @@ app.get('/:user.json', (req, res) -> app.get('/:user/transactions', (req, res) -> db = require("redis").createClient() user = req.params.user + r = 'transactions': [] db.lrange("#{user}:transactions", 0, -1, (err, transactions) -> - for i in transactions - db.hgetall("#{user}:transactions:#{i}", (err, t) -> - res.write(JSON.stringify(t)) + process = (err, t) -> + r.transactions.push t + + if i >= transactions.length + res.write(JSON.stringify(r)) res.end() - ) + else + db.hgetall("#{user}:transactions:#{transactions[i++]}", process) + + i = 0 + db.hgetall("#{user}:transactions:#{transactions[i++]}", process) ) ) + app.get('/ticker', (req, res) -> symbol = req.params.symbol symbol or= 'virtexCAD' diff --git a/public/js/report.coffee b/public/js/report.coffee index 650e25b4..e045454e 100644 --- a/public/js/report.coffee +++ b/public/js/report.coffee @@ -1,29 +1,32 @@ +#= require jquery-1.8.2.min.js +#= require jquery-ui-1.9.0.custom.min.js + $(-> $('.date').datepicker() $.getJSON('transactions', (data) -> $.each(data.transactions, -> - keys = Object.keys(this) - transaction = this - - $.each(keys, (i,v) -> - $('tbody tr:last td:eq(' + i + ')').html(transaction[v]) - }) - - $('tbody:last').append($('tbody tr:last').clone()) - }) - $('tbody tr:last').remove() + $('tbody').append(""" + <tr> + <td>#{this.date}</td> + <td>#{this.address}</td> + <td>#{this.exchange}</td> + <td>#{this.received}</td> + <td>#{(this.received * this.exchange).toFixed(2)}</td> + </tr> + """) + ) btc = 0 $('td:nth-child(4)').each(-> btc += parseFloat($(this).html()) - }) + ) $('#btc').html(btc) cad = 0 $('td:nth-child(5)').each(-> cad += parseFloat($(this).html()) - }) + ) $('#cad').html(cad) - }) + ) ) diff --git a/views/report.html b/views/report.html index 762ce7d9..70fbe81c 100644 --- a/views/report.html +++ b/views/report.html @@ -11,6 +11,7 @@ <div class="container-fluid"> <h1>Transactions Report</h1> + <input id="user" type="hidden" value="{{user}}" /> From: <input id="from" name="from" type="text" class="date" /> To: <input id="to" name="to" type="text" class="date" /> @@ -25,13 +26,6 @@ </tr> </thead> <tbody> - <tr> - <td></td> - <td></td> - <td></td> - <td></td> - <td></td> - </tr> </tbody> <tfoot> <tr> |
