Skip to content

Commit

Permalink
fix: criminal document download
Browse files Browse the repository at this point in the history
refactor: remove unneeded error handling from courtfilesearch
  • Loading branch information
JTraill committed Jan 20, 2025
1 parent 655d068 commit e5dc17a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 62 deletions.
21 changes: 4 additions & 17 deletions web/src/components/courtfilesearch/CourtFileSearchView.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@

<template>
<!-- todo: Extract this out to more generic location -->
<v-overlay :opacity="0.333" v-model="isLoading" />
<b-card
body-class="px-0"
bg-variant="light"
v-if="isLookupDataMounted && !isLookupDataReady"
>
<b-card style="min-height: 40px">
<span v-if="errorCode != '0'">
<span v-if="errorCode === '403'">
You are not authorized to access this page.
</span>
<span v-else>
Server is not responding.
<b>({{ errorText }} "{{ errorCode }}")</b></span
>
</span>
<span v-else> No Court File Search Found. </span>
</b-card>

<b-card style="min-height: 40px" v-if="errorCode > 0 && errorCode == '403'">
<span> You are not authorized to access this page. </span>
</b-card>
<!------------------------------------------------------->
<v-banner style="background-color: #62d3a4; color: #183a4a">
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/criminal/CriminalDocumentsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@
const getNameOfParticipant = (num) => {
commonStore.updateDisplayName({
lastName: participantFiles[num].lastName,
givenName: participantFiles[num].firstName,
lastName: participantFiles[num]?.lastName || '',
givenName: participantFiles[num]?.firstName || '',
});
return commonStore.displayName;
};
Expand Down
89 changes: 46 additions & 43 deletions web/src/components/shared.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import { CourtDocumentType, DocumentData } from "@/types/shared"
import { splunkLog } from "@/utils/utils"
import base64url from "base64url"
import { v4 as uuidv4 } from "uuid"
import { CourtDocumentType, DocumentData } from '@/types/shared';
import { splunkLog } from '@/utils/utils';
import { v4 as uuidv4 } from 'uuid';

export default {
convertToBase64Url(inputText: string): string {
const base64 = btoa(inputText);
return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
},
openDocumentsPdf(
documentType: CourtDocumentType,
documentData: DocumentData
): void {
const fileName = this.generateFileName(documentType, documentData).replace(
/\//g,
"_"
)
const isCriminal = documentType == CourtDocumentType.Criminal
'_'
);
const isCriminal = documentType == CourtDocumentType.Criminal;
const documentId = documentData.documentId
? base64url(documentData.documentId)
: documentData.documentId
const correlationId = uuidv4()
? this.convertToBase64Url(documentData.documentId)
: documentData.documentId;
const correlationId = uuidv4();

switch (documentType) {
case CourtDocumentType.CSR:
Expand All @@ -26,8 +29,8 @@ export default {
}/${encodeURIComponent(fileName)}?vcCivilFileId=${
documentData.fileId
}`
)
break
);
break;
case CourtDocumentType.ROP:
window.open(
`${
Expand All @@ -39,8 +42,8 @@ export default {
}&courtLevelCode=${documentData.courtLevel}&courtClassCode=${
documentData.courtClass
}`
)
break
);
break;
default:
this.openRequestedTab(
`${
Expand All @@ -51,8 +54,8 @@ export default {
documentData.fileId
}&CorrelationId=${correlationId}`,
correlationId
)
break
);
break;
}
},

Expand All @@ -62,53 +65,53 @@ export default {
): string {
const locationAbbreviation = (
documentData.location.match(/[A-Z]/g) || []
).join("")
).join('');
switch (documentType) {
case CourtDocumentType.Civil:
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.fileNumberText}-${documentData.documentDescription}-${documentData.dateFiled}-${documentData.documentId}.pdf`
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.fileNumberText}-${documentData.documentDescription}-${documentData.dateFiled}-${documentData.documentId}.pdf`;
case CourtDocumentType.ProvidedCivil:
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.fileNumberText}-${documentData.documentDescription}-${documentData.appearanceDate}-${documentData.partyName}.pdf`
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.fileNumberText}-${documentData.documentDescription}-${documentData.appearanceDate}-${documentData.partyName}.pdf`;
case CourtDocumentType.CSR:
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.fileNumberText}-${documentData.documentDescription}-${documentData.appearanceDate}.pdf`
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.fileNumberText}-${documentData.documentDescription}-${documentData.appearanceDate}.pdf`;
case CourtDocumentType.Criminal:
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.courtClass}-${documentData.fileNumberText}-${documentData.documentDescription}-${documentData.dateFiled}-${documentData.documentId}.pdf`
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.courtClass}-${documentData.fileNumberText}-${documentData.documentDescription}-${documentData.dateFiled}-${documentData.documentId}.pdf`;
case CourtDocumentType.ROP:
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.courtClass}-${documentData.fileNumberText}-${documentData.documentDescription}-${documentData.partId}.pdf`
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.courtClass}-${documentData.fileNumberText}-${documentData.documentDescription}-${documentData.partId}.pdf`;
case CourtDocumentType.CivilZip:
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.fileNumberText}-documents.zip`
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.fileNumberText}-documents.zip`;
case CourtDocumentType.CriminalZip:
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.courtClass}-${documentData.fileNumberText}-documents.zip`
return `${locationAbbreviation}-${documentData.courtLevel}-${documentData.courtClass}-${documentData.fileNumberText}-documents.zip`;
default:
throw Error(`No file structure for type: ${documentType}`)
throw Error(`No file structure for type: ${documentType}`);
}
},

openRequestedTab(url, correlationId) {
const start = new Date()
const startStr = start.toLocaleString("en-US", {
timeZone: "America/Vancouver"
})
const startMsg = `Request Tracking - Frontend request to API - CorrelationId: ${correlationId} Start time: ${startStr}`
const start = new Date();
const startStr = start.toLocaleString('en-US', {
timeZone: 'America/Vancouver',
});
const startMsg = `Request Tracking - Frontend request to API - CorrelationId: ${correlationId} Start time: ${startStr}`;
//console.log(startMsg);
splunkLog(startMsg)
splunkLog(startMsg);

const windowObjectReference = window.open(url)
const windowObjectReference = window.open(url);
if (windowObjectReference !== null) {
const end = new Date()
const endStr = start.toLocaleString("en-US", {
timeZone: "America/Vancouver"
})
const end = new Date();
const endStr = start.toLocaleString('en-US', {
timeZone: 'America/Vancouver',
});

const duration = (end.getTime() - start.getTime()) / 1000
const endMsg = `Request Tracking - API response received - CorrelationId: ${correlationId} End time: ${endStr} Duration: ${duration}s`
const duration = (end.getTime() - start.getTime()) / 1000;
const endMsg = `Request Tracking - API response received - CorrelationId: ${correlationId} End time: ${endStr} Duration: ${duration}s`;

// eslint-disable-next-line
windowObjectReference.onload = (event) => {
if (windowObjectReference.document.readyState === "complete") {
if (windowObjectReference.document.readyState === 'complete') {
//console.log(endMsg);
splunkLog(endMsg)
splunkLog(endMsg);
}
}
};
}
}
}
},
};

0 comments on commit e5dc17a

Please sign in to comment.