From 6df4542ba917cc986ba55718cdeec10adae41d3b Mon Sep 17 00:00:00 2001 From: jacovinus Date: Fri, 15 Dec 2023 13:02:18 +0100 Subject: [PATCH 1/3] fix: menu blocking ui --- .../main/plugins/settingsmenu/MainMenu.tsx | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/main/plugins/settingsmenu/MainMenu.tsx b/packages/main/plugins/settingsmenu/MainMenu.tsx index fe9ea108..a7a872d7 100644 --- a/packages/main/plugins/settingsmenu/MainMenu.tsx +++ b/packages/main/plugins/settingsmenu/MainMenu.tsx @@ -39,7 +39,7 @@ export const ButtonMenuStyles = (theme: QrynTheme) => ({ }); export default function MainMenu() { - const {key} = useLocation() + const { key } = useLocation(); const showDs = useSelector((store: any) => store.showDataSourceSetting); const currentUserRole = useSelector((store: any) => store.currentUser.role); const dispatch: any = useDispatch(); @@ -52,17 +52,19 @@ export default function MainMenu() { setUserType(currentUserRole); }, [currentUserRole]); - useEffect(()=>{ - handleClose() - - },[key]) + useEffect(() => { + handleClose(); + }, [key]); const handleClick = (event: React.MouseEvent) => { + event.stopPropagation(); + event.preventDefault(); setAnchorEl(() => event.currentTarget); }; - const handleClose = () => { - + const handleClose = (event?: any) => { + event?.stopPropagation(); + event?.preventDefault(); setAnchorEl(() => undefined); }; @@ -97,7 +99,7 @@ export default function MainMenu() { anchorEl={anchorEl} open={open} onClose={handleClose} - onClick={handleClose} + onClick={handleClick} PaperProps={{ elevation: 0, sx: MenuStyles(theme), @@ -114,21 +116,21 @@ export default function MainMenu() { - + Search - + Plugins - + Users @@ -137,7 +139,7 @@ export default function MainMenu() { {showDs && (userType === "admin" || userType === "superAdmin") && ( - + Datasources From f4d17c9ac8acb46df07ee393c5917fe0ce32def5 Mon Sep 17 00:00:00 2001 From: jacovinus Date: Fri, 15 Dec 2023 16:58:16 +0100 Subject: [PATCH 2/3] fix: error with label values at Cardinality --- packages/main/plugins/Cardinality/helpers.tsx | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/main/plugins/Cardinality/helpers.tsx b/packages/main/plugins/Cardinality/helpers.tsx index f67787cc..4dd30663 100644 --- a/packages/main/plugins/Cardinality/helpers.tsx +++ b/packages/main/plugins/Cardinality/helpers.tsx @@ -18,6 +18,9 @@ export const getValuesArrayToString = (values: string[]): string => { return values?.map((value) => `\"${value}\"`).join(","); }; +const labelsFreq = (arr: string[]) => + arr.reduce((cnt, cur) => ((cnt[cur] = cnt[cur] + 1 || 1), cnt), {}); + /** * * @param labelsArray @@ -31,7 +34,26 @@ const getSeriesArraySelector = (labelsArray: string[]): string => { let LabelsString = "{"; let labelslength = labelsArray.length; + + let lsarray = []; + // generate labels array splitting by equals or non equals + for (let i = 0; i < labelslength; i++) { + const [label] = labelsArray[i].split(/(=|!=)/); + lsarray.push(label); + } + // check for frequency of same label + const labelsFrequency = labelsFreq(lsarray); + for (let i = 0; i < labelslength; i++) { + let currentLabel = lsarray[i]; + // check if non equals label is hit and another one in the room is present + if ( + labelsArray[i].includes("!=") && + labelsFrequency[currentLabel] > 1 + ) { + continue; + } + const [lb, val] = labelsArray[i].split("="); LabelsString += `${lb}=\"${val}\"`; @@ -60,7 +82,10 @@ export const queryUpdater: QueryUpdater = { return getSeriesSelector("__name__", query); }, seriesCountByLabelName: ({ query }): string => { - return `{${query}!=""}`; + const queryStr = `{${query}!=""}`; + localStorage.setItem("labelValuePairs", `${query}!=`); + + return queryStr; }, seriesCountByFocusLabelValue: ({ query, focusLabel }): string => { return getSeriesSelector(focusLabel, query); @@ -229,7 +254,7 @@ export const useDataSourceData = (type: string) => { const isAuth = authData.basicAuth.value; - let user_pass= {u: '', p:''} + let user_pass = { u: "", p: "" }; if (isAuth) { let [user, password] = authData.fields.basicAuth; From 5b5f74091e1d4659735c646d0d5ce90ff552bfda Mon Sep 17 00:00:00 2001 From: jacovinus Date: Fri, 15 Dec 2023 17:16:00 +0100 Subject: [PATCH 3/3] fix: buttons contrast --- .../main/plugins/Cardinality/ConfigContainerStyles.tsx | 2 +- packages/main/plugins/Cardinality/DayPicker.tsx | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/main/plugins/Cardinality/ConfigContainerStyles.tsx b/packages/main/plugins/Cardinality/ConfigContainerStyles.tsx index 322f703f..b427a778 100644 --- a/packages/main/plugins/Cardinality/ConfigContainerStyles.tsx +++ b/packages/main/plugins/Cardinality/ConfigContainerStyles.tsx @@ -72,7 +72,7 @@ export const ConfigContainerStyles = (theme: any) => css` height: 30px; transition: 0.35s all; background: ${theme.primaryAccent}; - color: ${theme.contrast}; + color: ${theme.maxContrast}; padding: 4px 6px; border-radius: 3px; border: 1px solid ${theme.primary}; diff --git a/packages/main/plugins/Cardinality/DayPicker.tsx b/packages/main/plugins/Cardinality/DayPicker.tsx index 5d1f1f52..10b09a07 100644 --- a/packages/main/plugins/Cardinality/DayPicker.tsx +++ b/packages/main/plugins/Cardinality/DayPicker.tsx @@ -61,20 +61,20 @@ export const MenuStyles = (theme: any) => ({ "& .icon": { fontSize: "16px", marginRight: "4px", - color: `${theme.contrast}`, + color: `${theme.maxContrast}`, }, "& .item": { fontSize: "12px", - color: `${theme.contrast}`, + color: `${theme.maxContrast}`, }, ".rdp-day_selected, .rdp-day_selected:focus-visible, .rdp-day_selected:hover": { background: `${theme.primary}`, - color: `${theme.contrast}`, + color: `${theme.maxContrast}`, }, "& .rdp-day_selected : hover": { background: `${theme.primary}`, - color: `${theme.contrast}`, + color: `${theme.maxContrast}`, }, }); @@ -139,7 +139,7 @@ export default function PickerMenu() { size="small" sx={{ ml: 2, - color: `${theme.contrast}`, + color: `${theme.maxContrast}`, background: `${theme.primaryAccent}`, "&.MuiIconButton-root": { border: `1px solid ${theme.primary}`,