Revize b51488cd
Přidáno uživatelem Jaroslav Hrubý před téměř 3 roky(ů)
webapp/api/api.ts | ||
---|---|---|
699 | 699 |
*/ |
700 | 700 |
'role'?: ERole; |
701 | 701 |
} |
702 |
/** |
|
703 |
* |
|
704 |
* @export |
|
705 |
* @interface MarkAnnotationDoneRequest |
|
706 |
*/ |
|
707 |
export interface MarkAnnotationDoneRequest { |
|
708 |
/** |
|
709 |
* |
|
710 |
* @type {boolean} |
|
711 |
* @memberof MarkAnnotationDoneRequest |
|
712 |
*/ |
|
713 |
'done'?: boolean; |
|
714 |
} |
|
702 | 715 |
/** |
703 | 716 |
* |
704 | 717 |
* @export |
... | ... | |
1167 | 1180 |
*/ |
1168 | 1181 |
export const AnnotationApiAxiosParamCreator = function (configuration?: Configuration) { |
1169 | 1182 |
return { |
1183 |
/** |
|
1184 |
* |
|
1185 |
* @param {string} annotationId |
|
1186 |
* @param {MarkAnnotationDoneRequest} [markAnnotationDoneRequest] |
|
1187 |
* @param {*} [options] Override http request option. |
|
1188 |
* @throws {RequiredError} |
|
1189 |
*/ |
|
1190 |
annotationAnnotationIdDonePut: async (annotationId: string, markAnnotationDoneRequest?: MarkAnnotationDoneRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { |
|
1191 |
// verify required parameter 'annotationId' is not null or undefined |
|
1192 |
assertParamExists('annotationAnnotationIdDonePut', 'annotationId', annotationId) |
|
1193 |
const localVarPath = `/annotation/{annotationId}/done` |
|
1194 |
.replace(`{${"annotationId"}}`, encodeURIComponent(String(annotationId))); |
|
1195 |
// use dummy base URL string because the URL constructor only accepts absolute URLs. |
|
1196 |
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); |
|
1197 |
let baseOptions; |
|
1198 |
if (configuration) { |
|
1199 |
baseOptions = configuration.baseOptions; |
|
1200 |
} |
|
1201 |
|
|
1202 |
const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; |
|
1203 |
const localVarHeaderParameter = {} as any; |
|
1204 |
const localVarQueryParameter = {} as any; |
|
1205 |
|
|
1206 |
|
|
1207 |
|
|
1208 |
localVarHeaderParameter['Content-Type'] = 'application/json'; |
|
1209 |
|
|
1210 |
setSearchParams(localVarUrlObj, localVarQueryParameter); |
|
1211 |
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; |
|
1212 |
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; |
|
1213 |
localVarRequestOptions.data = serializeDataIfNeeded(markAnnotationDoneRequest, localVarRequestOptions, configuration) |
|
1214 |
|
|
1215 |
return { |
|
1216 |
url: toPathString(localVarUrlObj), |
|
1217 |
options: localVarRequestOptions, |
|
1218 |
}; |
|
1219 |
}, |
|
1170 | 1220 |
/** |
1171 | 1221 |
* |
1172 | 1222 |
* @param {string} annotationId |
... | ... | |
1436 | 1486 |
export const AnnotationApiFp = function(configuration?: Configuration) { |
1437 | 1487 |
const localVarAxiosParamCreator = AnnotationApiAxiosParamCreator(configuration) |
1438 | 1488 |
return { |
1489 |
/** |
|
1490 |
* |
|
1491 |
* @param {string} annotationId |
|
1492 |
* @param {MarkAnnotationDoneRequest} [markAnnotationDoneRequest] |
|
1493 |
* @param {*} [options] Override http request option. |
|
1494 |
* @throws {RequiredError} |
|
1495 |
*/ |
|
1496 |
async annotationAnnotationIdDonePut(annotationId: string, markAnnotationDoneRequest?: MarkAnnotationDoneRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> { |
|
1497 |
const localVarAxiosArgs = await localVarAxiosParamCreator.annotationAnnotationIdDonePut(annotationId, markAnnotationDoneRequest, options); |
|
1498 |
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); |
|
1499 |
}, |
|
1439 | 1500 |
/** |
1440 | 1501 |
* |
1441 | 1502 |
* @param {string} annotationId |
... | ... | |
1523 | 1584 |
export const AnnotationApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { |
1524 | 1585 |
const localVarFp = AnnotationApiFp(configuration) |
1525 | 1586 |
return { |
1587 |
/** |
|
1588 |
* |
|
1589 |
* @param {string} annotationId |
|
1590 |
* @param {MarkAnnotationDoneRequest} [markAnnotationDoneRequest] |
|
1591 |
* @param {*} [options] Override http request option. |
|
1592 |
* @throws {RequiredError} |
|
1593 |
*/ |
|
1594 |
annotationAnnotationIdDonePut(annotationId: string, markAnnotationDoneRequest?: MarkAnnotationDoneRequest, options?: any): AxiosPromise<void> { |
|
1595 |
return localVarFp.annotationAnnotationIdDonePut(annotationId, markAnnotationDoneRequest, options).then((request) => request(axios, basePath)); |
|
1596 |
}, |
|
1526 | 1597 |
/** |
1527 | 1598 |
* |
1528 | 1599 |
* @param {string} annotationId |
... | ... | |
1603 | 1674 |
* @extends {BaseAPI} |
1604 | 1675 |
*/ |
1605 | 1676 |
export class AnnotationApi extends BaseAPI { |
1677 |
/** |
|
1678 |
* |
|
1679 |
* @param {string} annotationId |
|
1680 |
* @param {MarkAnnotationDoneRequest} [markAnnotationDoneRequest] |
|
1681 |
* @param {*} [options] Override http request option. |
|
1682 |
* @throws {RequiredError} |
|
1683 |
* @memberof AnnotationApi |
|
1684 |
*/ |
|
1685 |
public annotationAnnotationIdDonePut(annotationId: string, markAnnotationDoneRequest?: MarkAnnotationDoneRequest, options?: AxiosRequestConfig) { |
|
1686 |
return AnnotationApiFp(this.configuration).annotationAnnotationIdDonePut(annotationId, markAnnotationDoneRequest, options).then((request) => request(this.axios, this.basePath)); |
|
1687 |
} |
|
1688 |
|
|
1606 | 1689 |
/** |
1607 | 1690 |
* |
1608 | 1691 |
* @param {string} annotationId |
webapp/components/annotation/AnnotationPanel.tsx | ||
---|---|---|
2 | 2 |
import { AnnotationItem } from './AnnotationItem'; |
3 | 3 |
import { useContext } from 'react'; |
4 | 4 |
import { AnnotationContext } from '../../contexts/AnnotationContext'; |
5 |
import { Button } from 'antd'; |
|
5 | 6 |
|
6 | 7 |
/** |
7 | 8 |
* Creates a panel in the annotation screen that contains a list of annotations. |
8 | 9 |
* @returns Panel with a list of annotations. |
9 | 10 |
*/ |
10 | 11 |
export function AnnotationPanel() { |
11 |
const { mappedTags } = useContext(AnnotationContext); |
|
12 |
const { mappedTags, finishAnnotation } = useContext(AnnotationContext);
|
|
12 | 13 |
|
13 | 14 |
return ( |
14 | 15 |
<div> |
16 |
<div style={{ height: '80vh', overflowY: 'auto', marginBottom: 20 }}> |
|
17 |
<Stack gap={2}> |
|
18 |
{mappedTags?.map((tag, index) => { |
|
19 |
return <AnnotationItem key={index} tag={tag} />; |
|
20 |
})} |
|
21 |
</Stack> |
|
22 |
</div> |
|
15 | 23 |
<Stack gap={2}> |
16 |
{mappedTags?.map((tag, index) => {
|
|
17 |
return <AnnotationItem key={index} tag={tag} />;
|
|
18 |
})}
|
|
24 |
<Button type={'primary'} onClick={finishAnnotation}>
|
|
25 |
Dokončit
|
|
26 |
</Button>
|
|
19 | 27 |
</Stack> |
20 | 28 |
</div> |
21 | 29 |
); |
webapp/contexts/AnnotationContext.tsx | ||
---|---|---|
3 | 3 |
AnnotationInfo, |
4 | 4 |
ETagSentiment, |
5 | 5 |
ETagType, |
6 |
SubTagInfo, |
|
7 |
TagInfo, |
|
6 |
MarkAnnotationDoneRequest, |
|
8 | 7 |
TagInstanceInfo, |
9 | 8 |
} from '../api'; |
10 | 9 |
import { Tag } from '../components/types/tag'; |
11 |
import { annotationController, userController } from '../controllers';
|
|
10 |
import { annotationController } from '../controllers'; |
|
12 | 11 |
import { GetSelectionInfo } from '../utils/selectionUtils'; |
13 |
import { ShowConfirmDelete, ShowToast } from '../utils/alerts'; |
|
12 |
import { ShowConfirm, ShowConfirmDelete, ShowToast } from '../utils/alerts'; |
|
13 |
import { useRouter } from 'next/router'; |
|
14 | 14 |
|
15 | 15 |
/** |
16 | 16 |
* Interface of an annotation context provider. |
... | ... | |
44 | 44 |
*/ |
45 | 45 |
deleteOccurrence: (occurrence: TagInstanceInfo) => void; |
46 | 46 |
|
47 |
/** |
|
48 |
* Finishes annotation of document (marked as DONE). |
|
49 |
*/ |
|
50 |
finishAnnotation: () => void; |
|
51 |
|
|
47 | 52 |
/** |
48 | 53 |
* Changes a position of an occurrence of an annotation. |
49 | 54 |
* @param occurrence Occurrence whose position should be changed. |
... | ... | |
121 | 126 |
return; |
122 | 127 |
}, |
123 | 128 |
|
129 |
/** |
|
130 |
* Finishes annotation of document (marked as DONE). |
|
131 |
*/ |
|
132 |
finishAnnotation: () => { |
|
133 |
return; |
|
134 |
}, |
|
135 |
|
|
124 | 136 |
/** |
125 | 137 |
* Default implementation of changePosition method. |
126 | 138 |
* @param occurrence Occurrence whose position should be changed. |
... | ... | |
188 | 200 |
|
189 | 201 |
const [submitting, setSubmitting] = useState(false); |
190 | 202 |
|
203 |
const router = useRouter(); |
|
204 |
|
|
191 | 205 |
async function markSelectedText( |
192 | 206 |
tagId: string, |
193 | 207 |
subtagId: string | null, |
... | ... | |
254 | 268 |
}, 'značku'); |
255 | 269 |
}; |
256 | 270 |
|
271 |
/** |
|
272 |
* Finishes annotation of document (marked as DONE). |
|
273 |
*/ |
|
274 |
const finishAnnotation = () => { |
|
275 |
const req: MarkAnnotationDoneRequest = { done: true }; |
|
276 |
ShowConfirm( |
|
277 |
() => |
|
278 |
annotationController |
|
279 |
.annotationAnnotationIdDonePut(props.annotationId, req) |
|
280 |
.then(() => { |
|
281 |
router.push('/documents/annotator'); |
|
282 |
ShowToast('Anotování bylo úspěšně dokončeno'); |
|
283 |
}), |
|
284 |
'dokončit anotování' |
|
285 |
); |
|
286 |
}; |
|
287 |
|
|
257 | 288 |
/** |
258 | 289 |
* Changes a position of an occurrence of an annotation. |
259 | 290 |
* @param occurrence Occurrence whose position should be changed. |
... | ... | |
364 | 395 |
setTags, |
365 | 396 |
addOccurrence, |
366 | 397 |
deleteOccurrence, |
398 |
finishAnnotation, |
|
367 | 399 |
changeLength, |
368 | 400 |
changePosition, |
369 | 401 |
changeNote, |
webapp/utils/alerts.ts | ||
---|---|---|
1 | 1 |
import Swal, { SweetAlertIcon, SweetAlertPosition } from 'sweetalert2'; |
2 | 2 |
import withReactContent from 'sweetalert2-react-content'; |
3 |
import { AxiosResponse } from 'axios'; |
|
4 | 3 |
|
5 | 4 |
const MySwal = withReactContent(Swal); |
6 | 5 |
|
... | ... | |
43 | 42 |
} |
44 | 43 |
}); |
45 | 44 |
} |
45 |
|
|
46 |
export function ShowConfirm(action: () => void, actionLabel: string) { |
|
47 |
Swal.fire({ |
|
48 |
icon: 'question', |
|
49 |
title: 'Opravdu si přejete ' + actionLabel + '?', |
|
50 |
showCancelButton: true, |
|
51 |
confirmButtonText: 'Potvrdit', |
|
52 |
confirmButtonColor: '#5278ff', |
|
53 |
cancelButtonText: 'Zrušit', |
|
54 |
cancelButtonColor: '#c0c0c0', |
|
55 |
}).then((result) => { |
|
56 |
if (result.isConfirmed) { |
|
57 |
action(); |
|
58 |
} |
|
59 |
}); |
|
60 |
} |
Také k dispozici: Unified diff
Annotation finishing implemented