From a2c4739344ab42ee168baf6bc40a24dc25d0bd41 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Thu, 2 Jul 2020 20:52:50 -0700 Subject: [PATCH] improve qr code page and adding more meta to others --- src/data_types.rs | 8 ++++++ src/main.rs | 15 ++++++++--- static/css/main.css | 4 +++ templates/address.html.tera | 19 +++++++++----- templates/block.html.tera | 4 +-- templates/transaction.html.tera | 46 ++++++++++++++++++++++++++------- 6 files changed, 75 insertions(+), 21 deletions(-) diff --git a/src/data_types.rs b/src/data_types.rs index a5ffd3e..dcc02ab 100644 --- a/src/data_types.rs +++ b/src/data_types.rs @@ -234,3 +234,11 @@ pub struct RingSignatures { pub txnFee: Option, pub outPk: Option> } + +#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)] +pub struct QRData { + pub tx_amount: String, + pub tx_description: String, + pub recipient_name: String, + pub tx_payment_id: String +} diff --git a/src/main.rs b/src/main.rs index 0ba1046..c3cfea1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,19 +109,26 @@ fn show_wallet_address( recipient_name: Option, tx_payment_id: Option ) -> Template { + let qr_data: QRData = QRData { + tx_amount: tx_amount.unwrap_or("".to_string()), + tx_description: tx_description.unwrap_or("".to_string()), + recipient_name: recipient_name.unwrap_or("".to_string()), + tx_payment_id: tx_payment_id.unwrap_or("".to_string()) + }; let address_uri = format!( "wownero:{}&tx_amount={}&tx_description={}&recipient_name={}&tx_payment_id={}", wallet_address, - tx_amount.unwrap_or("".to_string()), - tx_description.unwrap_or("".to_string()), - recipient_name.unwrap_or("".to_string()), - tx_payment_id.unwrap_or("".to_string()) + qr_data.tx_amount, + qr_data.tx_description, + qr_data.recipient_name, + qr_data.tx_payment_id ); let qr_code: String = qrcode_generator::to_svg_to_string(address_uri, QrCodeEcc::Low, 256, None) .unwrap(); let qr_code: String = base64::encode(qr_code); let context: JsonValue = json!({ "qr_code": qr_code, + "qr_data": qr_data, "wallet_address": wallet_address }); Template::render("address", context) diff --git a/static/css/main.css b/static/css/main.css index b2dba89..37273cf 100755 --- a/static/css/main.css +++ b/static/css/main.css @@ -308,6 +308,10 @@ p.subheader { padding-bottom: 1em; } +.qr_code { + text-align: center; +} + #slim-header { text-align: center; } diff --git a/templates/address.html.tera b/templates/address.html.tera index f63a811..b129d2e 100644 --- a/templates/address.html.tera +++ b/templates/address.html.tera @@ -11,18 +11,25 @@

Wallet Address

-

Address: {{ wallet_address }}

+
-
+
+
    +
  • Address: {{ wallet_address }}
  • +
  • Tx Amount: {{ qr_data.tx_amount }}
  • +
  • Tx Payment Id: {{ qr_data.tx_payment_id }}
  • +
  • Tx Description: {{ qr_data.tx_description }}
  • +
  • Recipient Name: {{ qr_data.recipient_name }}
  • +

Want to generate a QR code for incoming payment?

- - - - + + + +
diff --git a/templates/block.html.tera b/templates/block.html.tera index 61336f8..f13052b 100644 --- a/templates/block.html.tera +++ b/templates/block.html.tera @@ -78,11 +78,11 @@

- + + {% if tx_hashes %} - {% if tx_hashes %} {% for hash in tx_hashes %} diff --git a/templates/transaction.html.tera b/templates/transaction.html.tera index e5283d9..30c177b 100644 --- a/templates/transaction.html.tera +++ b/templates/transaction.html.tera @@ -2,14 +2,6 @@ {% block content %} -{% for i in tx_info %} -{{i.block_height}} -{{i.block_timestamp}} -{{i.double_spend_seen}} -{{i.in_pool}} -{{i.output_indices}} -{% endfor %} -
@@ -20,7 +12,7 @@

Transaction {{ tx_hash | truncate(length=4) }}

Full Hash: {{ tx_hash }}

-

Block Timestamp: {% if tx_info.0.block_timestamp %}{{ tx_info.0.block_timestamp }}{% else %}?{% endif %}

+

Block Timestamp: {% if tx_info.0.block_timestamp %}{{ tx_info.0.block_timestamp | date(format="%Y-%m-%d %H:%M") }}{% else %}?{% endif %}

@@ -47,10 +39,46 @@

{{ tx_info.0.double_spend_seen }}

+
+
+
+

Transaction Fee

+
+

{{ tx_info.0.as_json_full.rct_signatures.txnFee / 1000000000000 | default(value="?") }} WOW

+
+
+
+
+
+

Version

+
+

{{ tx_info.0.as_json_full.version | default(value="?") }}

+
+
+
+
+
+

Inputs / Outputs

+
+

{{ tx_info.0.as_json_full.vin | length | default(value="?") }} / {{ tx_info.0.as_json_full.vout | length | default(value="?") }}

+
+


+
+
+
+

Stealth Addresses

+
+
    + {% for i in tx_info.0.as_json_full.vout %} +
  1. {{ i.target.key }}
  2. + {% endfor %} +
+
+
{% if tx_info.0.block_height %}

View Block

{% endif %}

Transactions ({% if tx_hashes %}{{ tx_hashes | length - 1 }}{% else %}?{% endif %})

Transactions ({% if tx_hashes %}{{ tx_hashes | length }}{% else %}0{% endif %})

Hash
{{ hash | truncate(length=12) }}