ready for deployment to main

This commit is contained in:
Billy Lo 2021-10-24 13:28:13 -04:00
parent deb2222322
commit 8eeb31c988
5 changed files with 53 additions and 59 deletions

View File

@ -1,6 +1,6 @@
API_BASE_URL=http://192.168.2.200 API_BASE_URL=http://evergreen
VERIFIER_HOST=http://192.168.2.200:5001/grassroot-verifier/us-central1 VERIFIER_HOST=http://evergreen:5001/grassroot-verifier/us-central1
HITCOUNT_HOST=http://localhost:8080 HITCOUNT_HOST=http://localhost:8080
REGISTRATION_HOST=http://192.168.2.200:5001/grassroot-verifier/us-central1 REGISTRATION_HOST=http://evergreen:5001/grassroot-verifier/us-central1
FUNCTION_SUFFIX=v2 FUNCTION_SUFFIX=v2
GPAY_BASE_URL=http://localhost:5002/grassroots-gpay/us-central1/googlesign GPAY_BASE_URL=http://localhost:5002/grassroots-gpay/us-central1/googlesign

1
.gitignore vendored
View File

@ -33,3 +33,4 @@ yarn-error.log*
# Idea files # Idea files
.idea .idea
*.local *.local
*.local

View File

@ -12,38 +12,15 @@
} }
.big-text { .big-text {
font-size: 40; font-size: 64;
} }
</style> </style>
<script src='displayLocallyStoredPDF.js'></script>
</head> </head>
<body> <body>
<a class='center big-text' id="mylink">Open locally stored PDF</a> <a class='center big-text' id="mylink">View Receipt</a>
<script>updatePage();</script>
<script>
console.log('start');
let dataUrl = localStorage.getItem('pdfDataUrl');
let script = `function showData(base64URL){
var win = window.open();
win.document.write('<iframe src="' + base64URL + '" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>');
}
showData('${dataUrl}');
`;
let hrefValue = `javascript:${script};`
const myLinkElement = document.getElementById('mylink');
if (dataUrl) {
console.log('ready');
myLinkElement.setAttribute('href', hrefValue);
// myLinkElement.click();
} else {
myLinkElement.textContent = 'PDF receipt not saved locally.';
}
</script>
</body> </body>
</html> </html>

View File

@ -0,0 +1,23 @@
function updatePage() {
let dataUrl = localStorage.getItem('pdfDataUrl');
const myLinkElement = document.getElementById('mylink');
if (dataUrl != undefined) {
let script = `function showData(base64URL){
var win = window.open();
win.document.write('<iframe src="' + base64URL + '" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>');
} showData('${dataUrl}');`;
let hrefValue = `javascript:${script};`;
myLinkElement.setAttribute('href', hrefValue);
} else {
if (navigator.userAgent.indexOf('Safari') != -1) {
myLinkElement.textContent = 'Sorry. This feature requires the use of Safari as default browser. You can change it in Settings - Chrome/Firefox';
} else {
myLinkElement.textContent = 'Original receipt not available locally. Please re-create your wallet pass. Thanks.';
}
}
}

View File

@ -83,61 +83,54 @@ export class Payload {
this.img1x = Constants.img1xBlack; this.img1x = Constants.img1xBlack;
this.img2x = Constants.img2xBlack; this.img2x = Constants.img2xBlack;
const displayLocallyStoredPDFUrl = window.location.href + "/displayLocallyStoredPDF.html"; let displayLocallyStoredPDFUrl = window.location.href + "displayLocallyStoredPDF.html";
const attributedValue = `<a href="${displayLocallyStoredPDFUrl}">Display locally stored PDF</a>`; console.log(displayLocallyStoredPDFUrl)
const attributedValue = `<a href="${displayLocallyStoredPDFUrl}">View</a>`;
console.log('*** attributedValue ***'); console.log('*** attributedValue ***');
console.log(attributedValue); console.log(attributedValue);
this.generic.backFields.push({ this.generic.backFields.push({
key: "original", key: "original",
label: "Label", label: "Original receipt (saved locally in Safari)",
attributedValue: attributedValue attributedValue: attributedValue
}); });
} }
} }
} }
function createHref(dataUrl) {
// https://stackoverflow.com/a/56738510/2789065
let script = `function debugBase64(base64URL){
var win = window.open();
win.document.write('<iframe src="' + base64URL + '" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>');
}
debugBase64('${dataUrl}');
`;
let hrefValue = `javascript:${script};`
return hrefValue;
}
function processSHCReceipt(receipt: SHCReceipt, generic: PassDictionary) { function processSHCReceipt(receipt: SHCReceipt, generic: PassDictionary) {
console.log(`processing receipt for origin ${receipt.cardOrigin}`); console.log(`processing receipt for origin ${receipt.cardOrigin}`);
if (generic.primaryFields.length == 0) { if (generic.primaryFields.length == 0) {
const lastReceiptIndex = receipt.vaccinations.length - 1
const mostRecentReceipt = receipt.vaccinations[lastReceiptIndex];
const vaccineName = mostRecentReceipt.vaccineName.substring(0,1).toUpperCase() + mostRecentReceipt.vaccineName.substring(1).toLowerCase();
const value = `#${lastReceiptIndex + 1} - ${vaccineName}`;
generic.primaryFields.push( generic.primaryFields.push(
{ {
key: "name", key: "name",
label: "", label: `${receipt.name} (Last vaccinated: ${mostRecentReceipt.vaccinationDate})`,
value: `${receipt.name}` value: value
} }
); );
} }
let fieldToPush; generic.secondaryFields.push({
key: "details",
label: "For details",
value: "Touch the circle with ... on the top right"
});
generic.backFields.push({
key: "date-of-birth",
label: "Date of Birth",
value: receipt.dateOfBirth
});
for (let i = 0; i < receipt.vaccinations.length; i++) { for (let i = 0; i < receipt.vaccinations.length; i++) {
if (i <= 1) generic.backFields.push(
fieldToPush = generic.secondaryFields;
else if (i <= 3)
fieldToPush = generic.auxiliaryFields;
else if (i <= 5)
fieldToPush = generic.backFields;
fieldToPush.push(
{ {
key: 'vaccine' + i, key: 'vaccine' + i,
label: receipt.vaccinations[i].vaccineName, label: receipt.vaccinations[i].vaccineName,