From 19de73f9da1a864d6cd62a23a1a794e5766af5dd Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Tue, 19 Sep 2023 02:55:47 +0200 Subject: [PATCH] Allow configuring nfc permission beforehand (#5319) * Allow configuring nfc permission beforehand * UI improvements --------- Co-authored-by: Dennis Reimann --- .../Views/UIStores/CheckoutAppearance.cshtml | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml b/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml index b53e527c6..29cf8bd31 100644 --- a/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml +++ b/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml @@ -24,6 +24,7 @@ $("#UseClassicCheckout").prop('checked', false); $("#CheckoutV2Settings").addClass('show'); $("#ClassicCheckoutSettings").removeClass('show'); + $("#CheckNFC").removeClass('d-none'); $("#PlaySoundOnPayment").prop('checked', true); $("#ShowPayInWalletButton").prop('checked', false); $("#ShowStoreHeader").prop('checked', false); @@ -32,10 +33,28 @@ $("#UseClassicCheckout").prop('checked', false); $("#CheckoutV2Settings").addClass('show'); $("#ClassicCheckoutSettings").removeClass('show'); + $("#CheckNFC").addClass('d-none'); $("#PlaySoundOnPayment").prop('checked', false); $("#ShowPayInWalletButton").prop('checked', true); $("#ShowStoreHeader").prop('checked', true); }); + + delegate('click', '#CheckNFC button', async e => { + if ('NDEFReader' in window) { + const ndef = new NDEFReader(); + try { + await ndef.scan(); + e.target.classList = 'btn btn-outline-success'; + e.target.innerText = 'NFC access granted'; + } catch (error) { + e.target.classList = 'btn btn-outline-warning'; + e.target.innerText = 'Please allow NFC access in your browser settings'; + } + } else { + e.target.classList = 'btn btn-outline-danger'; + e.target.innerText = 'NFC is not supported by this browser'; + } + }); } @@ -98,13 +117,14 @@ -
- +
+ +