Revize 06d1aa21
Přidáno uživatelem Jaroslav Hrubý před téměř 3 roky(ů)
webapp/pages/_app.tsx | ||
---|---|---|
1 | 1 |
// @ts-nocheck |
2 | 2 |
import '../styles/globals.css'; |
3 | 3 |
import 'bootstrap/dist/css/bootstrap.css'; |
4 |
import '@fortawesome/fontawesome-svg-core/styles.css'; |
|
4 | 5 |
|
5 | 6 |
import type { AppProps } from 'next/app'; |
6 | 7 |
import Head from 'next/head'; |
webapp/pages/classes/index.tsx | ||
---|---|---|
15 | 15 |
const router = useRouter(); |
16 | 16 |
|
17 | 17 |
useEffect(() => { |
18 |
if (role !== 'ADMINISTRATOR') { |
|
19 |
logout(); |
|
20 |
router.push('/login'); |
|
21 |
} |
|
22 |
|
|
23 |
if (!redirecting) { |
|
18 |
if (!redirecting && role === 'ADMINISTRATOR') { |
|
24 | 19 |
// TODO load classes |
25 | 20 |
} |
26 | 21 |
}, [redirecting, role, router]); |
webapp/pages/documents/admin/index.tsx | ||
---|---|---|
9 | 9 |
import { LoggedUserContext } from '../../../contexts/LoggedUserContext'; |
10 | 10 |
import { MainLayout } from '../../../layouts/MainLayout'; |
11 | 11 |
|
12 |
|
|
13 | 12 |
function AdminDocumentPage() { |
14 | 13 |
const redirecting = useUnauthRedirect('/login'); |
15 | 14 |
const { logout, role } = useContext(LoggedUserContext); |
16 | 15 |
const router = useRouter(); |
17 |
useEffect(() => { |
|
18 |
console.log(role); |
|
19 |
if (role !== 'ADMINISTRATOR') { |
|
20 |
logout(); |
|
21 |
router.push('/login'); |
|
22 |
} |
|
23 | 16 |
|
24 |
if (!redirecting) { |
|
17 |
useEffect(() => { |
|
18 |
if (!redirecting && role === 'ADMINISTRATOR') { |
|
25 | 19 |
// TODO load documents |
26 | 20 |
} |
27 | 21 |
}, [logout, redirecting, role, router]); |
webapp/pages/documents/annotator/index.tsx | ||
---|---|---|
15 | 15 |
const redirecting = useUnauthRedirect('/login'); |
16 | 16 |
const { logout, role } = useContext(LoggedUserContext); |
17 | 17 |
const router = useRouter(); |
18 |
const [documents, setDocuments] = useState<AnnotationListInfo[] | null | undefined>( |
|
19 |
[] |
|
20 |
); |
|
18 |
const [documents, setDocuments] = useState<AnnotationListInfo[]>([]); |
|
21 | 19 |
|
22 | 20 |
useEffect(() => { |
23 |
console.log(role); |
|
24 |
if (role !== 'ANNOTATOR') { |
|
25 |
logout(); |
|
26 |
router.push('/login'); |
|
27 |
} |
|
28 |
|
|
29 | 21 |
async function fetchData() { |
30 | 22 |
let docs = (await userController.userAnnotationsGet()).data.annotations; |
31 |
console.log(docs); |
|
32 |
setDocuments(docs); |
|
23 |
if (!docs) { |
|
24 |
setDocuments([]); |
|
25 |
} else { |
|
26 |
setDocuments(docs); |
|
27 |
} |
|
33 | 28 |
} |
34 |
if (!redirecting) { |
|
29 |
if (!redirecting && role === 'ANNOTATOR') {
|
|
35 | 30 |
fetchData(); |
36 | 31 |
} |
37 | 32 |
}, [logout, redirecting, role, router]); |
... | ... | |
69 | 64 |
key: 'action', |
70 | 65 |
dataIndex: 'annotationId', |
71 | 66 |
render: (anotationId: number) => ( |
72 |
<Button onClick={() => router.push('/annotation/' + anotationId)}> |
|
67 |
<Button |
|
68 |
key={anotationId} |
|
69 |
type={'primary'} |
|
70 |
onClick={() => router.push('/annotation/' + anotationId)} |
|
71 |
> |
|
73 | 72 |
Anotovat |
74 | 73 |
</Button> |
75 | 74 |
), |
76 | 75 |
}, |
77 | 76 |
]; |
78 | 77 |
|
79 |
// TODO switch to REAL data from Controller |
|
80 |
const data = []; |
|
81 |
for (let i = 0; i < 100; i++) { |
|
82 |
let state = 'DONE'; |
|
83 |
if (i % 3 === 1) { |
|
84 |
state = 'IN_PROGRESS'; |
|
85 |
} |
|
86 |
if (i % 3 === 2) { |
|
87 |
state = 'NEW'; |
|
88 |
} |
|
89 |
|
|
90 |
data.push({ |
|
91 |
key: i, |
|
92 |
documentName: `Dokument ${i}`, |
|
93 |
state: state, |
|
94 |
annotationId: i, |
|
95 |
}); |
|
96 |
} |
|
97 |
|
|
98 | 78 |
return redirecting || role !== 'ANNOTATOR' ? null : ( |
99 | 79 |
<MainLayout> |
100 | 80 |
<Typography.Title level={2}> |
101 | 81 |
<FontAwesomeIcon icon={faFileLines} /> Dokumenty |
102 | 82 |
</Typography.Title> |
103 |
<Table columns={columns} dataSource={data} size="small" scroll={{ y: 500 }} /> |
|
83 |
<Table |
|
84 |
columns={columns} |
|
85 |
dataSource={documents} |
|
86 |
size="small" |
|
87 |
scroll={{ y: 500 }} |
|
88 |
/> |
|
104 | 89 |
</MainLayout> |
105 | 90 |
); |
106 | 91 |
} |
webapp/pages/export/index.tsx | ||
---|---|---|
14 | 14 |
const { logout, role } = useContext(LoggedUserContext); |
15 | 15 |
const router = useRouter(); |
16 | 16 |
|
17 |
useEffect(() => { |
|
18 |
if (role !== 'ADMINISTRATOR') { |
|
19 |
logout(); |
|
20 |
router.push('/login'); |
|
21 |
} |
|
22 |
}, [logout, redirecting, role, router]); |
|
23 |
|
|
24 | 17 |
return redirecting || role !== 'ADMINISTRATOR' ? null : ( |
25 | 18 |
<MainLayout> |
26 | 19 |
<Typography.Title level={2}> |
webapp/pages/tags/index.tsx | ||
---|---|---|
15 | 15 |
const router = useRouter(); |
16 | 16 |
|
17 | 17 |
useEffect(() => { |
18 |
if (role !== 'ADMINISTRATOR') { |
|
19 |
logout(); |
|
20 |
router.push('/login'); |
|
18 |
if (!redirecting && role === 'ADMINISTRATOR') { |
|
19 |
// TODO load tags |
|
21 | 20 |
} |
22 | 21 |
}, [logout, redirecting, role, router]); |
23 | 22 |
|
webapp/pages/users/index.tsx | ||
---|---|---|
15 | 15 |
const router = useRouter(); |
16 | 16 |
|
17 | 17 |
useEffect(() => { |
18 |
if (role !== 'ADMINISTRATOR') { |
|
19 |
logout(); |
|
20 |
router.push('/login'); |
|
18 |
if (!redirecting && role === 'ADMINISTRATOR') { |
|
19 |
// TODO load users |
|
21 | 20 |
} |
22 | 21 |
}, [logout, redirecting, role, router]); |
23 | 22 |
|
webapp/styles/MainLayout.module.scss | ||
---|---|---|
1 | 1 |
.layoutWrapper { |
2 |
background-color: lightgray;
|
|
2 |
background-color: #ffffff;
|
|
3 | 3 |
display: grid; |
4 | 4 |
|
5 | 5 |
grid: |
Také k dispozici: Unified diff
Refactoring