diff --git a/.env.local b/.env.local index fdfc86cd..af89d049 100644 --- a/.env.local +++ b/.env.local @@ -44,7 +44,7 @@ RELAYPATH = "dev-pedw-hc" GOOGLE_TAG_MANAGER = GTM-T78CBC3 -SHOWLOGIN = "false" +SHOWLOGIN = "true" SHOWREPRESENTATIONS = false SHOWFILEUPLOAD = "false" SHOWMAPS = "true" diff --git a/actions/azurestorage.js b/actions/azurestorage.js index 36b89743..eeb42cd0 100644 --- a/actions/azurestorage.js +++ b/actions/azurestorage.js @@ -78,6 +78,7 @@ export const getBlobs = async (containerName, casefolderID) => { "path": blob.name, "documentType": blobDocumentType, "versionId": blob.versionId, + "caseObj": casefolderID + "/" + casefolderID + "_case.json", "isCurrentVersion": blob.isCurrentVersion, "contentLength": blob.properties.contentLength, "contentType": blob.contentType, @@ -137,7 +138,7 @@ export const createBlob = async (formContent, containerName, caseref) => { let caseID = formContent.pinswg_name; const content = JSON.stringify(formContent); - const blobName = caseID + "/" + caseID + ".json"; + const blobName = caseID + "/" + caseID + "_appeal.json"; console.log("blobName:", blobName); const blockBlobClient = containerClient.getBlockBlobClient(blobName); @@ -280,6 +281,8 @@ export const downloadAllProgressFiles = async ( let blobClient = {}; let downloadedBlob = {}; let downloaded = ""; + let caseBlob = {}; + let caseDownloaded = ""; let blobCount = 0; for (const prop in progressBlobObj) { @@ -295,8 +298,29 @@ export const downloadAllProgressFiles = async ( downloaded = downloaded.substring(0, downloaded.length - 1); - //console.log(downloaded); - return '{ "@odata.count": ' + blobCount + ',"value": [' + downloaded + "]}"; + for (const prop in progressBlobObj) { + //console.log(`${prop}: ${progressBlobObj[prop].caseObj}`); + blobClient = containerClient.getBlobClient( + progressBlobObj[prop].caseObj + ); + caseBlob = await blobClient.download(0); + caseDownloaded = + caseDownloaded + + (await streamToBuffer(caseBlob.readableStreamBody)) + + ","; + } + + caseDownloaded = caseDownloaded.substring(0, caseDownloaded.length - 1); + + return ( + '{ "@odata.count": ' + + blobCount + + ',"value": [' + + downloaded + + '],"case":[' + + caseDownloaded + + "]}" + ); }; const streamToBuffer = async (readableStream) => { @@ -324,7 +348,6 @@ export const getCaseBlob = async ( creds ); - console.log("have got to create case"); containerClient.createIfNotExists(); let blobCount = 0; @@ -335,7 +358,7 @@ export const getCaseBlob = async ( } const content = JSON.stringify(formContent); - const blobName = caseReference + "/case/" + caseReference + ".json"; + const blobName = caseReference + "/case/" + caseReference + "_case.json"; console.log("blobName:", blobName); const blockBlobClient = containerClient.getBlockBlobClient(blobName); @@ -365,16 +388,18 @@ export const getProgressBlobs = async (containerName, caseReference) => { blobCount++; } - //console.log("this is the caasefolder:", caseReference, blobCount); + console.log("this is the caasefolder:", caseReference, blobCount); let blobObj = []; for await (const blob of containerClient.listBlobsFlat({ - prefix: caseReference + "/" + caseReference + ".json", + prefix: caseReference + "/" + caseReference + "_appeal.json", })) { + console.log("in here"); blobObj.push({ "name": blob.name.split("/")[1], "path": blob.name, "versionId": blob.versionId, + "caseObj": caseReference + "/" + caseReference + "_case.json", "isCurrentVersion": blob.isCurrentVersion, "contentLength": blob.properties.contentLength, "contentType": blob.contentType, @@ -444,6 +469,11 @@ export const getAllProgressBlobs = async (containerName) => { "name": blob.name.split("/")[1], "path": blob.name, "versionId": blob.versionId, + "caseObj": + blob.name.split("/")[0] + + "/case/" + + blob.name.split("/")[0] + + "_case.json", "isCurrentVersion": blob.isCurrentVersion, "contentLength": blob.properties.contentLength, "contentType": blob.contentType, diff --git a/actions/index.js b/actions/index.js index f1d38b78..43c39593 100644 --- a/actions/index.js +++ b/actions/index.js @@ -743,21 +743,6 @@ export const getAwaitingSubmissionProxy = (loggedInUserId) => { }); }; -export const getAwaitingSubmissionFromBlobProxy = (containerName) => { - return axios - .get( - BASE_URL + - "/api/file/getawaitingsubmissionfromblob?container=" + - containerName - ) - .then((res) => { - return res.data; - }) - .catch((error) => { - //console.log("API call error", error); - }); -}; - export const getAwaitingSubmission = (loggedInUserId) => { return axios .get( @@ -792,6 +777,21 @@ export const getAwaitingSubmissionFromBlob = (containerName) => { }); }; +export const getAwaitingSubmissionFromBlobProxy = (containerName) => { + return axios + .get( + BASE_URL + + "/api/file/getawaitingsubmissionfromblob?container=" + + containerName + ) + .then((res) => { + return res.data; + }) + .catch((error) => { + //console.log("API call error", error); + }); +}; + export const getPortalModuleDetails = (appealType, caseReference) => { //console.log( // BASE_URL + @@ -934,6 +934,45 @@ export const createNewCase = ( }); }; +export const createNewCaseBlob = ( + appealTypeId, + lpaID, + contactid, + createBody, + containerName, + lpaName +) => { + appealTypeId = parseInt(appealTypeId); + + var data = createBody; + + data.pinswg_lpaname = lpaName; + + var queryUrl = + "/api/file/createcase_api?appealTypeId=" + + appealTypeId + + "&lpaID=" + + lpaID + + "&contactid=" + + contactid + + "&containername=" + + containerName; + + var config = { + method: "post", + url: BASE_URL + queryUrl, + data: data, + }; + + return axios(config) + .then((res) => { + return res.data; + }) + .catch((error) => { + console.log("this serror", error); + }); +}; + export const updateCase = async ( incidentId, updateBody, @@ -972,6 +1011,44 @@ export const updateCase = async ( }); }; +export const updateCaseBlob = async ( + incidentId, + updateBody, + updateFormCollection, + primaryAttribute, + caseReference +) => { + var data = updateBody; + + var appealObj = await getAppealID( + caseReference, + updateFormCollection, + primaryAttribute + ); + + var queryUrl = + "/api/file/updatecase_api?updateFormCollection=" + + updateFormCollection + + "&appealObj=" + + appealObj; + + var config = { + method: "post", + url: queryUrl, + data: updateBody, + }; + + //console.log(data); + + return axios(config) + .then((res) => { + return res.data; + }) + .catch((error) => { + //console.log("API call error", error); + }); +}; + export const patchCase = async (incidentid) => { var queryUrl = "/api/endpoint/patchcase_api?incidentid=" + incidentid; var config = { @@ -1232,7 +1309,7 @@ export const downloadBlob = (containerName, blobName) => { { responseType: "blob" } ) .then((response) => { - console.log("Downloaded blob content:"); + //console.log("Downloaded blob content:"); res.setHeader( "content-disposition", diff --git a/components/myportal.js b/components/myportal.js index 54c50776..1703c185 100644 --- a/components/myportal.js +++ b/components/myportal.js @@ -94,7 +94,7 @@ const MyPortal = (props) => {