Projekt

Obecné

Profil

Stáhnout (22.9 KB) Statistiky
| Větev: | Tag: | Revize:
1 8c45ccb0 hrubyjar
import 'antd/dist/antd.css';
2 3396af93 Dominik Poch
import React, { FocusEvent, useContext, useEffect, useState } from 'react';
3 8c45ccb0 hrubyjar
4
import { useUnauthRedirect } from '../../../hooks';
5
import { useRouter } from 'next/router';
6 937bfbee Jaroslav Hrubý
import { Button, Dropdown, Input, Menu, Row, Space, Table, Tag, Typography } from 'antd';
7 99a58334 Jaroslav Hrubý
import { faArrowsRotate, faFileLines, faUser } from '@fortawesome/free-solid-svg-icons';
8 8c45ccb0 hrubyjar
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9
import { LoggedUserContext } from '../../../contexts/LoggedUserContext';
10 bae9fbba Jaroslav Hrubý
import { MainLayout } from '../../../layouts/MainLayout';
11 4a7bae81 Jaroslav Hrubý
import AddDocumentModal from '../../../components/modals/AddDocumentModal';
12 ff61085f Lukáš Vlček
import {
13 99a58334 Jaroslav Hrubý
    DeleteDocumentsRequest,
14 ff61085f Lukáš Vlček
    DocumentListInfo,
15 87a3d8d1 Lukáš Vlček
    DocumentListResponse,
16 ff61085f Lukáš Vlček
    DocumentUserInfo,
17
    EState,
18 99a58334 Jaroslav Hrubý
    ExportRequest,
19 ff61085f Lukáš Vlček
} from '../../../api';
20 c6109e2d Lukáš Vlček
import { documentController, userController } from '../../../controllers';
21 9bfa1e39 Jaroslav Hrubý
import AssignDocumentModal from '../../../components/modals/AssignDocumentModal';
22 99a58334 Jaroslav Hrubý
import { ShowConfirm, ShowConfirmDelete, ShowToast } from '../../../utils/alerts';
23 43d49a98 Jaroslav Hrubý
import { TableDocInfo } from '../../../components/types/TableDocInfo';
24 ff61085f Lukáš Vlček
import {
25
    getAnnotationStateColor,
26 c4f198c3 Jaroslav Hrubý
    getAnnotationStateString,
27 ff61085f Lukáš Vlček
    getNameTruncated,
28
    getUserInfoAlt,
29
} from '../../../utils/strings';
30 87a3d8d1 Lukáš Vlček
import { ABadge, BadgeStyle } from '../../../components/common/ABadge';
31 e7eca311 Lukáš Vlček
import SetRequiredAnnotationsCountModal from '../../../components/modals/SetRequiredAnnotationsCountModal';
32 d7167305 Jaroslav Hrubý
import DocPreviewModal from '../../../components/modals/DocPreviewModal';
33 0db53e25 Jaroslav Hrubý
import { UserFilter } from '../../../components/types/UserFilter';
34 669ffe38 Jaroslav Hrubý
import { getColumnSearchProps, getLocaleProps } from '../../../utils/tableUtils';
35 c4f198c3 Jaroslav Hrubý
import { SweetAlertIcon } from 'sweetalert2';
36 3396af93 Dominik Poch
import { Stack } from 'react-bootstrap';
37 fa93df26 Dominik Poch
38
import { faCircleCheck, faClock } from '@fortawesome/free-regular-svg-icons';
39
import styles from '/styles/Icon.module.scss';
40 937bfbee Jaroslav Hrubý
import { FileSearchOutlined, UserDeleteOutlined } from '@ant-design/icons';
41 fa93df26 Dominik Poch
42 8c45ccb0 hrubyjar
function AdminDocumentPage() {
43
    const redirecting = useUnauthRedirect('/login');
44
    const { logout, role } = useContext(LoggedUserContext);
45 c4f198c3 Jaroslav Hrubý
    const [finalizing, setFinalizing] = React.useState(false);
46 9bfa1e39 Jaroslav Hrubý
    const [visibleAdd, setVisibleAdd] = React.useState(false);
47
    const [visibleAssign, setVisibleAssign] = React.useState(false);
48 d7167305 Jaroslav Hrubý
    const [visiblePreview, setVisiblePreview] = React.useState(false);
49 e7eca311 Lukáš Vlček
    const [visibleSetCount, setVisibleSetCount] = React.useState(false);
50
51 8c45ccb0 hrubyjar
    const router = useRouter();
52
53 43d49a98 Jaroslav Hrubý
    const [documents, setDocuments] = useState<TableDocInfo[]>([]);
54 0db53e25 Jaroslav Hrubý
    const [userFilters, setUserFilters] = useState<UserFilter[]>([]);
55 cca0bfa0 Lukáš Vlček
    const [selectedDocs, setSelectedDocs] = useState<string[]>([]);
56 db3fa00e Jaroslav Hrubý
    const [selectedRows, setSelectedRows] = useState([]);
57 d7167305 Jaroslav Hrubý
    const [previewDocContent, setPreviewDocContent] = useState<string>();
58
    const [previewDocName, setPreviewDocName] = useState<string>();
59 3396af93 Dominik Poch
    const [annotationCount, setAnnotationCount] = useState<number>();
60 c6109e2d Lukáš Vlček
61 43d49a98 Jaroslav Hrubý
    async function fetchData() {
62 ef5792a8 Lukáš Vlček
        const docs = (await documentController.documentsGet()).data.documents;
63 43d49a98 Jaroslav Hrubý
        // @ts-ignore
64
        const tableDocs: TableDocInfo[] = docs?.map((doc, index) => {
65
            return { key: index, ...doc };
66
        });
67 9bfa1e39 Jaroslav Hrubý
68 0db53e25 Jaroslav Hrubý
        const users = (await userController.usersGet()).data.users;
69
        // @ts-ignore
70
        const filters: UserFilter[] = users?.map((user) => {
71
            return {
72 99a58334 Jaroslav Hrubý
                text: user.surname + ' ' + user.name,
73 0db53e25 Jaroslav Hrubý
                value: user.username,
74
            };
75
        });
76
        setUserFilters(filters);
77
78 3396af93 Dominik Poch
        let annotationCountRes =
79
            await documentController.documentsRequiredAnnotationsGlobalGet();
80
        setAnnotationCount(annotationCountRes.data.requiredAnnotationsGlobal);
81
82 43d49a98 Jaroslav Hrubý
        if (!docs) {
83
            setDocuments([]);
84
        } else {
85
            setDocuments(tableDocs);
86 c6109e2d Lukáš Vlček
        }
87 43d49a98 Jaroslav Hrubý
    }
88 c6109e2d Lukáš Vlček
89 43d49a98 Jaroslav Hrubý
    useEffect(() => {
90 06d1aa21 Jaroslav Hrubý
        if (!redirecting && role === 'ADMINISTRATOR') {
91 c6109e2d Lukáš Vlček
            fetchData();
92 8c45ccb0 hrubyjar
        }
93
    }, [logout, redirecting, role, router]);
94
95 c4f198c3 Jaroslav Hrubý
    const finalizeDocumentConfirm = async (
96
        document: DocumentListInfo,
97
        recreate: boolean
98
    ) => {
99
        let desc = recreate ? 'Dosavadní změny finální verze budou smazány' : '';
100
        let icon: SweetAlertIcon = recreate ? 'warning' : 'question';
101
102
        const doneAnnotations = document.annotatingUsers?.filter(
103
            (usr) => usr.state === EState.Done
104
        ).length;
105
106
        if (
107
            doneAnnotations !== undefined &&
108
            document.requiredAnnotations !== undefined &&
109
            doneAnnotations < document.requiredAnnotations
110
        ) {
111
            icon = 'warning';
112
            desc =
113
                'Není dokončen požadovaný počet anotací <br /> (dokončeno ' +
114
                doneAnnotations +
115
                ' z ' +
116
                document.requiredAnnotations +
117
                ')';
118
        }
119
        recreate
120
            ? ShowConfirm(
121
                  () => finalizeDocument(document.id),
122
                  'vytvořit novou finální verzi dokumentu',
123
                  desc,
124
                  icon
125
              )
126
            : ShowConfirm(
127
                  () => finalizeDocument(document.id),
128
                  'vytvořit finální verzi dokumentu',
129
                  desc,
130
                  icon
131
              );
132
    };
133
134
    const finalizeDocument = async (documentId: string | undefined) => {
135
        setFinalizing(true);
136
        const finalAnnotationId = (
137
            await documentController.documentDocumentIdFinalPost(
138
                documentId ? documentId : ''
139
            )
140
        ).data.finalAnnotationId;
141
        if (!finalAnnotationId) {
142
            ShowToast('Finální verzi se nepovedlo vytvořit', 'error');
143
        } else {
144
            router.push({
145
                pathname: '/annotation/[annotationId]',
146
                query: { annotationId: finalAnnotationId, final: true },
147
            });
148
        }
149
        setFinalizing(false);
150
    };
151
152
    const editFinalizedDocument = async (finalAnnotationId: string) => {
153
        setFinalizing(true);
154
        if (!finalAnnotationId) {
155
            ShowToast('Finální verze dosud neexistuje', 'warning');
156
        } else {
157
            router.push({
158
                pathname: '/annotation/[annotationId]',
159
                query: { annotationId: finalAnnotationId, final: true },
160
            });
161
        }
162
        setFinalizing(false);
163
    };
164
165 ef5792a8 Lukáš Vlček
    async function removeUserFromDocument(documentID: string, annotatorID: string) {
166
        const res =
167
            await documentController.documentsDocumentIdAnnotatorsAnnotatorIdDelete(
168
                documentID,
169
                annotatorID
170
            );
171
172
        if (res.status === 200) {
173
            ShowToast('Uživatel byl úspěšně odebrán z dokumentu');
174
        }
175
        await fetchData();
176
    }
177
178 c4f198c3 Jaroslav Hrubý
    const getFinalizationStateIcon = (state: EState) => {
179
        const color = getAnnotationStateColor(state);
180
        const label = getAnnotationStateString(state);
181 fa93df26 Dominik Poch
        let icon = <FontAwesomeIcon icon={faCircleCheck} className={styles.iconLeft} />;
182 c4f198c3 Jaroslav Hrubý
        if (state === 'NEW') {
183 fa93df26 Dominik Poch
            icon = <FontAwesomeIcon icon={faClock} className={styles.iconLeft} />;
184 c4f198c3 Jaroslav Hrubý
        }
185
        if (state === 'IN_PROGRESS') {
186 fa93df26 Dominik Poch
            icon = <FontAwesomeIcon icon={faArrowsRotate} className={styles.iconLeft} />;
187 c4f198c3 Jaroslav Hrubý
        }
188
189
        return (
190
            <Tag icon={icon} color={color} key={label}>
191
                {label.toUpperCase()}
192
            </Tag>
193
        );
194
    };
195
196 9bfa1e39 Jaroslav Hrubý
    const showAssignModal = () => {
197
        if (selectedDocs.length == 0) {
198
            ShowToast('Vyberte dokument pro přiřazení', 'warning', 3000, 'top-end');
199
        } else {
200
            setVisibleAssign(true);
201
        }
202
    };
203 e7eca311 Lukáš Vlček
    const showRequiredAnnotationsCountModal = () => {
204
        if (selectedDocs.length == 0) {
205
            ShowToast(
206
                'Vyberte dokument, pro které chcete nastavit požadovaný počet anotací',
207
                'warning',
208
                3000,
209
                'top-end'
210
            );
211
        } else {
212
            setVisibleSetCount(true);
213
        }
214
    };
215 9bfa1e39 Jaroslav Hrubý
    const showAddModal = () => {
216
        setVisibleAdd(true);
217 4a7bae81 Jaroslav Hrubý
    };
218
219 d7167305 Jaroslav Hrubý
    const showPreviewModal = async (id: string, name: string) => {
220
        const documentContent = (await documentController.documentDocumentIdGet(id)).data
221
            .content;
222 e97b42bc Jaroslav Hrubý
        if (documentContent) {
223
            setPreviewDocName(name);
224
            setPreviewDocContent(documentContent);
225
            setVisiblePreview(true);
226
        }
227 d7167305 Jaroslav Hrubý
    };
228
229 99a58334 Jaroslav Hrubý
    const deleteDocuments = () => {
230
        const req: DeleteDocumentsRequest = { documentIds: selectedDocs };
231
232
        ShowConfirmDelete(() => {
233
            documentController.documentsDelete(req).then(() => {
234
                ShowToast('Dokumenty byly úspěšně odstraněny');
235
                fetchData();
236 db3fa00e Jaroslav Hrubý
                clearSelection();
237 99a58334 Jaroslav Hrubý
            });
238
        }, 'dokumenty');
239
    };
240
241 9e60bee1 Lukáš Vlček
    const exportDocuments = async () => {
242 99a58334 Jaroslav Hrubý
        const req: ExportRequest = { documentIds: selectedDocs };
243 9e60bee1 Lukáš Vlček
        const res = await documentController.documentsExportPost(req);
244
        if (res?.data) {
245
            download(res.data, 'export.zip');
246 db3fa00e Jaroslav Hrubý
            clearSelection();
247 9e60bee1 Lukáš Vlček
        }
248 99a58334 Jaroslav Hrubý
    };
249
250 9e60bee1 Lukáš Vlček
    function download(baseData: string, filename: string) {
251
        if (!baseData) {
252
            console.log('base data null');
253
            return;
254
        }
255
256
        const linkSource = `data:application/zip;base64,${baseData}`;
257
        const downloadLink = document.createElement('a');
258
259
        downloadLink.href = linkSource;
260
        downloadLink.download = filename;
261
        downloadLink.click();
262
263
        // Clean up and remove the link
264
        // downloadLink.parentNode.removeChild(downloadLink);
265
    }
266
267 3396af93 Dominik Poch
    const changeDefaultAnotationCount = (e: FocusEvent<HTMLInputElement>) => {
268
        documentController.documentsRequiredAnnotationsGlobalPost({
269
            requiredAnnotations: parseInt(e.currentTarget.value),
270
        });
271
    };
272
273 db3fa00e Jaroslav Hrubý
    const hideModalWithClear = () => {
274 43d49a98 Jaroslav Hrubý
        fetchData();
275 9bfa1e39 Jaroslav Hrubý
        setVisibleAssign(false);
276 e7eca311 Lukáš Vlček
        setVisibleSetCount(false);
277 db3fa00e Jaroslav Hrubý
        clearSelection();
278
    };
279
280
    const hideModal = () => {
281
        fetchData();
282
        setVisibleAdd(false);
283 d7167305 Jaroslav Hrubý
        setVisiblePreview(false);
284 8c45ccb0 hrubyjar
    };
285
286 937bfbee Jaroslav Hrubý
    const removeUserDocument = (user: DocumentUserInfo, record: DocumentListInfo) => {
287
        ShowConfirm(
288
            async () => {
289
                if (!record.id || !user?.id) {
290
                    return;
291
                }
292
                await removeUserFromDocument(record.id, user.id);
293
            },
294
            'odebrat uživatele ' +
295
                user.name +
296
                ' ' +
297
                user.surname +
298
                ' (' +
299
                user.username +
300
                ') z tohoto dokumentu',
301
            'Dosavadní postup tohoto anotátora na daném dokumentu bude nenávratně smazán'
302
        );
303
    };
304
305
    const menu = (user: DocumentUserInfo, record: DocumentListInfo) => {
306
        return (
307
            <Menu>
308
                <Menu.ItemGroup title={getNameTruncated(user)}>
309
                    <Menu.Item
310
                        icon={<FileSearchOutlined />}
311
                        onClick={() =>
312
                            router.push({
313
                                pathname: '/annotation/[annotationId]',
314
                                query: { annotationId: user.annotationId, final: false },
315
                            })
316
                        }
317
                    >
318
                        Zobrazit anotaci
319
                    </Menu.Item>
320
                    <Menu.Item
321
                        icon={<UserDeleteOutlined />}
322
                        onClick={() => removeUserDocument(user, record)}
323
                    >
324
                        Odebrat
325
                    </Menu.Item>
326
                </Menu.ItemGroup>
327
            </Menu>
328
        );
329
    };
330
331 ef5792a8 Lukáš Vlček
    function getUserTag(user: DocumentUserInfo, record: DocumentListInfo) {
332
        return (
333 937bfbee Jaroslav Hrubý
            <Dropdown overlay={menu(user, record)}>
334
                <Space
335
                    size={2}
336 ef5792a8 Lukáš Vlček
                    style={{
337 937bfbee Jaroslav Hrubý
                        paddingRight: 10,
338 ef5792a8 Lukáš Vlček
                        color: getAnnotationStateColor(user.state),
339
                    }}
340
                >
341
                    <FontAwesomeIcon
342
                        icon={faUser}
343
                        title={getUserInfoAlt(user)}
344
                        className={'me-2'}
345
                    />
346
                    {record.finalAnnotations?.some(
347
                        (annot) => annot.userId === user.id
348
                    ) ? (
349
                        <u>{getNameTruncated(user)}</u>
350
                    ) : (
351
                        getNameTruncated(user)
352
                    )}
353 937bfbee Jaroslav Hrubý
                </Space>
354
            </Dropdown>
355 ef5792a8 Lukáš Vlček
        );
356
    }
357
358 c6109e2d Lukáš Vlček
    const columns = [
359
        {
360
            title: 'Název dokumentu',
361
            dataIndex: 'name',
362
            key: 'name',
363 eba090c1 Lukáš Vlček
            width: '30%',
364 0db53e25 Jaroslav Hrubý
            ...getColumnSearchProps('name', 'název'),
365 669ffe38 Jaroslav Hrubý
            sorter: {
366
                // @ts-ignore
367
                compare: (a, b) => a.name.localeCompare(b.name),
368
                multiple: 2,
369
            },
370 c6109e2d Lukáš Vlček
        },
371
        {
372
            title: 'Délka',
373
            dataIndex: 'length',
374
            key: 'length',
375 eba090c1 Lukáš Vlček
            width: '5%',
376 c4f198c3 Jaroslav Hrubý
            align: 'center' as 'center',
377 0db53e25 Jaroslav Hrubý
            sorter: {
378
                // @ts-ignore
379
                compare: (a, b) => a.length - b.length,
380
                multiple: 1,
381
            },
382 c6109e2d Lukáš Vlček
        },
383 87a3d8d1 Lukáš Vlček
        {
384
            title: 'Dokončeno | přiřazeno | vyžadováno',
385
            key: 'annotationCounts',
386 c4f198c3 Jaroslav Hrubý
            width: '15%',
387
            align: 'center' as 'center',
388 87a3d8d1 Lukáš Vlček
            render: (
389
                columnData: DocumentListResponse,
390
                record: DocumentListInfo,
391
                index: number
392
            ) => {
393
                const finished =
394
                    record.annotatingUsers?.filter((d) => d.state === EState.Done)
395
                        .length ?? 0;
396
397
                return (
398
                    <div>
399
                        <ABadge
400
                            style={
401
                                finished === record.annotatingUsers?.length
402
                                    ? BadgeStyle.SUCCESS
403
                                    : BadgeStyle.WARNING
404
                            }
405
                        >
406
                            {finished}
407
                        </ABadge>
408
                        {' | '}
409
                        <ABadge
410
                            style={
411 ef2143b8 Lukáš Vlček
                                (record.annotatingUsers?.length ?? 0) >=
412
                                (record.requiredAnnotations ?? 0)
413 87a3d8d1 Lukáš Vlček
                                    ? BadgeStyle.SUCCESS
414
                                    : BadgeStyle.WARNING
415
                            }
416
                        >
417
                            {record.annotatingUsers?.length}
418
                        </ABadge>
419
                        {' | '}
420
                        <ABadge style={BadgeStyle.GENERAL}>
421
                            {record.requiredAnnotations}
422
                        </ABadge>
423
                    </div>
424
                );
425
            },
426
        },
427 c6109e2d Lukáš Vlček
        {
428
            title: 'Anotátoři',
429
            dataIndex: 'annotatingUsers',
430
            key: 'annotatingUsers',
431 c4f198c3 Jaroslav Hrubý
            width: '20%',
432 ff61085f Lukáš Vlček
            render: (
433
                columnData: DocumentUserInfo[],
434
                record: DocumentListInfo,
435
                index: number
436
            ) => {
437 ef5792a8 Lukáš Vlček
                return <div>{columnData.map((e) => getUserTag(e, record))}</div>;
438 c6109e2d Lukáš Vlček
            },
439 0db53e25 Jaroslav Hrubý
            filters: userFilters,
440
            filterSearch: true,
441
            // @ts-ignore
442
            onFilter: (value, record) =>
443
                // @ts-ignore
444
                record.annotatingUsers.find((user) => user['username'] === value),
445
            sorter: {
446
                // @ts-ignore
447
                compare: (a, b) => a.annotatingUsers.length - b.annotatingUsers.length,
448 669ffe38 Jaroslav Hrubý
                multiple: 3,
449 0db53e25 Jaroslav Hrubý
            },
450 c6109e2d Lukáš Vlček
        },
451 d7167305 Jaroslav Hrubý
        {
452
            title: '',
453
            key: 'action',
454
            dataIndex: ['id', 'name'],
455 c4f198c3 Jaroslav Hrubý
            align: 'center' as 'center',
456 4eaee414 Lukáš Vlček
            width: '10%',
457 d7167305 Jaroslav Hrubý
            // @ts-ignore
458
            render: (text, row) => (
459 eba090c1 Lukáš Vlček
                <Button
460
                    style={{ width: '80px' }}
461
                    key={row.id}
462
                    onClick={() => showPreviewModal(row.id, row.name)}
463
                >
464 d7167305 Jaroslav Hrubý
                    Náhled
465
                </Button>
466
            ),
467
        },
468 c4f198c3 Jaroslav Hrubý
        {
469
            title: 'Finální verze dokumentu',
470
            key: 'final',
471
            dataIndex: ['id', 'finalizedExists'],
472 4eaee414 Lukáš Vlček
            width: '20%',
473 c4f198c3 Jaroslav Hrubý
            // @ts-ignore
474
            render: (text, row) =>
475
                row.finalizedExists ? (
476 eba090c1 Lukáš Vlček
                    <>
477
                        <Row>
478
                            <Space>
479
                                <Button
480
                                    disabled={finalizing}
481 8b02c5d8 Jaroslav Hrubý
                                    onClick={() => finalizeDocumentConfirm(row, true)}
482 eba090c1 Lukáš Vlček
                                >
483
                                    Znovu vytvořit
484
                                </Button>
485
                            </Space>
486
                        </Row>
487
                        <Row style={{ marginTop: '5px' }}>
488
                            <Space>
489
                                <Button
490
                                    disabled={finalizing}
491
                                    onClick={() =>
492
                                        editFinalizedDocument(row.finalizedAnnotationId)
493
                                    }
494
                                >
495
                                    Upravit
496
                                </Button>
497
                                {getFinalizationStateIcon(row.finalizedState)}
498
                            </Space>
499
                        </Row>
500
                    </>
501 c4f198c3 Jaroslav Hrubý
                ) : (
502
                    <Button
503
                        disabled={finalizing}
504
                        onClick={() => finalizeDocumentConfirm(row, false)}
505
                    >
506
                        Finalizovat
507
                    </Button>
508
                ),
509
            filters: [
510
                {
511
                    text: 'Nefinalizováno',
512
                    value: null,
513
                },
514
                {
515
                    text: 'Nový',
516
                    value: 'NEW',
517
                },
518
                {
519
                    text: 'Rozpracováno',
520
                    value: 'IN_PROGRESS',
521
                },
522
                {
523
                    text: 'Hotovo',
524
                    value: 'DONE',
525
                },
526
            ],
527
            // @ts-ignore
528
            onFilter: (value, record) => record.finalizedState === value,
529
        },
530 c6109e2d Lukáš Vlček
    ];
531
532 db3fa00e Jaroslav Hrubý
    const clearSelection = () => {
533
        setSelectedRows([]);
534
    };
535
536
    const onSelectChange = (
537
        selectedRowKeys: React.Key[],
538
        selectedRows: DocumentListInfo[]
539
    ) => {
540
        // @ts-ignore
541
        setSelectedDocs(selectedRows.map((row) => row.id));
542
        // @ts-ignore
543
        setSelectedRows(selectedRowKeys);
544
    };
545
546 9bfa1e39 Jaroslav Hrubý
    const rowSelection = {
547 db3fa00e Jaroslav Hrubý
        selectedRowKeys: selectedRows,
548
        onChange: onSelectChange,
549 9bfa1e39 Jaroslav Hrubý
    };
550
551 8c45ccb0 hrubyjar
    return redirecting || role !== 'ADMINISTRATOR' ? null : (
552
        <MainLayout>
553 c3b99cdb Lukáš Vlček
            <div
554
                style={{
555
                    display: 'flex',
556
                    flexDirection: 'row',
557
                    justifyContent: 'space-between',
558
                    flexWrap: 'wrap',
559
                }}
560
            >
561
                <Typography.Title level={2}>
562
                    <FontAwesomeIcon icon={faFileLines} /> Dokumenty
563
                </Typography.Title>
564
565
                <Stack
566
                    style={{
567
                        width: '400px',
568
                        border: '1px solid lightgray',
569
                        borderRadius: 3,
570
                        padding: 10,
571
                        marginBottom: 30,
572
                        display: 'flex',
573
                        flexDirection: 'row',
574
                        justifyContent: 'space-between',
575
                    }}
576
                    direction="horizontal"
577
                    key={annotationCount}
578
                >
579
                    <span>Výchozí požadovaný počet anotací:</span>
580
                    <Input
581
                        style={{ width: '100px' }}
582
                        defaultValue={annotationCount}
583
                        onBlur={changeDefaultAnotationCount}
584
                    />
585
                </Stack>
586
            </div>
587
588
            <div
589
                style={{
590
                    padding: '10px',
591
                    display: 'flex',
592
                    flexDirection: 'row',
593
                    justifyContent: 'flex-start',
594
                    gap: '20px',
595 99a58334 Jaroslav Hrubý
                    marginBottom: '20px',
596 c3b99cdb Lukáš Vlček
                }}
597
            >
598
                <Button type={'primary'} onClick={showAddModal}>
599
                    Nahrát dokument
600
                </Button>
601
602 9e60bee1 Lukáš Vlček
                <div style={{ display: 'flex', gap: '3px', flexWrap: 'wrap' }}>
603 792f82f0 Lukáš Vlček
                    <Button
604
                        danger
605
                        disabled={!(selectedDocs?.length > 0)}
606
                        onClick={() => deleteDocuments()}
607
                    >
608
                        Smazat dokumenty
609
                    </Button>
610 99a58334 Jaroslav Hrubý
611 792f82f0 Lukáš Vlček
                    <Button
612
                        disabled={!(selectedDocs?.length > 0)}
613
                        onClick={() => exportDocuments()}
614
                    >
615
                        Export
616
                    </Button>
617 c3b99cdb Lukáš Vlček
                    <Button
618
                        onClick={showAssignModal}
619
                        disabled={!(selectedDocs?.length > 0)}
620
                    >
621
                        Přiřadit vybrané dokumenty uživatelům
622
                    </Button>
623
                    <Button
624
                        onClick={showRequiredAnnotationsCountModal}
625
                        disabled={!(selectedDocs?.length > 0)}
626
                    >
627
                        Nastavit požadovaný počet anotací vybraným dokumentům
628
                    </Button>
629
                </div>
630
            </div>
631 3396af93 Dominik Poch
632 9bfa1e39 Jaroslav Hrubý
            {visibleAdd && <AddDocumentModal onCancel={hideModal} />}
633
            {visibleAssign && (
634 db3fa00e Jaroslav Hrubý
                <AssignDocumentModal
635
                    documentsIds={selectedDocs}
636
                    onCancel={hideModalWithClear}
637
                />
638 9bfa1e39 Jaroslav Hrubý
            )}
639 d7167305 Jaroslav Hrubý
            {visiblePreview && (
640
                <DocPreviewModal
641
                    onCancel={hideModal}
642 329a602d Jaroslav Hrubý
                    documentName={previewDocName ?? ''}
643
                    content={
644
                        previewDocContent ?? 'Nastala chyba při načítání obsahu dokumentu'
645 cca0bfa0 Lukáš Vlček
                    }
646
                />
647 d8873409 Vojtěch Bartička
            )}
648 e7eca311 Lukáš Vlček
            {visibleSetCount && (
649
                <SetRequiredAnnotationsCountModal
650
                    documentsIds={selectedDocs}
651 db3fa00e Jaroslav Hrubý
                    onCancel={hideModalWithClear}
652 d7167305 Jaroslav Hrubý
                />
653
            )}
654 c6109e2d Lukáš Vlček
655
            <Table
656 669ffe38 Jaroslav Hrubý
                locale={{ ...getLocaleProps() }}
657 db3fa00e Jaroslav Hrubý
                rowSelection={rowSelection}
658 0db53e25 Jaroslav Hrubý
                // @ts-ignore
659 c6109e2d Lukáš Vlček
                columns={columns}
660
                dataSource={documents}
661 9bfa1e39 Jaroslav Hrubý
                size="middle"
662 99a58334 Jaroslav Hrubý
                scroll={{ y: 'calc(65vh - 4em)' }}
663
                pagination={false}
664 c6109e2d Lukáš Vlček
            />
665 8c45ccb0 hrubyjar
        </MainLayout>
666
    );
667
}
668
669
export default AdminDocumentPage;