Adding helper for auth key resolution
This commit is contained in:
parent
902189c34d
commit
e4f4766f5f
@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
|
import { getAuthKeyFromProperties } from '../helpers/index'
|
||||||
|
|
||||||
import * as d3 from "d3";
|
import * as d3 from "d3";
|
||||||
import * as align from "d3-sankey";
|
import * as align from "d3-sankey";
|
||||||
@ -34,41 +35,35 @@ function fetchData() {
|
|||||||
//clear errors
|
//clear errors
|
||||||
errorMessage.value = null;
|
errorMessage.value = null;
|
||||||
|
|
||||||
var authKey;
|
try {
|
||||||
|
var authKey = getAuthKeyFromProperties(props);
|
||||||
if (props.sessionIdentifier.length > 0) {
|
} catch (error) {
|
||||||
authKey = props.sessionIdentifier;
|
console.error(error);
|
||||||
} else if (props.username.length > 0) {
|
errorMessage.value = error;
|
||||||
authKey = props.username;
|
return;
|
||||||
} else {
|
|
||||||
errorMessage.value =
|
|
||||||
"_sessionIdentifier or username must be passed as query params.";
|
|
||||||
}
|
}
|
||||||
if (authKey) {
|
fetch(
|
||||||
fetch(
|
`${import.meta.env.VITE_EO_SERVICES_URL}/api/interactions-flow?filter=${multiSelected.value
|
||||||
`${import.meta.env.VITE_EO_SERVICES_URL}/api/interactions-flow?filter=${
|
}&authKey=${authKey}`,
|
||||||
multiSelected.value
|
{
|
||||||
}&authKey=${authKey}`,
|
credentials: "include", // fetch won't send cookies unless you set credentials
|
||||||
{
|
}
|
||||||
credentials: "include", // fetch won't send cookies unless you set credentials
|
)
|
||||||
|
.then((response) => {
|
||||||
|
// check for error response
|
||||||
|
if (!response.ok) {
|
||||||
|
// get error message from body or default to response statusText
|
||||||
|
const error = response.data || response.statusText;
|
||||||
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
)
|
response.json().then((data) => {
|
||||||
.then((response) => {
|
generateSankey(data);
|
||||||
// check for error response
|
|
||||||
if (!response.ok) {
|
|
||||||
// get error message from body or default to response statusText
|
|
||||||
const error = response.data || response.statusText;
|
|
||||||
return Promise.reject(error);
|
|
||||||
}
|
|
||||||
response.json().then((data) => {
|
|
||||||
generateSankey(data);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.log(error);
|
|
||||||
errorMessage.value = error;
|
|
||||||
});
|
});
|
||||||
}
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
errorMessage.value = error;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateSankey(data) {
|
function generateSankey(data) {
|
||||||
@ -104,9 +99,9 @@ function generateSankey(data) {
|
|||||||
.nodeId((d) => d.name)
|
.nodeId((d) => d.name)
|
||||||
.nodeAlign(
|
.nodeAlign(
|
||||||
align[
|
align[
|
||||||
`sankey${alignSelected.value[0].toUpperCase()}${alignSelected.value.slice(
|
`sankey${alignSelected.value[0].toUpperCase()}${alignSelected.value.slice(
|
||||||
1
|
1
|
||||||
)}`
|
)}`
|
||||||
]
|
]
|
||||||
) // d3.sankeyLeft, etc.
|
) // d3.sankeyLeft, etc.
|
||||||
.nodeWidth(15)
|
.nodeWidth(15)
|
||||||
@ -178,10 +173,10 @@ function generateSankey(data) {
|
|||||||
linkColor === "source-target"
|
linkColor === "source-target"
|
||||||
? (d) => `url(#${d.uid})`
|
? (d) => `url(#${d.uid})`
|
||||||
: linkColor === "source"
|
: linkColor === "source"
|
||||||
? (d) => color(d.source.category)
|
? (d) => color(d.source.category)
|
||||||
: linkColor === "target"
|
: linkColor === "target"
|
||||||
? (d) => color(d.target.category)
|
? (d) => color(d.target.category)
|
||||||
: linkColor
|
: linkColor
|
||||||
)
|
)
|
||||||
.attr("stroke-width", (d) => Math.max(1, d.width));
|
.attr("stroke-width", (d) => Math.max(1, d.width));
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
import { getAuthKeyFromProperties } from '../helpers/index'
|
||||||
|
|
||||||
import ContactTable from "../components/ContactTable.vue";
|
import ContactTable from "../components/ContactTable.vue";
|
||||||
import ContactsSummary from "../components/ContactsSummary.vue";
|
import ContactsSummary from "../components/ContactsSummary.vue";
|
||||||
@ -23,16 +24,8 @@ function fetchData() {
|
|||||||
errorMessage.value = null;
|
errorMessage.value = null;
|
||||||
contactData.value = null;
|
contactData.value = null;
|
||||||
|
|
||||||
var authKey;
|
var authKey = getAuthKeyFromProperties(props);
|
||||||
|
|
||||||
if (props.sessionIdentifier.length > 0) {
|
|
||||||
authKey = props.sessionIdentifier;
|
|
||||||
} else if (props.username.length > 0) {
|
|
||||||
authKey = props.username;
|
|
||||||
} else {
|
|
||||||
errorMessage.value =
|
|
||||||
"_sessionIdentifier or username must be passed as query params.";
|
|
||||||
}
|
|
||||||
if (authKey) {
|
if (authKey) {
|
||||||
fetch(
|
fetch(
|
||||||
`${
|
`${
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user