Projekt

Obecné

Profil

« Předchozí | Další » 

Revize ef5792a8

Přidáno uživatelem Lukáš Vlček před téměř 3 roky(ů)

Annotators removing from documents

Zobrazit rozdíly:

webapp/api/api.ts
571 571
     */
572 572
    'role'?: ERole;
573 573
}
574
/**
575
 * 
576
 * @export
577
 * @interface DeleteDocumentsRequest
578
 */
579
export interface DeleteDocumentsRequest {
580
    /**
581
     * 
582
     * @type {Array<string>}
583
     * @memberof DeleteDocumentsRequest
584
     */
585
    'documentIds'?: Array<string> | null;
586
}
574 587
/**
575 588
 * 
576 589
 * @export
......
781 794
 * @interface DocumentListResponse
782 795
 */
783 796
export interface DocumentListResponse {
784
    /**
785
     * 
786
     * @type {number}
787
     * @memberof DocumentListResponse
788
     */
789
    'totalCount'?: number;
790
    /**
791
     * 
792
     * @type {number}
793
     * @memberof DocumentListResponse
794
     */
795
    'pageCount'?: number;
796
    /**
797
     * 
798
     * @type {number}
799
     * @memberof DocumentListResponse
800
     */
801
    'pageIndex'?: number;
802 797
    /**
803 798
     * 
804 799
     * @type {Array<DocumentListInfo>}
......
957 952
export type ETagType = typeof ETagType[keyof typeof ETagType];
958 953

  
959 954

  
955
/**
956
 * 
957
 * @export
958
 * @interface ExportRequest
959
 */
960
export interface ExportRequest {
961
    /**
962
     * 
963
     * @type {Array<string>}
964
     * @memberof ExportRequest
965
     */
966
    'documentIds'?: Array<string> | null;
967
}
960 968
/**
961 969
 * 
962 970
 * @export
......
2917 2925
        },
2918 2926
        /**
2919 2927
         * 
2920
         * @param {number} [pageIndex] 
2921
         * @param {number} [pageSize] 
2928
         * @param {DeleteDocumentsRequest} [deleteDocumentsRequest] 
2922 2929
         * @param {*} [options] Override http request option.
2923 2930
         * @throws {RequiredError}
2924 2931
         */
2925
        documentsGet: async (pageIndex?: number, pageSize?: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
2932
        documentsDelete: async (deleteDocumentsRequest?: DeleteDocumentsRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
2926 2933
            const localVarPath = `/documents`;
2927 2934
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
2928 2935
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
......
2931 2938
                baseOptions = configuration.baseOptions;
2932 2939
            }
2933 2940

  
2934
            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
2941
            const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options};
2935 2942
            const localVarHeaderParameter = {} as any;
2936 2943
            const localVarQueryParameter = {} as any;
2937 2944

  
2938
            if (pageIndex !== undefined) {
2939
                localVarQueryParameter['pageIndex'] = pageIndex;
2945

  
2946
    
2947
            localVarHeaderParameter['Content-Type'] = 'application/json';
2948

  
2949
            setSearchParams(localVarUrlObj, localVarQueryParameter);
2950
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
2951
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
2952
            localVarRequestOptions.data = serializeDataIfNeeded(deleteDocumentsRequest, localVarRequestOptions, configuration)
2953

  
2954
            return {
2955
                url: toPathString(localVarUrlObj),
2956
                options: localVarRequestOptions,
2957
            };
2958
        },
2959
        /**
2960
         * 
2961
         * @param {string} documentId 
2962
         * @param {string} annotatorId 
2963
         * @param {*} [options] Override http request option.
2964
         * @throws {RequiredError}
2965
         */
2966
        documentsDocumentIdAnnotatorsAnnotatorIdDelete: async (documentId: string, annotatorId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
2967
            // verify required parameter 'documentId' is not null or undefined
2968
            assertParamExists('documentsDocumentIdAnnotatorsAnnotatorIdDelete', 'documentId', documentId)
2969
            // verify required parameter 'annotatorId' is not null or undefined
2970
            assertParamExists('documentsDocumentIdAnnotatorsAnnotatorIdDelete', 'annotatorId', annotatorId)
2971
            const localVarPath = `/documents/{documentId}/annotators/{annotatorId}`
2972
                .replace(`{${"documentId"}}`, encodeURIComponent(String(documentId)))
2973
                .replace(`{${"annotatorId"}}`, encodeURIComponent(String(annotatorId)));
2974
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
2975
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
2976
            let baseOptions;
2977
            if (configuration) {
2978
                baseOptions = configuration.baseOptions;
2940 2979
            }
2941 2980

  
2942
            if (pageSize !== undefined) {
2943
                localVarQueryParameter['pageSize'] = pageSize;
2981
            const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options};
2982
            const localVarHeaderParameter = {} as any;
2983
            const localVarQueryParameter = {} as any;
2984

  
2985

  
2986
    
2987
            setSearchParams(localVarUrlObj, localVarQueryParameter);
2988
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
2989
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
2990

  
2991
            return {
2992
                url: toPathString(localVarUrlObj),
2993
                options: localVarRequestOptions,
2994
            };
2995
        },
2996
        /**
2997
         * 
2998
         * @param {ExportRequest} [exportRequest] 
2999
         * @param {*} [options] Override http request option.
3000
         * @throws {RequiredError}
3001
         */
3002
        documentsExportPost: async (exportRequest?: ExportRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
3003
            const localVarPath = `/documents/export`;
3004
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
3005
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
3006
            let baseOptions;
3007
            if (configuration) {
3008
                baseOptions = configuration.baseOptions;
2944 3009
            }
2945 3010

  
3011
            const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
3012
            const localVarHeaderParameter = {} as any;
3013
            const localVarQueryParameter = {} as any;
3014

  
3015

  
3016
    
3017
            localVarHeaderParameter['Content-Type'] = 'application/json';
3018

  
3019
            setSearchParams(localVarUrlObj, localVarQueryParameter);
3020
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
3021
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
3022
            localVarRequestOptions.data = serializeDataIfNeeded(exportRequest, localVarRequestOptions, configuration)
3023

  
3024
            return {
3025
                url: toPathString(localVarUrlObj),
3026
                options: localVarRequestOptions,
3027
            };
3028
        },
3029
        /**
3030
         * 
3031
         * @param {*} [options] Override http request option.
3032
         * @throws {RequiredError}
3033
         */
3034
        documentsGet: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
3035
            const localVarPath = `/documents`;
3036
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
3037
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
3038
            let baseOptions;
3039
            if (configuration) {
3040
                baseOptions = configuration.baseOptions;
3041
            }
3042

  
3043
            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
3044
            const localVarHeaderParameter = {} as any;
3045
            const localVarQueryParameter = {} as any;
3046

  
2946 3047

  
2947 3048
    
2948 3049
            setSearchParams(localVarUrlObj, localVarQueryParameter);
......
3114 3215
        },
