get pending reps to dashboard from St Acc
This commit is contained in:
+81
-1
@@ -41,7 +41,7 @@ export const createContainerSas = async (containerName) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Need only list permission to list blobs
|
// Need only list permission to list blobs
|
||||||
const containerPermissions = "rcwltd";
|
const containerPermissions = "rcwltdf";
|
||||||
|
|
||||||
// Best practice: SAS options are time-limited
|
// Best practice: SAS options are time-limited
|
||||||
const sasOptions = {
|
const sasOptions = {
|
||||||
@@ -472,6 +472,50 @@ export const downloadAllProgressFiles = async (
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const downloadAllRepsFiles = async (containerName, repsBlobObj) => {
|
||||||
|
console.log(
|
||||||
|
"/////////////////////////\n downloading files: " +
|
||||||
|
JSON.stringify(repsBlobObj) +
|
||||||
|
"\n/////////////////////////\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
const containerToken = await createContainerSas(containerName);
|
||||||
|
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
|
||||||
|
const containerClient = new ContainerClient(sasUrl);
|
||||||
|
|
||||||
|
let blobClient = {};
|
||||||
|
let downloadedBlob = {};
|
||||||
|
let repArr = [];
|
||||||
|
let downloaded = "";
|
||||||
|
let caseBlob = {};
|
||||||
|
let caseDownloaded = "";
|
||||||
|
let blobCount = 0;
|
||||||
|
|
||||||
|
for (const prop in repsBlobObj) {
|
||||||
|
console.log(`Progress - ${prop}: ${repsBlobObj[prop].name}`);
|
||||||
|
blobClient = containerClient.getBlobClient(repsBlobObj[prop].name);
|
||||||
|
downloadedBlob = await blobClient.download(0);
|
||||||
|
let repBlobObj = await streamToBuffer(
|
||||||
|
downloadedBlob.readableStreamBody
|
||||||
|
);
|
||||||
|
|
||||||
|
repBlobObj = JSON.parse(repBlobObj);
|
||||||
|
|
||||||
|
repBlobObj["casereference"] = repsBlobObj[prop].name.split("/")[0];
|
||||||
|
|
||||||
|
repBlobObj = JSON.stringify(repBlobObj);
|
||||||
|
|
||||||
|
downloaded = downloaded + repBlobObj + ",";
|
||||||
|
blobCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
downloaded = downloaded.substring(0, downloaded.length - 1);
|
||||||
|
|
||||||
|
return JSON.parse(
|
||||||
|
'{ "@odata.count": ' + blobCount + ',"value": [' + downloaded + "]}"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const streamToBuffer = async (readableStream) => {
|
const streamToBuffer = async (readableStream) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
@@ -605,3 +649,39 @@ export const getAllProgressBlobs = async (containerName) => {
|
|||||||
|
|
||||||
return blobObj;
|
return blobObj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getRepslobs = async (containerName, caseReference) => {
|
||||||
|
const containerToken = await createContainerSas(containerName);
|
||||||
|
|
||||||
|
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
|
||||||
|
|
||||||
|
const containerClient = new ContainerClient(sasUrl);
|
||||||
|
|
||||||
|
let blobCount = 0;
|
||||||
|
for await (const blob of containerClient.findBlobsByTags(
|
||||||
|
"blobType='Representation'"
|
||||||
|
)) {
|
||||||
|
blobCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("this is the caasefolder:", caseReference, blobCount);
|
||||||
|
|
||||||
|
let blobObj = [];
|
||||||
|
for await (const blob of containerClient.findBlobsByTags(
|
||||||
|
"blobType='Representation'"
|
||||||
|
)) {
|
||||||
|
console.log("in here");
|
||||||
|
console.log(blob);
|
||||||
|
blobObj.push(blob);
|
||||||
|
}
|
||||||
|
|
||||||
|
// blobObj = _.sortBy(blobObj, [
|
||||||
|
// function (o) {
|
||||||
|
// return o.lastModified;
|
||||||
|
// },
|
||||||
|
// ]).reverse()[0];
|
||||||
|
|
||||||
|
console.log("blobObjwwwww:", blobObj);
|
||||||
|
|
||||||
|
return blobObj;
|
||||||
|
};
|
||||||
|
|||||||
@@ -793,6 +793,27 @@ export const getAwaitingSubmissionFromBlob = (containerName) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getRepsFromBlob = (containerName) => {
|
||||||
|
console.log(
|
||||||
|
"///////////////////////getRepsFromBlob: " +
|
||||||
|
containerName +
|
||||||
|
"\n///////////////////////\n"
|
||||||
|
);
|
||||||
|
return axios
|
||||||
|
.get(
|
||||||
|
BASE_URL +
|
||||||
|
"/api/file/getrepsblob?container=" +
|
||||||
|
containerName +
|
||||||
|
hashAPIPath("/api/file/getrepsblob?container=" + containerName)
|
||||||
|
)
|
||||||
|
.then((res) => {
|
||||||
|
return res.data;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
//console.log("API call error", error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const getAwaitingSubmissionFromBlobProxy = (containerName) => {
|
export const getAwaitingSubmissionFromBlobProxy = (containerName) => {
|
||||||
return axios
|
return axios
|
||||||
.get(
|
.get(
|
||||||
|
|||||||
@@ -288,7 +288,6 @@ const CaseSummary = (props) => {
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{props.currentView.showReps == true ||
|
{props.currentView.showReps == true ||
|
||||||
(props.currentView.showReps == "true" &&
|
(props.currentView.showReps == "true" &&
|
||||||
_.has(detailsObj, "pinswg_startdate") &&
|
_.has(detailsObj, "pinswg_startdate") &&
|
||||||
@@ -335,7 +334,9 @@ const CaseSummary = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{props.currentView.showReps == true &&
|
|
||||||
|
{props.currentView.showReps == true ||
|
||||||
|
(props.currentView.showReps == "true" &&
|
||||||
_.has(detailsObj, "pinswg_startdate") &&
|
_.has(detailsObj, "pinswg_startdate") &&
|
||||||
hasEndDate &&
|
hasEndDate &&
|
||||||
showRepsEnded(
|
showRepsEnded(
|
||||||
@@ -354,7 +355,7 @@ const CaseSummary = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
))}
|
||||||
{/* 1{" "}
|
{/* 1{" "}
|
||||||
{_.has(detailsObj, "pinswg_startdatetimeiftheevent") &&
|
{_.has(detailsObj, "pinswg_startdatetimeiftheevent") &&
|
||||||
detailsObj.pinswg_startdatetimeiftheevent}
|
detailsObj.pinswg_startdatetimeiftheevent}
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import Link from "next/link";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
import useTranslation from "next-translate/useTranslation";
|
||||||
|
import TopThree from "./topthree_reps";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import { setCurrentView } from "../../store/currentView/action";
|
||||||
|
|
||||||
|
const MyRepresentations = (props) => {
|
||||||
|
let { t } = useTranslation();
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const { locale } = router;
|
||||||
|
const { setCurrentView } = props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="card" id="casescomment-card">
|
||||||
|
<div className="card-body">
|
||||||
|
<h3 className="heading-small card-heading">
|
||||||
|
{t("myportal:myrepresentations-card-title")}dd
|
||||||
|
</h3>
|
||||||
|
<div className="cardModuleContainer">
|
||||||
|
<TopThree
|
||||||
|
showTopThree={props.myRepresentations.myRepresentations}
|
||||||
|
showDetails={
|
||||||
|
props.myRepresentations.myRepresentationsDetails
|
||||||
|
}
|
||||||
|
topThreeType={"myRepresentations"}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{props.myRepresentations.myRepresentations["@odata.count"] >
|
||||||
|
3 && (
|
||||||
|
<div className="cardVieAll">
|
||||||
|
<Link href="/myportal/viewall" shallow>
|
||||||
|
<a
|
||||||
|
className="govuk-link--no-underline"
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentView({
|
||||||
|
"viewName": "My Representations",
|
||||||
|
"viewKey": "myRepresentations",
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("myportal:viewall-link")}
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch) => {
|
||||||
|
return {
|
||||||
|
setCurrentView: (currentView) => {
|
||||||
|
dispatch(setCurrentView(currentView));
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(null, mapDispatchToProps)(MyRepresentations);
|
||||||
@@ -123,7 +123,7 @@ const TopThree = (props) => {
|
|||||||
return objArr._pinswg_watchedcase_value;
|
return objArr._pinswg_watchedcase_value;
|
||||||
break;
|
break;
|
||||||
case "myRepresentations":
|
case "myRepresentations":
|
||||||
return objArr.ticketnumber;
|
return objArr.casereference;
|
||||||
break;
|
break;
|
||||||
case "awaitingSubmission":
|
case "awaitingSubmission":
|
||||||
return objArr.ticketnumber;
|
return objArr.ticketnumber;
|
||||||
@@ -152,9 +152,8 @@ const TopThree = (props) => {
|
|||||||
"myRepresentations"
|
"myRepresentations"
|
||||||
? showTopThreeArr[key]
|
? showTopThreeArr[key]
|
||||||
.ticketnumber
|
.ticketnumber
|
||||||
: showTopThreeArr[key][
|
: showTopThreeArr[key]
|
||||||
"_pinswg_case_value@OData.Community.Display.V1.FormattedValue"
|
.casereference
|
||||||
]
|
|
||||||
: showTopThreeArr[key][
|
: showTopThreeArr[key][
|
||||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||||
],
|
],
|
||||||
@@ -177,11 +176,7 @@ const TopThree = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="cardModuleReference">
|
<div className="cardModuleReference">
|
||||||
<b>{t("myportal:case-reference")}:</b>{" "}
|
<b>{t("myportal:case-reference")}:</b>{" "}
|
||||||
{
|
{showTopThreeArr[key].casereference}
|
||||||
showTopThreeArr[key][
|
|
||||||
"_pinswg_case_value@OData.Community.Display.V1.FormattedValue"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import {
|
||||||
|
downloadAllRepsFiles,
|
||||||
|
getRepslobs,
|
||||||
|
} from "../../../actions/azurestorage";
|
||||||
|
import _ from "lodash";
|
||||||
|
import nextConnect from "next-connect";
|
||||||
|
import middleware from "../middleware/middleware";
|
||||||
|
|
||||||
|
const ApiProxy = nextConnect();
|
||||||
|
ApiProxy.use(middleware);
|
||||||
|
|
||||||
|
ApiProxy.get(async (req, res) => {
|
||||||
|
var containerName = req.query.container;
|
||||||
|
var casefolderID = req.query.casefolderID;
|
||||||
|
|
||||||
|
var checkHash = req.query.hash;
|
||||||
|
var checkquerypath =
|
||||||
|
"/api/file/getrepsblob?container=" +
|
||||||
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID;
|
||||||
|
|
||||||
|
console.log(checkquerypath);
|
||||||
|
// console.log(hashAPIPath(checkquerypath), checkHash);
|
||||||
|
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||||
|
|
||||||
|
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||||
|
const blobObj = await getRepslobs(containerName, casefolderID)
|
||||||
|
.then((data) => {
|
||||||
|
console.log("ertyuikjhgfg", data);
|
||||||
|
|
||||||
|
return downloadAllRepsFiles(containerName, data);
|
||||||
|
})
|
||||||
|
.then((data) => {
|
||||||
|
return res.status(200).json(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
// return res.status(400).json();
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
|
||||||
|
export const config = {
|
||||||
|
api: {
|
||||||
|
bodyParser: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ApiProxy;
|
||||||
@@ -5,6 +5,7 @@ import Head from "next/head";
|
|||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import {
|
import {
|
||||||
|
getRepsFromBlob,
|
||||||
getAwaitingSubmissionFromBlob,
|
getAwaitingSubmissionFromBlob,
|
||||||
getAwaitingSubmission,
|
getAwaitingSubmission,
|
||||||
getMyCases,
|
getMyCases,
|
||||||
@@ -194,7 +195,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
await getPersonalAccount(loggedInUser),
|
await getPersonalAccount(loggedInUser),
|
||||||
await getMyCases(loggedInUser),
|
await getMyCases(loggedInUser),
|
||||||
await getMyRepresentations(loggedInUser),
|
await getRepsFromBlob(thisSession.user.id),
|
||||||
await getWatchedCases(loggedInUser),
|
await getWatchedCases(loggedInUser),
|
||||||
await getAwaitingSubmission(loggedInUser),
|
await getAwaitingSubmission(loggedInUser),
|
||||||
await getAwaitingSubmissionFromBlob(thisSession.user.id),
|
await getAwaitingSubmissionFromBlob(thisSession.user.id),
|
||||||
@@ -216,12 +217,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
} else {
|
} else {
|
||||||
const [
|
const [
|
||||||
myCasesDetails,
|
myCasesDetails,
|
||||||
myRepresentationsDetails,
|
|
||||||
watchedCasesDetails,
|
watchedCasesDetails,
|
||||||
awaitingSubmissionDetails,
|
awaitingSubmissionDetails,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
await getDetails(myCases, "myCases"),
|
await getDetails(myCases, "myCases"),
|
||||||
await getDetails(myRepresentations, "myRepresentations"),
|
|
||||||
await getDetails(watchedCases, "myWatchedCases"),
|
await getDetails(watchedCases, "myWatchedCases"),
|
||||||
await getDetails(awaitingSubmission, "awaitingSubmission"),
|
await getDetails(awaitingSubmission, "awaitingSubmission"),
|
||||||
]);
|
]);
|
||||||
@@ -231,9 +230,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
store.dispatch(setMyCases(myCases));
|
store.dispatch(setMyCases(myCases));
|
||||||
store.dispatch(setMyCasesDetails(myCasesDetails));
|
store.dispatch(setMyCasesDetails(myCasesDetails));
|
||||||
store.dispatch(setMyRepresentations(myRepresentations));
|
store.dispatch(setMyRepresentations(myRepresentations));
|
||||||
store.dispatch(
|
|
||||||
setMyRepresentationsDetails(myRepresentationsDetails)
|
|
||||||
);
|
|
||||||
store.dispatch(setWatchedCases(watchedCases));
|
store.dispatch(setWatchedCases(watchedCases));
|
||||||
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
||||||
store.dispatch(setAwaitingSubmission(awaitingSubmission));
|
store.dispatch(setAwaitingSubmission(awaitingSubmission));
|
||||||
|
|||||||
Reference in New Issue
Block a user