partial synch with ph2 updates
This commit is contained in:
+124
-29
@@ -210,31 +210,31 @@ export const getBlobs = async (containerName, casefolderID) => {
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
encodeURIComponent(casefolderID) +
|
||||
"&blobname=" +
|
||||
blob.name,
|
||||
encodeURIComponent(blob.name),
|
||||
"hashedfilepath": hashAPIPath(
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
encodeURIComponent(casefolderID) +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[2]
|
||||
encodeURIComponent(blob.name.split("/")[2])
|
||||
),
|
||||
"deletepath":
|
||||
"/api/file/deleteblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
encodeURIComponent(casefolderID) +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[2],
|
||||
encodeURIComponent(blob.name.split("/")[2]),
|
||||
"hasheddeletepath": hashAPIPath(
|
||||
"/api/file/deleteblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
encodeURIComponent(casefolderID) +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[2]
|
||||
encodeURIComponent(blob.name.split("/")[2])
|
||||
),
|
||||
"hashgetblobs": hashAPIPath(
|
||||
"/api/file/getbloblist?container=" +
|
||||
@@ -309,7 +309,7 @@ export const createRepBlob = async (formContent, containerName, caseref) => {
|
||||
|
||||
const tags = {
|
||||
containerid: containerName,
|
||||
caseID: formContent.caseRef,
|
||||
caseID: formContent.ticketnumber,
|
||||
blobType: "Representation",
|
||||
};
|
||||
|
||||
@@ -317,7 +317,7 @@ export const createRepBlob = async (formContent, containerName, caseref) => {
|
||||
const withTags = await blockBlobClient.setTags(tags);
|
||||
const withMeta = await blockBlobClient.setMetadata(tags);
|
||||
|
||||
return formContent.pinswg_name;
|
||||
return formContent.ticketnumber;
|
||||
};
|
||||
|
||||
export const createAppealPDFBlob = async (
|
||||
@@ -432,7 +432,6 @@ export const createRepPDFBlob = async (
|
||||
containerid: containerName,
|
||||
caseID: caseID,
|
||||
blobType: "Representation PDF",
|
||||
documentLocationId: whichLocation,
|
||||
ishareLocation: whichLocation,
|
||||
documentLocationId: whichLocation,
|
||||
};
|
||||
@@ -624,7 +623,6 @@ export const uploadFile = async (formContent, containerName, foldername) => {
|
||||
caseID: foldername.split("/")[0],
|
||||
documentType: files[prop][0].fieldName.split(".")[1],
|
||||
blobType: "RepresentationFile",
|
||||
documentLocationId: whichLocation,
|
||||
ishareLocation: whichLocation,
|
||||
documentLocationId: whichLocation,
|
||||
};
|
||||
@@ -1244,17 +1242,17 @@ export const getProgressBlobs = async (containerName, caseReference) => {
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
caseReference +
|
||||
encodeURIComponent(caseReference) +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[1]
|
||||
encodeURIComponent(blob.name.split("/")[1])
|
||||
),
|
||||
"hasheddeletepath": hashAPIPath(
|
||||
"/api/file/deleteblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
caseReference +
|
||||
encodeURIComponent(caseReference) +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[1]
|
||||
encodeURIComponent(blob.name.split("/")[1])
|
||||
),
|
||||
"hashgetblobs": hashAPIPath(
|
||||
"/api/file/getbloblist?container=" +
|
||||
@@ -1415,20 +1413,20 @@ export const getRepsFilesBlobs = async (
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
blob.name.split("/")[0] +
|
||||
"/" +
|
||||
blob.name.split("/")[1] +
|
||||
encodeURIComponent(
|
||||
blob.name.split("/")[0] + "/" + blob.name.split("/")[1]
|
||||
) +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[3],
|
||||
encodeURIComponent(blob.name.split("/")[3]),
|
||||
"hashedfilepath": hashAPIPath(
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
blob.name.split("/")[0] +
|
||||
"/" +
|
||||
blob.name.split("/")[1] +
|
||||
encodeURIComponent(
|
||||
blob.name.split("/")[0] + "/" + blob.name.split("/")[1]
|
||||
) +
|
||||
"&blobname=" +
|
||||
blob.name
|
||||
encodeURIComponent(blob.name.split("/")[3])
|
||||
),
|
||||
"deletepath":
|
||||
"/api/file/deleteblob?container=" +
|
||||
@@ -1443,11 +1441,11 @@ export const getRepsFilesBlobs = async (
|
||||
"/api/file/deleteblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
blob.name.split("/")[0] +
|
||||
"/" +
|
||||
blob.name.split("/")[1] +
|
||||
encodeURIComponent(
|
||||
blob.name.split("/")[0] + "/" + blob.name.split("/")[1]
|
||||
) +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[3]
|
||||
encodeURIComponent(blob.name.split("/")[3])
|
||||
),
|
||||
"hashgetblobs": hashAPIPath(
|
||||
"/api/file/getbloblist?container=" +
|
||||
@@ -1459,7 +1457,7 @@ export const getRepsFilesBlobs = async (
|
||||
),
|
||||
});
|
||||
}
|
||||
//console.log("blobObj:", blobObj);
|
||||
console.log("blobObj:", blobObj);
|
||||
|
||||
return blobObj;
|
||||
};
|
||||
@@ -1702,3 +1700,100 @@ export const listBlobHierarchical = async (
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function formatTimeSince(date) {
|
||||
if (!date) return "Unknown date";
|
||||
|
||||
const now = new Date();
|
||||
const diffMs = now - date;
|
||||
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
||||
|
||||
if (diffDays < 7) {
|
||||
return `${diffDays} day${diffDays !== 1 ? "s" : ""} ago`;
|
||||
} else {
|
||||
const diffWeeks = Math.floor(diffDays / 7);
|
||||
return `${diffWeeks} week${diffWeeks !== 1 ? "s" : ""} ago`;
|
||||
}
|
||||
}
|
||||
|
||||
function formatDateDisplay(date) {
|
||||
return date
|
||||
? `${date.toLocaleString("en-GB")} (${formatTimeSince(date)})`
|
||||
: "Unknown";
|
||||
}
|
||||
|
||||
export async function listBlobHierarchicalForUser(containerClient) {
|
||||
const blobNames = [];
|
||||
for await (const blob of containerClient.listBlobsFlat()) {
|
||||
const lastModifiedDate = blob.properties?.lastModified || null;
|
||||
const createdOnDate = blob.properties?.createdOn || null;
|
||||
|
||||
let displayDate = "";
|
||||
|
||||
if (createdOnDate && lastModifiedDate) {
|
||||
if (
|
||||
createdOnDate.toDateString() === lastModifiedDate.toDateString()
|
||||
) {
|
||||
// Same day — show just one
|
||||
displayDate = `Date: ${formatDateDisplay(lastModifiedDate)}`;
|
||||
} else {
|
||||
// Different days — show both
|
||||
displayDate = `Created: ${formatDateDisplay(
|
||||
createdOnDate
|
||||
)}, Modified: ${formatDateDisplay(lastModifiedDate)}`;
|
||||
}
|
||||
} else if (lastModifiedDate) {
|
||||
displayDate = `Modified: ${formatDateDisplay(lastModifiedDate)}`;
|
||||
} else if (createdOnDate) {
|
||||
displayDate = `Created: ${formatDateDisplay(createdOnDate)}`;
|
||||
} else {
|
||||
displayDate = "Unknown date";
|
||||
}
|
||||
|
||||
blobNames.push({
|
||||
name: blob.name,
|
||||
size: blob.properties.contentLength || 0,
|
||||
lastModified: lastModifiedDate
|
||||
? lastModifiedDate.toISOString()
|
||||
: null,
|
||||
createdOn: createdOnDate ? createdOnDate.toISOString() : null,
|
||||
displayDate,
|
||||
});
|
||||
}
|
||||
return blobNames;
|
||||
}
|
||||
|
||||
export async function listContainersForUser(
|
||||
blobServiceClient,
|
||||
containerNamePrefix,
|
||||
emailAddress
|
||||
) {
|
||||
const options = {
|
||||
includeDeleted: false,
|
||||
includeMetadata: true,
|
||||
includeSystem: true,
|
||||
prefix: containerNamePrefix,
|
||||
};
|
||||
|
||||
const results = [];
|
||||
|
||||
for await (const containerItem of blobServiceClient.listContainers(
|
||||
options
|
||||
)) {
|
||||
const containerClient = blobServiceClient.getContainerClient(
|
||||
containerItem.name
|
||||
);
|
||||
const blobNames = await listBlobHierarchicalForUser(
|
||||
containerClient
|
||||
).catch(console.error);
|
||||
|
||||
if (blobNames && blobNames.length > 0) {
|
||||
results.push({
|
||||
container: containerItem.name,
|
||||
blobs: blobNames,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return results; // array of non-empty containers
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user