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
VERIFIER_HOST=http://192.168.2.200:5001/grassroot-verifier/us-central1
API_BASE_URL=http://evergreen
VERIFIER_HOST=http://evergreen:5001/grassroot-verifier/us-central1
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
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
*.local
*.local

View File

@ -12,38 +12,15 @@
}
.big-text {
font-size: 40;
font-size: 64;
}
</style>
<script src='displayLocallyStoredPDF.js'></script>
</head>
<body>
<a class='center big-text' id="mylink">Open locally stored PDF</a>
<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>
<a class='center big-text' id="mylink">View Receipt</a>
<script>updatePage();</script>
</body>
</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.img2x = Constants.img2xBlack;
const displayLocallyStoredPDFUrl = window.location.href + "/displayLocallyStoredPDF.html";
const attributedValue = `<a href="${displayLocallyStoredPDFUrl}">Display locally stored PDF</a>`;
let displayLocallyStoredPDFUrl = window.location.href + "displayLocallyStoredPDF.html";
console.log(displayLocallyStoredPDFUrl)
const attributedValue = `<a href="${displayLocallyStoredPDFUrl}">View</a>`;
console.log('*** attributedValue ***');
console.log(attributedValue);
this.generic.backFields.push({
key: "original",
label: "Label",
label: "Original receipt (saved locally in Safari)",
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) {
console.log(`processing receipt for origin ${receipt.cardOrigin}`);
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(
{
key: "name",
label: "",
value: `${receipt.name}`
label: `${receipt.name} (Last vaccinated: ${mostRecentReceipt.vaccinationDate})`,
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++) {
if (i <= 1)
fieldToPush = generic.secondaryFields;
else if (i <= 3)
fieldToPush = generic.auxiliaryFields;
else if (i <= 5)
fieldToPush = generic.backFields;
fieldToPush.push(
generic.backFields.push(
{
key: 'vaccine' + i,
label: receipt.vaccinations[i].vaccineName,