Merged PR 461: updated token call for debug
updated token call for debug Related work items: #6209
This commit is contained in:
+48
-28
@@ -4,7 +4,7 @@ import CryptoJS from "crypto-js";
|
||||
|
||||
//import {XMLHttpRequest} from 'xmlhttprequest';
|
||||
|
||||
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
||||
//process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
||||
|
||||
let BASE_URL;
|
||||
const port = parseInt(process.env.PORT, 10) || 3000;
|
||||
@@ -39,14 +39,6 @@ export const getSASToken = () => {
|
||||
"https://" + m_ResourceURI + "/" + m_Path + "/"
|
||||
);
|
||||
|
||||
console.log("///////////////////////");
|
||||
console.log("WEBAPI_URL: " + WEBAPI_URL);
|
||||
console.log("m_ResourceURI: " + m_ResourceURI);
|
||||
console.log("m_Path: " + m_Path);
|
||||
console.log("m_SasKey: " + m_SasKey);
|
||||
console.log("m_SasKeyName: " + m_SasKeyName);
|
||||
console.log("///////////////////////");
|
||||
|
||||
var t0 = new Date(1970, 1, 1, 0, 0, 0, 0);
|
||||
var t1 = new Date();
|
||||
var expireInSeconds =
|
||||
@@ -71,6 +63,14 @@ export const getSASToken = () => {
|
||||
m_SasKeyName;
|
||||
|
||||
console.log("///////////////////////");
|
||||
console.log(
|
||||
"encodedURI:" + "https://" + m_ResourceURI + "/" + m_Path + "/"
|
||||
);
|
||||
console.log("WEBAPI_URL: " + WEBAPI_URL);
|
||||
console.log("m_ResourceURI: " + m_ResourceURI);
|
||||
console.log("m_Path: " + m_Path);
|
||||
console.log("m_SasKey: " + m_SasKey);
|
||||
console.log("m_SasKeyName: " + m_SasKeyName);
|
||||
console.log("token: " + token);
|
||||
console.log("///////////////////////");
|
||||
return token;
|
||||
@@ -79,7 +79,7 @@ export const getSASToken = () => {
|
||||
const accessToken =
|
||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IlVXelVaa0U3OEx0NVBGRkJ0LV9seVdoMjdjTSIsImtpZCI6IlVX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";
|
||||
|
||||
const SASToken = getSASToken();
|
||||
//const SASToken = getSASToken();
|
||||
|
||||
const crmHeaders = {
|
||||
withCredentials: true,
|
||||
@@ -104,15 +104,27 @@ const crmHeadersReturn = {
|
||||
},
|
||||
};
|
||||
|
||||
const azureHeaders = {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"ServiceBusAuthorization": SASToken,
|
||||
},
|
||||
const azureHeaders = (SASToken) => {
|
||||
console.log({
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"ServiceBusAuthorization": SASToken,
|
||||
},
|
||||
});
|
||||
return {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"ServiceBusAuthorization": SASToken,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
// const azureHeaders = {
|
||||
@@ -126,27 +138,35 @@ const azureHeaders = {
|
||||
// },
|
||||
// };
|
||||
|
||||
export const getBasicSearch = (searchString) => {
|
||||
export const getBasicSearch = (token, searchString) => {
|
||||
console.log("\n\n", token, searchString);
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL +
|
||||
"incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" +
|
||||
searchString +
|
||||
"') and pinswg_appealcasetype ne null &$count=true",
|
||||
azureHeaders
|
||||
azureHeaders(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.then((res) => {
|
||||
console.log(" ");
|
||||
console.log("/////////////////////");
|
||||
console.log("data:" + res.data.value);
|
||||
console.log("/////////////////////");
|
||||
console.log(" ");
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("thiserror", error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getBasicDNSSearch = (searchString) => {
|
||||
export const getBasicDNSSearch = (token, searchString) => {
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL +
|
||||
"incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011&$count=true",
|
||||
azureHeaders
|
||||
azureHeaders(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
@@ -200,7 +220,7 @@ export const getAdvancedSearch = (searchString) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getBasicSearchDetails = (appealType, caseReference) => {
|
||||
export const getBasicSearchDetails = (token, appealType, caseReference) => {
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL +
|
||||
@@ -208,7 +228,7 @@ export const getBasicSearchDetails = (appealType, caseReference) => {
|
||||
"?$filter=pinswg_name eq '" +
|
||||
caseReference +
|
||||
"'&$count=true",
|
||||
azureHeaders
|
||||
azureHeaders(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
@@ -216,14 +236,14 @@ export const getBasicSearchDetails = (appealType, caseReference) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getBasicDNSSearchDetails = (appealType, caseReference) => {
|
||||
export const getBasicDNSSearchDetails = (token, appealType, caseReference) => {
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL +
|
||||
"pinswg_dnses?$filter=pinswg_name eq '" +
|
||||
caseReference +
|
||||
"'&$count=true",
|
||||
azureHeaders
|
||||
azureHeaders(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
|
||||
@@ -22,7 +22,11 @@ import {
|
||||
setSearchDetails,
|
||||
getSearchResultsObj,
|
||||
} from "../store/searchOutput/action";
|
||||
import { getBasicDNSSearch, getBasicSearchDetails } from "../actions";
|
||||
import {
|
||||
getBasicDNSSearch,
|
||||
getBasicSearchDetails,
|
||||
getSASToken,
|
||||
} from "../actions";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
@@ -61,10 +65,15 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
async ({ query, req, res }) => {
|
||||
console.log("query-", query);
|
||||
|
||||
const searchResultsObj = await getBasicDNSSearch();
|
||||
const token = await getSASToken();
|
||||
|
||||
const searchResultsObj = await getBasicDNSSearch(token);
|
||||
//console.log(searchResultsObj);
|
||||
|
||||
const searchDetailsObj = await getSearchDetails(searchResultsObj);
|
||||
const searchDetailsObj = await getSearchDetails(
|
||||
token,
|
||||
searchResultsObj
|
||||
);
|
||||
//console.log(searchDetailsObj);
|
||||
store.dispatch(setSearchResults(searchResultsObj));
|
||||
store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
@@ -81,7 +90,7 @@ const getFormCollection = (formtype) => {
|
||||
return collectionName[0];
|
||||
};
|
||||
|
||||
const getSearchDetails = (searchResultsObj) => {
|
||||
const getSearchDetails = (token, searchResultsObj) => {
|
||||
//console.log(searchResultsObj);
|
||||
|
||||
let detailsArr = [];
|
||||
@@ -92,6 +101,7 @@ const getSearchDetails = (searchResultsObj) => {
|
||||
} else {
|
||||
detailsArr.push(
|
||||
getBasicSearchDetails(
|
||||
token,
|
||||
getFormCollection(
|
||||
"pinswg_" +
|
||||
searchDetail[
|
||||
|
||||
+16
-11
@@ -22,7 +22,7 @@ import {
|
||||
setSearchDetails,
|
||||
getSearchResultsObj,
|
||||
} from "../store/searchOutput/action";
|
||||
import { getBasicSearch, getBasicSearchDetails } from "../actions";
|
||||
import { getBasicSearch, getBasicSearchDetails, getSASToken } from "../actions";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
@@ -60,14 +60,18 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) =>
|
||||
async ({ query, req, res }) => {
|
||||
console.log("query-", query);
|
||||
// const [searchResultsObj, searchDetailsObj] = await Promise.all(
|
||||
// await getBasicSearch(query.q),
|
||||
// await getBasicSearchDetails(query.d)
|
||||
// );
|
||||
|
||||
const searchResultsObj = await getBasicSearch(query.q);
|
||||
const searchDetailsObj = await getSearchDetails(searchResultsObj);
|
||||
// console.log(searchDetailsObj);
|
||||
const token = await getSASToken();
|
||||
|
||||
const searchResultsObj = await getBasicSearch(token, query.q);
|
||||
|
||||
console.log("sssss", searchResultsObj);
|
||||
|
||||
const searchDetailsObj = await getSearchDetails(
|
||||
token,
|
||||
searchResultsObj
|
||||
);
|
||||
console.log(searchDetailsObj);
|
||||
store.dispatch(setSearchResults(searchResultsObj));
|
||||
store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
store.dispatch(setSearch(query.q));
|
||||
@@ -83,11 +87,11 @@ const getFormCollection = (formtype) => {
|
||||
return collectionName[0];
|
||||
};
|
||||
|
||||
const getSearchDetails = (searchResultsObj) => {
|
||||
//console.log(searchResultsObj);
|
||||
const getSearchDetails = (token, searchResultsObj) => {
|
||||
console.log(searchResultsObj);
|
||||
|
||||
let detailsArr = [];
|
||||
console.log("searcg results", searchResultsObj);
|
||||
console.log("search results", searchResultsObj);
|
||||
searchResultsObj = searchResultsObj.value;
|
||||
const detailsObj = searchResultsObj.map((searchDetail, index) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
@@ -95,6 +99,7 @@ const getSearchDetails = (searchResultsObj) => {
|
||||
} else {
|
||||
detailsArr.push(
|
||||
getBasicSearchDetails(
|
||||
token,
|
||||
getFormCollection(
|
||||
"pinswg_" +
|
||||
searchDetail[
|
||||
|
||||
Reference in New Issue
Block a user