Skip to content
Snippets Groups Projects
Commit 15741f83 authored by Caner Candan's avatar Caner Candan
Browse files

* added division in history page + finished transfer page

parent aff28258
No related branches found
No related tags found
No related merge requests found
static/favicon.ico

1.37 KiB

{% with messages=get_flashed_messages(with_categories=true) %}
{% if messages %} {% if messages %}
<div class="row"> <div class="row">
<div class="span12"> <div class="span12">
{% for message in messages %} {% for category, message in messages %}
<div class="alert alert-{% if message.tags == 'error' %}danger{% else %}{{message.tags}}{% endif %} fade in"> <div class="alert alert-{% if category == 'error' %}danger{% else %}{{category}}{% endif %} fade in">
<a class="close" title="Close" href="#" data-dismiss="alert">&times;</a> <a class="close" title="Close" href="#" data-dismiss="alert">&times;</a>
<strong>{{message.tags|title}}:</strong> {{message}} <strong>{{category|title}}:</strong> {{message}}
</div> </div>
{% endfor %} {% endfor %}
</div><!-- end span --> </div><!-- end span -->
</div><!-- end row --> </div><!-- end row -->
{% endif %} {% endif %}
{% endwith %}
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
<head> <head>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<title>{% block page_title %}uCoin - {% block section_title %}{% endblock %}{% endblock %}</title> <title>{% block page_title %}uCoin - {% block section_title %}{% endblock %}{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!-- Bootstrap --> <!-- Bootstrap -->
<link href="{{ url_for('static', filename='bootstrap/css/bootstrap.min.css') }}" rel="stylesheet" media="screen"> <link href="{{ url_for('static', filename='bootstrap/css/bootstrap.min.css') }}" rel="stylesheet" media="screen"/>
<link href="{{ url_for('static', filename='bootstrap/css/bootstrap-theme.min.css') }}" rel="stylesheet" media="screen"> <link href="{{ url_for('static', filename='bootstrap/css/bootstrap-theme.min.css') }}" rel="stylesheet" media="screen"/>
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"/>
<style>body {overflow-y: scroll;}</style> <style>body {overflow-y: scroll;}</style>
<script type="text/javascript"> <script type="text/javascript">
......
...@@ -16,9 +16,18 @@ ...@@ -16,9 +16,18 @@
{% endwith %} {% endwith %}
<div class="col-md-7"> <div class="col-md-7">
<ul class="nav nav-tabs pull-right"> <ul class="nav nav-tabs pull-right">
{% for name, color in [("all", "default"), ("transfer", "info"), ("issuance", "success"), ("fusion", "warning")] -%} {% for name, color in [("all", "default"), ("transfer", "info"), ("issuance", "success"), ("fusion", "warning"), ("division", "danger")] -%}
<li {% if type == name %}class="active"{% endif %}><a href="{{ url_for('wallet_history', pgp_fingerprint=key.fingerprint, type=name) }}"><span class="label label-{{color}}">{{name|title}}</span></a></li> <li {% if type == name %}class="active"{% endif %}>
<a href="{{ url_for('wallet_history', pgp_fingerprint=key.fingerprint, type=name) }}">
<span class="label label-{{color}}">{{name|title}}</span>
</a>
</li>
{% endfor -%} {% endfor -%}
<li>
<a href="{{ url_for('wallet_history_refresh', pgp_fingerprint=key.fingerprint, type=type) }}">
<i class="glyphicon glyphicon-refresh"></i>
</a>
</li>
</ul> </ul>
</div> </div>
</div> </div>
...@@ -36,10 +45,10 @@ ...@@ -36,10 +45,10 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for r in data -%} {% for number, tx in data.items()|reverse -%}
{% with tx=r.value.transaction -%} {# {% with tx=r.value.transaction -%} #}
{% if type == "all" or tx.type|lower == type|lower -%} {% if type == "all" or tx.type|lower == type|lower -%}
<tr class="row1 {% if tx.type == 'TRANSFER' %}active{% elif tx.type == 'ISSUANCE' %}success{% else %}warning{% endif %}"> <tr class="row1 {% if tx.type == 'TRANSFER' %}active{% elif tx.type == 'ISSUANCE' %}success{% elif tx.type == 'FUSION' %}warning{% else %}danger{% endif %}">
<td>{{tx.number}}</td> <td>{{tx.number}}</td>
<td> <td>
...@@ -57,7 +66,7 @@ ...@@ -57,7 +66,7 @@
</td> </td>
<td> <td>
<span class="label label-{% if tx.type == 'TRANSFER' %}info{% elif tx.type == 'ISSUANCE' %}success{% else %}warning{% endif %}">{{tx.type|title}}</span> <span class="label label-{% if tx.type == 'TRANSFER' %}info{% elif tx.type == 'ISSUANCE' %}success{% elif tx.type == 'FUSION' %}warning{% else %}danger{% endif %}">{{tx.type|title}}</span>
<a class="tooltip_link" title="{{tx.comment|trim}}">{{tx.comment|trim|truncate(150)}}</a> <a class="tooltip_link" title="{{tx.comment|trim}}">{{tx.comment|trim|truncate(150)}}</a>
</td> </td>
...@@ -70,7 +79,7 @@ ...@@ -70,7 +79,7 @@
</td> </td>
</tr> </tr>
{% endif -%} {% endif -%}
{% endwith -%} {# {% endwith -%} #}
{% endfor -%} {% endfor -%}
</tbody> </tbody>
</table> </table>
......
...@@ -15,19 +15,17 @@ ...@@ -15,19 +15,17 @@
<div class="col-md-3"> <div class="col-md-3">
<div class="alert alert-info tooltip_link" title="{{coins}}">Account balance: <span class="badge alert-default">{{clist.0}}</span></div> <div class="alert alert-info tooltip_link" title="{{coins}}">Account balance: <span class="badge alert-default">{{clist.0}}</span></div>
</div> </div>
<div class="col-md-2"> <div class="col-md-9">
<div class="alert alert-info">{{coins}}</div> <div class="alert alert-info">{{coins}}</div>
</div> </div>
{% endwith -%} {% endwith -%}
<div class="col-md-7">
</div>
</div> </div>
<form role="form" method="post" action="{{ url_for('wallet_transfer', pgp_fingerprint=key.fingerprint) }}"> <form role="form" method="post" action="{{ url_for('wallet_transfer', pgp_fingerprint=key.fingerprint) }}">
<div class="panel panel-success"> <div class="panel panel-success">
<div class="panel-heading"><h4>Recipient</h4></div> <div class="panel-heading"><h4>Recipient</h4></div>
<div class="panel-body"> <div class="panel-body">
<input class="typeahead" type="text" placeholder="Your recipient" name="recipient"/> <input class="typeahead form-control" type="text" placeholder="Your recipient" name="recipient"/>
</div> </div>
</div> </div>
...@@ -49,6 +47,13 @@ ...@@ -49,6 +47,13 @@
</div> </div>
</div> </div>
<div class="panel panel-success">
<div class="panel-heading"><h4>Message</h4></div>
<div class="panel-body">
<textarea class="form-control" name="message" placeholder="Write here a comment" rows="5"></textarea>
</div>
</div>
<div class="form-group"> <div class="form-group">
<button class="btn btn-lg btn-primary btn-block" type="submit">Transfer</button> <button class="btn btn-lg btn-primary btn-block" type="submit">Transfer</button>
</div> </div>
......
...@@ -18,16 +18,22 @@ ...@@ -18,16 +18,22 @@
# #
from pprint import pprint from pprint import pprint
import ucoin, json, logging, argparse, sys, gnupg, hashlib, re, datetime as dt import\
ucoin, json, logging, argparse, sys,\
gnupg, hashlib, re, datetime as dt
from collections import OrderedDict from collections import OrderedDict
from merkle import Merkle from merkle import Merkle
from flask import Flask, request, render_template, jsonify from flask import\
Flask, request, render_template,\
jsonify, redirect, abort, url_for,\
flash
from io import StringIO from io import StringIO
from werkzeug.contrib.cache import SimpleCache from werkzeug.contrib.cache import SimpleCache
from itertools import combinations, chain from itertools import combinations, chain
logger = logging.getLogger("cli") logger = logging.getLogger("cli")
app = Flask(__name__) app = Flask(__name__)
app.secret_key = 'some_secret'
cache = SimpleCache() cache = SimpleCache()
@app.template_filter('split') @app.template_filter('split')
...@@ -93,6 +99,9 @@ def get_sender_transactions(pgp_fingerprint): ...@@ -93,6 +99,9 @@ def get_sender_transactions(pgp_fingerprint):
rv = cache.get(k) rv = cache.get(k)
if rv is None: if rv is None:
rv = list(ucoin.hdc.transactions.Sender(pgp_fingerprint).get()) rv = list(ucoin.hdc.transactions.Sender(pgp_fingerprint).get())
__dict = {}
for item in rv: __dict[item['value']['transaction']['number']] = item['value']['transaction']
rv = __dict
cache.set(k, rv, timeout=5*60) cache.set(k, rv, timeout=5*60)
return rv return rv
...@@ -101,6 +110,9 @@ def get_recipient_transactions(pgp_fingerprint): ...@@ -101,6 +110,9 @@ def get_recipient_transactions(pgp_fingerprint):
rv = cache.get(k) rv = cache.get(k)
if rv is None: if rv is None:
rv = list(ucoin.hdc.transactions.Recipient(pgp_fingerprint).get()) rv = list(ucoin.hdc.transactions.Recipient(pgp_fingerprint).get())
__dict = {}
for item in rv: __dict[item['value']['transaction']['number']] = item['value']['transaction']
rv = __dict
cache.set(k, rv, timeout=5*60) cache.set(k, rv, timeout=5*60)
return rv return rv
...@@ -131,6 +143,14 @@ def wallet_history(pgp_fingerprint, type='all'): ...@@ -131,6 +143,14 @@ def wallet_history(pgp_fingerprint, type='all'):
type=type, type=type,
clist=clist(pgp_fingerprint)) clist=clist(pgp_fingerprint))
@app.route('/wallets/<pgp_fingerprint>/history/refresh')
@app.route('/wallets/<pgp_fingerprint>/history/refresh/<type>')
def wallet_history_refresh(pgp_fingerprint, type='all'):
k = 'sender_transactions_%s' % pgp_fingerprint; cache.set(k, None)
k = 'recipient_transactions_%s' % pgp_fingerprint; cache.set(k, None)
flash(u'History refreshed', 'info')
return redirect(url_for('wallet_history', pgp_fingerprint=pgp_fingerprint, type=type))
def powerset(iterable): def powerset(iterable):
xs = list(iterable) xs = list(iterable)
return chain.from_iterable( combinations(xs,n) for n in range(len(xs)+1) ) return chain.from_iterable( combinations(xs,n) for n in range(len(xs)+1) )
...@@ -245,9 +265,11 @@ def wallet_transfer(pgp_fingerprint): ...@@ -245,9 +265,11 @@ def wallet_transfer(pgp_fingerprint):
coins = cget(pgp_fingerprint, selected_combination) coins = cget(pgp_fingerprint, selected_combination)
if not transfer(pgp_fingerprint, recipient, coins, message): if not transfer(pgp_fingerprint, recipient, coins, message):
raise ValueError('transfer error') flash(u'Transfer error', 'error')
else:
flash(u'Transfer success (%s %s)' % (str(selected_combination), recipient), 'success')
return '%s %s' % (str(selected_combination), recipient) return redirect(url_for('wallet_transfer', pgp_fingerprint=pgp_fingerprint))
@app.route('/wallets/public_keys') @app.route('/wallets/public_keys')
def wallet_public_keys(): def wallet_public_keys():
...@@ -513,9 +535,12 @@ if __name__ == '__main__': ...@@ -513,9 +535,12 @@ if __name__ == '__main__':
def run(): def run():
print('Running...') print('Running...')
app.secret_key = ucoin.settings['secret_key']
app.run(debug=True) app.run(debug=True)
subparsers.add_parser('run', help='Run the webclient').set_defaults(func=run) sp = subparsers.add_parser('run', help='Run the webclient')
sp.add_argument('--secret_key', '-s', help='Pass a secret key used by the server for sessions', default='some_secret')
sp.set_defaults(func=run)
args = parser.parse_args() args = parser.parse_args()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment