Revize ef5792a8
Přidáno uživatelem Lukáš Vlček před téměř 3 roky(ů)
webapp/pages/documents/admin/index.tsx | ||
---|---|---|
38 | 38 |
} from '@ant-design/icons'; |
39 | 39 |
import { SweetAlertIcon } from 'sweetalert2'; |
40 | 40 |
import { Stack } from 'react-bootstrap'; |
41 |
import { AxiosRequestConfig } from 'axios'; |
|
42 |
import { constants } from 'http2'; |
|
43 |
import HTTP_STATUS_ACCEPTED = module; |
|
44 |
import HTTP_STATUS_OK = module; |
|
41 | 45 |
|
42 | 46 |
function AdminDocumentPage() { |
43 | 47 |
const redirecting = useUnauthRedirect('/login'); |
... | ... | |
58 | 62 |
const [annotationCount, setAnnotationCount] = useState<number>(); |
59 | 63 |
|
60 | 64 |
async function fetchData() { |
61 |
const docs = (await documentController.documentsGet(0, 1000)).data.documents;
|
|
65 |
const docs = (await documentController.documentsGet()).data.documents; |
|
62 | 66 |
// @ts-ignore |
63 | 67 |
const tableDocs: TableDocInfo[] = docs?.map((doc, index) => { |
64 | 68 |
return { key: index, ...doc }; |
... | ... | |
161 | 165 |
setFinalizing(false); |
162 | 166 |
}; |
163 | 167 |
|
168 |
async function removeUserFromDocument(documentID: string, annotatorID: string) { |
|
169 |
const res = |
|
170 |
await documentController.documentsDocumentIdAnnotatorsAnnotatorIdDelete( |
|
171 |
documentID, |
|
172 |
annotatorID |
|
173 |
); |
|
174 |
|
|
175 |
if (res.status === 200) { |
|
176 |
ShowToast('Uživatel byl úspěšně odebrán z dokumentu'); |
|
177 |
} |
|
178 |
await fetchData(); |
|
179 |
} |
|
180 |
|
|
164 | 181 |
const getFinalizationStateIcon = (state: EState) => { |
165 | 182 |
const color = getAnnotationStateColor(state); |
166 | 183 |
const label = getAnnotationStateString(state); |
... | ... | |
226 | 243 |
setVisiblePreview(false); |
227 | 244 |
}; |
228 | 245 |
|
246 |
function getUserTag(user: DocumentUserInfo, record: DocumentListInfo) { |
|
247 |
return ( |
|
248 |
<span |
|
249 |
className={'userTagWrapper'} |
|
250 |
title={getUserInfoAlt(user) + '\nStav: ' + user.state} |
|
251 |
onClick={() => { |
|
252 |
ShowConfirm( |
|
253 |
async () => { |
|
254 |
if (!record.id || !user?.id) { |
|
255 |
return; |
|
256 |
} |
|
257 |
await removeUserFromDocument(record.id, user.id); |
|
258 |
}, |
|
259 |
'odebrat uživatele ' + |
|
260 |
user.name + |
|
261 |
' ' + |
|
262 |
user.surname + |
|
263 |
' (' + |
|
264 |
user.username + |
|
265 |
') z tohoto dokumentu', |
|
266 |
'Dosavadní postup tohoto anotátora na daném dokumentu bude nenávratně smazán' |
|
267 |
); |
|
268 |
}} |
|
269 |
> |
|
270 |
<span |
|
271 |
key={user.username + '.' + record.id} |
|
272 |
style={{ |
|
273 |
color: getAnnotationStateColor(user.state), |
|
274 |
}} |
|
275 |
className={'me-3 userTag'} |
|
276 |
> |
|
277 |
<FontAwesomeIcon |
|
278 |
icon={faUser} |
|
279 |
title={getUserInfoAlt(user)} |
|
280 |
className={'me-2'} |
|
281 |
/> |
|
282 |
{record.finalAnnotations?.some( |
|
283 |
(annot) => annot.userId === user.id |
|
284 |
) ? ( |
|
285 |
<u>{getNameTruncated(user)}</u> |
|
286 |
) : ( |
|
287 |
getNameTruncated(user) |
|
288 |
)} |
|
289 |
</span> |
|
290 |
<span className={'remove'}>Odebrat</span> |
|
291 |
</span> |
|
292 |
); |
|
293 |
} |
|
294 |
|
|
229 | 295 |
const columns = [ |
230 | 296 |
{ |
231 | 297 |
title: 'Název dokumentu', |
... | ... | |
305 | 371 |
record: DocumentListInfo, |
306 | 372 |
index: number |
307 | 373 |
) => { |
308 |
return ( |
|
309 |
<div> |
|
310 |
{columnData.map((e) => ( |
|
311 |
<span |
|
312 |
key={e.username + '.' + record.id} |
|
313 |
title={getUserInfoAlt(e) + '\nStav: ' + e.state} |
|
314 |
style={{ |
|
315 |
color: getAnnotationStateColor(e.state), |
|
316 |
padding: 3, |
|
317 |
}} |
|
318 |
className={'me-3'} |
|
319 |
> |
|
320 |
<FontAwesomeIcon |
|
321 |
icon={faUser} |
|
322 |
title={getUserInfoAlt(e)} |
|
323 |
className={'me-2'} |
|
324 |
/> |
|
325 |
{record.finalAnnotations?.some( |
|
326 |
(annot) => annot.userId === e.id |
|
327 |
) ? ( |
|
328 |
<u>{getNameTruncated(e)}</u> |
|
329 |
) : ( |
|
330 |
getNameTruncated(e) |
|
331 |
)} |
|
332 |
</span> |
|
333 |
))} |
|
334 |
</div> |
|
335 |
); |
|
374 |
return <div>{columnData.map((e) => getUserTag(e, record))}</div>; |
|
336 | 375 |
}, |
337 | 376 |
filters: userFilters, |
338 | 377 |
filterSearch: true, |
Také k dispozici: Unified diff
Annotators removing from documents