3115 3216
        /**
3116 3217
         * 
3117
         * @param {number} [pageIndex] 
3118
         * @param {number} [pageSize] 
3218
         * @param {DeleteDocumentsRequest} [deleteDocumentsRequest] 
3219
         * @param {*} [options] Override http request option.
3220
         * @throws {RequiredError}
3221
         */
3222
        async documentsDelete(deleteDocumentsRequest?: DeleteDocumentsRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
3223
            const localVarAxiosArgs = await localVarAxiosParamCreator.documentsDelete(deleteDocumentsRequest, options);
3224
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
3225
        },
3226
        /**
3227
         * 
3228
         * @param {string} documentId 
3229
         * @param {string} annotatorId 
3119 3230
         * @param {*} [options] Override http request option.
3120 3231
         * @throws {RequiredError}
3121 3232
         */
3122
        async documentsGet(pageIndex?: number, pageSize?: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DocumentListResponse>> {
3123
            const localVarAxiosArgs = await localVarAxiosParamCreator.documentsGet(pageIndex, pageSize, options);
3233
        async documentsDocumentIdAnnotatorsAnnotatorIdDelete(documentId: string, annotatorId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
3234
            const localVarAxiosArgs = await localVarAxiosParamCreator.documentsDocumentIdAnnotatorsAnnotatorIdDelete(documentId, annotatorId, options);
3235
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
3236
        },
3237
        /**
3238
         * 
3239
         * @param {ExportRequest} [exportRequest] 
3240
         * @param {*} [options] Override http request option.
3241
         * @throws {RequiredError}
3242
         */
3243
        async documentsExportPost(exportRequest?: ExportRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
3244
            const localVarAxiosArgs = await localVarAxiosParamCreator.documentsExportPost(exportRequest, options);
3245
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
3246
        },
3247
        /**
3248
         * 
3249
         * @param {*} [options] Override http request option.
3250
         * @throws {RequiredError}
3251
         */
3252
        async documentsGet(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DocumentListResponse>> {
3253
            const localVarAxiosArgs = await localVarAxiosParamCreator.documentsGet(options);
3124 3254
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
3125 3255
        },
3126 3256
        /**
......
3192 3322
        },
3193 3323
        /**
3194 3324
         * 
3195
         * @param {number} [pageIndex] 
3196
         * @param {number} [pageSize] 
3325
         * @param {DeleteDocumentsRequest} [deleteDocumentsRequest] 
3326
         * @param {*} [options] Override http request option.
3327
         * @throws {RequiredError}
3328
         */
3329
        documentsDelete(deleteDocumentsRequest?: DeleteDocumentsRequest, options?: any): AxiosPromise<void> {
3330
            return localVarFp.documentsDelete(deleteDocumentsRequest, options).then((request) => request(axios, basePath));
3331
        },
3332
        /**
3333
         * 
3334
         * @param {string} documentId 
3335
         * @param {string} annotatorId 
3197 3336
         * @param {*} [options] Override http request option.
3198 3337
         * @throws {RequiredError}
3199 3338
         */
3200
        documentsGet(pageIndex?: number, pageSize?: number, options?: any): AxiosPromise<DocumentListResponse> {
3201
            return localVarFp.documentsGet(pageIndex, pageSize, options).then((request) => request(axios, basePath));
3339
        documentsDocumentIdAnnotatorsAnnotatorIdDelete(documentId: string, annotatorId: string, options?: any): AxiosPromise<void> {
3340
            return localVarFp.documentsDocumentIdAnnotatorsAnnotatorIdDelete(documentId, annotatorId, options).then((request) => request(axios, basePath));
3341
        },
3342
        /**
3343
         * 
3344
         * @param {ExportRequest} [exportRequest] 
3345
         * @param {*} [options] Override http request option.
3346
         * @throws {RequiredError}
3347
         */
3348
        documentsExportPost(exportRequest?: ExportRequest, options?: any): AxiosPromise<void> {
3349
            return localVarFp.documentsExportPost(exportRequest, options).then((request) => request(axios, basePath));
3350
        },
3351
        /**
3352
         * 
3353
         * @param {*} [options] Override http request option.
3354
         * @throws {RequiredError}
3355
         */
3356
        documentsGet(options?: any): AxiosPromise<DocumentListResponse> {
3357
            return localVarFp.documentsGet(options).then((request) => request(axios, basePath));
3202 3358
        },
3203 3359
        /**
3204 3360
         * 
......
3269 3425

  
3270 3426
    /**
3271 3427
     * 
3272
     * @param {number} [pageIndex] 
3273
     * @param {number} [pageSize] 
3428
     * @param {DeleteDocumentsRequest} [deleteDocumentsRequest] 
3429
     * @param {*} [options] Override http request option.
3430
     * @throws {RequiredError}
3431
     * @memberof DocumentApi
3432
     */
3433
    public documentsDelete(deleteDocumentsRequest?: DeleteDocumentsRequest, options?: AxiosRequestConfig) {
3434
        return DocumentApiFp(this.configuration).documentsDelete(deleteDocumentsRequest, options).then((request) => request(this.axios, this.basePath));
3435
    }
3436

  
3437
    /**
3438
     * 
3439
     * @param {string} documentId 
3440
     * @param {string} annotatorId 
3441
     * @param {*} [options] Override http request option.
3442
     * @throws {RequiredError}
3443
     * @memberof DocumentApi
3444
     */
3445
    public documentsDocumentIdAnnotatorsAnnotatorIdDelete(documentId: string, annotatorId: string, options?: AxiosRequestConfig) {
3446
        return DocumentApiFp(this.configuration).documentsDocumentIdAnnotatorsAnnotatorIdDelete(documentId, annotatorId, options).then((request) => request(this.axios, this.basePath));
3447
    }
3448

  
3449
    /**
3450
     * 
3451
     * @param {ExportRequest} [exportRequest] 
3452
     * @param {*} [options] Override http request option.
3453
     * @throws {RequiredError}
3454
     * @memberof DocumentApi
3455
     */
3456
    public documentsExportPost(exportRequest?: ExportRequest, options?: AxiosRequestConfig) {
3457
        return DocumentApiFp(this.configuration).documentsExportPost(exportRequest, options).then((request) => request(this.axios, this.basePath));
3458
    }
3459

  
3460
    /**
3461
     * 
3274 3462
     * @param {*} [options] Override http request option.
3275 3463
     * @throws {RequiredError}
3276 3464
     * @memberof DocumentApi
3277 3465
     */
3278
    public documentsGet(pageIndex?: number, pageSize?: number, options?: AxiosRequestConfig) {
3279
        return DocumentApiFp(this.configuration).documentsGet(pageIndex, pageSize, options).then((request) => request(this.axios, this.basePath));
3466
    public documentsGet(options?: AxiosRequestConfig) {
3467
        return DocumentApiFp(this.configuration).documentsGet(options).then((request) => request(this.axios, this.basePath));
3280 3468
    }
3281 3469

  
3282 3470
    /**
webapp/pages/_app.tsx
1 1
// @ts-nocheck
2
import '../styles/globals.css';
2
import '../styles/globals.scss';
3 3
import 'bootstrap/dist/css/bootstrap.css';
4 4
import '@fortawesome/fontawesome-svg-core/styles.css';
5 5

  
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,
webapp/styles/globals.css
1
html,
2
body {
3
  padding: 0;
4
  margin: 0;
5
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
6
    Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
7
}
8

  
9
a {
10
  color: inherit;
11
  text-decoration: none;
12
}
13

  
14
* {
15
  box-sizing: border-box;
16
}
17

  
18
.navbar-wrapper{
19
  width: 100vw;
20
  margin: 0;
21
  display: flex;
22
  justify-content: space-around;
23
  padding-left: 10px;
24
  padding-right: 10px;
25
  background: #001529;
26
}
webapp/styles/globals.scss
1
html,
2
body {
3
  padding: 0;
4
  margin: 0;
5
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
6
    Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
7
}
8

  
9
a {
10
  color: inherit;
11
  text-decoration: none;
12
}
13

  
14
* {
15
  box-sizing: border-box;
16
}
17

  
18
.navbar-wrapper{
19
  width: 100vw;
20
  margin: 0;
21
  display: flex;
22
  justify-content: space-around;
23
  padding-left: 10px;
24
  padding-right: 10px;
25
  background: #001529;
26
}
27

  
28
.userTagWrapper{
29
  padding: 2px;
30
  position: relative;
31
  cursor: pointer;
32

  
33

  
34
  .userTag{
35
    opacity: 1;
36

  
37
  }
38
  .remove {
39
    transition: .5s ease;
40
    opacity: 0;
41
    position: absolute;
42
    top: 80%;
43
    left: 50%;
44
    transform: translate(-50%, -50%);
45
    -ms-transform: translate(-50%, -50%);
46
    text-align: center;
47
  }
48
}
49

  
50
.userTagWrapper:hover .remove{
51
  opacity: 1;
52
}
53

  
54
.userTagWrapper:hover .userTag{
55
  opacity: 0.3
56
}
57

  

Také k dispozici: Unified diff