updated storage account stuff to take auth id
This commit is contained in:
+70
-31
@@ -14,7 +14,7 @@ const STORAGE_CONTAINER = process.env.AZURE_PEDW_CONTAINER;
|
|||||||
export const createContainer = async (containerName) => {
|
export const createContainer = async (containerName) => {
|
||||||
const creds = new DefaultAzureCredential();
|
const creds = new DefaultAzureCredential();
|
||||||
|
|
||||||
containerName = containerName.toLowerCase();
|
//containerName = containerName.toLowerCase();
|
||||||
|
|
||||||
// console.log(
|
// console.log(
|
||||||
// "container name:",
|
// "container name:",
|
||||||
@@ -40,6 +40,8 @@ export const createContainer = async (containerName) => {
|
|||||||
// console.log(`- ${container.name}`);
|
// console.log(`- ${container.name}`);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
console.log("\n//////////////////\n container name :", containerName);
|
||||||
|
|
||||||
return containerName;
|
return containerName;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,7 +55,7 @@ export const getContainers = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBlobs = async (containerName) => {
|
export const getBlobs = async (containerName, casefolderID) => {
|
||||||
const creds = new DefaultAzureCredential();
|
const creds = new DefaultAzureCredential();
|
||||||
|
|
||||||
const containerClient = new ContainerClient(
|
const containerClient = new ContainerClient(
|
||||||
@@ -65,14 +67,14 @@ export const getBlobs = async (containerName) => {
|
|||||||
|
|
||||||
const blobObj = [];
|
const blobObj = [];
|
||||||
for await (const blob of containerClient.listBlobsFlat({
|
for await (const blob of containerClient.listBlobsFlat({
|
||||||
prefix: "files/",
|
prefix: casefolderID + "/files/",
|
||||||
})) {
|
})) {
|
||||||
let blobDocumentType = blob.name
|
let blobDocumentType = blob.name
|
||||||
.split("/")[1]
|
.split("/")[2]
|
||||||
.slice(0, blob.name.split("/")[1].indexOf("_"));
|
.slice(0, blob.name.split("/")[2].indexOf("_"));
|
||||||
|
|
||||||
blobObj.push({
|
blobObj.push({
|
||||||
"name": blob.name.split("/")[1],
|
"name": blob.name.split("/")[2],
|
||||||
"path": blob.name,
|
"path": blob.name,
|
||||||
"documentType": blobDocumentType,
|
"documentType": blobDocumentType,
|
||||||
"versionId": blob.versionId,
|
"versionId": blob.versionId,
|
||||||
@@ -80,28 +82,50 @@ export const getBlobs = async (containerName) => {
|
|||||||
"contentLength": blob.properties.contentLength,
|
"contentLength": blob.properties.contentLength,
|
||||||
"contentType": blob.contentType,
|
"contentType": blob.contentType,
|
||||||
"lastModified": blob.properties.lastModified,
|
"lastModified": blob.properties.lastModified,
|
||||||
|
"filepath":
|
||||||
|
"/api/file/downloadblob?container=" +
|
||||||
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID +
|
||||||
|
"&blobname=" +
|
||||||
|
blob.name.split("/")[2],
|
||||||
"hashedfilepath": hashAPIPath(
|
"hashedfilepath": hashAPIPath(
|
||||||
"/api/file/downloadblob?container=" +
|
"/api/file/downloadblob?container=" +
|
||||||
containerName.toLowerCase() +
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID +
|
||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
blob.name.split("/")[1]
|
blob.name.split("/")[2]
|
||||||
),
|
),
|
||||||
|
"deletepath":
|
||||||
|
"/api/file/deleteblob?container=" +
|
||||||
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID +
|
||||||
|
"&blobname=" +
|
||||||
|
blob.name.split("/")[2],
|
||||||
"hasheddeletepath": hashAPIPath(
|
"hasheddeletepath": hashAPIPath(
|
||||||
"/api/file/deleteblob?container=" +
|
"/api/file/deleteblob?container=" +
|
||||||
containerName.toLowerCase() +
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID +
|
||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
blob.name.split("/")[1]
|
blob.name.split("/")[2]
|
||||||
),
|
),
|
||||||
"hashgetblobs": hashAPIPath(
|
"hashgetblobs": hashAPIPath(
|
||||||
"/api/file/getbloblist?container=" + containerName.toLowerCase()
|
"/api/file/getbloblist?container=" +
|
||||||
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
console.log("blobObj:", blobObj);
|
||||||
|
|
||||||
return blobObj;
|
return blobObj;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createBlob = async (formContent, containerName) => {
|
export const createBlob = async (formContent, containerName, caseref) => {
|
||||||
const creds = new DefaultAzureCredential();
|
const creds = new DefaultAzureCredential();
|
||||||
|
|
||||||
const containerClient = new ContainerClient(
|
const containerClient = new ContainerClient(
|
||||||
@@ -109,21 +133,19 @@ export const createBlob = async (formContent, containerName) => {
|
|||||||
creds
|
creds
|
||||||
);
|
);
|
||||||
|
|
||||||
|
formContent = JSON.parse(formContent);
|
||||||
|
let caseID = formContent.pinswg_name;
|
||||||
|
|
||||||
const content = JSON.stringify(formContent);
|
const content = JSON.stringify(formContent);
|
||||||
const blobName =
|
const blobName = caseID + "/" + caseID + ".json";
|
||||||
formContent.pinswg_name + "_" + new Date().getTime() + ".json";
|
|
||||||
|
console.log("blobName:", blobName);
|
||||||
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
||||||
|
|
||||||
const uploadBlobResponse = await blockBlobClient.upload(
|
const uploadBlobResponse = await blockBlobClient.upload(
|
||||||
content,
|
content,
|
||||||
Buffer.byteLength(content)
|
Buffer.byteLength(content)
|
||||||
);
|
);
|
||||||
|
|
||||||
// console.log("Blobs:");
|
|
||||||
// for await (const blob of containerClient.listBlobsByHierarchy("/")) {
|
|
||||||
// console.log(`- ${blob.name}`);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return formContent.pinswg_name;
|
return formContent.pinswg_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -159,11 +181,13 @@ export const uploadFile = async (formContent, containerName, foldername) => {
|
|||||||
const files = formContent;
|
const files = formContent;
|
||||||
|
|
||||||
//console.log(...formContent);
|
//console.log(...formContent);
|
||||||
//console.log("files...", files, files.length);
|
console.log("files...", files, Object.keys(files).length, foldername);
|
||||||
|
|
||||||
for (const prop in files) {
|
for (const prop in files) {
|
||||||
//console.log(`files[${prop}] = ${files[prop][0].size}`);
|
console.log(`files[${prop}] = ${files[prop][0].size}`);
|
||||||
const blobName = "files/" + files[prop][0].fieldName;
|
const blobName = foldername + "/files/" + files[prop][0].fieldName;
|
||||||
|
|
||||||
|
console.log(blobName);
|
||||||
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
||||||
const uploadBlobResponse = await blockBlobClient.uploadFile(
|
const uploadBlobResponse = await blockBlobClient.uploadFile(
|
||||||
files[prop][0].path,
|
files[prop][0].path,
|
||||||
@@ -185,14 +209,18 @@ export const downloadFile = async (containerName, blobName) => {
|
|||||||
creds
|
creds
|
||||||
);
|
);
|
||||||
|
|
||||||
const blobClient = containerClient.getBlobClient("files/" + blobName);
|
const blobClient = containerClient.getBlobClient(blobName);
|
||||||
const downloadedBlob = await blobClient.download(0);
|
const downloadedBlob = await blobClient.download(0);
|
||||||
|
|
||||||
const downloaded = await streamToBuffer(downloadedBlob.readableStreamBody);
|
const downloaded = await streamToBuffer(downloadedBlob.readableStreamBody);
|
||||||
return downloaded;
|
return downloaded;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const downloadProgressFile = async (containerName, blobName) => {
|
export const downloadProgressFile = async (
|
||||||
|
containerName,
|
||||||
|
blobName,
|
||||||
|
casefolderID
|
||||||
|
) => {
|
||||||
//console.log.apply(containerName, blobName);
|
//console.log.apply(containerName, blobName);
|
||||||
const creds = new DefaultAzureCredential();
|
const creds = new DefaultAzureCredential();
|
||||||
|
|
||||||
@@ -202,6 +230,7 @@ export const downloadProgressFile = async (containerName, blobName) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const blobClient = containerClient.getBlobClient(blobName);
|
const blobClient = containerClient.getBlobClient(blobName);
|
||||||
|
console.log("herher:", containerName, blobName, casefolderID);
|
||||||
const downloadedBlob = await blobClient.download(0);
|
const downloadedBlob = await blobClient.download(0);
|
||||||
|
|
||||||
const downloaded = await streamToBuffer(downloadedBlob.readableStreamBody);
|
const downloaded = await streamToBuffer(downloadedBlob.readableStreamBody);
|
||||||
@@ -221,7 +250,7 @@ const streamToBuffer = async (readableStream) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getProgressBlobs = async (containerName) => {
|
export const getProgressBlobs = async (containerName, caseReference) => {
|
||||||
const creds = new DefaultAzureCredential();
|
const creds = new DefaultAzureCredential();
|
||||||
|
|
||||||
const containerClient = new ContainerClient(
|
const containerClient = new ContainerClient(
|
||||||
@@ -231,8 +260,11 @@ export const getProgressBlobs = async (containerName) => {
|
|||||||
|
|
||||||
containerClient.createIfNotExists();
|
containerClient.createIfNotExists();
|
||||||
|
|
||||||
|
console.log("thisi s the caasefolder:", caseReference);
|
||||||
let blobObj = [];
|
let blobObj = [];
|
||||||
for await (const blob of containerClient.listBlobsFlat()) {
|
for await (const blob of containerClient.listBlobsFlat({
|
||||||
|
prefix: caseReference + "/" + caseReference + ".json",
|
||||||
|
})) {
|
||||||
blobObj.push({
|
blobObj.push({
|
||||||
"name": blob.name.split("/")[1],
|
"name": blob.name.split("/")[1],
|
||||||
"path": blob.name,
|
"path": blob.name,
|
||||||
@@ -243,18 +275,25 @@ export const getProgressBlobs = async (containerName) => {
|
|||||||
"lastModified": blob.properties.lastModified,
|
"lastModified": blob.properties.lastModified,
|
||||||
"hashedfilepath": hashAPIPath(
|
"hashedfilepath": hashAPIPath(
|
||||||
"/api/file/downloadblob?container=" +
|
"/api/file/downloadblob?container=" +
|
||||||
containerName.toLowerCase() +
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
caseReference +
|
||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
blob.name.split("/")[1]
|
blob.name.split("/")[1]
|
||||||
),
|
),
|
||||||
"hasheddeletepath": hashAPIPath(
|
"hasheddeletepath": hashAPIPath(
|
||||||
"/api/file/deleteblob?container=" +
|
"/api/file/deleteblob?container=" +
|
||||||
containerName.toLowerCase() +
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
caseReference +
|
||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
blob.name.split("/")[1]
|
blob.name.split("/")[1]
|
||||||
),
|
),
|
||||||
"hashgetblobs": hashAPIPath(
|
"hashgetblobs": hashAPIPath(
|
||||||
"/api/file/getbloblist?container=" + containerName.toLowerCase()
|
"/api/file/getbloblist?container=" +
|
||||||
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
caseReference
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -265,7 +304,7 @@ export const getProgressBlobs = async (containerName) => {
|
|||||||
},
|
},
|
||||||
]).reverse()[0];
|
]).reverse()[0];
|
||||||
|
|
||||||
console.log(blobObj.path);
|
console.log("blobObj:", blobObj);
|
||||||
|
|
||||||
return blobObj;
|
return blobObj;
|
||||||
};
|
};
|
||||||
|
|||||||
+40
-11
@@ -132,6 +132,7 @@ export const azureHeadersPagedCustom = (access_token, showNumberOfRecords) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const hashAPIPath = (queryPath) => {
|
export const hashAPIPath = (queryPath) => {
|
||||||
|
console.log(queryPath);
|
||||||
var hashlink = CryptoJS.HmacSHA256(
|
var hashlink = CryptoJS.HmacSHA256(
|
||||||
queryPath,
|
queryPath,
|
||||||
CryptoJS.enc.Hex.parse(WORDKEY)
|
CryptoJS.enc.Hex.parse(WORDKEY)
|
||||||
@@ -1040,12 +1041,19 @@ export const createAccount = (formValues) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const uploadFiles = async (formValues, filesObj, uploadhash) => {
|
export const uploadFiles = async (
|
||||||
|
formValues,
|
||||||
|
filesObj,
|
||||||
|
containerID,
|
||||||
|
casefolderID
|
||||||
|
) => {
|
||||||
let files = filesObj;
|
let files = filesObj;
|
||||||
|
|
||||||
//console.log(formValues);
|
//console.log(formValues);
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
formData.append("appealData", JSON.stringify(formValues));
|
formData.append("appealData", JSON.stringify(formValues));
|
||||||
|
formData.append("containerID", containerID);
|
||||||
|
formData.append("casefolderID", casefolderID);
|
||||||
|
|
||||||
// files.forEach((file) => formData.append("files", file));
|
// files.forEach((file) => formData.append("files", file));
|
||||||
|
|
||||||
@@ -1076,15 +1084,19 @@ export const uploadFiles = async (formValues, filesObj, uploadhash) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getFilesFromBlob = (containerName) => {
|
export const getFilesFromBlob = (containerName, casefolderID) => {
|
||||||
return axios
|
return axios
|
||||||
.get(
|
.get(
|
||||||
BASE_URL +
|
BASE_URL +
|
||||||
"/api/file/getbloblist?container=" +
|
"/api/file/getbloblist?container=" +
|
||||||
containerName.toLowerCase() +
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID +
|
||||||
hashAPIPath(
|
hashAPIPath(
|
||||||
"/api/file/getbloblist?container=" +
|
"/api/file/getbloblist?container=" +
|
||||||
containerName.toLowerCase()
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@@ -1096,12 +1108,18 @@ export const getFilesFromBlob = (containerName) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getFilesFromBlobHashed = (containerName, getblobshash) => {
|
export const getFilesFromBlobHashed = (
|
||||||
|
containerName,
|
||||||
|
getblobshash,
|
||||||
|
casefolderID
|
||||||
|
) => {
|
||||||
return axios
|
return axios
|
||||||
.get(
|
.get(
|
||||||
BASE_URL +
|
BASE_URL +
|
||||||
"/api/file/getbloblist?container=" +
|
"/api/file/getbloblist?container=" +
|
||||||
containerName.toLowerCase() +
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID +
|
||||||
getblobshash
|
getblobshash
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@@ -1113,12 +1131,19 @@ export const getFilesFromBlobHashed = (containerName, getblobshash) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteBlob = async (containerName, blobName, deleteblobhash) => {
|
export const deleteBlob = async (
|
||||||
|
containerName,
|
||||||
|
blobName,
|
||||||
|
deleteblobhash,
|
||||||
|
casefolderID
|
||||||
|
) => {
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(
|
const res = await axios.get(
|
||||||
BASE_URL +
|
BASE_URL +
|
||||||
"/api/file/deleteblob?container=" +
|
"/api/file/deleteblob?container=" +
|
||||||
containerName.toLowerCase() +
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID +
|
||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
blobName +
|
blobName +
|
||||||
deleteblobhash
|
deleteblobhash
|
||||||
@@ -1155,16 +1180,20 @@ export const downloadBlob = (containerName, blobName) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getProgressFromBlob = async (containerName) => {
|
export const getProgressFromBlob = async (containerName, casereference) => {
|
||||||
console.log("cont:", containerName);
|
console.log("cont:", containerName);
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(
|
const res = await axios.get(
|
||||||
BASE_URL +
|
BASE_URL +
|
||||||
"/api/file/getprogressobjblob?container=" +
|
"/api/file/getprogressobjblob?container=" +
|
||||||
containerName.toLowerCase() +
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casereference +
|
||||||
hashAPIPath(
|
hashAPIPath(
|
||||||
"/api/file/getprogressobjblob?container=" +
|
"/api/file/getprogressobjblob?container=" +
|
||||||
containerName.toLowerCase()
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casereference
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return res.data;
|
return res.data;
|
||||||
|
|||||||
@@ -1255,6 +1255,7 @@ export function FileUploadField(props) {
|
|||||||
hint={props.hint}
|
hint={props.hint}
|
||||||
fileList={props.fileList}
|
fileList={props.fileList}
|
||||||
setFilesForAppeal={props.setFilesForAppeal}
|
setFilesForAppeal={props.setFilesForAppeal}
|
||||||
|
containerID={props.containerID}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -1459,15 +1460,18 @@ const RenderFileUpload = (field) => {
|
|||||||
containerName,
|
containerName,
|
||||||
blobName,
|
blobName,
|
||||||
deleteblobhash,
|
deleteblobhash,
|
||||||
getblobshash
|
getblobshash,
|
||||||
|
casefolderID
|
||||||
) => {
|
) => {
|
||||||
//console.log(containerName, blobName, deleteblobhash);
|
//console.log(containerName, blobName, deleteblobhash);
|
||||||
deleteBlob(containerName, blobName, deleteblobhash)
|
deleteBlob(containerName, blobName, deleteblobhash, casefolderID)
|
||||||
.then((data) => data)
|
.then((data) => data)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
getFilesFromBlobHashed(containerName, getblobshash).then(
|
getFilesFromBlobHashed(
|
||||||
(newfilelist) => field.setFilesForAppeal(newfilelist)
|
containerName,
|
||||||
);
|
getblobshash,
|
||||||
|
casefolderID
|
||||||
|
).then((newfilelist) => field.setFilesForAppeal(newfilelist));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1543,10 +1547,11 @@ const RenderFileUpload = (field) => {
|
|||||||
className="govuk-summary-list__actionLink watched_link govuk-!-margin-right-5 govuk-!-text-align-left"
|
className="govuk-summary-list__actionLink watched_link govuk-!-margin-right-5 govuk-!-text-align-left"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
deleteThisBlob(
|
deleteThisBlob(
|
||||||
field.ticketnumber,
|
field.containerID,
|
||||||
blob.name,
|
blob.name,
|
||||||
blob.hasheddeletepath,
|
blob.hasheddeletepath,
|
||||||
blob.hashgetblobs
|
blob.hashgetblobs,
|
||||||
|
field.ticketnumber
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
title="Remove this file"
|
title="Remove this file"
|
||||||
@@ -1565,7 +1570,9 @@ const RenderFileUpload = (field) => {
|
|||||||
scroll={false}
|
scroll={false}
|
||||||
href={
|
href={
|
||||||
"/api/file/downloadblob?container=" +
|
"/api/file/downloadblob?container=" +
|
||||||
field.ticketnumber.toLowerCase() +
|
field.containerID +
|
||||||
|
"&casefolderID=" +
|
||||||
|
field.ticketnumber +
|
||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
blob.name +
|
blob.name +
|
||||||
blob.hashedfilepath
|
blob.hashedfilepath
|
||||||
|
|||||||
@@ -189,6 +189,10 @@ export default function BuildField(props) {
|
|||||||
setFilesForAppeal={
|
setFilesForAppeal={
|
||||||
props.props.props.setFilesForAppeal
|
props.props.props.setFilesForAppeal
|
||||||
}
|
}
|
||||||
|
containerID={
|
||||||
|
props.props.props.props.accountDetails
|
||||||
|
.containerID
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -111,13 +111,23 @@ let BuildSection = (props) => {
|
|||||||
|
|
||||||
//console.log(fileListObj);
|
//console.log(fileListObj);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"\n////////////////////////\n upload files:",
|
||||||
|
props.props.accountDetails.containerID
|
||||||
|
);
|
||||||
|
|
||||||
var dataObj = values;
|
var dataObj = values;
|
||||||
|
|
||||||
for (let key in dataObj) {
|
for (let key in dataObj) {
|
||||||
_.includes(key, "pinswg_fileUpload") == true && delete dataObj[key];
|
_.includes(key, "pinswg_fileUpload") == true && delete dataObj[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadFiles(dataObj, fileListObj).then((data) => {
|
uploadFiles(
|
||||||
|
dataObj,
|
||||||
|
fileListObj,
|
||||||
|
props.props.accountDetails.containerID,
|
||||||
|
props.props.appealType.caseReference.ticketnumber
|
||||||
|
).then((data) => {
|
||||||
//console.log("hello", data);
|
//console.log("hello", data);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -1,35 +1,34 @@
|
|||||||
import {
|
|
||||||
createContainer,
|
|
||||||
getContainers,
|
|
||||||
getBlobs,
|
|
||||||
createBlob,
|
|
||||||
uploadFile,
|
|
||||||
deleteBlob,
|
|
||||||
} from "../../../actions/azurestorage";
|
|
||||||
import { hashAPIPath } from "../../../actions";
|
import { hashAPIPath } from "../../../actions";
|
||||||
|
import { deleteBlob } from "../../../actions/azurestorage";
|
||||||
|
|
||||||
import middleware from "../middleware/middleware";
|
|
||||||
import nextConnect from "next-connect";
|
import nextConnect from "next-connect";
|
||||||
|
import middleware from "../middleware/middleware";
|
||||||
|
|
||||||
const ApiProxy = nextConnect();
|
const ApiProxy = nextConnect();
|
||||||
ApiProxy.use(middleware);
|
ApiProxy.use(middleware);
|
||||||
|
|
||||||
ApiProxy.get(async (req, res) => {
|
ApiProxy.get(async (req, res) => {
|
||||||
var containerName = req.query.container;
|
var containerName = req.query.container;
|
||||||
|
var casefolderID = req.query.casefolderID;
|
||||||
var blobName = req.query.blobname;
|
var blobName = req.query.blobname;
|
||||||
var checkHash = req.query.hash;
|
var checkHash = req.query.hash;
|
||||||
|
|
||||||
var checkquerypath =
|
var checkquerypath =
|
||||||
"/api/file/deleteblob?container=" +
|
"/api/file/deleteblob?container=" +
|
||||||
containerName.toLowerCase() +
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID +
|
||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
blobName;
|
blobName;
|
||||||
|
|
||||||
console.log(hashAPIPath(checkquerypath), checkHash);
|
// console.log(hashAPIPath(checkquerypath), checkHash);
|
||||||
console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||||
|
|
||||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||||
await deleteBlob(containerName, "files/" + blobName).then((data) => {
|
await deleteBlob(
|
||||||
|
containerName,
|
||||||
|
casefolderID + "/files/" + blobName
|
||||||
|
).then((data) => {
|
||||||
return res.status(200).json({ data: data });
|
return res.status(200).json({ data: data });
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,24 +1,8 @@
|
|||||||
import {
|
import { downloadFile } from "../../../actions/azurestorage";
|
||||||
createContainer,
|
|
||||||
getContainers,
|
|
||||||
getBlobs,
|
|
||||||
createBlob,
|
|
||||||
uploadFile,
|
|
||||||
deleteBlob,
|
|
||||||
downloadFile,
|
|
||||||
} from "../../../actions/azurestorage";
|
|
||||||
import { BlobServiceClient, ContainerClient } from "@azure/storage-blob";
|
|
||||||
import {
|
|
||||||
DefaultAzureCredential,
|
|
||||||
InteractiveBrowserCredential,
|
|
||||||
EnvironmentCredential,
|
|
||||||
ClientSecretCredential,
|
|
||||||
} from "@azure/identity";
|
|
||||||
|
|
||||||
import middleware from "../middleware/middleware";
|
|
||||||
import nextConnect from "next-connect";
|
import nextConnect from "next-connect";
|
||||||
import CryptoJS from "crypto-js";
|
|
||||||
import { hashAPIPath } from "../../../actions";
|
import { hashAPIPath } from "../../../actions";
|
||||||
|
import middleware from "../middleware/middleware";
|
||||||
|
|
||||||
const WORDKEY = process.env.HASHKEY;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
@@ -28,21 +12,27 @@ ApiProxy.use(middleware);
|
|||||||
|
|
||||||
ApiProxy.get(async (req, res) => {
|
ApiProxy.get(async (req, res) => {
|
||||||
var containerName = req.query.container;
|
var containerName = req.query.container;
|
||||||
|
var casefolderID = req.query.casefolderID;
|
||||||
var blobName = req.query.blobname;
|
var blobName = req.query.blobname;
|
||||||
var checkHash = req.query.hash;
|
var checkHash = req.query.hash;
|
||||||
|
|
||||||
var checkquerypath =
|
var checkquerypath =
|
||||||
"/api/file/downloadblob?container=" +
|
"/api/file/downloadblob?container=" +
|
||||||
containerName +
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID +
|
||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
blobName;
|
blobName.trim();
|
||||||
|
|
||||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||||
const downloaded = await downloadFile(containerName, blobName);
|
const downloaded = await downloadFile(
|
||||||
|
containerName,
|
||||||
|
casefolderID + "/files/" + decodeURI(blobName)
|
||||||
|
);
|
||||||
|
|
||||||
res.setHeader(
|
res.setHeader(
|
||||||
"content-disposition",
|
"content-disposition",
|
||||||
"attachment; filename=" + blobName
|
"attachment; filename=" + decodeURI(blobName)
|
||||||
);
|
);
|
||||||
return res.status(200).send(downloaded);
|
return res.status(200).send(downloaded);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
import {
|
|
||||||
createContainer,
|
|
||||||
getContainers,
|
|
||||||
getBlobs,
|
|
||||||
createBlob,
|
|
||||||
uploadFile,
|
|
||||||
} from "../../../actions/azurestorage";
|
|
||||||
import { hashAPIPath } from "../../../actions";
|
import { hashAPIPath } from "../../../actions";
|
||||||
|
import { getBlobs } from "../../../actions/azurestorage";
|
||||||
|
|
||||||
import middleware from "../middleware/middleware";
|
|
||||||
import nextConnect from "next-connect";
|
import nextConnect from "next-connect";
|
||||||
|
import middleware from "../middleware/middleware";
|
||||||
|
|
||||||
const ApiProxy = nextConnect();
|
const ApiProxy = nextConnect();
|
||||||
ApiProxy.use(middleware);
|
ApiProxy.use(middleware);
|
||||||
|
|
||||||
ApiProxy.get(async (req, res) => {
|
ApiProxy.get(async (req, res) => {
|
||||||
var containerName = req.query.container;
|
var containerName = req.query.container;
|
||||||
|
var casefolderID = req.query.casefolderID;
|
||||||
|
|
||||||
var checkHash = req.query.hash;
|
var checkHash = req.query.hash;
|
||||||
var checkquerypath = "/api/file/getbloblist?container=" + containerName;
|
var checkquerypath =
|
||||||
|
"/api/file/getbloblist?container=" +
|
||||||
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID;
|
||||||
|
|
||||||
// console.log(hashAPIPath(checkquerypath), checkHash);
|
// console.log(hashAPIPath(checkquerypath), checkHash);
|
||||||
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||||
|
|
||||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||||
await getBlobs(containerName).then((data) => {
|
await getBlobs(containerName, casefolderID).then((data) => {
|
||||||
return res.status(200).json({ files: data });
|
return res.status(200).json({ files: data });
|
||||||
});
|
});
|
||||||
} else {
|
// } else {
|
||||||
return res.status(400).json();
|
// return res.status(400).json();
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
|
|||||||
@@ -1,32 +1,33 @@
|
|||||||
import {
|
import {
|
||||||
createContainer,
|
|
||||||
getContainers,
|
|
||||||
getBlobs,
|
|
||||||
createBlob,
|
|
||||||
uploadFile,
|
|
||||||
getProgressBlobs,
|
|
||||||
downloadProgressFile,
|
downloadProgressFile,
|
||||||
|
getProgressBlobs,
|
||||||
} from "../../../actions/azurestorage";
|
} from "../../../actions/azurestorage";
|
||||||
import { hashAPIPath } from "../../../actions";
|
|
||||||
|
|
||||||
import middleware from "../middleware/middleware";
|
|
||||||
import nextConnect from "next-connect";
|
import nextConnect from "next-connect";
|
||||||
|
import middleware from "../middleware/middleware";
|
||||||
|
|
||||||
const ApiProxy = nextConnect();
|
const ApiProxy = nextConnect();
|
||||||
ApiProxy.use(middleware);
|
ApiProxy.use(middleware);
|
||||||
|
|
||||||
ApiProxy.get(async (req, res) => {
|
ApiProxy.get(async (req, res) => {
|
||||||
var containerName = req.query.container;
|
var containerName = req.query.container;
|
||||||
|
var casefolderID = req.query.casefolderID;
|
||||||
|
|
||||||
var checkHash = req.query.hash;
|
var checkHash = req.query.hash;
|
||||||
var checkquerypath =
|
var checkquerypath =
|
||||||
"/api/file/getprogressobjblob?container=" + containerName;
|
"/api/file/getprogressobjblob?container=" +
|
||||||
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID;
|
||||||
|
|
||||||
// console.log(hashAPIPath(checkquerypath), checkHash);
|
// console.log(hashAPIPath(checkquerypath), checkHash);
|
||||||
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||||
|
|
||||||
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||||
const blobObj = await getProgressBlobs(containerName)
|
const blobObj = await getProgressBlobs(containerName, casefolderID)
|
||||||
.then((data) => downloadProgressFile(containerName, data.path))
|
.then((data) =>
|
||||||
|
downloadProgressFile(containerName, data.path, casefolderID)
|
||||||
|
)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
return res.status(200).json(data);
|
return res.status(200).json(data);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import {
|
||||||
|
createContainer,
|
||||||
|
getContainers,
|
||||||
|
getBlobs,
|
||||||
|
createBlob,
|
||||||
|
uploadFile,
|
||||||
|
} from "../../../actions/azurestorage";
|
||||||
|
import { hashAPIPath } from "../../../actions";
|
||||||
|
|
||||||
|
import middleware from "../middleware/middleware";
|
||||||
|
import nextConnect from "next-connect";
|
||||||
|
|
||||||
|
const ApiProxy = nextConnect();
|
||||||
|
ApiProxy.use(middleware);
|
||||||
|
|
||||||
|
ApiProxy.get(async (req, res) => {
|
||||||
|
var containerName = req.query.ident;
|
||||||
|
var checkHash = req.query.hash;
|
||||||
|
var checkquerypath = "/api/file/setupcontainer?ident=" + containerName;
|
||||||
|
|
||||||
|
console.log(req.query);
|
||||||
|
console.log(checkquerypath.length);
|
||||||
|
console.log(hashAPIPath(checkquerypath));
|
||||||
|
// console.log(checkquerypath, hashAPIPath(checkquerypath), checkHash);
|
||||||
|
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||||
|
|
||||||
|
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||||
|
await createContainer(containerName)
|
||||||
|
.then((data) => {
|
||||||
|
return res.status(200).json({ data: "success" });
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(consoleLogger(err));
|
||||||
|
res.status(400).json(err);
|
||||||
|
});
|
||||||
|
// } else {
|
||||||
|
// return res.status(400).json();
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
|
||||||
|
export const config = {
|
||||||
|
api: {
|
||||||
|
bodyParser: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ApiProxy;
|
||||||
@@ -14,10 +14,15 @@ ApiProxy.use(middleware);
|
|||||||
|
|
||||||
ApiProxy.post(async (req, res) => {
|
ApiProxy.post(async (req, res) => {
|
||||||
var checkHash = req.query.hash;
|
var checkHash = req.query.hash;
|
||||||
console.log(JSON.parse(req.body.appealData));
|
// console.log(JSON.stringify(req.body));
|
||||||
console.log(req.files);
|
// console.log(JSON.stringify(req.body.appealData));
|
||||||
|
// console.log(req.files);
|
||||||
|
|
||||||
const appealData = JSON.parse(req.body.appealData);
|
const appealData = req.body.appealData;
|
||||||
|
const containerID = req.body.containerID;
|
||||||
|
const casefolderID = req.body.casefolderID;
|
||||||
|
|
||||||
|
console.log("there are files:", Object.keys(req.files).length);
|
||||||
|
|
||||||
// var checkquerypath = "/api/file/upload";
|
// var checkquerypath = "/api/file/upload";
|
||||||
|
|
||||||
@@ -25,11 +30,18 @@ ApiProxy.post(async (req, res) => {
|
|||||||
// console.log(hashAPIPath(checkquerypath) == "?hash=" + checkHash);
|
// console.log(hashAPIPath(checkquerypath) == "?hash=" + checkHash);
|
||||||
|
|
||||||
// if (hashAPIPath(checkquerypath) == "?hash=" + checkHash) {
|
// if (hashAPIPath(checkquerypath) == "?hash=" + checkHash) {
|
||||||
createContainer(appealData.pinswg_name.trim()).then((containerName) => {
|
//createContainer(containerID).then((containerName) => {
|
||||||
createBlob(appealData, containerName).then((data) => {
|
|
||||||
uploadFile(req.files, containerName, data);
|
console.log(
|
||||||
});
|
"does this et folder name:",
|
||||||
|
appealData.pinswg_name,
|
||||||
|
casefolderID
|
||||||
|
);
|
||||||
|
createBlob(appealData, containerID, casefolderID).then((data) => {
|
||||||
|
Object.keys(req.files).length > 0 &&
|
||||||
|
uploadFile(req.files, containerID, casefolderID);
|
||||||
});
|
});
|
||||||
|
//});
|
||||||
|
|
||||||
return res.status(200).json({ data: "success" });
|
return res.status(200).json({ data: "success" });
|
||||||
// } else {
|
// } else {
|
||||||
|
|||||||
+9
-6
@@ -16,7 +16,10 @@ import Footer from "../components/footer";
|
|||||||
import Header from "../components/header";
|
import Header from "../components/header";
|
||||||
import Main from "../components/main";
|
import Main from "../components/main";
|
||||||
import ServiceBanner from "../components/servicebanner";
|
import ServiceBanner from "../components/servicebanner";
|
||||||
import { setAccountDetails } from "../store/accountDetails/action";
|
import {
|
||||||
|
setAccountDetails,
|
||||||
|
setContainerID,
|
||||||
|
} from "../store/accountDetails/action";
|
||||||
import { getGovGatewayConfig } from "../store/govgateway/action";
|
import { getGovGatewayConfig } from "../store/govgateway/action";
|
||||||
import { wrapper } from "../store/store";
|
import { wrapper } from "../store/store";
|
||||||
import { getSession, useSession, signIn, signOut } from "next-auth/react";
|
import { getSession, useSession, signIn, signOut } from "next-auth/react";
|
||||||
@@ -169,12 +172,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
|
|
||||||
let thisSession = await getSession(ctx);
|
let thisSession = await getSession(ctx);
|
||||||
|
|
||||||
console.log(ctx);
|
|
||||||
|
|
||||||
var relayToken = await getToken();
|
var relayToken = await getToken();
|
||||||
relayToken = relayToken.access_token;
|
relayToken = relayToken.access_token;
|
||||||
|
|
||||||
console.log("auth sess:", thisSession);
|
console.log("\n///////////////\nauth sess:", thisSession);
|
||||||
|
|
||||||
const showLoginCheck = process.env.SHOWLOGIN || false;
|
const showLoginCheck = process.env.SHOWLOGIN || false;
|
||||||
const showMapCheck = process.env.SHOWMAPS || false;
|
const showMapCheck = process.env.SHOWMAPS || false;
|
||||||
@@ -187,7 +188,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
let ggLocale =
|
let ggLocale =
|
||||||
typeof query.ui_locales != "undefined" && query.ui_locales;
|
typeof query.ui_locales != "undefined" && query.ui_locales;
|
||||||
|
|
||||||
console.log("\n", "hasloginCode:", hasLoginCode);
|
console.log("hasloginCode:", hasLoginCode);
|
||||||
|
|
||||||
// store.dispatch(getGovGatewayConfig(providerConfig));
|
// store.dispatch(getGovGatewayConfig(providerConfig));
|
||||||
|
|
||||||
@@ -198,6 +199,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
|
|
||||||
if (hasLoginCode == true) {
|
if (hasLoginCode == true) {
|
||||||
loginEmailStr = hashString(thisSession.user.email);
|
loginEmailStr = hashString(thisSession.user.email);
|
||||||
|
store.dispatch(setContainerID(thisSession.user.id));
|
||||||
|
|
||||||
portalUserObj = await getPortalLogin(
|
portalUserObj = await getPortalLogin(
|
||||||
thisSession.user.email,
|
thisSession.user.email,
|
||||||
relayToken
|
relayToken
|
||||||
@@ -220,7 +223,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
} else {
|
} else {
|
||||||
console.log("empty session");
|
console.log("empty session");
|
||||||
}
|
}
|
||||||
|
console.log("///////////////\n");
|
||||||
if (ggToken.status == 400) {
|
if (ggToken.status == 400) {
|
||||||
return {
|
return {
|
||||||
redirect: {
|
redirect: {
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ import BuildSection from "../../components/newappeal/buildsection";
|
|||||||
import CompleteAppeal from "../../components/newappeal/complete";
|
import CompleteAppeal from "../../components/newappeal/complete";
|
||||||
import TimeOut from "../../components/timeout";
|
import TimeOut from "../../components/timeout";
|
||||||
|
|
||||||
import { setLoggedInUserId } from "../../store/accountDetails/action";
|
import {
|
||||||
|
setLoggedInUserId,
|
||||||
|
setContainerID,
|
||||||
|
} from "../../store/accountDetails/action";
|
||||||
import {
|
import {
|
||||||
setAppealLPA,
|
setAppealLPA,
|
||||||
setAppealType,
|
setAppealType,
|
||||||
@@ -38,6 +41,7 @@ import { getGovGatewayConfig } from "../../store/govgateway/action";
|
|||||||
import { wrapper } from "../../store/store";
|
import { wrapper } from "../../store/store";
|
||||||
import { getPartSavedDetails } from "../../components/utils";
|
import { getPartSavedDetails } from "../../components/utils";
|
||||||
import { getProgressBlobs } from "../../actions/azurestorage";
|
import { getProgressBlobs } from "../../actions/azurestorage";
|
||||||
|
import { getSession, useSession } from "next-auth/react";
|
||||||
|
|
||||||
let Home = (props) => {
|
let Home = (props) => {
|
||||||
const { footerLinks, pages, formData } = props;
|
const { footerLinks, pages, formData } = props;
|
||||||
@@ -217,6 +221,13 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
console.log("the query", query.appealtypes);
|
console.log("the query", query.appealtypes);
|
||||||
let loggedInUser = cookies.pinsUser;
|
let loggedInUser = cookies.pinsUser;
|
||||||
|
|
||||||
|
let thisSession = await getSession(ctx);
|
||||||
|
console.log("nextAuth Session:", thisSession);
|
||||||
|
|
||||||
|
let loggedInUserIdent = thisSession.user.id;
|
||||||
|
|
||||||
|
console.log("logged ident:", loggedInUserIdent);
|
||||||
|
|
||||||
const [
|
const [
|
||||||
appealTypeData,
|
appealTypeData,
|
||||||
mandatoryFieldsData,
|
mandatoryFieldsData,
|
||||||
@@ -227,11 +238,11 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
await getAppealsTypes(),
|
await getAppealsTypes(),
|
||||||
await getMandatoryFields(query.appealtypes),
|
await getMandatoryFields(query.appealtypes),
|
||||||
await getPickLists(query.appealtypes),
|
await getPickLists(query.appealtypes),
|
||||||
await getFilesFromBlob(query.casereference),
|
await getFilesFromBlob(loggedInUserIdent, query.casereference),
|
||||||
await getProgressFromBlob(query.casereference),
|
await getProgressFromBlob(loggedInUserIdent, query.casereference),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
console.log("has blobprgess:", blobProgress);
|
console.log("has blobprogess:", loggedInUserIdent, query.casereference);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Removed to make progress from Blob not CRM
|
// Removed to make progress from Blob not CRM
|
||||||
@@ -283,6 +294,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
|
store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
|
||||||
store.dispatch(setAppealType(appealTypeData));
|
store.dispatch(setAppealType(appealTypeData));
|
||||||
store.dispatch(setFilesForAppeal(blobList));
|
store.dispatch(setFilesForAppeal(blobList));
|
||||||
|
store.dispatch(setContainerID(thisSession.user.id));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+19
-1
@@ -12,6 +12,7 @@ import {
|
|||||||
getPortalModuleDetails,
|
getPortalModuleDetails,
|
||||||
getWatchedCases,
|
getWatchedCases,
|
||||||
} from "../../actions";
|
} from "../../actions";
|
||||||
|
import { createContainer } from "../../actions/azurestorage";
|
||||||
import { getProviderConfig } from "../../actions/govgateway";
|
import { getProviderConfig } from "../../actions/govgateway";
|
||||||
import Breadcrumbs from "../../components/breadcrumbs";
|
import Breadcrumbs from "../../components/breadcrumbs";
|
||||||
import CookieBanner from "../../components/cookieBanner";
|
import CookieBanner from "../../components/cookieBanner";
|
||||||
@@ -21,6 +22,7 @@ import MyPortal from "../../components/myportal";
|
|||||||
import { getFormCollectionByID } from "../../components/utils";
|
import { getFormCollectionByID } from "../../components/utils";
|
||||||
import {
|
import {
|
||||||
setAccountDetails,
|
setAccountDetails,
|
||||||
|
setContainerID,
|
||||||
setLoggedInUserId,
|
setLoggedInUserId,
|
||||||
} from "../../store/accountDetails/action";
|
} from "../../store/accountDetails/action";
|
||||||
import {
|
import {
|
||||||
@@ -161,6 +163,18 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
|
|
||||||
console.log("nextAuth Session:", thisSession);
|
console.log("nextAuth Session:", thisSession);
|
||||||
|
|
||||||
|
if (_.has(thisSession, "user") == false) {
|
||||||
|
return {
|
||||||
|
redirect: {
|
||||||
|
destination: "/error",
|
||||||
|
permanent: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create Storage container for logged in user
|
||||||
|
await createContainer(thisSession.user.id);
|
||||||
|
|
||||||
let providerConfig = await getProviderConfig();
|
let providerConfig = await getProviderConfig();
|
||||||
|
|
||||||
store.dispatch(getGovGatewayConfig(providerConfig));
|
store.dispatch(getGovGatewayConfig(providerConfig));
|
||||||
@@ -213,9 +227,13 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
store.dispatch(
|
store.dispatch(
|
||||||
setAwaitingSubmissionDetails(awaitingSubmissionDetails)
|
setAwaitingSubmissionDetails(awaitingSubmissionDetails)
|
||||||
);
|
);
|
||||||
|
store.dispatch(setContainerID(thisSession.user.id));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: { showFileUpload: process.env.SHOWFILEUPLOAD },
|
props: {
|
||||||
|
showFileUpload: process.env.SHOWFILEUPLOAD,
|
||||||
|
containerID: thisSession.user.id,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import { useEffect } from "react";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import xpath from "xpath";
|
import xpath from "xpath";
|
||||||
import {
|
import {
|
||||||
createCase,
|
|
||||||
getCase,
|
getCase,
|
||||||
getAppealsTypes,
|
getAppealsTypes,
|
||||||
getMandatoryFields,
|
getMandatoryFields,
|
||||||
getPickLists,
|
getPickLists,
|
||||||
getFilesFromBlob,
|
getFilesFromBlob,
|
||||||
|
getProgressFromBlob,
|
||||||
} from "../../actions";
|
} from "../../actions";
|
||||||
import { getProviderConfig } from "../../actions/govgateway";
|
import { getProviderConfig } from "../../actions/govgateway";
|
||||||
import Breadcrumbs from "../../components/breadcrumbs";
|
import Breadcrumbs from "../../components/breadcrumbs";
|
||||||
@@ -24,7 +24,10 @@ import BuildSection from "../../components/newappeal/buildsection";
|
|||||||
import CompleteAppeal from "../../components/newappeal/complete";
|
import CompleteAppeal from "../../components/newappeal/complete";
|
||||||
import TimeOut from "../../components/timeout";
|
import TimeOut from "../../components/timeout";
|
||||||
|
|
||||||
import { setLoggedInUserId } from "../../store/accountDetails/action";
|
import {
|
||||||
|
setLoggedInUserId,
|
||||||
|
setContainerID,
|
||||||
|
} from "../../store/accountDetails/action";
|
||||||
import {
|
import {
|
||||||
setAppealLPA,
|
setAppealLPA,
|
||||||
setAppealType,
|
setAppealType,
|
||||||
@@ -36,6 +39,8 @@ import {
|
|||||||
import { setForm } from "../../store/formData/action";
|
import { setForm } from "../../store/formData/action";
|
||||||
import { getGovGatewayConfig } from "../../store/govgateway/action";
|
import { getGovGatewayConfig } from "../../store/govgateway/action";
|
||||||
import { wrapper } from "../../store/store";
|
import { wrapper } from "../../store/store";
|
||||||
|
import { getProgressBlobs } from "../../actions/azurestorage";
|
||||||
|
import { getSession, useSession } from "next-auth/react";
|
||||||
|
|
||||||
let Home = (props) => {
|
let Home = (props) => {
|
||||||
const { footerLinks, pages, formData } = props;
|
const { footerLinks, pages, formData } = props;
|
||||||
@@ -217,17 +222,27 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
console.log("ref:", query.id);
|
console.log("ref:", query.id);
|
||||||
let loggedInUser = cookies.pinsUser;
|
let loggedInUser = cookies.pinsUser;
|
||||||
|
|
||||||
|
let thisSession = await getSession(ctx);
|
||||||
|
console.log("nextAuth Session:", thisSession);
|
||||||
|
|
||||||
|
let loggedInUserIdent = thisSession.user.id;
|
||||||
|
|
||||||
|
console.log("logged ident:", loggedInUserIdent);
|
||||||
|
|
||||||
const [
|
const [
|
||||||
caseReferenceData,
|
caseReferenceData,
|
||||||
appealTypeData,
|
appealTypeData,
|
||||||
mandatoryFieldsData,
|
mandatoryFieldsData,
|
||||||
pickListData,
|
pickListData,
|
||||||
//blobList,
|
//blobList,
|
||||||
|
blobProgress,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
await getCase(query.id),
|
await getCase(query.id),
|
||||||
await getAppealsTypes(),
|
await getAppealsTypes(),
|
||||||
await getMandatoryFields(query.appealtypes),
|
await getMandatoryFields(query.appealtypes),
|
||||||
await getPickLists(query.appealtypes),
|
await getPickLists(query.appealtypes),
|
||||||
|
await getProgressFromBlob(loggedInUserIdent, query.casereference),
|
||||||
|
|
||||||
//await getFilesFromBlob(query.casereference),
|
//await getFilesFromBlob(query.casereference),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -255,6 +270,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
store.dispatch(setCaseReference(caseReference));
|
store.dispatch(setCaseReference(caseReference));
|
||||||
store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
|
store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
|
||||||
store.dispatch(setAppealType(appealTypeData));
|
store.dispatch(setAppealType(appealTypeData));
|
||||||
|
store.dispatch(setContainerID(thisSession.user.id));
|
||||||
|
|
||||||
//store.dispatch(setFilesForAppeal(blobList));
|
//store.dispatch(setFilesForAppeal(blobList));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import useTranslation from "next-translate/useTranslation";
|
import useTranslation from "next-translate/useTranslation";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { getSession, useSession } from "next-auth/react";
|
import { getSession, useSession } from "next-auth/react";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -16,6 +17,7 @@ import Header from "../../components/header";
|
|||||||
import CreateCase from "../../components/newappeal/createCase";
|
import CreateCase from "../../components/newappeal/createCase";
|
||||||
import {
|
import {
|
||||||
setAccountDetails,
|
setAccountDetails,
|
||||||
|
setContainerID,
|
||||||
setLoggedInUserId,
|
setLoggedInUserId,
|
||||||
} from "../../store/accountDetails/action";
|
} from "../../store/accountDetails/action";
|
||||||
import { setAppealType } from "../../store/appealType/action";
|
import { setAppealType } from "../../store/appealType/action";
|
||||||
@@ -120,7 +122,7 @@ const Home = (props) => {
|
|||||||
appealType={props.setAppealType}
|
appealType={props.setAppealType}
|
||||||
loggedInUser={props.accountDetails.loggedinUserId}
|
loggedInUser={props.accountDetails.loggedinUserId}
|
||||||
whichForm={props.form}
|
whichForm={props.form}
|
||||||
loggedInUserIdent={loggedInUserIdent}
|
containerID={props.accountDetails.containerID}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
@@ -141,6 +143,14 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
let thisSession = await getSession(ctx);
|
let thisSession = await getSession(ctx);
|
||||||
console.log("nextAuth Session:", thisSession);
|
console.log("nextAuth Session:", thisSession);
|
||||||
|
|
||||||
|
if (_.has(thisSession, "user") == false) {
|
||||||
|
return {
|
||||||
|
redirect: {
|
||||||
|
destination: "/error",
|
||||||
|
permanent: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
let loggedInUserIdent = thisSession.user.id;
|
let loggedInUserIdent = thisSession.user.id;
|
||||||
let loggedInUser = cookies.pinsUser;
|
let loggedInUser = cookies.pinsUser;
|
||||||
|
|
||||||
@@ -163,6 +173,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
store.dispatch(setLPA(lpaData));
|
store.dispatch(setLPA(lpaData));
|
||||||
store.dispatch(setLoggedInUserId(loggedInUser));
|
store.dispatch(setLoggedInUserId(loggedInUser));
|
||||||
store.dispatch(setAccountDetails(accountDetails));
|
store.dispatch(setAccountDetails(accountDetails));
|
||||||
|
store.dispatch(setContainerID(thisSession.user.id));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: { loggedInUserIdent: loggedInUserIdent },
|
props: { loggedInUserIdent: loggedInUserIdent },
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export const AccountDetailsDataActionTypes = {
|
|||||||
SETLOGGEDINUSER: "SETLOGGEDINUSER",
|
SETLOGGEDINUSER: "SETLOGGEDINUSER",
|
||||||
SETACCOUNTCREATED: "SETACCOUNTCREATED",
|
SETACCOUNTCREATED: "SETACCOUNTCREATED",
|
||||||
USER_LOGOUT: "USER_LOGOUT",
|
USER_LOGOUT: "USER_LOGOUT",
|
||||||
|
SETCONTAINERID: "SETCONTAINERID",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setCookieConsent = (cookieObj) => (dispatch) => {
|
export const setCookieConsent = (cookieObj) => (dispatch) => {
|
||||||
@@ -47,3 +48,10 @@ export const setAccCr = (accCr) => (dispatch) => {
|
|||||||
accCr: accCr,
|
accCr: accCr,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setContainerID = (containerID) => (dispatch) => {
|
||||||
|
return dispatch({
|
||||||
|
type: AccountDetailsDataActionTypes.SETCONTAINERID,
|
||||||
|
containerID: containerID,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const AccountDetailsDataInitialState = {
|
|||||||
loggedinUserId: "",
|
loggedinUserId: "",
|
||||||
accCr: false,
|
accCr: false,
|
||||||
cookieObj: "",
|
cookieObj: "",
|
||||||
|
containerID: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function reducer(
|
export default function reducer(
|
||||||
@@ -32,6 +33,11 @@ export default function reducer(
|
|||||||
...state,
|
...state,
|
||||||
cookieObj: action.cookieObj,
|
cookieObj: action.cookieObj,
|
||||||
};
|
};
|
||||||
|
case AccountDetailsDataActionTypes.SETCONTAINERID:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
containerID: action.containerID,
|
||||||
|
};
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user