Skip to content

Commit

Permalink
fix clicking ids/sps from the list pie chart
Browse files Browse the repository at this point in the history
  • Loading branch information
lionick committed Sep 2, 2024
1 parent 48f1191 commit 0638628
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
13 changes: 7 additions & 6 deletions javascript/src/components/Dashboard/loginIdpPieChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {getLoginsPerIdp} from "../../utils/queries";
import {optionsPieChart} from "../../utils/helpers/enums";
import {convertDateByGroup, formatStartDate, formatEndDate} from "../Common/utils";

var idpsArray = [];

const LoginIdpPieChart = ({
spId,
tenenvId,
Expand All @@ -28,8 +28,9 @@ const LoginIdpPieChart = ({
formatEndDate(today)

let idpsChartArray = [["Identity Provider", "Logins"]];
let idpsArray = [];
const [idps, setIdps] = useState(idpsChartArray);

const [idpsAr, setIdpsArray] = useState(idpsArray);
const params = {
params: {
'tenenv_id': tenenvId,
Expand Down Expand Up @@ -57,6 +58,7 @@ const LoginIdpPieChart = ({
idpsArray.push([element.id, element.name, element.identifier])
})
setIdps(idpsChartArray)
setIdpsArray(idpsArray)
})

}, [uniqueLogins])
Expand Down Expand Up @@ -90,10 +92,9 @@ const LoginIdpPieChart = ({
callback: ({chartWrapper, google}) => {
const chart = chartWrapper.getChart();

if (cookies.userinfo != undefined
&& !!permissions?.actions?.identity_providers?.['view']) {

google.visualization.events.addListener(chart, 'click', selectHandler);
}


google.visualization.events.addListener(chart, 'onmouseover', showTooltip);
google.visualization.events.addListener(chart, 'onmouseout', hideTooltip);
Expand All @@ -114,7 +115,7 @@ const LoginIdpPieChart = ({

var selection = chart.getSelection();
if (selection.length) {
var identifier = idpsArray[selection[0].row];
var identifier = idpsAr[selection[0].row];
goToSpecificProviderHandler(identifier[0])
}
}
Expand Down
11 changes: 6 additions & 5 deletions javascript/src/components/Dashboard/loginSpPieChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {useQuery} from "react-query";
import {optionsPieChart} from "../../utils/helpers/enums";
import {convertDateByGroup, formatStartDate, formatEndDate} from "../Common/utils";

var spsArray = [];

const LoginSpPieChart = ({
idpId,
Expand All @@ -21,7 +20,9 @@ const LoginSpPieChart = ({
goToSpecificProviderHandler
}) => {
let spsChartArray = [["Service Provider", "Logins"]];
let spsArray = [];
const [sps, setSps] = useState(spsChartArray);
const [spsAr, setSpsArray] = useState(spsArray);
const oneYearAgo = new Date();
oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1);
formatStartDate(oneYearAgo)
Expand Down Expand Up @@ -59,6 +60,7 @@ const LoginSpPieChart = ({
spsArray.push([element.id, element.name, element.identifier])
})
setSps(spsChartArray)
setSpsArray(spsArray)
})
}, [uniqueLogins])

Expand Down Expand Up @@ -91,10 +93,9 @@ const LoginSpPieChart = ({
callback: ({chartWrapper, google}) => {
const chart = chartWrapper.getChart();

if (cookies.userinfo != undefined
&& !!permissions?.actions?.service_providers?.['view']) {

google.visualization.events.addListener(chart, 'click', selectHandler);
}

google.visualization.events.addListener(chart, 'onmouseover', showTooltip);
google.visualization.events.addListener(chart, 'onmouseout', hideTooltip);

Expand All @@ -112,7 +113,7 @@ const LoginSpPieChart = ({
function selectHandler() {
var selection = chart.getSelection();
if (selection.length) {
var identifier = spsArray[selection[0].row];
var identifier = spsAr[selection[0].row];
goToSpecificProviderHandler(identifier[0], "sp")
}
}
Expand Down

0 comments on commit 0638628

Please sign in to comment.