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

* added history feature to wallets

parent 028481d2
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,12 @@
});
</script>
<script type="text/javascript">
$(function() {
$('.tooltip_link').tooltip();
});
</script>
{% block foot %}{% endblock %}
</body>
......
......@@ -11,12 +11,11 @@
<a id="list" href="{{ url_for('wallets') }}" class="list-group-item"><i class="glyphicon glyphicon-list-alt"></i> Wallet list</a>
</div>
{% if key %}
{% if key -%}
<div class="list-group" style="background-color: #f7f5fa;">
<a id="new" href="{{ url_for('new_wallet') }}" class="list-group-item"><i class="glyphicon glyphicon-plus-sign"></i> New</a>
<a id="list" href="{{ url_for('wallets') }}" class="list-group-item"><i class="glyphicon glyphicon-list-alt"></i> Wallet list</a>
<a id="history" href="{{ url_for('wallet_history', pgp_fingerprint=key.fingerprint) }}" class="list-group-item"><i class="glyphicon glyphicon-calendar"></i> History</a>
</div>
{% endif %}
{% endif -%}
</div>
<div class="col-lg-9">
{% block sub_content %}{% endblock %}
......@@ -32,6 +31,11 @@
'/': 'list',
'{{ url_for('new_wallet') }}': 'new',
'{{ url_for('wallets') }}': 'list',
{% if key -%}
'{{ url_for('wallet_history', pgp_fingerprint=key.fingerprint) }}': 'history',
'{{ url_for('wallet_history', pgp_fingerprint=key.fingerprint, type=type) }}': 'history',
{% endif -%}
};
var matches = window.location.pathname.match(/^(\/[^?]*)/g);
......
{% extends "wallets/base.html" %}
{% block sub_content %}
<h1><span class="label label-default">History</span> <span class="label label-primary">{{key.uids.0|truncate(50)}}</span></h1>
<ul class="nav nav-tabs pull-right">
{% for name, color in [("all", "default"), ("transfer", "info"), ("issuance", "success"), ("fusion", "warning")] -%}
<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 -%}
</ul>
{% for label,data in [("Received", recipient), ("Sent", sender)] -%}
<h3>{{label}} transactions</h3>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th class="col-md-1 text-left">#</th>
<th class="col-md-2 text-center">{{"Sender" if label == "Received" else "Recipient" }}</th>
<th class="col-md-8 text-center">Comment</th>
<th class="col-md-1 text-center">Amount</th>
</tr>
</thead>
<tbody>
{% for r in data -%}
{% with tx=r.value.transaction -%}
{% 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 %}">
<td>{{tx.number}}</td>
<td>
{% with reference=tx.sender if label == "Received" else tx.recipient -%}
{% with name=settings.list_keys[reference].uids.0 if settings.list_keys[reference] else "", keyid=reference[-8:] -%}
<a class="tooltip_link" title="{{name}} ({{keyid}})">
{% if reference == key.fingerprint -%}
<span class="label label-default">me</span>
{% else -%}
<span class="label label-info">{{name|truncate(25) if name else keyid}}</span>
{% endif -%}
</a>
{% endwith -%}
{% endwith -%}
</td>
<td>
<span class="label label-{% if tx.type == 'TRANSFER' %}info{% elif tx.type == 'ISSUANCE' %}success{% else %}warning{% endif %}">{{tx.type|title}}</span>
<a class="tooltip_link" title="{{tx.comment|trim}}">{{tx.comment|trim|truncate(150)}}</a>
</td>
<td class="text-right">
{% with coins=tx.coins|map(attribute="id")|map("compute_coin")|list -%}
<span class="badge alert-{{'success' if label == 'Received' else 'danger'}} tooltip_link" title="{{coins|join(' + ')}}">
{{coins|sum}}
</span>
{% endwith -%}
</td>
</tr>
{% endif -%}
{% endwith -%}
{% endfor -%}
</tbody>
</table>
{% endfor -%}
{% endblock %}
......@@ -9,7 +9,7 @@
<div class="list-group">
{% for fp,k in settings.list_keys.items() %}
<a href="{{ url_for('wallet_detail', pgp_fingerprint=fp) }}" class="list-group-item {% if k.keyid == settings.keyid %}active{% endif %}">
<a href="{{ url_for('wallet_history', pgp_fingerprint=fp) }}" class="list-group-item {% if k.keyid == settings.keyid %}active{% endif %}">
<h4 class="list-group-item-heading">{{k.uids.0}}</h4>
<p class="list-group-item-text">{{fp}}</p>
</a>
......
......@@ -76,12 +76,14 @@
if (!(email.val())) {
email.parent().addClass('has-error');
create.button('error');
email.focus().select();
return false;
}
if (!(realm.val())) {
realm.parent().addClass('has-error');
create.button('error');
realm.focus().select();
return false;
}
......
......@@ -28,6 +28,15 @@ logger = logging.getLogger("cli")
app = Flask(__name__)
@app.template_filter('split')
def split_filter(s, sep=' '):
return s.split(sep)
@app.template_filter('compute_coin')
def compute_coin_filter(coin):
fpr, number, base, power, origin, origin_number = coin.split('-')
return int(base)*10**int(power)
def render_prettyprint(template_name, result):
s = StringIO()
pprint(result, s)
......@@ -67,9 +76,18 @@ VotersCount\t\t%(votersCount)s
def wallets():
return render_template('wallets/index.html', settings=ucoin.settings)
@app.route('/wallets/<pgp_fingerprint>')
def wallet_detail(pgp_fingerprint):
return render_template('wallets/detail.html', settings=ucoin.settings, key=ucoin.settings['list_keys'].get(pgp_fingerprint))
@app.route('/wallets/<pgp_fingerprint>/history')
@app.route('/wallets/<pgp_fingerprint>/history/<type>')
def wallet_history(pgp_fingerprint, type='all'):
sender = ucoin.hdc.transactions.Sender(pgp_fingerprint).get()
recipient = ucoin.hdc.transactions.Recipient(pgp_fingerprint).get()
return render_template('wallets/history.html',
settings=ucoin.settings,
key=ucoin.settings['list_keys'].get(pgp_fingerprint),
sender=sender,
recipient=recipient,
type=type)
@app.route('/wallets/new')
def new_wallet():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment