From ad2dddc9a4bb3211594923c69f31e4e67b60ffcd Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Wed, 13 Aug 2025 13:45:33 +0100 Subject: [PATCH 1/2] updated home page copy --- components/homepage/casecomment.js | 22 +-------- components/homepage/login.js | 71 ++++++++++++------------------ locales/cy/home.json | 16 +++---- locales/en/home.json | 16 +++---- styles/sass/patterns/_card.scss | 12 +++++ 5 files changed, 57 insertions(+), 80 deletions(-) diff --git a/components/homepage/casecomment.js b/components/homepage/casecomment.js index eace402d..258063b7 100644 --- a/components/homepage/casecomment.js +++ b/components/homepage/casecomment.js @@ -8,17 +8,7 @@ export default function CaseComment() { const { locale } = router; return (
-
-

- {t("home:casescomment-card-title")} -

- -

- {t("home:casescomment-card-paragraph-three")} -

-

- {t("home:casescomment-card-paragraph-four")} -

+

{t("home:casescomment-card-paragraph-one")}{" "}

-

- {t("home:casescomment-card-paragraph-two")} -

-

- {t("home:watch-case-card-title")} -

-

- {t("home:watch-case-paragraph-one")} -

+ {/*

{t("home:casescomment-card-paragraph-two")}

*/} diff --git a/components/homepage/login.js b/components/homepage/login.js index 6c67dfcb..496f37f0 100644 --- a/components/homepage/login.js +++ b/components/homepage/login.js @@ -78,49 +78,24 @@ let Login = (props) => {

{t("home:signin-benefits-paragraph")}

-

- {/* {t("home:login-card-title")} */} - {t("home:login-card-title-temp")} -

{" "} - {/*
-
- {session && "Signed in as " + session.user?.email} -
-
- - {!session && ( - - )} - {session && ( - - )} -
*/} -

- {t("home:login-comingsoon-temp-1")}{" "} -

- {/*

- {t("home:login-comingsoon-temp-1a")}{" "} -

*/} +
    +
  • + {" "} + + {" "} + {t("home:login-card-title-temp")}{" "} + {" "} + {t("home:login-comingsoon-temp-1")} +
  • +
  • + {t("home:casescomment-card-title")}{" "} + {t("home:casescomment-card-paragraph-two")} +
  • +
  • + {t("home:watch-case-card-title")}{" "} + {t("home:watch-case-paragraph-one")} +
  • +

{t("home:login-comingsoon-temp-2")} @@ -178,9 +153,17 @@ let Login = (props) => { +

+ {t("home:casescomment-card-paragraph-one")}{" "} + + {t("home:login-contact-email")} + +

-
); diff --git a/locales/cy/home.json b/locales/cy/home.json index d957be71..b9a8c85d 100644 --- a/locales/cy/home.json +++ b/locales/cy/home.json @@ -1,8 +1,8 @@ { "login-card-title-temp": "Cyflwyno apêl newydd", - "login-comingsoon-temp-1": "Mae'r gwasanaeth hwn yn cael ei ddatblygu i gefnogi apeliadau a cheisiadau ar-lein. Gallwch chi godi apeliadau cynllunio ar hyn o bryd.", + "login-comingsoon-temp-1": "yn erbyn gwrthodiad eich Awdurdod Cynllunio Lleol i roi caniatâd cynllunio neu fethiant i benderfynu ar gais cynllunio mewn pryd.", "login-comingsoon-temp-1a": "Ar hyn o bryd, gallwch gyflwyno Apeliadau Cynllunio a78, Apeliadau Cydsyniad Adeilad Rhestredig ac Ardal Gadwraeth, Apeliadau Deiliaid Tai a Mân Apeliadau Masnachol - HAS/CAS, Apeliadau Hysbysebion a Barnu'n Annilys.", - "login-comingsoon-temp-2": "Wrth i ni ddatblygu’r gwasanaeth ar-lein, dewch o hyd i:", + "login-comingsoon-temp-2": "Mae'r gwasanaeth hwn ar agor ar hyn o bryd i gyflwyno apeliadau newydd yn erbyn gwrthod caniatâd cynllunio neu fethu â phenderfynu ar gais cynllunio mewn pryd (apeliadau adran 78). Mae'r gwasanaeth yn cael ei ddatblygu i gefnogi apeliadau a cheisiadau ar-lein eraill. Yn y cyfamser, gallwch ddod o hyd i'r ffurflenni yma", "login-comingsoon-forms-link-1": "https://llyw.cymru/ffurflenni-apelio", "login-comingsoon-forms-label-1": "ffurflenni apêl cynllunio a ffurflenni cais cynllunio", "login-comingsoon-forms-link-2": "https://llyw.cymru/trwyddedau-amgylcheddol", @@ -32,9 +32,9 @@ "casesearch-card-advanced-link": "Chwiliad uwch", "casesearch-search-validation-required": "Angenrheidiol", "casesearch-search-validation-minlength": "Rhaid iddo gynnwys 4 nod neu fwy", - "casescomment-card-title": "Sylw ar apêl neu gais", - "casescomment-card-paragraph-one": "Fel arall, gallwch wneud sylwadau ar apêl (ac eithrio apêl gan ddeiliad tŷ neu apêl fasnachol) drwy e-bostio ", - "casescomment-card-paragraph-two": "Ni all partïon â buddiant wneud sylwadau ar apeliadau deiliaid tai a masnachol yn ystod y cam apelio. Bydd unrhyw sylwadau a wnaed yn ystod y cam ymgeisio yn cael eu darparu gan yr awdurdod cynllunio lleol a'u hystyried gan yr Arolygydd.", + "casescomment-card-title": "Sylwadau ar apeliadau neu geisiadau", + "casescomment-card-paragraph-one": "Fel arall, gallwch ofyn am ffurflenni neu wneud sylwadau ar apêl yn ystod y cyfnod cynrychioliadau drwy e-bostio ", + "casescomment-card-paragraph-two": "yn ystod y cyfnod cynrychioliadau neu gyflwyno datganiadau achos. Cyfeiriwch at y dyddiadau cau penodol i'r achos. Ar gyfer apeliadau deiliaid tai a masnachol, ni all partïon â diddordeb wneud sylwadau yn ystod y cam apelio. Bydd unrhyw sylwadau a wneir yn ystod y cam ymgeisio yn cael eu darparu gan yr Awdurdod Cynllunio Lleol a'u hystyried gan yr Arolygydd.", "inspectorate-card-visit-label": "Ymweld â'r Arolygiaeth Gynllunio", "inspectorate-card-visit-link": "Hafan", "inspectorate-card-alt-text": "Yr Arolygiaeth Gynllunio", @@ -48,9 +48,9 @@ "completed-uploading-files-label": "{{number}} ffeil wedi'u huwchlwytho", "remove-this-file-label": "Tynnu'r ffeil hon", "watch-case-card-title": "Gwylio achos", - "watch-case-paragraph-one": "Os oes gennych ddiddordeb mewn achos, dewiswch ei wylio o'ch dangosfwrdd.", + "watch-case-paragraph-one": "i gadw golwg ar y camau nesaf a chanlyniad yr apêl.", "casescomment-card-paragraph-three": "Gallwch wneud sylwadau ar apeliadau a cheisiadau yn ystod y cyfnod cynrychioli neu gyflwyno datganiadau achos neu'r Holiadur LPA.", "casescomment-card-paragraph-four": "Cyfeiriwch at y dyddiadau cau ar gyfer cynrychioli achosion unigol ar gyfer datganiadau a sylwadau.", - "signin-benefits-title": "Buddion mewngofnodi", - "signin-benefits-paragraph": "Mae cofrestru ar y porth Gwaith Achos Cynllunio yn caniatáu ichi:" + "signin-benefits-title": "Mewngofnodwch i'ch porth", + "signin-benefits-paragraph": "Drwy fewngofnodi gyda'r botwm Mewngofnodi, byddwch yn gallu:" } \ No newline at end of file diff --git a/locales/en/home.json b/locales/en/home.json index ec8ac994..17dfcce2 100644 --- a/locales/en/home.json +++ b/locales/en/home.json @@ -1,8 +1,8 @@ { "login-card-title-temp": "Submit a new appeal", - "login-comingsoon-temp-1": "This service is being developed to support online appeals and applications. You can currently raise planning appeals.", + "login-comingsoon-temp-1": "against your Local Planning Authority’s refusal of planning permission or failure to determine a planning application in time.", "login-comingsoon-temp-1a": "You can currently raise Planning Appeals s78.", - "login-comingsoon-temp-2": "While we develop the online service, find:", + "login-comingsoon-temp-2": "This service is currently open to submit new appeals against refusal of planning permission or failure to determine a planning application in time (section 78 appeals). The service is being developed to support other online appeals and applications. In the meantime, you can find the forms here", "login-comingsoon-forms-link-1": "https://gov.wales/planning-appeal-forms", "login-comingsoon-forms-label-1": "planning appeal and application forms", "login-comingsoon-forms-link-2": "https://gov.wales/environmental-permits", @@ -32,9 +32,9 @@ "casesearch-card-advanced-link": "Advanced search", "casesearch-search-validation-required": "Required", "casesearch-search-validation-minlength": "Must be 4 characters or more", - "casescomment-card-title": "Comment on an appeal or application", - "casescomment-card-paragraph-one": "Alternatively you can comment on an appeal (excluding householder or commercial) by emailing ", - "casescomment-card-paragraph-two": "For householder and commercial appeals, interested parties are unable to comment at appeal stage. Any comments made at application stage will be provided by the Local Planning Authority and considered by the inspector.", + "casescomment-card-title": "Comment on appeals or applications", + "casescomment-card-paragraph-one": "Alternatively, you can request forms or comment on an appeal during the representation period by emailing ", + "casescomment-card-paragraph-two": "during the representation period or submit statements of case. Please refer to the case specific deadlines. For householder and commercial appeals, interested parties are unable to comment at appeal stage. Any comments made at application stage will be provided by the Local Planning Authority and considered by the Inspector.", "inspectorate-card-visit-label": "Visit the Planning Inspectorate", "inspectorate-card-visit-link": "Home", "inspectorate-card-alt-text": "The Planning Inspectorate", @@ -48,9 +48,9 @@ "completed-uploading-files-label": "{{number}} files uploaded", "remove-this-file-label": "Remove this file", "watch-case-card-title": "Watch a case", - "watch-case-paragraph-one": "If you are interested in a case you select to watch it from your dashboard.", + "watch-case-paragraph-one": "to keep track of the next steps and outcome of the appeal.", "casescomment-card-paragraph-three": "You can make comments on appeals and applications during the representation period or submit statements of case or the LPA Questionnaire.", "casescomment-card-paragraph-four": "Please refer to the individual case representation deadlines for statements and comments.", - "signin-benefits-title": "Sign in benefits", - "signin-benefits-paragraph": "Registering on the Planning Casework portal allows you to:" + "signin-benefits-title": "Sign in to your portal", + "signin-benefits-paragraph": "By signing in with the Sign in button, you will be able to:" } \ No newline at end of file diff --git a/styles/sass/patterns/_card.scss b/styles/sass/patterns/_card.scss index 9aa27ed3..3ce8868d 100644 --- a/styles/sass/patterns/_card.scss +++ b/styles/sass/patterns/_card.scss @@ -329,4 +329,16 @@ div.cardModuleItem:last-of-type { // box-shadow: 0 2px 0 #0b0c0c; } } +} + + +.card { + .cardList-nobullet { + list-style-type: none; + padding-left: 20px; + + li { + margin-bottom: 10px; + } + } } \ No newline at end of file From ec3a5911267a6cee8499f071fd4f787bd5a4536b Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Wed, 13 Aug 2025 15:57:18 +0100 Subject: [PATCH 2/2] updated storage admin --- actions/azurestorage.js | 81 +++++- pages/storageAdmin.js | 627 +++++++++++++++++++++++----------------- 2 files changed, 434 insertions(+), 274 deletions(-) diff --git a/actions/azurestorage.js b/actions/azurestorage.js index a3c02dc0..2ecad913 100644 --- a/actions/azurestorage.js +++ b/actions/azurestorage.js @@ -1693,14 +1693,91 @@ 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"; +} + +function formatBlobDates(blob) { + const created = blob.createdOn ? new Date(blob.createdOn) : null; + const modified = blob.lastModified ? new Date(blob.lastModified) : null; + + if (!created && !modified) return "Unknown"; + + // If both exist and are the same + if (created && modified && created.getTime() === modified.getTime()) { + return `${created.toLocaleString("en-GB")} (${formatTimeSince( + created + )})`; + } + + // If modified exists and is newer than created + if (created && modified && modified.getTime() > created.getTime()) { + return `Created: ${created.toLocaleString("en-GB")} (${formatTimeSince( + created + )}), Modified: ${modified.toLocaleString("en-GB")} (${formatTimeSince( + modified + )})`; + } + + // Only one date exists + const date = modified || created; + return `${date.toLocaleString("en-GB")} (${formatTimeSince(date)})`; +} + export async function listBlobHierarchicalForUser(containerClient) { const blobNames = []; for await (const blob of containerClient.listBlobsFlat()) { - // blobNames.push(blob.name); + 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, // in bytes + size: blob.properties.contentLength || 0, + lastModified: lastModifiedDate + ? lastModifiedDate.toISOString() + : null, + createdOn: createdOnDate ? createdOnDate.toISOString() : null, + displayDate, }); } return blobNames; diff --git a/pages/storageAdmin.js b/pages/storageAdmin.js index 09eda695..c65167d9 100644 --- a/pages/storageAdmin.js +++ b/pages/storageAdmin.js @@ -1,3 +1,6 @@ +import CookieBanner from "../components/cookieBanner"; +import Footer from "../components/footer"; +import Header from "../components/header"; import { DefaultAzureCredential } from "@azure/identity"; import { BlobServiceClient, ContainerClient } from "@azure/storage-blob"; import { v4 as uuidv4 } from "uuid"; @@ -7,6 +10,7 @@ import { listBlobHierarchical, listContainersForUser, } from "../actions/azurestorage"; +import Head from "next/head"; import Link from "next/link"; import { PrismaClient } from "@prisma/client"; import { @@ -19,8 +23,10 @@ import { getIP, sendRepCompleteMessage, deleteMyRepresentationsFromBlob, + deleteAwaitingSubmissionsFromBlob, } from "../actions"; import CryptoJS from "crypto-js"; +import { useState } from "react"; function getUpToLastSlash(url) { let lastSlash = url.lastIndexOf("/"); @@ -47,6 +53,48 @@ async function streamToString(readableStream) { }); } +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 formatBlobDates(blob) { + const created = blob.createdOn ? new Date(blob.createdOn) : null; + const modified = blob.lastModified ? new Date(blob.lastModified) : null; + + if (!created && !modified) return "Unknown"; + + // If both exist and are the same + if (created && modified && created.getTime() === modified.getTime()) { + return `${created.toLocaleString("en-GB")} (${formatTimeSince( + created + )})`; + } + + // If modified exists and is newer than created + if (created && modified && modified.getTime() > created.getTime()) { + return `Created: ${created.toLocaleString("en-GB")} (${formatTimeSince( + created + )}), Modified: ${modified.toLocaleString("en-GB")} (${formatTimeSince( + modified + )})`; + } + + // Only one date exists + const date = modified || created; + return `${date.toLocaleString("en-GB")} (${formatTimeSince(date)})`; +} + const deleteRepItem = (containerID, caseID, repfile) => { deleteMyRepresentationsFromBlob(containerID, caseID, repfile).then( (data) => { @@ -56,185 +104,312 @@ const deleteRepItem = (containerID, caseID, repfile) => { ); }; +const deleteCaseItem = (containerID, caseID) => { + deleteAwaitingSubmissionsFromBlob(containerID, caseID).then((data) => { + return data; + }); +}; + export default function StoragePage({ data }) { console.log(data); + + const [showRepJson, setShowRepJson] = useState(true); + const [showTmpFile, setShowTmpFile] = useState(true); + + const toggleAll = () => { + const newState = !(showRepJson || showTmpFile); + setShowRepJson(newState); + setShowTmpFile(newState); + }; return ( -
-
-

Storage Account Contents

- {data.map((user) => ( -
- {user.containers.map((c) => ( -
-
-

- {c.container} - {user.email} -

- {c.folders.map((folder) => ( -
-

- {folder.folderPath || "Root"} -

- {/* {folder.hasRepJson && ( +
+ + Storage Account Browser + +
+ +
+
+
+

Storage Account Contents

+ + {/* Toggle buttons */} +
+ + + +
+ + {data.map((user) => ( +
+ {user.containers.map((c) => ( +
+
+

+ {c.container} - {user.email} +

+ {c.folders.map((folder) => ( +
+

+ {folder.folderPath || + "Root"} +

+ {/* {folder.hasRepJson && (

rep.json file found:{" "} {folder.repJsonBlob.name}

)} */} - {folder.hasRepJson && ( -
- {" "} - - {folder.repComplete && ( - + + )} + {folder.hasRepJson && ( +
+ {" "} + - )} - {folder.repComplete && ( - - )} -
- )} - -
    - {folder.blobs.map((blob) => ( -
  • - - {blob.name} ( - {bytesToSize( - blob.contentLength || - blob.size + className=" cardModuleRemoveCase govuk-link govuk-link--no-underline govuk-link--inverse " + onClick={() => { + confirm( + "Do you want tyo delete rep " + + folder.repJsonBlob.name.split( + "/" + )[0] + + "?\n" + ) && + (deleteRepItem( + c.container, + folder.repJsonBlob.name.split( + "/" + )[0], + folder.repJsonBlob.name.split( + "/" + )[1] + ), + alert( + "Rep Deleted!" + ), + window.location.reload()); + }} + > + Delete Rep + + {folder.repComplete && ( + )} + {folder.repComplete && ( + + )} +
+ )} + +
    + {folder.blobs.map( + (blob) => ( +
  • + + { + blob.name + }{" "} + ( + {bytesToSize( + blob.contentLength || + blob.size + )} + ) + {" "} + {blob.lastModified && ( + + {/* { + blob.displayDate + } */} + {formatBlobDates( + blob + )} + + )} +
  • ) - - - ))} -
+ )} + +
+ ))}
- ))} -
+
+ ))}
))}
- ))} +
+
); @@ -299,112 +474,6 @@ export async function getServerSideProps({ req }) { user.email ); - // Add hashedName for each blob - // const containersWithHashes = containers.map((container) => { - // console.log("eee "); - - // const groupedByFolder = container.blobs.reduce((acc, blob) => { - // // Get folder path - everything before last slash, or "" if no slash - // const folderPath = getUpToLastSlash(blob.name.trim()) || ""; - - // const hashedfilepath = hashAPIPath( - // "/api/file/downloadblob?container=" + - // container.container + - // "&casefolderID=" + - // folderPath + - // "&blobname=" + - // blob.name - // .substring(blob.name.lastIndexOf("/") + 1) - // .trim(), - // process.env.HASHKEY - // ); - - // const blobWithHash = { ...blob, hashedfilepath }; - - // // Find or create folder group - // let folderGroup = acc.find( - // (f) => f.folderPath === folderPath - // ); - // if (!folderGroup) { - // folderGroup = { folderPath, blobs: [] }; - // acc.push(folderGroup); - // } - // folderGroup.blobs.push(blobWithHash); - - // return acc; - // }, []); - - // console.log(groupedByFolder); - // return { - // ...container, - // blobs: container.blobs.map((blob) => ({ - // ...blob, - // hashedfilepath: hashAPIPath( - // "/api/file/downloadblob?container=" + - // container.container + - // "&casefolderID=" + - // getUpToLastSlash(blob.name.trim()) + - // "&blobname=" + - // blob.name - // .substring(blob.name.lastIndexOf("/") + 1) - // .trim(), - // process.env.HASHKEY - // ), - // })), - // }; - // }); - - // const containersWithHashes = containers.map((container) => { - // const groupedByFolder = container.blobs.reduce((acc, blob) => { - // const folderPath = getUpToLastSlash(blob.name.trim()) || ""; - - // const hashedfilepath = hashAPIPath( - // "/api/file/downloadblob?container=" + - // container.container + - // "&casefolderID=" + - // folderPath + - // "&blobname=" + - // blob.name - // .substring(blob.name.lastIndexOf("/") + 1) - // .trim(), - // process.env.HASHKEY - // ); - - // const blobWithHash = { ...blob, hashedfilepath }; - - // let folderGroup = acc.find( - // (f) => f.folderPath === folderPath - // ); - // if (!folderGroup) { - // folderGroup = { - // folderPath, - // blobs: [], - // hasRepJson: false, // flag - // repJsonBlob: null, // save the rep.json blob if found - // }; - // acc.push(folderGroup); - // } - - // folderGroup.blobs.push(blobWithHash); - - // // Check if this blob ends with "rep.json" - // if (blob.name.toLowerCase().endsWith("rep.json")) { - // folderGroup.hasRepJson = true; - // folderGroup.repJsonBlob = blobWithHash; - // // You can also do some processing here if you want - // } - - // return acc; - // }, []); - - // return { - // ...container, - // folders: groupedByFolder, - // // Optionally remove flat blobs if you don't want them - // // blobs: undefined, - // }; - // }); - const containersWithHashes = await Promise.all( containers.map(async (container) => { const groupedByFolder = await container.blobs.reduce( @@ -429,7 +498,16 @@ export async function getServerSideProps({ req }) { process.env.HASHKEY ); - const blobWithHash = { ...blob, hashedfilepath }; + const fileNameOnly = blob.name.substring( + blob.name.lastIndexOf("/") + 1 + ); + const isTmpFile = fileNameOnly.startsWith("TMP-"); + + const blobWithHash = { + ...blob, + hashedfilepath, + isTmpFile, + }; let folderGroup = acc.find( (f) => f.folderPath === folderPath @@ -440,13 +518,18 @@ export async function getServerSideProps({ req }) { blobs: [], hasRepJson: false, repJsonBlob: null, - repComplete: false, // new flag + repComplete: false, + hasTmpFile: false, }; acc.push(folderGroup); } folderGroup.blobs.push(blobWithHash); + if (isTmpFile) { + folderGroup.hasTmpFile = true; + } + // If this blob ends with rep.json, fetch and parse JSON if (blob.name.toLowerCase().endsWith("rep.json")) { folderGroup.hasRepJson = true;