Merge branch 'Development' into SIPS-Development
This commit is contained in:
@@ -37,7 +37,7 @@ export default async function ApiProxy(req, res) {
|
||||
var queryUrl =
|
||||
"stringmaps?$filter=objecttypecode eq 'incident' and attributename eq 'pinswg_appealcasetype' " +
|
||||
(process.env.SHOWSIPS !== "true"
|
||||
? "and pinswg_appealcasetype ne 846040002"
|
||||
? "and attributevalue ne 846040002"
|
||||
: "") +
|
||||
"&$count=true&$select=value,stringmapid,organizationid,attributevalue&$orderby=value asc";
|
||||
|
||||
@@ -47,7 +47,7 @@ export default async function ApiProxy(req, res) {
|
||||
// "stringmaps?$filter=objecttypecode eq 'incident' and attributename eq 'pinswg_appealcasetype' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue&$orderby=value asc";
|
||||
//"stringmaps?$filter=objecttypecode eq 'incident' and attributename eq 'pinswg_appealcasetype' and value ne 'Developments of National Significance' and value ne 'LDP' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue&$orderby=value asc";
|
||||
|
||||
//console.log(queryUrl);
|
||||
console.log(queryUrl);
|
||||
|
||||
return axios
|
||||
.get(
|
||||
|
||||
@@ -51,7 +51,7 @@ export default async function ApiProxy(req, res) {
|
||||
searchString +
|
||||
"')) and pinswg_appealcasetype ne null " +
|
||||
(process.env.SHOWSIPS !== "true"
|
||||
? "and pinswg_appealcasetype ne 846040002"
|
||||
? "and pinswg_appealcasetype ne 846040002 "
|
||||
: "") +
|
||||
"and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "8d31911b-b8ea-ef11-ab08-00224800be9c",
|
||||
"appealTypeID": "846040002",
|
||||
"tmpNav": "pinswg_sipsid",
|
||||
"NavigationProperty": "pinswg_SIPSids",
|
||||
"NavigationProperty": "pinswg_sipscase",
|
||||
"value": "SIP",
|
||||
},
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
import { azureHeaders, consoleLogger, getToken } from "../../../actions";
|
||||
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
||||
|
||||
import { getNavigationPropertyByPrimaryAttribute } from "../../../components/utils";
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
|
||||
const WEBAPI_URL =
|
||||
@@ -55,6 +55,11 @@ export default async function ApiProxy(req, res) {
|
||||
var incidentID = req.query.incidentID;
|
||||
var token = await getToken();
|
||||
|
||||
let navigationProperty =
|
||||
getNavigationPropertyByPrimaryAttribute(
|
||||
primaryIdAttribute
|
||||
).NavigationProperty;
|
||||
|
||||
var queryUrl =
|
||||
appealTypeName +
|
||||
"?$filter=_" +
|
||||
@@ -63,7 +68,11 @@ export default async function ApiProxy(req, res) {
|
||||
: primaryIdAttribute + "s_value ") +
|
||||
" eq " +
|
||||
incidentID +
|
||||
"&$count=true";
|
||||
"&$count=true" +
|
||||
"&$expand=" +
|
||||
navigationProperty +
|
||||
"($select=ticketnumber)";
|
||||
|
||||
//" and statuscode eq 1&$count=true";
|
||||
|
||||
// queryUrl =
|
||||
@@ -91,6 +100,13 @@ export default async function ApiProxy(req, res) {
|
||||
azureHeaders(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
let flattened = data.value.map((r) => ({
|
||||
...r,
|
||||
ticketnumber: r[navigationProperty]?.ticketnumber || null,
|
||||
}));
|
||||
|
||||
data.value = flattened;
|
||||
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@@ -34,7 +34,7 @@ import CryptoJS from "crypto-js";
|
||||
import _ from "lodash";
|
||||
import { azureHeadersPaged, consoleLogger, getToken } from "../../../actions";
|
||||
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
||||
|
||||
import { getNavigationPropertyByPrimaryAttribute } from "../../../components/utils";
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
|
||||
const WEBAPI_URL =
|
||||
@@ -59,6 +59,11 @@ export default async function ApiProxy(req, res) {
|
||||
var incidentID = req.query.incidentID;
|
||||
var token = await getToken();
|
||||
|
||||
let navigationProperty =
|
||||
getNavigationPropertyByPrimaryAttribute(
|
||||
primaryIdAttribute
|
||||
).NavigationProperty;
|
||||
|
||||
var queryUrl =
|
||||
appealTypeName +
|
||||
"?$filter=_" +
|
||||
@@ -67,7 +72,11 @@ export default async function ApiProxy(req, res) {
|
||||
: primaryIdAttribute + "s_value ") +
|
||||
" eq " +
|
||||
incidentID +
|
||||
"&$count=true";
|
||||
"&$count=true" +
|
||||
"&$expand=" +
|
||||
navigationProperty +
|
||||
"($select=ticketnumber)";
|
||||
|
||||
//" and statuscode eq 1&$count=true";
|
||||
|
||||
queryUrl =
|
||||
@@ -86,10 +95,18 @@ export default async function ApiProxy(req, res) {
|
||||
azureHeadersPaged(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
let flattened = data.value.map((r) => ({
|
||||
...r,
|
||||
ticketnumber: r[navigationProperty]?.ticketnumber || null,
|
||||
}));
|
||||
|
||||
data.value = flattened;
|
||||
|
||||
var dataStr;
|
||||
_.has(data, "@odata.nextLink") == true &&
|
||||
((dataStr = JSON.stringify(data["@odata.nextLink"])),
|
||||
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
|
||||
|
||||
return res.status(200).json(data);
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@@ -85,7 +85,7 @@ export default async function ApiProxy(req, res) {
|
||||
searchString +
|
||||
"')) and pinswg_appealcasetype ne null " +
|
||||
(process.env.SHOWSIPS !== "true"
|
||||
? "and pinswg_appealcasetype ne 846040002"
|
||||
? "and pinswg_appealcasetype ne 846040002 "
|
||||
: "") +
|
||||
"and pinswg_publishtoweb eq true&$orderby=" +
|
||||
orderby +
|
||||
|
||||
@@ -48,7 +48,9 @@ export default async function ApiProxy(req, res) {
|
||||
// "&$select=pinswg_emailnotifications,modifiedon,pinswg_appealcasetype,pinswg_watchlistid,_pinswg_watchedcase_value,statuscode,pinswg_representationsubmitted,pinswg_representationtype&$count=true&$orderby=createdon desc&$expand=pinswg_WatchedCase($select=pinswg_AssociatedLPA)";
|
||||
|
||||
var queryUrl =
|
||||
"/api/endpoint/getwatchedcases_api?loggedInUserId=" + loggedInUserId;
|
||||
"pinswg_watchlists?$filter= _pinswg_contact_value eq " +
|
||||
loggedInUserId +
|
||||
"&$select=modifiedon,pinswg_appealcasetype,pinswg_watchlistid,_pinswg_watchedcase_value,statuscode,pinswg_representationsubmitted,pinswg_representationtype&$count=true&$orderby=createdon desc&$expand=pinswg_WatchedCase($select=pinswg_AssociatedLPA)";
|
||||
|
||||
return axios
|
||||
.get(
|
||||
@@ -56,32 +58,33 @@ export default async function ApiProxy(req, res) {
|
||||
azureHeaders(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
// data.value.forEach(function (element) {
|
||||
// element.ticketnumber = element.pinswg_WatchedCase?.ticketnumber;
|
||||
// element.pinswg_title =
|
||||
// element[
|
||||
// "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
// ];
|
||||
data.value.forEach(function (element) {
|
||||
element.ticketnumber = element.pinswg_WatchedCase.ticketnumber;
|
||||
element.pinswg_title =
|
||||
element[
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
];
|
||||
|
||||
// element[
|
||||
// "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
|
||||
// ] =
|
||||
// element.pinswg_WatchedCase?.[
|
||||
// "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
|
||||
// ];
|
||||
// element._pinswg_associatedlpa_value =
|
||||
// element.pinswg_WatchedCase?._pinswg_associatedlpa_value;
|
||||
// element[
|
||||
// "_ownerid_value@OData.Community.Display.V1.FormattedValue"
|
||||
// ] =
|
||||
// element.pinswg_WatchedCase?.[
|
||||
// "_ownerid_value@OData.Community.Display.V1.FormattedValue"
|
||||
// ];
|
||||
// element._ownerid_value =
|
||||
// element.pinswg_WatchedCase?._ownerid_value;
|
||||
element[
|
||||
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
|
||||
] =
|
||||
element.pinswg_WatchedCase[
|
||||
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
|
||||
];
|
||||
element._pinswg_associatedlpa_value =
|
||||
element.pinswg_WatchedCase._pinswg_associatedlpa_value;
|
||||
element[
|
||||
"_ownerid_value@OData.Community.Display.V1.FormattedValue"
|
||||
] =
|
||||
element.pinswg_WatchedCase[
|
||||
"_ownerid_value@OData.Community.Display.V1.FormattedValue"
|
||||
];
|
||||
element._ownerid_value =
|
||||
element.pinswg_WatchedCase._ownerid_value;
|
||||
|
||||
delete element.pinswg_WatchedCase;
|
||||
});
|
||||
|
||||
// delete element.pinswg_WatchedCase;
|
||||
// });
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@@ -24,10 +24,19 @@ ApiProxy.get(async (req, res) => {
|
||||
"&blobname=" +
|
||||
blobName.trim();
|
||||
|
||||
// console.log(checkquerypath);
|
||||
|
||||
// console.log(hashAPIPath(checkquerypath));
|
||||
|
||||
// console.log(req.query);
|
||||
|
||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
const bloblocation =
|
||||
casefolderID + (blobName.indexOf(".json") > 0 ? "/" : "/files/");
|
||||
|
||||
const downloaded = await downloadFile(
|
||||
containerName,
|
||||
casefolderID + "/files/" + decodeURI(blobName)
|
||||
bloblocation + decodeURI(blobName)
|
||||
);
|
||||
|
||||
res.setHeader(
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import { BlobServiceClient } from "@azure/storage-blob";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
if (req.method !== "POST") {
|
||||
res.status(405).json({ error: "Method not allowed" });
|
||||
return;
|
||||
}
|
||||
|
||||
const { container, blobName } = req.body;
|
||||
|
||||
if (!container || !blobName) {
|
||||
res.status(400).json({ error: "Missing container or blobName" });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const accountName = process.env.AZURE_STORAGE_ACCOUNT_NAME;
|
||||
const creds = new DefaultAzureCredential();
|
||||
const blobServiceClient = new BlobServiceClient(
|
||||
`https://${accountName}.blob.core.windows.net`,
|
||||
creds
|
||||
);
|
||||
|
||||
const containerClient = blobServiceClient.getContainerClient(container);
|
||||
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
||||
|
||||
// Download blob content
|
||||
const downloadResponse = await blockBlobClient.download(0);
|
||||
const downloaded = await streamToString(
|
||||
downloadResponse.readableStreamBody
|
||||
);
|
||||
|
||||
// Parse JSON
|
||||
const json = JSON.parse(downloaded);
|
||||
|
||||
// Remove repComplete element if it exists
|
||||
if ("repComplete" in json) {
|
||||
delete json.repComplete;
|
||||
}
|
||||
|
||||
const tags = {
|
||||
containerid: json.containerID,
|
||||
caseID: json.ticketnumber,
|
||||
blobType: "Representation",
|
||||
};
|
||||
|
||||
// Convert back to string
|
||||
const updatedContent = JSON.stringify(json, null, 2);
|
||||
|
||||
// Upload updated content (overwrite)
|
||||
await blockBlobClient.upload(
|
||||
updatedContent,
|
||||
Buffer.byteLength(updatedContent),
|
||||
{
|
||||
blobHTTPHeaders: { blobContentType: "application/json" },
|
||||
}
|
||||
);
|
||||
|
||||
console.log("the tags:", tags);
|
||||
const withTags = await blockBlobClient.setTags(tags);
|
||||
const withMeta = await blockBlobClient.setMetadata(tags);
|
||||
|
||||
res.status(200).json({ message: "repComplete removed successfully" });
|
||||
} catch (error) {
|
||||
console.error("Error editing rep.json:", error);
|
||||
res.status(500).json({ error: "Failed to edit rep.json" });
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to read stream to string
|
||||
async function streamToString(readableStream) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunks = [];
|
||||
readableStream.on("data", (data) => {
|
||||
chunks.push(data.toString());
|
||||
});
|
||||
readableStream.on("end", () => {
|
||||
resolve(chunks.join(""));
|
||||
});
|
||||
readableStream.on("error", reject);
|
||||
});
|
||||
}
|
||||
@@ -166,7 +166,7 @@ export default async function handler(req, res) {
|
||||
|
||||
var containerID = reqBodyobj.containerID;
|
||||
var casefolderID = reqBodyobj.casefolderID;
|
||||
var caseRef = reqBodyobj.caseRef;
|
||||
var caseRef = reqBodyobj.ticketnumber;
|
||||
var representationType = reqBodyobj.representationType;
|
||||
var repRaiser = reqBodyobj.lastname;
|
||||
var localeSelect = reqBodyobj.locale;
|
||||
|
||||
Reference in New Issue
Block a user