Revize 99a58334
Přidáno uživatelem Jaroslav Hrubý před asi 2 roky(ů)
webapp/pages/documents/admin/index.tsx | ||
---|---|---|
3 | 3 |
|
4 | 4 |
import { useUnauthRedirect } from '../../../hooks'; |
5 | 5 |
import { useRouter } from 'next/router'; |
6 |
import { Button, Row, Space, Table, Tag, Typography, Input } from 'antd';
|
|
7 |
import { faFileLines, faUser } from '@fortawesome/free-solid-svg-icons'; |
|
6 |
import { Button, Input, Row, Space, Table, Tag, Typography } from 'antd';
|
|
7 |
import { faArrowsRotate, faFileLines, faUser } from '@fortawesome/free-solid-svg-icons';
|
|
8 | 8 |
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
9 | 9 |
import { LoggedUserContext } from '../../../contexts/LoggedUserContext'; |
10 | 10 |
import { MainLayout } from '../../../layouts/MainLayout'; |
11 | 11 |
import AddDocumentModal from '../../../components/modals/AddDocumentModal'; |
12 | 12 |
import { |
13 |
DeleteDocumentsRequest, |
|
13 | 14 |
DocumentListInfo, |
14 | 15 |
DocumentListResponse, |
15 | 16 |
DocumentUserInfo, |
16 | 17 |
EState, |
18 |
ExportRequest, |
|
17 | 19 |
} from '../../../api'; |
18 | 20 |
import { documentController, userController } from '../../../controllers'; |
19 | 21 |
import AssignDocumentModal from '../../../components/modals/AssignDocumentModal'; |
20 |
import { ShowConfirm, ShowToast } from '../../../utils/alerts'; |
|
22 |
import { ShowConfirm, ShowConfirmDelete, ShowToast } from '../../../utils/alerts';
|
|
21 | 23 |
import { TableDocInfo } from '../../../components/types/TableDocInfo'; |
22 | 24 |
import { |
23 | 25 |
getAnnotationStateColor, |
... | ... | |
32 | 34 |
import { getColumnSearchProps, getLocaleProps } from '../../../utils/tableUtils'; |
33 | 35 |
import { SweetAlertIcon } from 'sweetalert2'; |
34 | 36 |
import { Stack } from 'react-bootstrap'; |
35 |
import { AxiosRequestConfig } from 'axios'; |
|
36 |
import { constants } from 'http2'; |
|
37 |
import HTTP_STATUS_ACCEPTED = module; |
|
38 |
import HTTP_STATUS_OK = module; |
|
39 |
|
|
40 |
import { faArrowsRotate } from '@fortawesome/free-solid-svg-icons'; |
|
41 | 37 |
|
42 | 38 |
import { faCircleCheck, faClock } from '@fortawesome/free-regular-svg-icons'; |
43 | 39 |
import styles from '/styles/Icon.module.scss'; |
... | ... | |
71 | 67 |
// @ts-ignore |
72 | 68 |
const filters: UserFilter[] = users?.map((user) => { |
73 | 69 |
return { |
74 |
text: user.name + ' ' + user.surname,
|
|
70 |
text: user.surname + ' ' + user.name,
|
|
75 | 71 |
value: user.username, |
76 | 72 |
}; |
77 | 73 |
}); |
... | ... | |
228 | 224 |
} |
229 | 225 |
}; |
230 | 226 |
|
227 |
const deleteDocuments = () => { |
|
228 |
const req: DeleteDocumentsRequest = { documentIds: selectedDocs }; |
|
229 |
|
|
230 |
ShowConfirmDelete(() => { |
|
231 |
documentController.documentsDelete(req).then(() => { |
|
232 |
ShowToast('Dokumenty byly úspěšně odstraněny'); |
|
233 |
fetchData(); |
|
234 |
}); |
|
235 |
}, 'dokumenty'); |
|
236 |
}; |
|
237 |
|
|
238 |
const exportDocuments = () => { |
|
239 |
const req: ExportRequest = { documentIds: selectedDocs }; |
|
240 |
documentController.documentsExportPost(req); |
|
241 |
}; |
|
242 |
|
|
231 | 243 |
const changeDefaultAnotationCount = (e: FocusEvent<HTMLInputElement>) => { |
232 | 244 |
documentController.documentsRequiredAnnotationsGlobalPost({ |
233 | 245 |
requiredAnnotations: parseInt(e.currentTarget.value), |
... | ... | |
516 | 528 |
flexDirection: 'row', |
517 | 529 |
justifyContent: 'flex-start', |
518 | 530 |
gap: '20px', |
531 |
marginBottom: '20px', |
|
519 | 532 |
}} |
520 | 533 |
> |
521 | 534 |
<Button type={'primary'} onClick={showAddModal}> |
522 | 535 |
Nahrát dokument |
523 | 536 |
</Button> |
524 | 537 |
|
538 |
<Button |
|
539 |
danger |
|
540 |
disabled={!(selectedDocs?.length > 0)} |
|
541 |
onClick={() => deleteDocuments()} |
|
542 |
> |
|
543 |
Smazat dokumenty |
|
544 |
</Button> |
|
545 |
|
|
546 |
<Button |
|
547 |
disabled={!(selectedDocs?.length > 0)} |
|
548 |
onClick={() => exportDocuments()} |
|
549 |
> |
|
550 |
Export |
|
551 |
</Button> |
|
552 |
|
|
525 | 553 |
<div> |
526 | 554 |
<Button |
527 | 555 |
onClick={showAssignModal} |
... | ... | |
568 | 596 |
columns={columns} |
569 | 597 |
dataSource={documents} |
570 | 598 |
size="middle" |
571 |
scroll={{ y: 600 }} |
|
599 |
scroll={{ y: 'calc(65vh - 4em)' }} |
|
600 |
pagination={false} |
|
572 | 601 |
/> |
573 | 602 |
</MainLayout> |
574 | 603 |
); |
Také k dispozici: Unified diff
Tables - scroll instead pagination, export and delete buttons