corpushub-design-system 0.0.4 → 0.0.6
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/dist/common/AppTable/styles.scss +6 -2
- package/dist/configs/Localization.js +2 -0
- package/dist/configs/localization/BackupTexts.d.ts +74 -0
- package/dist/configs/localization/BackupTexts.js +74 -0
- package/dist/features/Backup/BackupCreate/BackupCreate.d.ts +11 -0
- package/dist/features/Backup/BackupCreate/BackupCreate.js +26 -0
- package/dist/features/Backup/BackupCreate/index.d.ts +2 -0
- package/dist/features/Backup/BackupCreate/index.js +2 -0
- package/dist/features/Backup/BackupCreate/style.scss +0 -0
- package/dist/features/Backup/BackupInfo/BackupInfo.d.ts +8 -0
- package/dist/features/Backup/BackupInfo/BackupInfo.js +36 -0
- package/dist/features/Backup/BackupInfo/index.d.ts +2 -0
- package/dist/features/Backup/BackupInfo/index.js +2 -0
- package/dist/features/Backup/BackupInfo/style.scss +23 -0
- package/dist/features/Backup/BackupRestore/BackupRestore.d.ts +7 -0
- package/dist/features/Backup/BackupRestore/BackupRestore.js +52 -0
- package/dist/features/Backup/BackupRestore/index.d.ts +3 -0
- package/dist/features/Backup/BackupRestore/index.js +2 -0
- package/dist/features/Backup/BackupRestore/style.scss +17 -0
- package/dist/features/Backup/BackupService.d.ts +18 -0
- package/dist/features/Backup/BackupService.js +39 -0
- package/dist/features/Backup/BackupTable/BackupSearchFilter.d.ts +5 -0
- package/dist/features/Backup/BackupTable/BackupSearchFilter.js +4 -0
- package/dist/features/Backup/BackupTable/BackupTable.d.ts +8 -0
- package/dist/features/Backup/BackupTable/BackupTable.js +121 -0
- package/dist/features/Backup/BackupTable/index.d.ts +4 -0
- package/dist/features/Backup/BackupTable/index.js +3 -0
- package/dist/features/Backup/BackupTable/style.scss +19 -0
- package/dist/features/Backup/index.d.ts +7 -0
- package/dist/features/Backup/index.js +4 -0
- package/dist/features/Backup/types/Backup.d.ts +14 -0
- package/dist/features/Backup/types/Backup.js +1 -0
- package/dist/features/index.d.ts +2 -0
- package/dist/features/index.js +1 -0
- package/package.json +1 -1
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
|
|
14
14
|
.MuiTableCell-root {
|
|
15
15
|
height: 42px;
|
|
16
|
+
|
|
17
|
+
&:last-child {
|
|
18
|
+
padding-right: 12px;
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
.MuiTableRow-root {
|
|
@@ -34,14 +38,14 @@
|
|
|
34
38
|
.MuiTableCell-head {
|
|
35
39
|
@include tag-medium-2;
|
|
36
40
|
color: var(--text-primary);
|
|
37
|
-
font-family:
|
|
41
|
+
font-family: 'Lora';
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
.MuiTableCell-body {
|
|
42
46
|
@include label-medium-1;
|
|
43
47
|
color: var(--text-primary);
|
|
44
|
-
font-family:
|
|
48
|
+
font-family: 'Work Sans';
|
|
45
49
|
cursor: pointer;
|
|
46
50
|
}
|
|
47
51
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import i18n from "i18next";
|
|
2
2
|
import languageDetector from "i18next-browser-languagedetector";
|
|
3
3
|
import { initReactI18next } from "react-i18next";
|
|
4
|
+
import { BackupTexts } from "./localization/BackupTexts";
|
|
4
5
|
import { BaseTexts } from "./localization/BaseTexts";
|
|
5
6
|
import { CommentsTexts } from "./localization/CommentsTexts";
|
|
6
7
|
import { CommonTexts } from "./localization/CommonTexts";
|
|
@@ -32,6 +33,7 @@ const CORE_NAMESPACES = {
|
|
|
32
33
|
consent: ConsentTexts,
|
|
33
34
|
};
|
|
34
35
|
const FEATURE_NAMESPACES = {
|
|
36
|
+
backup: BackupTexts,
|
|
35
37
|
comments: CommentsTexts,
|
|
36
38
|
'conllu-graph': ConlluGraphTexts,
|
|
37
39
|
'corpus-owner': CorpusOwnerTexts,
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export declare const BackupTexts: {
|
|
2
|
+
en: {
|
|
3
|
+
'label.title': string;
|
|
4
|
+
'button.create': string;
|
|
5
|
+
'placeholder.empty': string;
|
|
6
|
+
'backup.field.filename': string;
|
|
7
|
+
'backup.field.status': string;
|
|
8
|
+
'backup.field.user.name': string;
|
|
9
|
+
'backup.field.log': string;
|
|
10
|
+
'backup.field.id': string;
|
|
11
|
+
'backup.field.download': string;
|
|
12
|
+
'backup.label.log': string;
|
|
13
|
+
'backup.status.error': string;
|
|
14
|
+
'backup.status.processing': string;
|
|
15
|
+
'backup.status.finished': string;
|
|
16
|
+
'modal.title': string;
|
|
17
|
+
'modal.description': string;
|
|
18
|
+
'modal.button.close': string;
|
|
19
|
+
'modal.title.info': string;
|
|
20
|
+
'modal.restore.title': string;
|
|
21
|
+
'modal.restore.message.corpus': string;
|
|
22
|
+
'modal.restore.message.lexicon': string;
|
|
23
|
+
'modal.restore.message.parser': string;
|
|
24
|
+
'modal.restore.confirm': string;
|
|
25
|
+
};
|
|
26
|
+
'pt-BR': {
|
|
27
|
+
'label.title': string;
|
|
28
|
+
'button.create': string;
|
|
29
|
+
'placeholder.empty': string;
|
|
30
|
+
'backup.field.id': string;
|
|
31
|
+
'backup.field.filename': string;
|
|
32
|
+
'backup.field.user.name': string;
|
|
33
|
+
'backup.field.status': string;
|
|
34
|
+
'backup.field.download': string;
|
|
35
|
+
'backup.field.log': string;
|
|
36
|
+
'backup.label.log': string;
|
|
37
|
+
'backup.status.error': string;
|
|
38
|
+
'backup.status.processing': string;
|
|
39
|
+
'backup.status.finished': string;
|
|
40
|
+
'modal.title': string;
|
|
41
|
+
'modal.description': string;
|
|
42
|
+
'modal.button.close': string;
|
|
43
|
+
'modal.title.info': string;
|
|
44
|
+
'modal.restore.title': string;
|
|
45
|
+
'modal.restore.message.corpus': string;
|
|
46
|
+
'modal.restore.message.lexicon': string;
|
|
47
|
+
'modal.restore.message.parser': string;
|
|
48
|
+
'modal.restore.confirm': string;
|
|
49
|
+
};
|
|
50
|
+
it: {
|
|
51
|
+
'label.title': string;
|
|
52
|
+
'button.create': string;
|
|
53
|
+
'placeholder.empty': string;
|
|
54
|
+
'backup.field.filename': string;
|
|
55
|
+
'backup.field.status': string;
|
|
56
|
+
'backup.field.user.name': string;
|
|
57
|
+
'backup.field.log': string;
|
|
58
|
+
'backup.field.id': string;
|
|
59
|
+
'backup.field.download': string;
|
|
60
|
+
'backup.label.log': string;
|
|
61
|
+
'backup.status.error': string;
|
|
62
|
+
'backup.status.processing': string;
|
|
63
|
+
'backup.status.finished': string;
|
|
64
|
+
'modal.title': string;
|
|
65
|
+
'modal.description': string;
|
|
66
|
+
'modal.button.close': string;
|
|
67
|
+
'modal.title.info': string;
|
|
68
|
+
'modal.restore.title': string;
|
|
69
|
+
'modal.restore.message.corpus': string;
|
|
70
|
+
'modal.restore.message.lexicon': string;
|
|
71
|
+
'modal.restore.message.parser': string;
|
|
72
|
+
'modal.restore.confirm': string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export const BackupTexts = {
|
|
2
|
+
en: {
|
|
3
|
+
'label.title': 'Backups',
|
|
4
|
+
'button.create': 'Create new',
|
|
5
|
+
'placeholder.empty': 'No backups available',
|
|
6
|
+
'backup.field.filename': 'File name',
|
|
7
|
+
'backup.field.status': 'Status',
|
|
8
|
+
'backup.field.user.name': 'User',
|
|
9
|
+
'backup.field.log': 'Log',
|
|
10
|
+
'backup.field.id': 'Date',
|
|
11
|
+
'backup.field.download': 'Actions',
|
|
12
|
+
'backup.label.log': 'Log',
|
|
13
|
+
'backup.status.error': 'error',
|
|
14
|
+
'backup.status.processing': 'processing',
|
|
15
|
+
'backup.status.finished': 'finished',
|
|
16
|
+
'modal.title': 'Create Backup',
|
|
17
|
+
'modal.description': 'This action will generate a new backup. This process may take some time.',
|
|
18
|
+
'modal.button.close': 'Close',
|
|
19
|
+
'modal.title.info': 'Backup Information',
|
|
20
|
+
'modal.restore.title': 'Confirm Restore',
|
|
21
|
+
'modal.restore.message.corpus': 'This corpus is already present on the platform. All data will be overwritten.',
|
|
22
|
+
'modal.restore.message.lexicon': 'This lexicon is already present on the platform. All data will be overwritten.',
|
|
23
|
+
'modal.restore.message.parser': 'This parser is already present on the platform. All data will be overwritten.',
|
|
24
|
+
'modal.restore.confirm': 'Are you sure you want to continue? This action is irreversible.',
|
|
25
|
+
},
|
|
26
|
+
'pt-BR': {
|
|
27
|
+
'label.title': 'Backups',
|
|
28
|
+
'button.create': 'Criar novo',
|
|
29
|
+
'placeholder.empty': 'Nenhum backup disponível',
|
|
30
|
+
'backup.field.id': 'Data',
|
|
31
|
+
'backup.field.filename': 'Nome do arquivo',
|
|
32
|
+
'backup.field.user.name': 'Usuário',
|
|
33
|
+
'backup.field.status': 'Status',
|
|
34
|
+
'backup.field.download': 'Ações',
|
|
35
|
+
'backup.field.log': 'Log',
|
|
36
|
+
'backup.label.log': 'Log',
|
|
37
|
+
'backup.status.error': 'erro',
|
|
38
|
+
'backup.status.processing': 'processando',
|
|
39
|
+
'backup.status.finished': 'concluído',
|
|
40
|
+
'modal.title': 'Criar Backup',
|
|
41
|
+
'modal.description': 'Esta ação irá gerar um novo backup. Esse processo pode levar algum tempo.',
|
|
42
|
+
'modal.button.close': 'Fechar',
|
|
43
|
+
'modal.title.info': 'Informações do Backup',
|
|
44
|
+
'modal.restore.title': 'Confirmar Restauração',
|
|
45
|
+
'modal.restore.message.corpus': 'Este corpus já está presente na plataforma. Todos os dados serão sobrescritos.',
|
|
46
|
+
'modal.restore.message.lexicon': 'Este léxico já está presente na plataforma. Todos os dados serão sobrescritos.',
|
|
47
|
+
'modal.restore.message.parser': 'Este parser já está presente na plataforma. Todos os dados serão sobrescritos.',
|
|
48
|
+
'modal.restore.confirm': 'Tem certeza de que deseja continuar? Esta ação é irreversível.',
|
|
49
|
+
},
|
|
50
|
+
it: {
|
|
51
|
+
'label.title': 'Backup',
|
|
52
|
+
'button.create': 'Crea nuovo',
|
|
53
|
+
'placeholder.empty': 'Nessun backup disponibile',
|
|
54
|
+
'backup.field.filename': 'Nome del file',
|
|
55
|
+
'backup.field.status': 'Stato',
|
|
56
|
+
'backup.field.user.name': 'Utente',
|
|
57
|
+
'backup.field.log': 'Log',
|
|
58
|
+
'backup.field.id': 'Data',
|
|
59
|
+
'backup.field.download': 'Azioni',
|
|
60
|
+
'backup.label.log': 'Log',
|
|
61
|
+
'backup.status.error': 'errore',
|
|
62
|
+
'backup.status.processing': 'in elaborazione',
|
|
63
|
+
'backup.status.finished': 'completato',
|
|
64
|
+
'modal.title': 'Crea Backup',
|
|
65
|
+
'modal.description': 'Questa azione genererà un nuovo backup. Questo processo potrebbe richiedere del tempo.',
|
|
66
|
+
'modal.button.close': 'Chiudi',
|
|
67
|
+
'modal.title.info': 'Informazioni sul Backup',
|
|
68
|
+
'modal.restore.title': 'Conferma Ripristino',
|
|
69
|
+
'modal.restore.message.corpus': 'Questo corpus è già presente sulla piattaforma. Tutti i dati verranno sovrascritti.',
|
|
70
|
+
'modal.restore.message.lexicon': 'Questo lessico è già presente sulla piattaforma. Tutti i dati verranno sovrascritti.',
|
|
71
|
+
'modal.restore.message.parser': 'Questo parser è già presente sulla piattaforma. Tutti i dati verranno sovrascritti.',
|
|
72
|
+
'modal.restore.confirm': 'Sei sicuro di voler continuare? Questa azione è irreversibile.',
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AccessMode } from '../../../configs/types/Access';
|
|
2
|
+
import Backup from '../types/Backup';
|
|
3
|
+
import './style.scss';
|
|
4
|
+
type Props = {
|
|
5
|
+
mode: AccessMode;
|
|
6
|
+
resourceUid: string;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onConfirm: (b: Backup) => void;
|
|
9
|
+
};
|
|
10
|
+
export default function BackupCreate({ mode, resourceUid, onClose, onConfirm, }: Props): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { useMessageUtils } from '../../../configs/useMessageUtils';
|
|
4
|
+
import AppModalConfirm from '../../../common/AppModal/AppModalConfirm';
|
|
5
|
+
import BackupService from '../BackupService';
|
|
6
|
+
import './style.scss';
|
|
7
|
+
export default function BackupCreate({ mode, resourceUid, onClose, onConfirm, }) {
|
|
8
|
+
const { t } = useTranslation('backup');
|
|
9
|
+
const { isLoading, dispatchLoading, dispatchError } = useMessageUtils();
|
|
10
|
+
const handleConfirm = () => {
|
|
11
|
+
if (isLoading() || !resourceUid)
|
|
12
|
+
return;
|
|
13
|
+
dispatchLoading(true);
|
|
14
|
+
BackupService.execute(mode, resourceUid)
|
|
15
|
+
.then((r) => {
|
|
16
|
+
onConfirm(r.data);
|
|
17
|
+
})
|
|
18
|
+
.catch((err) => {
|
|
19
|
+
dispatchError({ err, t });
|
|
20
|
+
})
|
|
21
|
+
.finally(() => {
|
|
22
|
+
dispatchLoading(false);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
return (_jsx(AppModalConfirm, { title: t('modal.title'), subtitle: t('modal.description'), onClose: onClose, onConfirm: handleConfirm }));
|
|
26
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import AppFormInfo from '../../../common/AppForm/AppFormInfo';
|
|
5
|
+
import AppModal from '../../../common/AppModal';
|
|
6
|
+
import DateUtils from '../../../functions/DateUtils';
|
|
7
|
+
import './style.scss';
|
|
8
|
+
export default function BackupInfo({ backup, onClose }) {
|
|
9
|
+
const { t } = useTranslation('backup');
|
|
10
|
+
const fields = useMemo(() => getBackupInfoFields(t), [t]);
|
|
11
|
+
return (_jsxs(AppModal, { title: t('modal.title.info'), className: "modal-metadata", close: onClose, closeLabel: t('modal.button.close'), children: [_jsx(AppFormInfo, { fields: fields, data: backup }), _jsxs("div", { className: "item item-log", children: [_jsx("span", { className: "label", children: t('backup.label.log') }), _jsx("div", { className: "pre-like", children: backup.log })] })] }));
|
|
12
|
+
}
|
|
13
|
+
const getBackupInfoFields = (t) => [
|
|
14
|
+
{
|
|
15
|
+
attr: 'filename',
|
|
16
|
+
name: t('backup.field.filename'),
|
|
17
|
+
type: 'display',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
attr: 'status',
|
|
21
|
+
name: t('backup.field.status'),
|
|
22
|
+
type: 'display',
|
|
23
|
+
fn: (status) => t(`backup.status.${status?.toLowerCase()}`),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
attr: 'user.name',
|
|
27
|
+
name: t('backup.field.user.name'),
|
|
28
|
+
type: 'display',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
attr: 'id',
|
|
32
|
+
name: t('backup.field.id'),
|
|
33
|
+
type: 'function',
|
|
34
|
+
fn: (id) => DateUtils.extractDateFromMongoId(id, true),
|
|
35
|
+
},
|
|
36
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.modal-metadata {
|
|
2
|
+
width: 50vw;
|
|
3
|
+
max-width: 50vw;
|
|
4
|
+
|
|
5
|
+
.body {
|
|
6
|
+
.item {
|
|
7
|
+
.label {
|
|
8
|
+
@include label-medium-2;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.item-log {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
gap: 8px;
|
|
16
|
+
margin-top: 16px;
|
|
17
|
+
|
|
18
|
+
.pre-like {
|
|
19
|
+
height: 200px;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AccessMode } from '../../../configs/types/Access';
|
|
2
|
+
import './style.scss';
|
|
3
|
+
export type BackupRestoreProps = {
|
|
4
|
+
mode: AccessMode;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
};
|
|
7
|
+
export default function BackupRestore({ mode, onClose }: BackupRestoreProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import AppDropzone from '../../../common/AppDropzone';
|
|
5
|
+
import AppModal from '../../../common/AppModal';
|
|
6
|
+
import { useMessageUtils } from '../../../configs/useMessageUtils';
|
|
7
|
+
import BackupService from '../BackupService';
|
|
8
|
+
import './style.scss';
|
|
9
|
+
export default function BackupRestore({ mode, onClose }) {
|
|
10
|
+
const { t } = useTranslation('backup');
|
|
11
|
+
const { isLoading, dispatchLoading, dispatchError } = useMessageUtils();
|
|
12
|
+
const [openExists, setOpenExists] = useState(false);
|
|
13
|
+
const [backup, setBackup] = useState();
|
|
14
|
+
const handleSuccess = (uploaded) => {
|
|
15
|
+
BackupService.restore(mode, uploaded)
|
|
16
|
+
.then((r) => {
|
|
17
|
+
setBackup(r.data);
|
|
18
|
+
if (r.data.message === 'corpus.exists') {
|
|
19
|
+
setOpenExists(true);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
handleExecute(r.data.id);
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
.catch((err) => {
|
|
26
|
+
dispatchError({ err, t });
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const handleExecute = (id) => {
|
|
30
|
+
if (isLoading())
|
|
31
|
+
return;
|
|
32
|
+
dispatchLoading(true);
|
|
33
|
+
BackupService.executeRestore(id)
|
|
34
|
+
.then(() => {
|
|
35
|
+
location.reload();
|
|
36
|
+
})
|
|
37
|
+
.catch((err) => {
|
|
38
|
+
dispatchError({ err, t });
|
|
39
|
+
})
|
|
40
|
+
.finally(() => {
|
|
41
|
+
dispatchLoading(false);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const handleError = () => {
|
|
45
|
+
dispatchError({ err: 'message:upload.error', t });
|
|
46
|
+
};
|
|
47
|
+
return (_jsxs(_Fragment, { children: [_jsx(AppDropzone, { folder: "/restore", onSuccess: handleSuccess, onError: handleError, onClose: onClose, keepName: true, accept: {
|
|
48
|
+
'application/gzip': ['.gz'],
|
|
49
|
+
'application/x-tar': ['.tar'],
|
|
50
|
+
'application/x-compressed-tar': ['.tar.gz'],
|
|
51
|
+
} }), openExists && (_jsx(AppModal, { title: t('modal.restore.title'), className: "modal-parameter", confirm: () => backup && handleExecute(backup.id), close: () => setOpenExists(false), children: _jsx("div", { className: "alert alert-danger m-b-0", children: _jsxs("p", { children: [_jsx("span", { children: t(`modal.restore.message.${mode}`) }), _jsx("b", { className: "ms-1", children: t('modal.restore.confirm') })] }) }) }))] }));
|
|
52
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AccessMode } from '../../configs/types/Access';
|
|
2
|
+
import { AppPage } from '../../common';
|
|
3
|
+
import { UploadedFile } from '../../common/AppDropzone/UploadedFile';
|
|
4
|
+
import { BackupSearchFilter } from './BackupTable/BackupSearchFilter';
|
|
5
|
+
import Backup from './types/Backup';
|
|
6
|
+
declare function page(mode: AccessMode, resourceUid: string, filter: BackupSearchFilter): Promise<import("axios").AxiosResponse<AppPage<Backup>, any, {}, any>>;
|
|
7
|
+
declare function execute(mode: AccessMode, resourceUid: string): Promise<import("axios").AxiosResponse<Backup, any, {}, any>>;
|
|
8
|
+
declare function restore(mode: AccessMode, uploaded: UploadedFile): Promise<import("axios").AxiosResponse<Backup, any, {}, any>>;
|
|
9
|
+
declare function executeRestore(id: string): Promise<import("axios").AxiosResponse<Backup, any, {}, any>>;
|
|
10
|
+
declare function download(id: string): Promise<import("axios").AxiosResponse<string, any, {}, any>>;
|
|
11
|
+
declare const BackupService: {
|
|
12
|
+
page: typeof page;
|
|
13
|
+
execute: typeof execute;
|
|
14
|
+
download: typeof download;
|
|
15
|
+
restore: typeof restore;
|
|
16
|
+
executeRestore: typeof executeRestore;
|
|
17
|
+
};
|
|
18
|
+
export default BackupService;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import api from '../../configs/api';
|
|
2
|
+
import { convertPageable } from '../../common';
|
|
3
|
+
const FUNCTIONS_API = () => import.meta.env.VITE_APP_FUNCTIONS_API;
|
|
4
|
+
const APP_BY_MODE = {
|
|
5
|
+
corpus: 'CORPUS',
|
|
6
|
+
parser: 'PARSER',
|
|
7
|
+
lexicon: 'LEXICON',
|
|
8
|
+
};
|
|
9
|
+
function page(mode, resourceUid, filter) {
|
|
10
|
+
const data = {
|
|
11
|
+
id: resourceUid,
|
|
12
|
+
app: APP_BY_MODE[mode],
|
|
13
|
+
...convertPageable(filter),
|
|
14
|
+
};
|
|
15
|
+
return api.post(`${FUNCTIONS_API()}/backup`, data);
|
|
16
|
+
}
|
|
17
|
+
function execute(mode, resourceUid) {
|
|
18
|
+
return api.get(`${FUNCTIONS_API()}/backup/${resourceUid}/${APP_BY_MODE[mode]}`);
|
|
19
|
+
}
|
|
20
|
+
function restore(mode, uploaded) {
|
|
21
|
+
return api.post(`${FUNCTIONS_API()}/backup/restore`, {
|
|
22
|
+
filename: uploaded.path,
|
|
23
|
+
app: APP_BY_MODE[mode],
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function executeRestore(id) {
|
|
27
|
+
return api.post(`${FUNCTIONS_API()}/backup/restore/${id}`);
|
|
28
|
+
}
|
|
29
|
+
function download(id) {
|
|
30
|
+
return api.get(`${FUNCTIONS_API()}/backup/download/${id}`);
|
|
31
|
+
}
|
|
32
|
+
const BackupService = {
|
|
33
|
+
page,
|
|
34
|
+
execute,
|
|
35
|
+
download,
|
|
36
|
+
restore,
|
|
37
|
+
executeRestore,
|
|
38
|
+
};
|
|
39
|
+
export default BackupService;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AccessMode } from '../../../configs/types/Access';
|
|
3
|
+
import './style.scss';
|
|
4
|
+
export type BackupTableProps = {
|
|
5
|
+
mode: AccessMode;
|
|
6
|
+
resourceUid: string;
|
|
7
|
+
};
|
|
8
|
+
export default function BackupTable({ mode, resourceUid }: BackupTableProps): React.JSX.Element;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import AppCard from '../../../common/AppCard/AppCard';
|
|
5
|
+
import AppPicture from '../../../common/AppPicture';
|
|
6
|
+
import AppPlaceholder from '../../../common/AppPlaceholder';
|
|
7
|
+
import AppTable from '../../../common/AppTable';
|
|
8
|
+
import { EMPTY_PAGE } from '../../../common/AppTable/types/AppPage';
|
|
9
|
+
import DateUtils from '../../../functions/DateUtils';
|
|
10
|
+
import { Button } from '../../../primitives';
|
|
11
|
+
import BackupCreate from '../BackupCreate';
|
|
12
|
+
import BackupInfo from '../BackupInfo';
|
|
13
|
+
import BackupService from '../BackupService';
|
|
14
|
+
import { EMPTY_BACKUP_SEARCH_FILTER, } from './BackupSearchFilter';
|
|
15
|
+
import './style.scss';
|
|
16
|
+
export default function BackupTable({ mode, resourceUid }) {
|
|
17
|
+
const { t } = useTranslation('backup');
|
|
18
|
+
const [filter, setFilter] = useState(EMPTY_BACKUP_SEARCH_FILTER);
|
|
19
|
+
const [data, setData] = useState();
|
|
20
|
+
const [selected, setSelected] = useState();
|
|
21
|
+
const [openInfo, setOpenInfo] = useState(false);
|
|
22
|
+
const [openCreate, setOpenCreate] = useState(false);
|
|
23
|
+
const load = () => {
|
|
24
|
+
if (!resourceUid)
|
|
25
|
+
return;
|
|
26
|
+
BackupService.page(mode, resourceUid, filter).then((r) => {
|
|
27
|
+
setData(r.data);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const onClickRow = (row) => {
|
|
31
|
+
setSelected(row);
|
|
32
|
+
setOpenInfo(true);
|
|
33
|
+
};
|
|
34
|
+
const handleCreate = () => {
|
|
35
|
+
setSelected(undefined);
|
|
36
|
+
setOpenCreate(true);
|
|
37
|
+
};
|
|
38
|
+
const onConfirm = (backup) => {
|
|
39
|
+
const updatedData = {
|
|
40
|
+
...(data || EMPTY_PAGE),
|
|
41
|
+
totalElements: (data?.totalElements ?? 0) + 1,
|
|
42
|
+
content: [backup, ...(data?.content ?? [])],
|
|
43
|
+
};
|
|
44
|
+
setData(updatedData);
|
|
45
|
+
setOpenCreate(false);
|
|
46
|
+
};
|
|
47
|
+
const handleDownload = (fileUrl) => {
|
|
48
|
+
if (!resourceUid)
|
|
49
|
+
return;
|
|
50
|
+
BackupService.download(resourceUid).then((r) => {
|
|
51
|
+
const filename = fileUrl.split('/').pop();
|
|
52
|
+
if (!filename) {
|
|
53
|
+
console.error('Invalid file URL');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const secureUrl = `${fileUrl}?token=${encodeURIComponent(r.data)}`;
|
|
57
|
+
window.open(secureUrl, '_blank');
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
const menuOptions = [
|
|
61
|
+
{
|
|
62
|
+
icon: 'add',
|
|
63
|
+
label: t('button.create'),
|
|
64
|
+
onClick: handleCreate,
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
const addDownloadButtonToCell = (props) => {
|
|
68
|
+
return (_jsx(Button, { text: t('backup.field.download'), size: "x-small", onClick: (e) => {
|
|
69
|
+
e.stopPropagation();
|
|
70
|
+
handleDownload(props.row.original.path);
|
|
71
|
+
} }));
|
|
72
|
+
};
|
|
73
|
+
const addDateToCell = (props) => {
|
|
74
|
+
return (_jsx("span", { children: DateUtils.extractDateFromMongoId(props.row.original.id, true) }));
|
|
75
|
+
};
|
|
76
|
+
const addUserToCell = (props) => {
|
|
77
|
+
const user = props.row.original.user;
|
|
78
|
+
return (_jsxs("div", { className: "user", children: [_jsx(AppPicture, { className: "avatar", src: user.picture, person: true }), _jsx("span", { className: "ms-2", children: user.name })] }));
|
|
79
|
+
};
|
|
80
|
+
const columns = React.useMemo(() => [
|
|
81
|
+
{
|
|
82
|
+
id: 'date',
|
|
83
|
+
header: t('backup.field.id'),
|
|
84
|
+
cell: addDateToCell,
|
|
85
|
+
size: 20,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 'filename',
|
|
89
|
+
header: t('backup.field.filename'),
|
|
90
|
+
accessorKey: 'filename',
|
|
91
|
+
size: 45,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 'user',
|
|
95
|
+
header: t('backup.field.user.name'),
|
|
96
|
+
cell: addUserToCell,
|
|
97
|
+
size: 25,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: 'status',
|
|
101
|
+
header: t('backup.field.status'),
|
|
102
|
+
accessorKey: 'status',
|
|
103
|
+
cell: (props) => t(`backup.status.${props.row.original.status.toLowerCase()}`),
|
|
104
|
+
size: 10,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: 'download',
|
|
108
|
+
header: t('backup.field.download'),
|
|
109
|
+
cell: addDownloadButtonToCell,
|
|
110
|
+
size: 10,
|
|
111
|
+
},
|
|
112
|
+
], [data, t]);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
load();
|
|
115
|
+
}, [filter, resourceUid, mode]);
|
|
116
|
+
return (_jsxs(AppCard, { title: t('label.title'), className: "base-card backup-table-card", dataTour: "admin-info-backups-panel", options: menuOptions, children: [data && data.totalElements !== 0 && (_jsx(AppTable, { columns: columns, data: data, onClickRow: onClickRow, pagination: { pageIndex: filter.page, pageSize: filter.size }, setPagination: (p) => {
|
|
117
|
+
setFilter({ ...filter, page: p.pageIndex, size: p.pageSize });
|
|
118
|
+
}, sorting: filter.sort || [], setSorting: (s) => {
|
|
119
|
+
setFilter({ ...filter, sort: s });
|
|
120
|
+
} })), data && data.totalElements === 0 && (_jsx(AppPlaceholder, { text: t('placeholder.empty') })), openInfo && selected && (_jsx(BackupInfo, { backup: selected, onClose: () => setOpenInfo(false) })), openCreate && (_jsx(BackupCreate, { mode: mode, resourceUid: resourceUid, onClose: () => setOpenCreate(false), onConfirm: onConfirm }))] }));
|
|
121
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as BackupTable } from './BackupTable';
|
|
2
|
+
export type { BackupTableProps } from './BackupTable';
|
|
3
|
+
export { EMPTY_BACKUP_SEARCH_FILTER, type BackupSearchFilter, } from './BackupTable';
|
|
4
|
+
export { default as BackupRestore } from './BackupRestore';
|
|
5
|
+
export type { BackupRestoreProps } from './BackupRestore';
|
|
6
|
+
export { default as BackupService } from './BackupService';
|
|
7
|
+
export type { Backup, BackupStatus } from './types/Backup';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { User } from '../../../configs/types/User';
|
|
2
|
+
export type BackupStatus = 'ERROR' | 'PROCESSING' | 'FINISHED';
|
|
3
|
+
export type Backup = {
|
|
4
|
+
id: string;
|
|
5
|
+
log: string;
|
|
6
|
+
ref: string;
|
|
7
|
+
filename: string;
|
|
8
|
+
user: User;
|
|
9
|
+
status: BackupStatus;
|
|
10
|
+
app: string;
|
|
11
|
+
message: string;
|
|
12
|
+
path: string;
|
|
13
|
+
};
|
|
14
|
+
export default Backup;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/features/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { default as CommentComponent } from "./Comments";
|
|
|
2
2
|
export { default as HeaderNotifications } from "./Comments/HeaderNotifications";
|
|
3
3
|
export type { Comment, CommentRequest } from "./Comments/types/Comment";
|
|
4
4
|
export { default as CommentService } from "./Comments/CommentService";
|
|
5
|
+
export { BackupTable, BackupRestore, BackupService, EMPTY_BACKUP_SEARCH_FILTER, } from "./Backup";
|
|
6
|
+
export type { Backup, BackupStatus, BackupTableProps, BackupRestoreProps, BackupSearchFilter, } from "./Backup";
|
|
5
7
|
export { AccessUsers, AccessUser, AccessGrant, AccessControlService, EMPTY_ACCESS_SEARCH_FILTER, EMPTY_PORTAL, PortalRoleName, } from "./AccessControl";
|
|
6
8
|
export type { AccessUsersProps, AccessUsersFilter, AccessResponse, UserAccessRequest, UserAccessResponse, PortalInformation, PortalInformationRequest, PortalRole, } from "./AccessControl";
|
|
7
9
|
export { CorpusOwner } from "./CorpusOwner";
|
package/dist/features/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as CommentComponent } from "./Comments";
|
|
2
2
|
export { default as HeaderNotifications } from "./Comments/HeaderNotifications";
|
|
3
3
|
export { default as CommentService } from "./Comments/CommentService";
|
|
4
|
+
export { BackupTable, BackupRestore, BackupService, EMPTY_BACKUP_SEARCH_FILTER, } from "./Backup";
|
|
4
5
|
export { AccessUsers, AccessUser, AccessGrant, AccessControlService, EMPTY_ACCESS_SEARCH_FILTER, EMPTY_PORTAL, PortalRoleName, } from "./AccessControl";
|
|
5
6
|
export { CorpusOwner } from "./CorpusOwner";
|
|
6
7
|
export { default as SentenceView } from "./SentenceView";
|