@cccsaurora/howler-ui 2.19.0-dev.950 → 2.19.0-dev.958
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/components/app/providers/ModalProvider.d.ts +1 -0
- package/components/app/providers/ModalProvider.js +5 -1
- package/components/routes/action/view/ActionDetails.js +4 -2
- package/components/routes/action/view/ActionSearch.js +12 -7
- package/components/routes/analytics/AnalyticDetails.js +9 -5
- package/components/routes/dossiers/Dossiers.js +15 -11
- package/components/routes/overviews/OverviewViewer.js +12 -8
- package/components/routes/overviews/Overviews.js +15 -11
- package/components/routes/templates/TemplateViewer.js +18 -13
- package/components/routes/views/Views.js +8 -4
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ export interface ModalOptions {
|
|
|
6
6
|
}
|
|
7
7
|
interface ModalContextType {
|
|
8
8
|
showModal: (children: ReactNode, options?: ModalOptions) => () => void;
|
|
9
|
+
withConfirmDeleteModal: (onConfirm: () => void, preferDelete?: boolean, preferCancel?: boolean) => () => void;
|
|
9
10
|
content?: ReactNode;
|
|
10
11
|
setContent: (children: ReactNode) => void;
|
|
11
12
|
options?: ModalOptions;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import ConfirmDeleteModal from '@cccsaurora/howler-ui/components/elements/display/modals/ConfirmDeleteModal';
|
|
2
3
|
import { createContext, useCallback, useEffect, useState } from 'react';
|
|
3
4
|
const defaultOptions = {
|
|
4
5
|
disableClose: false
|
|
@@ -23,6 +24,9 @@ const ModalProvider = ({ children }) => {
|
|
|
23
24
|
return () => setContent(null);
|
|
24
25
|
}, [options]);
|
|
25
26
|
const close = useCallback(() => setContent(null), []);
|
|
26
|
-
|
|
27
|
+
const withConfirmDeleteModal = useCallback((onConfirm, preferDelete, preferCancel) => {
|
|
28
|
+
return showModal(_jsx(ConfirmDeleteModal, { onConfirm: onConfirm, preferDelete: preferDelete, preferCancel: preferCancel }));
|
|
29
|
+
}, [showModal]);
|
|
30
|
+
return (_jsx(ModalContext.Provider, { value: { showModal, withConfirmDeleteModal, content, setContent, options, close }, children: children }));
|
|
27
31
|
};
|
|
28
32
|
export default ModalProvider;
|
|
@@ -4,13 +4,14 @@ import { Button, Checkbox, FormControlLabel, FormGroup, IconButton, LinearProgre
|
|
|
4
4
|
import api from '@cccsaurora/howler-ui/api';
|
|
5
5
|
import { useAppUser } from '@cccsaurora/howler-ui/commons/components/app/hooks';
|
|
6
6
|
import PageCenter from '@cccsaurora/howler-ui/commons/components/pages/PageCenter';
|
|
7
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
7
8
|
import FlexOne from '@cccsaurora/howler-ui/components/elements/addons/layout/FlexOne';
|
|
8
9
|
import Phrase from '@cccsaurora/howler-ui/components/elements/addons/search/phrase/Phrase';
|
|
9
10
|
import HowlerAvatar from '@cccsaurora/howler-ui/components/elements/display/HowlerAvatar';
|
|
10
11
|
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
11
12
|
import OperationEntry from '@cccsaurora/howler-ui/components/routes/action/shared/OperationEntry';
|
|
12
13
|
import howlerPluginStore from '@cccsaurora/howler-ui/plugins/store';
|
|
13
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
14
|
+
import { useCallback, useContext, useEffect, useState } from 'react';
|
|
14
15
|
import { useTranslation } from 'react-i18next';
|
|
15
16
|
import { usePluginStore } from 'react-pluggable';
|
|
16
17
|
import { Link, useParams } from 'react-router-dom';
|
|
@@ -26,6 +27,7 @@ const ActionDetails = () => {
|
|
|
26
27
|
const { response, onSearch, loading, setLoading, executeAction, deleteAction, progress, report } = useMyActionFunctions();
|
|
27
28
|
const [operations, setOperations] = useState([]);
|
|
28
29
|
const [action, setAction] = useState();
|
|
30
|
+
const { withConfirmDeleteModal } = useContext(ModalContext);
|
|
29
31
|
const onTriggerChange = useCallback(async (e) => {
|
|
30
32
|
let newTriggers = action.triggers ?? [];
|
|
31
33
|
if (e.target.checked && !newTriggers.includes(e.target.name)) {
|
|
@@ -63,7 +65,7 @@ const ActionDetails = () => {
|
|
|
63
65
|
user.roles.includes('admin') ||
|
|
64
66
|
user.roles.includes('actionrunner_basic') ||
|
|
65
67
|
user.roles.includes('actionrunner_advanced');
|
|
66
|
-
return (_jsx(PageCenter, { maxWidth: "1500px", textAlign: "left", height: "100%", children: _jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [_jsx(Typography, { variant: "h5", children: action?.name }), action?.owner_id && _jsx(HowlerAvatar, { sx: { width: 32, height: 32 }, userId: action.owner_id })] }), _jsx(Phrase, { fullWidth: true, value: action?.query, disabled: true, size: "small", onChange: () => { }, startAdornment: _jsx(IconButton, { onClick: () => onSearch(action?.query), children: _jsx(Search, { fontSize: "small" }) }) }), _jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [response && _jsx(QueryResultText, { count: response.total, query: action?.query }), _jsx(FlexOne, {}), ((action?.owner_id === user.username && editRoles) || user.roles?.includes('admin')) && (_jsx(Button, { startIcon: _jsx(Delete, {}), size: "small", variant: "outlined", color: "error", onClick: () => deleteAction(action?.action_id), children: t('button.delete') })), execRoles && (_jsx(Button, { startIcon: _jsx(PlayCircleOutline, {}), size: "small", variant: "outlined", color: "success", onClick: () => executeAction(action?.action_id), children: t('route.actions.execute') })), ((action?.owner_id === user.username && editRoles) || user.roles?.includes('admin')) && (_jsx(Button, { startIcon: _jsx(Edit, {}), size: "small", variant: "outlined", component: Link, to: `/action/${params.id}/edit`, children: t('route.actions.edit') }))] }), user.roles.includes('automation_advanced') && (_jsx(FormGroup, { children: _jsx(Stack, { direction: "row", spacing: 1, children: action?.operations
|
|
68
|
+
return (_jsx(PageCenter, { maxWidth: "1500px", textAlign: "left", height: "100%", children: _jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [_jsx(Typography, { variant: "h5", children: action?.name }), action?.owner_id && _jsx(HowlerAvatar, { sx: { width: 32, height: 32 }, userId: action.owner_id })] }), _jsx(Phrase, { fullWidth: true, value: action?.query, disabled: true, size: "small", onChange: () => { }, startAdornment: _jsx(IconButton, { onClick: () => onSearch(action?.query), children: _jsx(Search, { fontSize: "small" }) }) }), _jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [response && _jsx(QueryResultText, { count: response.total, query: action?.query }), _jsx(FlexOne, {}), ((action?.owner_id === user.username && editRoles) || user.roles?.includes('admin')) && (_jsx(Button, { startIcon: _jsx(Delete, {}), size: "small", variant: "outlined", color: "error", onClick: () => withConfirmDeleteModal(() => deleteAction(action?.action_id)), children: t('button.delete') })), execRoles && (_jsx(Button, { startIcon: _jsx(PlayCircleOutline, {}), size: "small", variant: "outlined", color: "success", onClick: () => executeAction(action?.action_id), children: t('route.actions.execute') })), ((action?.owner_id === user.username && editRoles) || user.roles?.includes('admin')) && (_jsx(Button, { startIcon: _jsx(Edit, {}), size: "small", variant: "outlined", component: Link, to: `/action/${params.id}/edit`, children: t('route.actions.edit') }))] }), user.roles.includes('automation_advanced') && (_jsx(FormGroup, { children: _jsx(Stack, { direction: "row", spacing: 1, children: action?.operations
|
|
67
69
|
?.map(a => (operations ?? []).find(_action => _action.id === a.operation_id)?.triggers ?? [])
|
|
68
70
|
.reduce((acc, triggers) => acc.filter(_t => triggers.includes(_t)))
|
|
69
71
|
.map(trigger => (_jsx(FormControlLabel, { control: _jsx(Checkbox, { name: trigger, onChange: onTriggerChange, checked: action?.triggers?.includes(trigger) ?? false }), label: t(`route.actions.trigger.${trigger}`) }, trigger))) }) })), loading &&
|
|
@@ -3,6 +3,7 @@ import { Delete, Engineering, Terminal } from '@mui/icons-material';
|
|
|
3
3
|
import { Autocomplete, Card, CardContent, CardHeader, Chip, Grid, IconButton, Stack, TextField, Tooltip, Typography } from '@mui/material';
|
|
4
4
|
import api from '@cccsaurora/howler-ui/api';
|
|
5
5
|
import { useAppUser } from '@cccsaurora/howler-ui/commons/components/app/hooks';
|
|
6
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
6
7
|
import FlexOne from '@cccsaurora/howler-ui/components/elements/addons/layout/FlexOne';
|
|
7
8
|
import { TuiListProvider } from '@cccsaurora/howler-ui/components/elements/addons/lists';
|
|
8
9
|
import { TuiListMethodContext } from '@cccsaurora/howler-ui/components/elements/addons/lists/TuiListProvider';
|
|
@@ -22,6 +23,7 @@ const ActionSearch = () => {
|
|
|
22
23
|
const { user } = useAppUser();
|
|
23
24
|
const { dispatchApi } = useMyApi();
|
|
24
25
|
const { load } = useContext(TuiListMethodContext);
|
|
26
|
+
const { withConfirmDeleteModal } = useContext(ModalContext);
|
|
25
27
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
26
28
|
const { deleteAction } = useMyActionFunctions();
|
|
27
29
|
const pageCount = useMyLocalStorageItem(StorageKey.PAGE_COUNT, 25)[0];
|
|
@@ -70,6 +72,14 @@ const ActionSearch = () => {
|
|
|
70
72
|
setOffset(_offset);
|
|
71
73
|
}
|
|
72
74
|
}, [offset, searchParams, setSearchParams]);
|
|
75
|
+
const onDelete = useCallback((e, actionId) => {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
e.stopPropagation();
|
|
78
|
+
withConfirmDeleteModal(async () => {
|
|
79
|
+
await deleteAction(actionId);
|
|
80
|
+
onSearch();
|
|
81
|
+
});
|
|
82
|
+
}, [deleteAction, onSearch, withConfirmDeleteModal]);
|
|
73
83
|
// Effect to initialize list of users.
|
|
74
84
|
useEffect(() => {
|
|
75
85
|
onSearch();
|
|
@@ -105,13 +115,8 @@ const ActionSearch = () => {
|
|
|
105
115
|
transitionProperty: 'border-color',
|
|
106
116
|
cursor: 'pointer',
|
|
107
117
|
mt: 1
|
|
108
|
-
}, children: [_jsx(CardHeader, { title: _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { variant: "h5", children: item.item.name }), item.item.triggers.length > 0 && (_jsx(Tooltip, { title: _jsx(Trans, { i18nKey: "route.actions.trigger.description", values: { triggers: item.item.triggers.join(', ') }, components: { bold: _jsx("strong", {}) } }), children: _jsx(Engineering, {}) })), _jsx(FlexOne, {}), ((item.item.owner_id === user.username && editRoles) || user.roles?.includes('admin')) && (_jsx(IconButton, { size: "small", onClick:
|
|
109
|
-
|
|
110
|
-
e.stopPropagation();
|
|
111
|
-
await deleteAction(item.item.action_id);
|
|
112
|
-
onSearch();
|
|
113
|
-
}, children: _jsx(Delete, {}) })), _jsx(HowlerAvatar, { sx: { width: 24, height: 24, marginRight: '8px !important' }, userId: item.item.owner_id })] }), subheader: item.item.query }), _jsx(CardContent, { sx: { paddingTop: 0 }, children: _jsx(Grid, { container: true, spacing: 1, children: item.item.operations.map(d => (_jsx(Grid, { item: true, children: _jsx(Chip, { size: "small", label: t(`operations.${d.operation_id}`) }) }, d.operation_id))) }) })] }, item.item.name));
|
|
114
|
-
}, [deleteAction, editRoles, navigate, onSearch, t, user.roles, user.username]);
|
|
118
|
+
}, children: [_jsx(CardHeader, { title: _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { variant: "h5", children: item.item.name }), item.item.triggers.length > 0 && (_jsx(Tooltip, { title: _jsx(Trans, { i18nKey: "route.actions.trigger.description", values: { triggers: item.item.triggers.join(', ') }, components: { bold: _jsx("strong", {}) } }), children: _jsx(Engineering, {}) })), _jsx(FlexOne, {}), ((item.item.owner_id === user.username && editRoles) || user.roles?.includes('admin')) && (_jsx(IconButton, { size: "small", onClick: e => onDelete(e, item.item.action_id), children: _jsx(Delete, {}) })), _jsx(HowlerAvatar, { sx: { width: 24, height: 24, marginRight: '8px !important' }, userId: item.item.owner_id })] }), subheader: item.item.query }), _jsx(CardContent, { sx: { paddingTop: 0 }, children: _jsx(Grid, { container: true, spacing: 1, children: item.item.operations.map(d => (_jsx(Grid, { item: true, children: _jsx(Chip, { size: "small", label: t(`operations.${d.operation_id}`) }) }, d.operation_id))) }) })] }, item.item.name));
|
|
119
|
+
}, [editRoles, navigate, onDelete, t, user.roles, user.username]);
|
|
115
120
|
return (_jsx(ItemManager, { onSearch: onSearch, onCreate: editRoles ? () => navigate('/action/execute') : undefined, onPageChange: onPageChange, phrase: phrase, setPhrase: setPhrase, hasError: hasError, searching: searching, aboveSearch: _jsx(Typography, { sx: theme => ({ fontStyle: 'italic', color: theme.palette.text.disabled, mb: 0.5 }), variant: "body2", children: t('route.actions.search.prompt') }), searchFilters: _jsx(Autocomplete, { multiple: true, size: "small", value: searchModifiers, onChange: (__, values) => setSearchModifiers(values), getOptionLabel: trigger => t(`route.actions.trigger.${trigger}`), options: VALID_ACTION_TRIGGERS, renderInput: params => (_jsx(TextField, { ...params, sx: { maxWidth: '500px' }, label: t('route.actions.trigger') })) }), renderer: renderer, response: response, createPrompt: "route.actions.create", searchPrompt: "route.actions.search", createIcon: _jsx(Terminal, { sx: { mr: 1 } }) }));
|
|
116
121
|
};
|
|
117
122
|
const ActionSearchProvider = () => {
|
|
@@ -5,6 +5,7 @@ import api from '@cccsaurora/howler-ui/api';
|
|
|
5
5
|
import { useAppUser } from '@cccsaurora/howler-ui/commons/components/app/hooks';
|
|
6
6
|
import PageCenter from '@cccsaurora/howler-ui/commons/components/pages/PageCenter';
|
|
7
7
|
import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
|
|
8
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
8
9
|
import { UserListContext } from '@cccsaurora/howler-ui/components/app/providers/UserListProvider';
|
|
9
10
|
import UserList from '@cccsaurora/howler-ui/components/elements/UserList';
|
|
10
11
|
import HowlerAvatar from '@cccsaurora/howler-ui/components/elements/display/HowlerAvatar';
|
|
@@ -31,6 +32,7 @@ const AnalyticDetails = () => {
|
|
|
31
32
|
const { dispatchApi } = useMyApi();
|
|
32
33
|
const theme = useTheme();
|
|
33
34
|
const { showSuccessMessage } = useMySnackbar();
|
|
35
|
+
const { withConfirmDeleteModal } = useContext(ModalContext);
|
|
34
36
|
const { users, searchUsers } = useContext(UserListContext);
|
|
35
37
|
const { config } = useContext(ApiConfigContext);
|
|
36
38
|
const [analytic, setAnalytic] = useState(null);
|
|
@@ -58,11 +60,13 @@ const AnalyticDetails = () => {
|
|
|
58
60
|
});
|
|
59
61
|
setAnalytic(result);
|
|
60
62
|
}, [analytic?.analytic_id, dispatchApi]);
|
|
61
|
-
const onDelete = useCallback(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const onDelete = useCallback(() => {
|
|
64
|
+
withConfirmDeleteModal(async () => {
|
|
65
|
+
await dispatchApi(api.analytic.del(analytic?.analytic_id));
|
|
66
|
+
showSuccessMessage(t('route.analytics.deleted'));
|
|
67
|
+
navigate('/analytics');
|
|
68
|
+
});
|
|
69
|
+
}, [analytic?.analytic_id, dispatchApi, navigate, withConfirmDeleteModal, showSuccessMessage, t]);
|
|
66
70
|
const onEdit = useCallback(async () => {
|
|
67
71
|
if (editingInterval) {
|
|
68
72
|
setIntervalLoading(true);
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Topic } from '@mui/icons-material';
|
|
3
3
|
import { Typography } from '@mui/material';
|
|
4
4
|
import api from '@cccsaurora/howler-ui/api';
|
|
5
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
5
6
|
import { TuiListProvider } from '@cccsaurora/howler-ui/components/elements/addons/lists';
|
|
6
7
|
import { TuiListMethodContext } from '@cccsaurora/howler-ui/components/elements/addons/lists/TuiListProvider';
|
|
7
8
|
import ItemManager from '@cccsaurora/howler-ui/components/elements/display/ItemManager';
|
|
@@ -18,6 +19,7 @@ const DossiersBase = () => {
|
|
|
18
19
|
const navigate = useNavigate();
|
|
19
20
|
const { dispatchApi } = useMyApi();
|
|
20
21
|
const { showSuccessMessage } = useMySnackbar();
|
|
22
|
+
const { withConfirmDeleteModal } = useContext(ModalContext);
|
|
21
23
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
22
24
|
const { load } = useContext(TuiListMethodContext);
|
|
23
25
|
const pageCount = useMyLocalStorageItem(StorageKey.PAGE_COUNT, 25)[0];
|
|
@@ -73,19 +75,21 @@ const DossiersBase = () => {
|
|
|
73
75
|
setOffset(_offset);
|
|
74
76
|
}
|
|
75
77
|
}, [offset, searchParams, setSearchParams]);
|
|
76
|
-
const onDelete = useCallback(
|
|
78
|
+
const onDelete = useCallback((e, id) => {
|
|
77
79
|
e.preventDefault();
|
|
78
80
|
e.stopPropagation();
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
withConfirmDeleteModal(async () => {
|
|
82
|
+
try {
|
|
83
|
+
await dispatchApi(api.dossier.del(id), { throwError: false, showError: true });
|
|
84
|
+
await onSearch();
|
|
85
|
+
showSuccessMessage(t('route.dossiers.manager.delete.success'));
|
|
86
|
+
}
|
|
87
|
+
catch (_err) {
|
|
88
|
+
// eslint-disable-next-line no-console
|
|
89
|
+
console.warn(_err);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}, [dispatchApi, onSearch, withConfirmDeleteModal, showSuccessMessage, t]);
|
|
89
93
|
useEffect(() => {
|
|
90
94
|
onSearch();
|
|
91
95
|
if (!searchParams.has('offset')) {
|
|
@@ -8,6 +8,7 @@ import { Check, DarkMode, Delete, SsidChart, WbSunny } from '@mui/icons-material
|
|
|
8
8
|
import { useApp } from '@cccsaurora/howler-ui/commons/components/app/hooks';
|
|
9
9
|
import AppInfoPanel from '@cccsaurora/howler-ui/commons/components/display/AppInfoPanel';
|
|
10
10
|
import useThemeBuilder from '@cccsaurora/howler-ui/commons/components/utils/hooks/useThemeBuilder';
|
|
11
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
11
12
|
import { OverviewContext } from '@cccsaurora/howler-ui/components/app/providers/OverviewProvider';
|
|
12
13
|
import HitOverview from '@cccsaurora/howler-ui/components/elements/hit/HitOverview';
|
|
13
14
|
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
@@ -25,6 +26,7 @@ const OverviewViewer = () => {
|
|
|
25
26
|
const [params, setParams] = useSearchParams();
|
|
26
27
|
const { getOverviews } = useContext(OverviewContext);
|
|
27
28
|
const { dispatchApi } = useMyApi();
|
|
29
|
+
const { withConfirmDeleteModal } = useContext(ModalContext);
|
|
28
30
|
const [overviewList, setOverviewList] = useState([]);
|
|
29
31
|
const [selectedOverview, setSelectedOverview] = useState(null);
|
|
30
32
|
const [content, setContent] = useState('');
|
|
@@ -124,15 +126,17 @@ const OverviewViewer = () => {
|
|
|
124
126
|
replace: true
|
|
125
127
|
});
|
|
126
128
|
}, [analytic, detection, params, setParams]);
|
|
127
|
-
const onDelete = useCallback(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
const onDelete = useCallback(() => {
|
|
130
|
+
withConfirmDeleteModal(async () => {
|
|
131
|
+
await dispatchApi(api.overview.del(selectedOverview.overview_id), {
|
|
132
|
+
logError: false,
|
|
133
|
+
showError: true,
|
|
134
|
+
throwError: false
|
|
135
|
+
});
|
|
136
|
+
setSelectedOverview(null);
|
|
137
|
+
setContent('');
|
|
132
138
|
});
|
|
133
|
-
|
|
134
|
-
setContent('');
|
|
135
|
-
}, [dispatchApi, selectedOverview?.overview_id]);
|
|
139
|
+
}, [dispatchApi, selectedOverview?.overview_id, withConfirmDeleteModal]);
|
|
136
140
|
const onSave = useCallback(async () => {
|
|
137
141
|
if (analytic && detection) {
|
|
138
142
|
try {
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Article } from '@mui/icons-material';
|
|
3
3
|
import { Typography } from '@mui/material';
|
|
4
4
|
import api from '@cccsaurora/howler-ui/api';
|
|
5
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
5
6
|
import { TuiListProvider } from '@cccsaurora/howler-ui/components/elements/addons/lists';
|
|
6
7
|
import { TuiListMethodContext } from '@cccsaurora/howler-ui/components/elements/addons/lists/TuiListProvider';
|
|
7
8
|
import ItemManager from '@cccsaurora/howler-ui/components/elements/display/ItemManager';
|
|
@@ -18,6 +19,7 @@ const OverviewsBase = () => {
|
|
|
18
19
|
const navigate = useNavigate();
|
|
19
20
|
const { dispatchApi } = useMyApi();
|
|
20
21
|
const { showSuccessMessage } = useMySnackbar();
|
|
22
|
+
const { withConfirmDeleteModal } = useContext(ModalContext);
|
|
21
23
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
22
24
|
const { load } = useContext(TuiListMethodContext);
|
|
23
25
|
const pageCount = useMyLocalStorageItem(StorageKey.PAGE_COUNT, 25)[0];
|
|
@@ -73,19 +75,21 @@ const OverviewsBase = () => {
|
|
|
73
75
|
setOffset(_offset);
|
|
74
76
|
}
|
|
75
77
|
}, [offset, searchParams, setSearchParams]);
|
|
76
|
-
const onDelete = useCallback(
|
|
78
|
+
const onDelete = useCallback((e, id) => {
|
|
77
79
|
e.preventDefault();
|
|
78
80
|
e.stopPropagation();
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
withConfirmDeleteModal(async () => {
|
|
82
|
+
try {
|
|
83
|
+
await dispatchApi(api.overview.del(id), { throwError: false, showError: true });
|
|
84
|
+
await onSearch();
|
|
85
|
+
showSuccessMessage(t('route.overviews.manager.delete.success'));
|
|
86
|
+
}
|
|
87
|
+
catch (_err) {
|
|
88
|
+
// eslint-disable-next-line no-console
|
|
89
|
+
console.warn(_err);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}, [dispatchApi, onSearch, withConfirmDeleteModal, showSuccessMessage, t]);
|
|
89
93
|
useEffect(() => {
|
|
90
94
|
onSearch();
|
|
91
95
|
if (!searchParams.has('offset')) {
|
|
@@ -3,10 +3,11 @@ import { Autocomplete, Button, CircularProgress, Divider, FormControl, LinearPro
|
|
|
3
3
|
import api from '@cccsaurora/howler-ui/api';
|
|
4
4
|
import PageCenter from '@cccsaurora/howler-ui/commons/components/pages/PageCenter';
|
|
5
5
|
import TemplateEditor from '@cccsaurora/howler-ui/components/routes/templates/TemplateEditor';
|
|
6
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
|
+
import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
import { Check, Delete, SsidChart } from '@mui/icons-material';
|
|
9
9
|
import AppInfoPanel from '@cccsaurora/howler-ui/commons/components/display/AppInfoPanel';
|
|
10
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
10
11
|
import { DEFAULT_FIELDS } from '@cccsaurora/howler-ui/components/elements/hit/HitOutline';
|
|
11
12
|
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
12
13
|
import isEqual from 'lodash-es/isEqual';
|
|
@@ -17,6 +18,7 @@ const TemplateViewer = () => {
|
|
|
17
18
|
const { t } = useTranslation();
|
|
18
19
|
const [params, setParams] = useSearchParams();
|
|
19
20
|
const { dispatchApi } = useMyApi();
|
|
21
|
+
const { withConfirmDeleteModal } = useContext(ModalContext);
|
|
20
22
|
const [templateList, setTemplateList] = useState([]);
|
|
21
23
|
const [selectedTemplate, setSelectedTemplate] = useState(null);
|
|
22
24
|
const [sessionTemplateList, setSessionTemplateList] = useState([]);
|
|
@@ -115,24 +117,27 @@ const TemplateViewer = () => {
|
|
|
115
117
|
}
|
|
116
118
|
return { ..._hit };
|
|
117
119
|
}, [analytic]);
|
|
118
|
-
const onDelete = useCallback(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
const onDelete = useCallback(() => {
|
|
121
|
+
withConfirmDeleteModal(async () => {
|
|
122
|
+
await dispatchApi(api.template.del(selectedTemplate.template_id), {
|
|
123
|
+
logError: false,
|
|
124
|
+
showError: true,
|
|
125
|
+
throwError: false
|
|
126
|
+
});
|
|
127
|
+
setSessionTemplateList(l => l.filter(v => v.analytic != selectedTemplate.analytic ||
|
|
128
|
+
v.detection != selectedTemplate.detection ||
|
|
129
|
+
v.type != selectedTemplate.type));
|
|
130
|
+
setTemplateList(l => l.filter(v => v.analytic != selectedTemplate.analytic ||
|
|
131
|
+
v.detection != selectedTemplate.detection ||
|
|
132
|
+
v.type != selectedTemplate.type));
|
|
123
133
|
});
|
|
124
|
-
setSessionTemplateList(l => l.filter(v => v.analytic != selectedTemplate.analytic ||
|
|
125
|
-
v.detection != selectedTemplate.detection ||
|
|
126
|
-
v.type != selectedTemplate.type));
|
|
127
|
-
setTemplateList(l => l.filter(v => v.analytic != selectedTemplate.analytic ||
|
|
128
|
-
v.detection != selectedTemplate.detection ||
|
|
129
|
-
v.type != selectedTemplate.type));
|
|
130
134
|
}, [
|
|
131
135
|
dispatchApi,
|
|
132
136
|
selectedTemplate?.analytic,
|
|
133
137
|
selectedTemplate?.detection,
|
|
134
138
|
selectedTemplate?.template_id,
|
|
135
|
-
selectedTemplate?.type
|
|
139
|
+
selectedTemplate?.type,
|
|
140
|
+
withConfirmDeleteModal
|
|
136
141
|
]);
|
|
137
142
|
const onSave = useCallback(async () => {
|
|
138
143
|
if (analytic && detection) {
|
|
@@ -4,6 +4,7 @@ import { Clear, Edit, SavedSearch, Star, StarBorder } from '@mui/icons-material'
|
|
|
4
4
|
import { Autocomplete, Card, Checkbox, IconButton, Skeleton, Stack, TextField, ToggleButton, ToggleButtonGroup, Tooltip, Typography } from '@mui/material';
|
|
5
5
|
import api from '@cccsaurora/howler-ui/api';
|
|
6
6
|
import { useAppUser } from '@cccsaurora/howler-ui/commons/components/app/hooks';
|
|
7
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
7
8
|
import { ViewContext } from '@cccsaurora/howler-ui/components/app/providers/ViewProvider';
|
|
8
9
|
import FlexOne from '@cccsaurora/howler-ui/components/elements/addons/layout/FlexOne';
|
|
9
10
|
import { TuiListProvider } from '@cccsaurora/howler-ui/components/elements/addons/lists';
|
|
@@ -27,6 +28,7 @@ const ViewsBase = () => {
|
|
|
27
28
|
const { user } = useAppUser();
|
|
28
29
|
const navigate = useNavigate();
|
|
29
30
|
const { dispatchApi } = useMyApi();
|
|
31
|
+
const { withConfirmDeleteModal } = useContext(ModalContext);
|
|
30
32
|
const fetchViews = useContextSelector(ViewContext, ctx => ctx.fetchViews);
|
|
31
33
|
const addFavourite = useContextSelector(ViewContext, ctx => ctx.addFavourite);
|
|
32
34
|
const removeFavourite = useContextSelector(ViewContext, ctx => ctx.removeFavourite);
|
|
@@ -105,12 +107,14 @@ const ViewsBase = () => {
|
|
|
105
107
|
setOffset(_offset);
|
|
106
108
|
}
|
|
107
109
|
}, [offset, searchParams, setSearchParams]);
|
|
108
|
-
const onDelete = useCallback(
|
|
110
|
+
const onDelete = useCallback((event, id) => {
|
|
109
111
|
event.preventDefault();
|
|
110
112
|
event.stopPropagation();
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
withConfirmDeleteModal(async () => {
|
|
114
|
+
await removeView(id);
|
|
115
|
+
onSearch();
|
|
116
|
+
});
|
|
117
|
+
}, [onSearch, removeView, withConfirmDeleteModal]);
|
|
114
118
|
const onFavourite = useCallback(async (event, id) => {
|
|
115
119
|
event.preventDefault();
|
|
116
120
|
if (user.favourite_views?.includes(id)) {
|