Skip to content

Commit

Permalink
1.4.1 (#2349)
Browse files Browse the repository at this point in the history
* Add IResponseUsedInDocument

* Add anchorText to response detail

* Change document model

* Add statsGet api route

* Add few comments

* update #2351, usedInDocuments + test

* introduce system settings

* add owner setting key + settings api router

* add api call for GET /settings/:key

* remove owner setting, add user role owner instead

* add endpoint / permission for getting owner user (Email)

* add api call to client's lib for getting owner data

* add request for getting first ever created audit + test + client api call

* add END key support in annotator, close #2321

* fix ENTER input, close #2320

* add api call for removing selected anchors from document + test

* Update IResponseUsedInDocument

* Improve documentation

* update implementation for IResponseUsedInDocument

* add Document's anchors tree structure, add test, finalize IResponseUsedInDocument

* Do not show entity tag if the provided entity is undefined

* Refactor warnings

* add PropSpecKind enum for Entity.extractIdsFromProps

* add TBasedWarnings to entity detail's warnings

* add parentT / resourceId from IResponseUsedInDocument to entities map

* Add section to the warning

* Add dummy api call to remove anchor

* 2065 list of anchors in entity detail open text in annotator from anchor list in one click anchor removal in detail (#2430)

* prepare anchor table

* implement the visual part of used in documents table

* remove mutation

* improvements

* abbreviate text, btn style

* hide delete btn

* prepare anchor btn, implement copy to clipboard

* open document modal from anchor

* scroll to anchor from used in documents

* refactor btn group props

* working solution

* 2416 add owner role to the user list table (#2452)

* sort users in user list

* sort, change icons, add tooltip

* conditions for owner role btns

* user icon to the navbar

* color rows

* remove owner from btn group in manage users, add owner to user import

* 2361 design and create the first owner modal (#2455)

* add modal and first attrs

* add validations to modal

* tidy up styles

* move validation rule to advanced components

* validations section header

* fns for add, edit, remove rules

* warning validation dict, add sections to modal

* validation settings to local state

* implement disabled settings

* better labels and descriptions to dict

* separate settings row to component

* tooltips

* capitalize descriptions

* owner only, hide settings

* better updating

* owner rights to menu

* add updateSettings api call

* Create group setting GET endpoint

* default import global validation settings

* fix groupSettings router

* update /settings/group/:group call

* 1989 switching off global | local validation rules in territory based validation rules (#2473)

* fetch settings preparation

* quick version with fetch

* fix empty validations

* log settings

* condition to disable submit btn

* add settingGroupUpdate to api

* add api handler for PUT settings/group/:groupid

* add acl permissions for put settings/group/:id

* add test for put settings/group/:id

* handle update

---------

Co-authored-by: Ján Mertel <[email protected]>

---------

Co-authored-by: Ján Mertel <[email protected]>
Co-authored-by: Petr Hanak <[email protected]>
  • Loading branch information
3 people authored Dec 9, 2024
1 parent cd2828e commit 36983e8
Show file tree
Hide file tree
Showing 83 changed files with 3,110 additions and 690 deletions.
188 changes: 185 additions & 3 deletions packages/client/src/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import {
IUser,
Relation,
RequestPermissionUpdate,
IRequestStats,
IAudit,
} from "@shared/types";
import { ISetting, ISettingGroup } from "@shared/types/settings";
import * as errors from "@shared/types/errors";
import { NetworkError } from "@shared/types/errors";
import { IRequestSearch } from "@shared/types/request-search";
Expand Down Expand Up @@ -674,21 +677,30 @@ class Api {
entityIds: string[],
options?: IApiOptions
): Promise<(EntitiesDeleteSuccessResponse | EntitiesDeleteErrorResponse)[]> {
const out: (EntitiesDeleteSuccessResponse | EntitiesDeleteErrorResponse)[] = [];
const out: (EntitiesDeleteSuccessResponse | EntitiesDeleteErrorResponse)[] =
[];
try {
const response = await this.connection.delete(`/entities/`, {
data: {
entityIds,
},
...options,
});
const data = (response.data as IResponseGeneric<Record<string, errors.CustomError | true>>).data;
const data = (
response.data as IResponseGeneric<
Record<string, errors.CustomError | true>
>
).data;
if (data) {
for (const errorEntityId of Object.keys(data)) {
if (data[errorEntityId] === true) {
out.push({ entityId: errorEntityId, details: data[errorEntityId] });
} else {
out.push({ entityId: errorEntityId, error: true, details: data[errorEntityId] });
out.push({
entityId: errorEntityId,
error: true,
details: data[errorEntityId],
});
}
}
}
Expand Down Expand Up @@ -851,6 +863,21 @@ class Api {
}
}

/**
* Stats
*/
async statsGet(
data: IRequestStats,
options?: IApiOptions
): Promise<AxiosResponse<IResponseAudit>> {
try {
const response = await this.connection.post(`/stats`, data, options);
return response;
} catch (err) {
throw this.handleError(err);
}
}

/**
* Audit
*/
Expand All @@ -869,6 +896,20 @@ class Api {
}
}

async auditGetFirst(
options?: IApiOptions
): Promise<AxiosResponse<IResponseGeneric<IAudit>>> {
try {
const response = await this.connection.get(
`/audits?skip=0&take=1&from=1970`,
options
);
return response;
} catch (err) {
throw this.handleError(err);
}
}

/**
* Statement
* Editor container
Expand Down Expand Up @@ -1218,6 +1259,40 @@ class Api {
}
}

async documentRemoveAnchors(
documentId: string,
entityId: string,
options?: IApiOptions
): Promise<AxiosResponse<IResponseGeneric>> {
try {
const response = await this.connection.patch(
`/documents/${documentId}/removeAnchors?entityId=${entityId}`,
document,
options
);
return response;
} catch (err) {
throw this.handleError(err);
}
}

async documentRemoveAnchor(
documentId: string,
entityId: string,
anchorText: string,
anchorIndex: number,
options?: IApiOptions
): Promise<AxiosResponse<IResponseGeneric>> {
try {
// todo add api endpoint

// @ts-ignore
return null;
} catch (err) {
throw this.handleError(err);
}
}

/**
* Document update
*/
Expand All @@ -1237,6 +1312,113 @@ class Api {
throw this.handleError(err);
}
}

/**
* Setting get
* @param settingId
* @param options
* @returns
*/
async settingGet(
settingId: string,
options?: IApiOptions
): Promise<AxiosResponse<IResponseGeneric<ISetting>>> {
try {
const response = await this.connection.get(
`/settings/${settingId}`,
options
);
return response;
} catch (err) {
throw this.handleError(err);
}
}

/**
* Setting group get
* @param settingId
* @param options
* @returns
*/
async settingGroupGet(
settingGroupId: string,
options?: IApiOptions
): Promise<AxiosResponse<IResponseGeneric<ISettingGroup>>> {
try {
const response = await this.connection.get(
`/settings/group/${settingGroupId}`,
options
);
return response;
} catch (err) {
throw this.handleError(err);
}
}

/**
* Setting group get
* @param settingId
* @param data
* @param options
* @returns
*/
async settingGroupUpdate(
settingGroupId: string,
data: { id: string; value: unknown }[],
options?: IApiOptions
): Promise<AxiosResponse<IResponseGeneric<ISettingGroup>>> {
try {
const response = await this.connection.put(
`/settings/group/${settingGroupId}`,
data,
options
);
return response;
} catch (err) {
throw this.handleError(err);
}
}

/**
* Setting update
* @param settingId
* @param data
* @param options
* @returns
*/
async settingUpdate(
settingId: string,
data: { value: unknown },
options?: IApiOptions
): Promise<AxiosResponse<IResponseGeneric>> {
try {
const response = await this.connection.put(
`/settings/${settingId}`,
data,
options
);
return response;
} catch (err) {
throw this.handleError(err);
}
}

/**
* Get owner's info
* @param settingId
* @param options
* @returns
*/
async usersGetOwner(
options?: IApiOptions
): Promise<AxiosResponse<IResponseGeneric<string>>> {
try {
const response = await this.connection.get(`/users/owner`, options);
return response;
} catch (err) {
throw this.handleError(err);
}
}
}

const apiSingleton = new Api();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ export const TextAnnotator = ({
</StyledCanvasWrapper>

{annotator && (
<ButtonGroup $marginTop={true}>
<ButtonGroup $marginTop>
<Button
key={EditMode.HIGHLIGHT}
icon={<FaPen size={11} />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
import React, { useEffect, useRef, useState } from "react";
import React, { useEffect, useState } from "react";

import { Modal, ModalContent, ModalFooter, ModalHeader } from "components";
import { IResponseDocument } from "@shared/types";
import { IDocument, IDocumentMeta, IResponseDocument } from "@shared/types";
import { Modal, ModalContent, ModalHeader } from "components";
import { useWindowSize } from "hooks/useWindowSize";
import { getShortLabelByLetterCount } from "utils/utils";
import TextAnnotator from "../Annotator/Annotator";
import AnnotatorProvider from "../Annotator/AnnotatorProvider";
import { Annotator } from "@inkvisitor/annotator/src/lib";

interface DocumentModal {
document: IResponseDocument | undefined;
interface DocumentModalEdit {
document: IResponseDocument | IDocumentMeta | IDocument | undefined;
onClose: () => void;
anchor?: { entityId: string; occurence?: number };
}
const DocumentModalEdit: React.FC<DocumentModal> = ({ onClose, document }) => {
const DocumentModalEdit: React.FC<DocumentModalEdit> = ({
onClose,
document,
anchor,
}) => {
const [show, setShow] = useState(false);

useEffect(() => {
setShow(true);
}, []);

const [windowWidth, windowHeight] = useWindowSize();

// const [annotatorInitialized, setAnnotatorInitialized] = useState(false);

return (
<Modal width={1000} showModal={show} onClose={onClose} fullHeight>
<ModalHeader
Expand All @@ -39,21 +45,21 @@ const DocumentModalEdit: React.FC<DocumentModal> = ({ onClose, document }) => {
width={965}
height={windowHeight - 180}
displayLineNumbers={true}
hlEntities={[]}
storedAnnotatorScroll={0}
forwardAnnotator={(newAnnotator) => {
// if (!annotatorInitialized && newAnnotator && anchor?.entityId) {
anchor?.entityId &&
newAnnotator?.scrollToAnchor(anchor?.entityId);
// setAnnotatorInitialized(true);
// }
}}
/>
</AnnotatorProvider>
) : (
<div>Document not found</div>
)}
</ModalContent>
{/* <ModalFooter>
<div
style={{
display: "flex",
justifyContent: "space-between",
width: "100%",
}}
></div>
</ModalFooter> */}
</Modal>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export const EntityTag: React.FC<EntityTag> = ({
const draggedEntity: DraggedEntityReduxItem = useAppSelector(
(state) => state.draggedEntity
);
if (entity === undefined) {
return null;
}

if (!entity) {
return null;
Expand Down
Loading

0 comments on commit 36983e8

Please sign in to comment.