commit fabfbe326fdf8454909c25aef2a01d1a3afd92de
Author: Jaroslav Hrubý <hrubyj@students.zcu.cz>
Date:   Fri May 20 15:03:08 2022 +0200

    Refactoring, fixes

diff --git a/Backend/Core/Seeding/Seeder.cs b/Backend/Core/Seeding/Seeder.cs
index 738a4a4..a46e438 100644
--- a/Backend/Core/Seeding/Seeder.cs
+++ b/Backend/Core/Seeding/Seeder.cs
@@ -131,7 +131,7 @@ namespace Core.Seeding
                     Surname = "Admin",
                     Role = ERole.ADMINISTRATOR,
                     Username = "admin",
-                    Password = BCrypt.Net.BCrypt.HashPassword("123a456b789c")
+                    Password = BCrypt.Net.BCrypt.HashPassword("admin")
                 };
                 context.Users.Add(admin);
 
diff --git a/webapp/api/api.ts b/webapp/api/api.ts
index bcb32e1..ed8512c 100644
--- a/webapp/api/api.ts
+++ b/webapp/api/api.ts
@@ -1872,7 +1872,19 @@ export interface UserInfo {
      * @type {number}
      * @memberof UserInfo
      */
-    'assignedDocumentsCount'?: number;
+    'finalizedDocumentsCount'?: number;
+    /**
+     * 
+     * @type {number}
+     * @memberof UserInfo
+     */
+    'inProgressDocumentsCount'?: number;
+    /**
+     * 
+     * @type {number}
+     * @memberof UserInfo
+     */
+    'newDocumentsCount'?: number;
     /**
      * 
      * @type {ERole}
diff --git a/webapp/components/modals/AssignDocumentModal.tsx b/webapp/components/modals/AssignDocumentModal.tsx
index 7f2cbf9..b4641f1 100644
--- a/webapp/components/modals/AssignDocumentModal.tsx
+++ b/webapp/components/modals/AssignDocumentModal.tsx
@@ -13,9 +13,11 @@ import { ShowToast } from '../../utils/alerts';
 import { getColumnSearchProps, getLocaleProps } from '../../utils/tableUtils';
 import { TableUserInfo } from '../types/TableUserInfo';
 import { TableDocInfo } from '../types/TableDocInfo';
+import { ABadge, BadgeStyle } from '../common/ABadge';
+import { ok } from 'assert';
 
 interface ModalProps {
-    onCancel: () => void;
+    onCancel: (ok: boolean) => void;
     documentsIds: (string | undefined)[];
 }
 
@@ -26,11 +28,11 @@ function AssignDocumentModal({ onCancel, documentsIds }: ModalProps) {
     const [selectedUsers, setSelectedUsers] = useState<string[]>([]);
 
     const handleOk = () => {
-        onCancel();
+        onCancel(true);
     };
 
     const handleCancel = () => {
-        onCancel();
+        onCancel(false);
     };
 
     async function fetchData() {
@@ -64,7 +66,7 @@ function AssignDocumentModal({ onCancel, documentsIds }: ModalProps) {
                         3000,
                         'top-end'
                     );
-                    onCancel();
+                    onCancel(true);
                 });
         }
     };
@@ -131,20 +133,33 @@ function AssignDocumentModal({ onCancel, documentsIds }: ModalProps) {
             },
         },
         {
-            title: 'Přiřazeno dokumentů',
+            title: 'Aktivní | Hotovo | Celkem',
             key: 'docCounts',
             align: 'center' as 'center',
             dataIndex: 'assignedDocumentsCount',
             // @ts-ignore
-            render: (assignedDocumentsCount) => (
+            render: (text, row) => (
                 <div>
-                    <Space size={'middle'}>
-                        <Badge count={assignedDocumentsCount} />
-                    </Space>
+                    <ABadge style={BadgeStyle.WARNING}>
+                        {row.newDocumentsCount + row.inProgressDocumentsCount}
+                    </ABadge>
+                    {' | '}
+                    <ABadge style={BadgeStyle.SUCCESS}>
+                        {row.finalizedDocumentsCount}
+                    </ABadge>
+                    {' | '}
+                    <ABadge style={BadgeStyle.GENERAL}>
+                        {row.finalizedDocumentsCount +
+                            row.newDocumentsCount +
+                            row.inProgressDocumentsCount}
+                    </ABadge>
                 </div>
             ),
             // @ts-ignore
-            sorter: (a, b) => a.assignedDocumentsCount - b.assignedDocumentsCount,
+            sorter: (a, b) =>
+                a.newDocumentsCount +
+                a.inProgressDocumentsCount -
+                (b.newDocumentsCount + b.inProgressDocumentsCount),
         },
     ];
 
@@ -154,7 +169,7 @@ function AssignDocumentModal({ onCancel, documentsIds }: ModalProps) {
             onOk={handleOk}
             visible={true}
             onCancel={handleCancel}
-            width={1000}
+            width={1100}
             footer={[
                 <Button key="back" onClick={handleCancel}>
                     Storno
diff --git a/webapp/components/modals/SetRequiredAnnotationsCountModal.tsx b/webapp/components/modals/SetRequiredAnnotationsCountModal.tsx
index bec7e6b..d294ce6 100644
--- a/webapp/components/modals/SetRequiredAnnotationsCountModal.tsx
+++ b/webapp/components/modals/SetRequiredAnnotationsCountModal.tsx
@@ -6,17 +6,17 @@ import { documentController } from '../../controllers';
 import { ShowToast } from '../../utils/alerts';
 
 interface ModalProps {
-    onCancel: () => void;
+    onCancel: (ok: boolean) => void;
     documentsIds: string[];
 }
 
 function SetRequiredAnnotationsCountModal({ onCancel, documentsIds }: ModalProps) {
     const handleOk = () => {
-        onCancel();
+        onCancel(true);
     };
 
     const handleCancel = () => {
-        onCancel();
+        onCancel(false);
     };
 
     const onFinish = async (values: any) => {
diff --git a/webapp/components/modals/UserDocumentsModal.tsx b/webapp/components/modals/UserDocumentsModal.tsx
index 497b358..3003e8e 100644
--- a/webapp/components/modals/UserDocumentsModal.tsx
+++ b/webapp/components/modals/UserDocumentsModal.tsx
@@ -1,7 +1,7 @@
-import { List, Modal, Skeleton, Tag } from 'antd';
+import { List, Modal, Skeleton, Tag, Typography } from 'antd';
 import 'antd/dist/antd.css';
 import React, { useContext, useEffect, useState } from 'react';
-import { AnnotationListInfo, EState } from '../../api';
+import { AnnotationListInfo, EState, UserInfo } from '../../api';
 import { userController } from '../../controllers';
 import { useUnauthRedirect } from '../../hooks';
 import { LoggedUserContext } from '../../contexts/LoggedUserContext';
@@ -10,16 +10,19 @@ import { faArrowsRotate } from '@fortawesome/free-solid-svg-icons';
 
 import { faCircleCheck, faClock } from '@fortawesome/free-regular-svg-icons';
 import styles from '/styles/Icon.module.scss';
+import { Badge, Tab, TabPane, Tabs } from 'react-bootstrap';
 
 interface ModalProps {
     onCancel: () => void;
-    userId: string | undefined;
+    user: UserInfo;
 }
 
-function UserDocumentsModal({ onCancel, userId }: ModalProps) {
+function UserDocumentsModal({ onCancel, user }: ModalProps) {
     const redirecting = useUnauthRedirect('/login');
     const { role } = useContext(LoggedUserContext);
     const [annotations, setAnnotations] = useState<AnnotationListInfo[]>([]);
+    const [finished, setFinished] = useState(0);
+    const [inProgress, setInProgress] = useState(0);
 
     const handleOk = () => {
         onCancel();
@@ -51,14 +54,23 @@ function UserDocumentsModal({ onCancel, userId }: ModalProps) {
     };
 
     useEffect(() => {
-        if (!redirecting && role === 'ADMINISTRATOR' && userId) {
+        if (!redirecting && role === 'ADMINISTRATOR' && user.id) {
             userController
-                .userUserIdAnnotationsGet(userId)
+                .userUserIdAnnotationsGet(user.id)
                 .then(({ data: { annotations } }) => {
                     setAnnotations(annotations || []);
                 });
+            if (
+                user &&
+                user.finalizedDocumentsCount !== undefined &&
+                user.inProgressDocumentsCount !== undefined &&
+                user.newDocumentsCount !== undefined
+            ) {
+                setFinished(user.finalizedDocumentsCount);
+                setInProgress(user.newDocumentsCount + user.inProgressDocumentsCount);
+            }
         }
-    }, [userId, redirecting, role]);
+    }, [redirecting, role]);
 
     return (
         <Modal
@@ -68,21 +80,98 @@ function UserDocumentsModal({ onCancel, userId }: ModalProps) {
             onCancel={handleCancel}
             footer={[null]}
         >
-            <List
-                dataSource={annotations}
-                size={'small'}
-                grid={{ gutter: 10, column: 1 }}
-                style={{ maxHeight: 400, overflowY: 'auto', overflowX: 'hidden' }}
-                renderItem={(item) => (
-                    <List.Item key={item.annotationId}>
-                        <List.Item.Meta
-                            title={item.documentName}
-                            // @ts-ignore
-                            avatar={getStateTag(item.state)}
-                        />
-                    </List.Item>
-                )}
-            />
+            <Tabs defaultActiveKey="all" id="tabs" className="mb-3">
+                <Tab
+                    eventKey="all"
+                    title={
+                        <div>
+                            <Typography.Text>Vše </Typography.Text>
+                            <Badge bg="info" pill>
+                                {inProgress + finished}
+                            </Badge>
+                        </div>
+                    }
+                >
+                    <List
+                        dataSource={annotations}
+                        size={'small'}
+                        grid={{ gutter: 10, column: 1 }}
+                        style={{ maxHeight: 400, overflowY: 'auto', overflowX: 'hidden' }}
+                        renderItem={(item) => (
+                            <List.Item key={item.annotationId}>
+                                <List.Item.Meta
+                                    title={item.documentName}
+                                    // @ts-ignore
+                                    avatar={getStateTag(item.state)}
+                                />
+                            </List.Item>
+                        )}
+                    />
+                </Tab>
+                <Tab
+                    eventKey="profile"
+                    title={
+                        <div>
+                            <Typography.Text>Nové a rozpracované </Typography.Text>
+                            <Badge bg="warning" pill>
+                                {inProgress}
+                            </Badge>
+                        </div>
+                    }
+                >
+                    <List
+                        dataSource={annotations}
+                        size={'small'}
+                        grid={{ gutter: 10, column: 1 }}
+                        style={{ maxHeight: 400, overflowY: 'auto', overflowX: 'hidden' }}
+                        renderItem={(item) =>
+                            item.state === EState.New ||
+                            item.state === EState.InProgress ? (
+                                <List.Item key={item.annotationId}>
+                                    <List.Item.Meta
+                                        title={item.documentName}
+                                        // @ts-ignore
+                                        avatar={getStateTag(item.state)}
+                                    />
+                                </List.Item>
+                            ) : (
+                                ''
+                            )
+                        }
+                    />
+                </Tab>
+                <Tab
+                    eventKey="contact"
+                    title={
+                        <div>
+                            <Typography.Text>Hotové </Typography.Text>
+                            <Badge bg="success" pill>
+                                {finished}
+                            </Badge>
+                        </div>
+                    }
+                >
+                    <List
+                        dataSource={annotations}
+                        size={'small'}
+                        grid={{ gutter: 10, column: 1 }}
+                        style={{ maxHeight: 400, overflowY: 'auto', overflowX: 'hidden' }}
+                        renderItem={(item) =>
+                            item.state === EState.Done ? (
+                                <List.Item key={item.annotationId}>
+                                    <List.Item.Meta
+                                        title={item.documentName}
+                                        // @ts-ignore
+                                        avatar={getStateTag(item.state)}
+                                    />
+                                </List.Item>
+                            ) : (
+                                ''
+                            )
+                        }
+                    />
+                </Tab>
+            </Tabs>
         </Modal>
     );
 }
diff --git a/webapp/components/types/TableUserInfo.tsx b/webapp/components/types/TableUserInfo.tsx
index 2385e99..e023a4b 100644
--- a/webapp/components/types/TableUserInfo.tsx
+++ b/webapp/components/types/TableUserInfo.tsx
@@ -6,6 +6,8 @@ export type TableUserInfo = {
     username?: string | null;
     name?: string | null;
     surname?: string | null;
-    assignedDocumentsCount?: number;
+    finalizedDocumentsCount?: number;
+    inProgressDocumentsCount?: number;
+    newDocumentsCount?: number;
     role?: ERole;
 };
diff --git a/webapp/pages/documents/admin/index.tsx b/webapp/pages/documents/admin/index.tsx
index bccd780..bf160cf 100644
--- a/webapp/pages/documents/admin/index.tsx
+++ b/webapp/pages/documents/admin/index.tsx
@@ -270,11 +270,13 @@ function AdminDocumentPage() {
         });
     };
 
-    const hideModalWithClear = () => {
+    const hideModalWithClear = (clear: boolean) => {
         fetchData();
         setVisibleAssign(false);
         setVisibleSetCount(false);
-        clearSelection();
+        if (clear) {
+            clearSelection();
+        }
     };
 
     const hideModal = () => {
diff --git a/webapp/pages/documents/annotator/index.tsx b/webapp/pages/documents/annotator/index.tsx
index 5adc7be..ff7e7a9 100644
--- a/webapp/pages/documents/annotator/index.tsx
+++ b/webapp/pages/documents/annotator/index.tsx
@@ -32,7 +32,7 @@ function UserDocumentPage() {
             if (!docs) {
                 setDocuments([]);
             } else {
-                setDocuments(docs);
+                setDocuments(docs.filter((doc) => doc.state !== EState.Done));
             }
         }
 
diff --git a/webapp/pages/users/index.tsx b/webapp/pages/users/index.tsx
index 8a99d50..8c642f8 100644
--- a/webapp/pages/users/index.tsx
+++ b/webapp/pages/users/index.tsx
@@ -167,7 +167,13 @@ function UsersPage() {
             render: (text, row) => (
                 <div>
                     <Space size={'middle'}>
-                        <Badge count={row.assignedDocumentsCount}>
+                        <Badge
+                            count={
+                                row.finalizedDocumentsCount +
+                                row.inProgressDocumentsCount +
+                                row.newDocumentsCount
+                            }
+                        >
                             <Button onClick={() => showDocsModal(row.id)}>
                                 Dokumenty
                             </Button>
@@ -210,7 +216,7 @@ function UsersPage() {
             {passwordEditVisible && (
                 <EditUserPasswordModal userInfo={user} onCancel={hideModals} />
             )}
-            {docsVisible && <UserDocumentsModal userId={user.id} onCancel={hideModals} />}
+            {docsVisible && <UserDocumentsModal user={user} onCancel={hideModals} />}
 
             <Table
                 locale={{ ...getLocaleProps() }}
