@centreon/ui 24.5.1 → 24.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -7
- package/public/mockServiceWorker.js +100 -81
- package/src/ActionsList/index.stories.tsx +1 -7
- package/src/Dashboard/Dashboard.styles.ts +2 -3
- package/src/Dashboard/Item.tsx +2 -11
- package/src/Dashboard/Layout.tsx +2 -4
- package/src/Graph/Tree/DescendantNodes.tsx +0 -1
- package/src/Graph/Tree/Links.tsx +2 -15
- package/src/Graph/Tree/Tree.cypress.spec.tsx +0 -24
- package/src/Graph/Tree/Tree.stories.tsx +1 -17
- package/src/Graph/Tree/models.ts +0 -3
- package/src/TopCounterElements/TopCounterLayout.tsx +4 -3
- package/src/TopCounterElements/useCloseOnLegacyPage.tsx +6 -9
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/useFetchQuery/index.test.ts +5 -0
- package/src/api/useFetchQuery/index.ts +5 -2
- package/src/api/useGraphQuery/index.ts +1 -7
- package/src/api/useMutationQuery/index.ts +5 -2
- package/src/api/useRequest/index.test.ts +3 -0
- package/src/api/useRequest/index.ts +6 -3
- package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +13 -27
- package/src/components/Form/AccessRights/AccessRights.stories.tsx +19 -0
- package/src/components/Form/AccessRights/AccessRights.styles.ts +1 -1
- package/src/components/Form/AccessRights/AccessRights.tsx +5 -6
- package/src/components/Form/AccessRights/Actions/Actions.styles.ts +7 -3
- package/src/components/Form/AccessRights/Actions/Actions.tsx +32 -15
- package/src/components/Form/AccessRights/Actions/useActions.ts +37 -4
- package/src/components/Form/AccessRights/models.ts +3 -0
- package/src/components/Form/AccessRights/storiesData.ts +3 -0
- package/src/components/List/Item/ListItem.styles.ts +2 -2
- package/src/components/Zoom/Minimap.tsx +2 -4
- package/src/components/Zoom/Zoom.cypress.spec.tsx +13 -13
- package/src/components/Zoom/Zoom.tsx +1 -4
- package/src/components/Zoom/ZoomContent.tsx +2 -5
- package/src/components/index.ts +0 -1
- package/src/index.ts +1 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/usePluralizedTranslation.ts +3 -20
- package/src/api/logger.ts +0 -11
- package/src/components/Form/AccessRights/useAccessRightsChange.ts +0 -30
- package/src/components/Form/AccessRights/utils.ts +0 -18
- package/src/components/Tabs/Tab.styles.ts +0 -25
- package/src/components/Tabs/TabPanel.tsx +0 -22
- package/src/components/Tabs/Tabs.cypress.spec.tsx +0 -70
- package/src/components/Tabs/Tabs.stories.tsx +0 -55
- package/src/components/Tabs/Tabs.tsx +0 -55
- package/src/components/Tabs/index.ts +0 -6
- package/src/utils/resourcesStatusURL.ts +0 -166
- package/src/utils/usePluralizedTranslation.test.ts +0 -159
|
@@ -7,7 +7,6 @@ import { MinimapPosition } from './models';
|
|
|
7
7
|
|
|
8
8
|
export interface ZoomProps {
|
|
9
9
|
children: JSX.Element | (({ width, height }) => JSX.Element);
|
|
10
|
-
id?: number | string;
|
|
11
10
|
minimapPosition?: MinimapPosition;
|
|
12
11
|
scaleMax?: number;
|
|
13
12
|
scaleMin?: number;
|
|
@@ -28,8 +27,7 @@ const Zoom = ({
|
|
|
28
27
|
scaleMin = 0.5,
|
|
29
28
|
scaleMax = 4,
|
|
30
29
|
showMinimap = false,
|
|
31
|
-
minimapPosition = 'top-left'
|
|
32
|
-
id = 0
|
|
30
|
+
minimapPosition = 'top-left'
|
|
33
31
|
}: ZoomProps): JSX.Element => {
|
|
34
32
|
return (
|
|
35
33
|
<ParentSize>
|
|
@@ -46,7 +44,6 @@ const Zoom = ({
|
|
|
46
44
|
{(zoom) => (
|
|
47
45
|
<ZoomContent
|
|
48
46
|
height={height}
|
|
49
|
-
id={id}
|
|
50
47
|
minimapPosition={minimapPosition}
|
|
51
48
|
showMinimap={showMinimap}
|
|
52
49
|
width={width}
|
|
@@ -18,7 +18,6 @@ import { ChildrenProps, MinimapPosition, ZoomState } from './models';
|
|
|
18
18
|
export interface Props {
|
|
19
19
|
children: ({ width, height, transformMatrix }: ChildrenProps) => JSX.Element;
|
|
20
20
|
height: number;
|
|
21
|
-
id?: number | string;
|
|
22
21
|
minimapPosition: MinimapPosition;
|
|
23
22
|
showMinimap?: boolean;
|
|
24
23
|
width: number;
|
|
@@ -31,8 +30,7 @@ const ZoomContent = ({
|
|
|
31
30
|
height,
|
|
32
31
|
children,
|
|
33
32
|
showMinimap,
|
|
34
|
-
minimapPosition
|
|
35
|
-
id
|
|
33
|
+
minimapPosition
|
|
36
34
|
}: Props): JSX.Element => {
|
|
37
35
|
const { classes } = useZoomStyles();
|
|
38
36
|
const contentRef = useRef<SVGGElement | null>(null);
|
|
@@ -94,7 +92,7 @@ const ZoomContent = ({
|
|
|
94
92
|
>
|
|
95
93
|
<RectClipPath
|
|
96
94
|
height={Math.max(contentClientRect?.height || 0, height)}
|
|
97
|
-
id=
|
|
95
|
+
id="zoom-clip"
|
|
98
96
|
rx={radius}
|
|
99
97
|
width={Math.max(contentClientRect?.width || 0, width)}
|
|
100
98
|
/>
|
|
@@ -126,7 +124,6 @@ const ZoomContent = ({
|
|
|
126
124
|
diffBetweenContentAndSvg || { left: 0, top: 0 }
|
|
127
125
|
}
|
|
128
126
|
height={height}
|
|
129
|
-
id={id}
|
|
130
127
|
isDraggingFromContainer={isDragging}
|
|
131
128
|
width={width}
|
|
132
129
|
zoom={zoom}
|
package/src/components/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -131,7 +131,7 @@ export {
|
|
|
131
131
|
default as useGraphQuery,
|
|
132
132
|
resourceTypeQueryParameter
|
|
133
133
|
} from './api/useGraphQuery';
|
|
134
|
-
export { default as QueryProvider
|
|
134
|
+
export { default as QueryProvider } from './api/QueryProvider';
|
|
135
135
|
export {
|
|
136
136
|
default as FileDropZone,
|
|
137
137
|
transformFileListToArray
|
package/src/utils/index.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
|
|
3
1
|
import { useTranslation } from 'react-i18next';
|
|
4
2
|
import pluralize from 'pluralize';
|
|
5
|
-
import { useAtomValue } from 'jotai';
|
|
6
|
-
import { equals, includes } from 'ramda';
|
|
7
|
-
|
|
8
|
-
import { userAtom } from '@centreon/ui-context';
|
|
9
3
|
|
|
10
4
|
interface TProps {
|
|
11
5
|
count: number;
|
|
@@ -16,21 +10,10 @@ export const usePluralizedTranslation = (): {
|
|
|
16
10
|
pluralizedT: (props: TProps) => string;
|
|
17
11
|
} => {
|
|
18
12
|
const translation = useTranslation();
|
|
19
|
-
const { locale } = useAtomValue(userAtom);
|
|
20
|
-
|
|
21
|
-
const isNotPartitiveLocale = includes('fr', locale);
|
|
22
13
|
|
|
23
|
-
const pluralizedT =
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return pluralize(
|
|
28
|
-
translation.t(label),
|
|
29
|
-
isZero && isNotPartitiveLocale ? 1 : count
|
|
30
|
-
);
|
|
31
|
-
},
|
|
32
|
-
[isNotPartitiveLocale]
|
|
33
|
-
);
|
|
14
|
+
const pluralizedT = ({ label, count }: TProps): string => {
|
|
15
|
+
return pluralize(translation.t(label), count);
|
|
16
|
+
};
|
|
34
17
|
|
|
35
18
|
return {
|
|
36
19
|
pluralizedT
|
package/src/api/logger.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useAtomValue } from 'jotai';
|
|
4
|
-
|
|
5
|
-
import { useDeepCompare } from '../../../utils';
|
|
6
|
-
|
|
7
|
-
import { valuesAtom } from './atoms';
|
|
8
|
-
import { formatValueForSubmition } from './utils';
|
|
9
|
-
import { AccessRightInitialValues } from './models';
|
|
10
|
-
|
|
11
|
-
export const useAccessRightsChange = (
|
|
12
|
-
onChange?: (values: Array<AccessRightInitialValues>) => void
|
|
13
|
-
): void => {
|
|
14
|
-
const values = useAtomValue(valuesAtom);
|
|
15
|
-
|
|
16
|
-
useEffect(
|
|
17
|
-
() => {
|
|
18
|
-
if (!onChange) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
onChange(
|
|
23
|
-
values
|
|
24
|
-
.filter(({ isRemoved }) => !isRemoved)
|
|
25
|
-
.map(formatValueForSubmition)
|
|
26
|
-
);
|
|
27
|
-
},
|
|
28
|
-
useDeepCompare([values])
|
|
29
|
-
);
|
|
30
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { omit } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import { AccessRight, AccessRightInitialValues } from './models';
|
|
4
|
-
|
|
5
|
-
export const formatValue = (
|
|
6
|
-
accessRight: AccessRight
|
|
7
|
-
): AccessRightInitialValues => {
|
|
8
|
-
return omit(['isAdded', 'isUpdated', 'isRemoved'], accessRight);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const formatValueForSubmition = (
|
|
12
|
-
accessRight: AccessRight
|
|
13
|
-
): AccessRightInitialValues => {
|
|
14
|
-
return {
|
|
15
|
-
...formatValue(accessRight),
|
|
16
|
-
id: Number((accessRight.id as string).split('_')[1])
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from 'tss-react/mui';
|
|
2
|
-
|
|
3
|
-
export const useTabsStyles = makeStyles()((theme) => ({
|
|
4
|
-
indicator: {
|
|
5
|
-
bottom: 'unset'
|
|
6
|
-
},
|
|
7
|
-
tab: {
|
|
8
|
-
'&[aria-selected="true"]': {
|
|
9
|
-
color: theme.palette.text.primary,
|
|
10
|
-
fontWeight: theme.typography.fontWeightBold
|
|
11
|
-
},
|
|
12
|
-
color: theme.palette.text.primary,
|
|
13
|
-
fontWeight: theme.typography.fontWeightRegular,
|
|
14
|
-
marginRight: theme.spacing(2),
|
|
15
|
-
minHeight: 0,
|
|
16
|
-
minWidth: 0,
|
|
17
|
-
padding: theme.spacing(0.5, 0)
|
|
18
|
-
},
|
|
19
|
-
tabPanel: {
|
|
20
|
-
padding: theme.spacing(1, 0, 0)
|
|
21
|
-
},
|
|
22
|
-
tabs: {
|
|
23
|
-
minHeight: theme.spacing(4.5)
|
|
24
|
-
}
|
|
25
|
-
}));
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { TabPanel as MuiTabPanel } from '@mui/lab';
|
|
2
|
-
|
|
3
|
-
import { useTabsStyles } from './Tab.styles';
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
children: JSX.Element;
|
|
7
|
-
value: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const TabPanel = ({ children, value }: Props): JSX.Element => {
|
|
11
|
-
const { classes } = useTabsStyles();
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<MuiTabPanel
|
|
15
|
-
className={classes.tabPanel}
|
|
16
|
-
data-tabPanel={value}
|
|
17
|
-
value={value}
|
|
18
|
-
>
|
|
19
|
-
{children}
|
|
20
|
-
</MuiTabPanel>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Typography } from '@mui/material';
|
|
2
|
-
|
|
3
|
-
import { TabPanel } from './TabPanel';
|
|
4
|
-
|
|
5
|
-
import { Tabs } from '.';
|
|
6
|
-
|
|
7
|
-
const initialize = (withTabListProps = false): void => {
|
|
8
|
-
cy.mount({
|
|
9
|
-
Component: (
|
|
10
|
-
<Tabs
|
|
11
|
-
defaultTab="tab 0"
|
|
12
|
-
tabList={
|
|
13
|
-
withTabListProps
|
|
14
|
-
? {
|
|
15
|
-
variant: 'fullWidth'
|
|
16
|
-
}
|
|
17
|
-
: undefined
|
|
18
|
-
}
|
|
19
|
-
tabs={[
|
|
20
|
-
{ label: 'Tab 0', value: 'tab 0' },
|
|
21
|
-
{ label: 'Tab 1', value: 'tab 1' }
|
|
22
|
-
]}
|
|
23
|
-
>
|
|
24
|
-
<TabPanel value="tab 0">
|
|
25
|
-
<Typography>Tab 0</Typography>
|
|
26
|
-
</TabPanel>
|
|
27
|
-
<TabPanel value="tab 1">
|
|
28
|
-
<Typography>Tab 1</Typography>
|
|
29
|
-
</TabPanel>
|
|
30
|
-
</Tabs>
|
|
31
|
-
)
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
describe('Tabs', () => {
|
|
36
|
-
it('displays tabs and their content when a tab is selected', () => {
|
|
37
|
-
initialize();
|
|
38
|
-
|
|
39
|
-
cy.get('[data-TabPanel="tab 0"]').should('not.have.attr', 'hidden');
|
|
40
|
-
cy.get('[data-TabPanel="tab 1"]').should('have.attr', 'hidden');
|
|
41
|
-
cy.findByLabelText('Tab 0')
|
|
42
|
-
.should('have.attr', 'aria-selected')
|
|
43
|
-
.and('equals', 'true');
|
|
44
|
-
cy.findByLabelText('Tab 1')
|
|
45
|
-
.should('have.attr', 'aria-selected')
|
|
46
|
-
.and('equals', 'false');
|
|
47
|
-
|
|
48
|
-
cy.contains('Tab 1').click();
|
|
49
|
-
|
|
50
|
-
cy.get('[data-TabPanel="tab 0"]').should('have.attr', 'hidden');
|
|
51
|
-
cy.get('[data-TabPanel="tab 1"]').should('not.have.attr', 'hidden');
|
|
52
|
-
cy.findByLabelText('Tab 0')
|
|
53
|
-
.should('have.attr', 'aria-selected')
|
|
54
|
-
.and('equals', 'false');
|
|
55
|
-
cy.findByLabelText('Tab 1')
|
|
56
|
-
.should('have.attr', 'aria-selected')
|
|
57
|
-
.and('equals', 'true');
|
|
58
|
-
|
|
59
|
-
cy.makeSnapshot();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('displays tabs when tabList props are set', () => {
|
|
63
|
-
initialize(true);
|
|
64
|
-
|
|
65
|
-
cy.get('[data-TabPanel="tab 0"]').should('not.have.attr', 'hidden');
|
|
66
|
-
cy.get('[data-TabPanel="tab 1"]').should('have.attr', 'hidden');
|
|
67
|
-
|
|
68
|
-
cy.makeSnapshot();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { Typography } from '@mui/material';
|
|
4
|
-
|
|
5
|
-
import { TabPanel } from './TabPanel';
|
|
6
|
-
|
|
7
|
-
import { Tabs } from '.';
|
|
8
|
-
|
|
9
|
-
const meta: Meta<typeof Tabs> = {
|
|
10
|
-
component: Tabs
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default meta;
|
|
14
|
-
type Story = StoryObj<typeof Tabs>;
|
|
15
|
-
|
|
16
|
-
const generateTabs = (size: number): Array<{ label: string; value: string }> =>
|
|
17
|
-
Array(size)
|
|
18
|
-
.fill(0)
|
|
19
|
-
.map((_, index) => ({ label: `Tab ${index}`, value: `tab ${index}` }));
|
|
20
|
-
|
|
21
|
-
export const Default: Story = {
|
|
22
|
-
args: {
|
|
23
|
-
defaultTab: 'tab 0',
|
|
24
|
-
tabs: generateTabs(2)
|
|
25
|
-
},
|
|
26
|
-
render: (args) => (
|
|
27
|
-
<Tabs {...args}>
|
|
28
|
-
{generateTabs(2).map(({ value, label }) => (
|
|
29
|
-
<TabPanel key={value} value={value}>
|
|
30
|
-
<Typography>{label}</Typography>
|
|
31
|
-
</TabPanel>
|
|
32
|
-
))}
|
|
33
|
-
</Tabs>
|
|
34
|
-
)
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const WithTabListProps: Story = {
|
|
38
|
-
args: {
|
|
39
|
-
defaultTab: 'tab 0',
|
|
40
|
-
tabList: {
|
|
41
|
-
textColor: 'inherit',
|
|
42
|
-
variant: 'fullWidth'
|
|
43
|
-
},
|
|
44
|
-
tabs: generateTabs(2)
|
|
45
|
-
},
|
|
46
|
-
render: (args) => (
|
|
47
|
-
<Tabs {...args}>
|
|
48
|
-
{generateTabs(2).map(({ value, label }) => (
|
|
49
|
-
<TabPanel key={value} value={value}>
|
|
50
|
-
<Typography>{label}</Typography>
|
|
51
|
-
</TabPanel>
|
|
52
|
-
))}
|
|
53
|
-
</Tabs>
|
|
54
|
-
)
|
|
55
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { TabContext, TabList, TabListProps } from '@mui/lab';
|
|
4
|
-
import { Tab } from '@mui/material';
|
|
5
|
-
|
|
6
|
-
import { useTabsStyles } from './Tab.styles';
|
|
7
|
-
|
|
8
|
-
type Props = {
|
|
9
|
-
children: Array<JSX.Element>;
|
|
10
|
-
defaultTab: string;
|
|
11
|
-
tabList?: TabListProps;
|
|
12
|
-
tabs: Array<{
|
|
13
|
-
label: string;
|
|
14
|
-
value: string;
|
|
15
|
-
}>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const Tabs = ({
|
|
19
|
-
children,
|
|
20
|
-
defaultTab,
|
|
21
|
-
tabs,
|
|
22
|
-
tabList
|
|
23
|
-
}: Props): JSX.Element => {
|
|
24
|
-
const { classes } = useTabsStyles();
|
|
25
|
-
|
|
26
|
-
const [selectedTab, setSelectedTab] = useState(defaultTab);
|
|
27
|
-
|
|
28
|
-
const changeTab = useCallback((_, newValue: string): void => {
|
|
29
|
-
setSelectedTab(newValue);
|
|
30
|
-
}, []);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<TabContext value={selectedTab}>
|
|
34
|
-
<TabList
|
|
35
|
-
classes={{
|
|
36
|
-
indicator: classes.indicator,
|
|
37
|
-
root: classes.tabs
|
|
38
|
-
}}
|
|
39
|
-
onChange={changeTab}
|
|
40
|
-
{...tabList}
|
|
41
|
-
>
|
|
42
|
-
{tabs.map(({ value, label }) => (
|
|
43
|
-
<Tab
|
|
44
|
-
aria-label={label}
|
|
45
|
-
className={classes.tab}
|
|
46
|
-
key={value}
|
|
47
|
-
label={label}
|
|
48
|
-
value={value}
|
|
49
|
-
/>
|
|
50
|
-
))}
|
|
51
|
-
</TabList>
|
|
52
|
-
{children}
|
|
53
|
-
</TabContext>
|
|
54
|
-
);
|
|
55
|
-
};
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
always,
|
|
3
|
-
cond,
|
|
4
|
-
equals,
|
|
5
|
-
flatten,
|
|
6
|
-
groupBy,
|
|
7
|
-
identity,
|
|
8
|
-
includes,
|
|
9
|
-
map,
|
|
10
|
-
pipe,
|
|
11
|
-
T
|
|
12
|
-
} from 'ramda';
|
|
13
|
-
|
|
14
|
-
import { SelectEntry } from '..';
|
|
15
|
-
|
|
16
|
-
import { centreonBaseURL } from './centreonBaseURL';
|
|
17
|
-
|
|
18
|
-
export interface Resource {
|
|
19
|
-
resourceType: string;
|
|
20
|
-
resources: Array<SelectEntry>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface GetResourcesUrlProps {
|
|
24
|
-
allResources: Array<Resource>;
|
|
25
|
-
isForOneResource: boolean;
|
|
26
|
-
resource?;
|
|
27
|
-
states: Array<string>;
|
|
28
|
-
statuses: Array<string>;
|
|
29
|
-
type: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const getDetailsPanelQueriers = ({ resource, type }): object => {
|
|
33
|
-
const { id, parentId, uuid } = resource;
|
|
34
|
-
|
|
35
|
-
const resourcesDetailsEndpoint = cond([
|
|
36
|
-
[
|
|
37
|
-
equals('host'),
|
|
38
|
-
always(`${centreonBaseURL}/api/latest/monitoring/resources/hosts/${id}`)
|
|
39
|
-
],
|
|
40
|
-
[
|
|
41
|
-
equals('service'),
|
|
42
|
-
always(
|
|
43
|
-
`${centreonBaseURL}/api/latest/monitoring/resources/hosts/${parentId}/services/${id}`
|
|
44
|
-
)
|
|
45
|
-
],
|
|
46
|
-
[
|
|
47
|
-
equals('metaservice'),
|
|
48
|
-
always(
|
|
49
|
-
`${centreonBaseURL}/api/latest/monitoring/resources/metaservices/${id}`
|
|
50
|
-
)
|
|
51
|
-
],
|
|
52
|
-
[
|
|
53
|
-
equals('anomaly-detection'),
|
|
54
|
-
always(
|
|
55
|
-
`${centreonBaseURL}/api/latest/monitoring/resources/anomaly-detection/${id}`
|
|
56
|
-
)
|
|
57
|
-
]
|
|
58
|
-
])(type);
|
|
59
|
-
|
|
60
|
-
const queryParameters = {
|
|
61
|
-
id,
|
|
62
|
-
resourcesDetailsEndpoint,
|
|
63
|
-
selectedTimePeriodId: 'last_24_h',
|
|
64
|
-
tab: 'details',
|
|
65
|
-
tabParameters: {},
|
|
66
|
-
uuid
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return queryParameters;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const getResourcesUrl = ({
|
|
73
|
-
type,
|
|
74
|
-
statuses,
|
|
75
|
-
states,
|
|
76
|
-
allResources,
|
|
77
|
-
isForOneResource,
|
|
78
|
-
resource
|
|
79
|
-
}: GetResourcesUrlProps): string => {
|
|
80
|
-
const resourcesCriterias = equals(type, 'all')
|
|
81
|
-
? {
|
|
82
|
-
name: 'resource_types',
|
|
83
|
-
value: [
|
|
84
|
-
{ id: 'service', name: 'Service' },
|
|
85
|
-
{ id: 'host', name: 'Host' }
|
|
86
|
-
]
|
|
87
|
-
}
|
|
88
|
-
: {
|
|
89
|
-
name: 'resource_types',
|
|
90
|
-
value: [
|
|
91
|
-
{ id: type, name: `${type.charAt(0).toUpperCase()}${type.slice(1)}` }
|
|
92
|
-
]
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const formattedStatuses = pipe(
|
|
96
|
-
flatten,
|
|
97
|
-
map((status: string) => {
|
|
98
|
-
return {
|
|
99
|
-
id: status.toLocaleUpperCase(),
|
|
100
|
-
name: `${status.charAt(0).toUpperCase()}${status.slice(1)}`
|
|
101
|
-
};
|
|
102
|
-
})
|
|
103
|
-
)(statuses);
|
|
104
|
-
|
|
105
|
-
const formattedStates = states.map((state) => {
|
|
106
|
-
return {
|
|
107
|
-
id: state,
|
|
108
|
-
name: `${state.charAt(0).toUpperCase()}${state.slice(1)}`
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const groupedResources = groupBy(
|
|
113
|
-
({ resourceType }) => resourceType,
|
|
114
|
-
allResources
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
const resourcesFilters = Object.entries(groupedResources).map(
|
|
118
|
-
([resourceType, res]) => {
|
|
119
|
-
const name = cond<Array<string>, string>([
|
|
120
|
-
[equals('host'), always('parent_name')],
|
|
121
|
-
[equals('service'), always('name')],
|
|
122
|
-
[T, identity]
|
|
123
|
-
])(resourceType);
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
name: name.replace('-', '_'),
|
|
127
|
-
value: flatten(
|
|
128
|
-
(res || []).map(({ resources: subResources }) => {
|
|
129
|
-
return subResources.map(({ name: resourceName }) => ({
|
|
130
|
-
id: includes(name, ['name', 'parent_name'])
|
|
131
|
-
? `\\b${resourceName}\\b`
|
|
132
|
-
: resourceName,
|
|
133
|
-
name: resourceName
|
|
134
|
-
}));
|
|
135
|
-
})
|
|
136
|
-
)
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
const filterQueryParameter = {
|
|
142
|
-
criterias: [
|
|
143
|
-
resourcesCriterias,
|
|
144
|
-
{ name: 'statuses', value: formattedStatuses },
|
|
145
|
-
{ name: 'states', value: formattedStates },
|
|
146
|
-
...resourcesFilters,
|
|
147
|
-
{ name: 'search', value: '' }
|
|
148
|
-
]
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const encodedFilterParams = encodeURIComponent(
|
|
152
|
-
JSON.stringify(filterQueryParameter)
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
if (!isForOneResource) {
|
|
156
|
-
return `/monitoring/resources?filter=${encodedFilterParams}&fromTopCounter=true`;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const detailsPanelQueriers = getDetailsPanelQueriers({ resource, type });
|
|
160
|
-
|
|
161
|
-
const encodedDetailsParams = encodeURIComponent(
|
|
162
|
-
JSON.stringify(detailsPanelQueriers)
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
return `/monitoring/resources?details=${encodedDetailsParams}&filter=${encodedFilterParams}&fromTopCounter=true`;
|
|
166
|
-
};
|