Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 3396af93

Přidáno uživatelem Dominik Poch před asi 2 roky(ů)

Added global annotation count setter

Added input of global annotation count to the document view

Zobrazit rozdíly:

webapp/pages/documents/admin/index.tsx
1 1
import 'antd/dist/antd.css';
2
import React, { useContext, useEffect, useState } from 'react';
2
import React, { FocusEvent, useContext, useEffect, useState } from 'react';
3 3

  
4 4
import { useUnauthRedirect } from '../../../hooks';
5 5
import { useRouter } from 'next/router';
6
import { Button, Space, Table, Typography } from 'antd';
6
import { Button, Input, Space, Table, Typography } from 'antd';
7 7
import { faFileLines, faUser } from '@fortawesome/free-solid-svg-icons';
8 8
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9 9
import { LoggedUserContext } from '../../../contexts/LoggedUserContext';
......
31 31
import { getColumnSearchProps, getLocaleProps } from '../../../utils/tableUtils';
32 32
import { UserOutlined } from '@ant-design/icons';
33 33
import Swal from 'sweetalert2';
34
import { Stack } from 'react-bootstrap';
34 35

  
35 36
function AdminDocumentPage() {
36 37
    const redirecting = useUnauthRedirect('/login');
......
47 48
    const [selectedDocs, setSelectedDocs] = useState<string[]>([]);
48 49
    const [previewDocContent, setPreviewDocContent] = useState<string>();
49 50
    const [previewDocName, setPreviewDocName] = useState<string>();
51
    const [annotationCount, setAnnotationCount] = useState<number>();
50 52

  
51 53
    async function fetchData() {
52 54
        const docs = (await documentController.documentsGet(0, 1000)).data.documents;
......
65 67
        });
66 68
        setUserFilters(filters);
67 69

  
70
        let annotationCountRes =
71
            await documentController.documentsRequiredAnnotationsGlobalGet();
72
        setAnnotationCount(annotationCountRes.data.requiredAnnotationsGlobal);
73

  
68 74
        if (!docs) {
69 75
            setDocuments([]);
70 76
        } else {
......
111 117
        }
112 118
    };
113 119

  
120
    const changeDefaultAnotationCount = (e: FocusEvent<HTMLInputElement>) => {
121
        documentController.documentsRequiredAnnotationsGlobalPost({
122
            requiredAnnotations: parseInt(e.currentTarget.value),
123
        });
124
    };
125

  
114 126
    const hideModal = () => {
115 127
        fetchData();
116 128
        setVisibleAdd(false);
......
252 264
            <Typography.Title level={2}>
253 265
                <FontAwesomeIcon icon={faFileLines} /> Dokumenty
254 266
            </Typography.Title>
267
            <Stack style={{ width: '30%' }} direction="horizontal" key={annotationCount}>
268
                <span style={{ width: '70%' }}>Výchozí počet anotací:</span>
269
                <Input
270
                    defaultValue={annotationCount}
271
                    onBlur={changeDefaultAnotationCount}
272
                />
273
            </Stack>
274

  
255 275
            <Button type={'primary'} onClick={showAddModal}>
256 276
                Nahrát dokument
257 277
            </Button>

Také k dispozici: Unified diff