Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions api/src/controllers/projects.contentMapper.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ const getSingleContentTypes = async (
res.status(201).json(resp);
};

/**
* update content mapping details a project.
*
* @param req - The request object.
* @param res - The response object.
* @returns A Promise that resolves to void.
*/
const updateContentMapper = async (req: Request, res: Response): Promise<void> => {
const project = await contentMapperService.updateContentMapper(req);
res.status(project.status).json(project);
}

export const contentMapperController = {
getContentTypes,
getFieldMapping,
Expand All @@ -119,4 +131,5 @@ export const contentMapperController = {
// removeMapping,
getSingleContentTypes,
removeContentMapper,
updateContentMapper
};
15 changes: 1 addition & 14 deletions api/src/controllers/projects.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,6 @@ const updateStackDetails = async (req: Request, res: Response): Promise<void> =>
res.status(project.status).json(project);
}

/**
* update content mapping details a project.
*
* @param req - The request object.
* @param res - The response object.
* @returns A Promise that resolves to void.
*/
const updateContentMapper = async (req: Request, res: Response): Promise<void> => {
const project = await projectService.updateContentMapper(req);
res.status(project.status).json(project);
}


export const projectController = {
getAllProjects,
Expand All @@ -193,6 +181,5 @@ export const projectController = {
updateCurrentStep,
deleteProject,
revertProject,
updateStackDetails,
updateContentMapper
updateStackDetails
};
3 changes: 2 additions & 1 deletion api/src/models/FieldMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ interface Advanced {
Unique: boolean;
NonLocalizable: boolean;
EmbedObject: boolean;
EmbedObjects:any;
EmbedObjects: any;
MinChars: string;
MaxChars: number;
Default_value: boolean;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions api/src/models/project-lowdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ interface Project {
isDeleted: boolean;
isNewStack: boolean;
newStackId: string;
stackDetails: StackDetails;
mapper_keys: [];
stackDetails: [];
mapperKeys: [];
extract_path: string;
}

interface ProjectDocument {
Expand Down
3 changes: 3 additions & 0 deletions api/src/routes/contentMapper.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ router.get(
asyncRouter(contentMapperController.removeContentMapper)
);

//update content mapper details
router.patch("/:orgId/:projectId/mapper_keys", asyncRouter(contentMapperController.updateContentMapper));

export default router;
3 changes: 0 additions & 3 deletions api/src/routes/projects.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,4 @@ router.patch("/:projectId", asyncRouter(projectController.revertProject));
//update stack details Project Route
router.patch("/:projectId/stack-details", asyncRouter(projectController.updateStackDetails));

//update content mapper details Project Route
router.patch("/:projectId", asyncRouter(projectController.updateContentMapper));

export default router;
2 changes: 1 addition & 1 deletion api/src/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const login = async (req: Request): Promise<LoginServiceType> => {
data.users.push({
...appTokenPayload,
authtoken: res?.data.user?.authtoken,
email: res?.data.user?.email,
email : res?.data.user?.email,
updated_at: new Date().toISOString(),
created_at: new Date().toISOString(),
});
Expand Down
86 changes: 76 additions & 10 deletions api/src/services/contentMapper.service.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove console

Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ const updateContentType = async (req: Request) => {
);
return {
status: 400,
message: HTTP_TEXTS.CANNOT_UPDATE_CONTENT_MAPPING
message: HTTP_TEXTS.CANNOT_UPDATE_CONTENT_MAPPING,
};
}

Expand All @@ -334,7 +334,7 @@ const updateContentType = async (req: Request) => {
);
return {
status: 400,
message: HTTP_TEXTS.INVALID_CONTENT_TYPE
message: HTTP_TEXTS.INVALID_CONTENT_TYPE,
};
}

Expand Down Expand Up @@ -363,14 +363,15 @@ const updateContentType = async (req: Request) => {
)
);
await ContentTypesMapperModelLowdb.update((data: any) => {
data.ContentTypesMappers[updateIndex].status = CONTENT_TYPE_STATUS[3];
data.ContentTypesMappers[updateIndex].status =
CONTENT_TYPE_STATUS[3];
});
return {
status: 400,
status: 400,
message: `${VALIDATION_ERRORS.STRING_REQUIRED.replace(
"$",
"ContentstackFieldType or contentstackFieldUid"
)}`
)}`,
};
}
}
Expand Down Expand Up @@ -405,8 +406,8 @@ const updateContentType = async (req: Request) => {
)
);
return {
status: 404,
message: HTTP_TEXTS.CONTENT_TYPE_NOT_FOUND
status: 404,
message: HTTP_TEXTS.CONTENT_TYPE_NOT_FOUND,
};
}

Expand Down Expand Up @@ -437,9 +438,8 @@ const updateContentType = async (req: Request) => {

return {
status: 200,
data: { updatedContentType }
data: { updatedContentType },
};

} catch (error: any) {
logger.error(
getLogMessage(
Expand All @@ -450,7 +450,7 @@ const updateContentType = async (req: Request) => {
);
return {
status: error?.status || 500,
message: error?.message || HTTP_TEXTS.INTERNAL_ERROR
message: error?.message || HTTP_TEXTS.INTERNAL_ERROR,
};
}
};
Expand Down Expand Up @@ -912,6 +912,71 @@ const removeContentMapper = async (req: Request) => {
}
};

/**
* Updates the content mapper details for a project.
*
* @param req - The request object containing the parameters and body.
* @returns An object with the status and data of the update operation.
* @throws BadRequestError if the project status is invalid.
* @throws ExceptionFunction if an error occurs during the update.
*/
const updateContentMapper = async (req: Request) => {
console.info("updateContentMapper", req.params, req.body);

const { orgId, projectId } = req.params;
const { token_payload, content_mapper } = req.body;
const srcFunc = "updateContentMapper";

console.info("HERE",content_mapper)
await ProjectModelLowdb.read();
const projectIndex = (await getProjectUtil(
projectId,
{
id: projectId,
org_id: orgId,
region: token_payload?.region,
owner: token_payload?.user_id,
},
srcFunc,
true
)) as number;

try {
ProjectModelLowdb.update((data: any) => {
// console.info("data ===============", data, content_mapper)
data.projects[projectIndex].mapperKeys = content_mapper;
data.projects[projectIndex].updated_at = new Date().toISOString();
});

logger.info(
getLogMessage(
srcFunc,
`Content mapping for project [Id : ${projectId}] has been successfully updated.`,
token_payload
)
);
return {
status: HTTP_CODES.OK,
data: {
message: HTTP_TEXTS.CONTENT_MAPPER_UPDATED,
},
};
} catch (error: any) {
logger.error(
getLogMessage(
srcFunc,
`Error occurred while updating content mapping for project [Id : ${projectId}].`,
token_payload,
error
)
);
throw new ExceptionFunction(
error?.message || HTTP_TEXTS.INTERNAL_ERROR,
error?.statusCode || error?.status || HTTP_CODES.SERVER_ERROR
);
}
};

export const contentMapperService = {
putTestData,
getContentTypes,
Expand All @@ -923,4 +988,5 @@ export const contentMapperService = {
removeContentMapper,
removeMapping,
getSingleContentTypes,
updateContentMapper
};
13 changes: 9 additions & 4 deletions api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ const createProject = async (req: Request) => {
label: '',
master_locale: '',
created_at: '',
}
},
mapperKeys: []
};

try {
Expand Down Expand Up @@ -213,6 +214,8 @@ const updateProject = async (req: Request) => {
data.projects[projectIndex].updated_by = user_id;
data.projects[projectIndex].updated_at = new Date().toISOString();
data.projects[projectIndex].stackDetails = updateData?.stackDetails;
data.projects[projectIndex].mapperKeys = updateData?.mapperKeys;

project = data.projects[projectIndex];
});

Expand Down Expand Up @@ -988,10 +991,13 @@ const updateStackDetails = async (req: Request) => {
* @throws ExceptionFunction if an error occurs during the update.
*/
const updateContentMapper = async (req: Request) => {
console.info("updateContentMapper", req.params, req.body);

const { orgId, projectId } = req.params;
const { token_payload, content_mapper } = req.body;
const srcFunc = "updateContentMapper";


await ProjectModelLowdb.read();
const projectIndex = (await getProjectUtil(
projectId,
Expand All @@ -1007,7 +1013,7 @@ const updateContentMapper = async (req: Request) => {

try {
ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].mapper_keys = content_mapper;
data.projects[projectIndex].mapperKeys = content_mapper;
data.projects[projectIndex].updated_at = new Date().toISOString();
});

Expand Down Expand Up @@ -1054,6 +1060,5 @@ export const projectService = {
updateCurrentStep,
deleteProject,
revertProject,
updateStackDetails,
updateContentMapper,
updateStackDetails
};
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "(cd ./api && npm install) ; (cd ./ui && npm install) ; (cd ./upload-api && npm install)"
"postinstall": "(cd ./api && npm install --force) ; (cd ./ui && npm install --force) ; (cd ./upload-api && npm install --force)",
"api": "cd ./api && npm run dev",
"upload": "cd ./upload-api && npm start",
"ui": "cd ./ui && npm start"
},
"repository": {
"type": "git",
Expand Down
19 changes: 19 additions & 0 deletions ui/src/common/assets/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -831,4 +831,23 @@ export const DEMAGNIFY = (
</svg>
);

/**
* SVG icon component for Schema Preview.
*
* @remarks
* This component renders an SVG icon for the Schema Preview action.
*
* @returns The SVG icon component.
*/
export const SCHEMA_PREVIEW = (
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fillRule="evenodd" clipRule="evenodd" d="M4 5.71485C4 4.76776 4.7835 4 5.75 4H23.25C24.2165 4 25 4.76776 25 5.71485V16.4939C25 16.8998 24.6642 17.2288 24.25 17.2288C23.8358 17.2288 23.5 16.8998 23.5 16.4939V5.71485C23.5 5.57955 23.3881 5.46987 23.25 5.46987H5.75C5.61193 5.46987 5.5 5.57955 5.5 5.71485V25.8284C5.5 25.9637 5.61193 26.0734 5.75 26.0734H15.75C16.1642 26.0734 16.5 26.4024 16.5 26.8083C16.5 27.2142 16.1642 27.5433 15.75 27.5433H5.75C4.7835 27.5433 4 26.7755 4 25.8284V5.71485Z" fill="#475161"/>
<path fillRule="evenodd" clipRule="evenodd" d="M9 9.64058C9 9.23425 9.33579 8.90485 9.75 8.90485H19.75C20.1642 8.90485 20.5 9.23425 20.5 9.64058C20.5 10.0469 20.1642 10.3763 19.75 10.3763H9.75C9.33579 10.3763 9 10.0469 9 9.64058Z" fill="#475161"/>
<path fillRule="evenodd" clipRule="evenodd" d="M9 15.0359C9 14.6296 9.33579 14.3002 9.75 14.3002H19.75C20.1642 14.3002 20.5 14.6296 20.5 15.0359C20.5 15.4422 20.1642 15.7716 19.75 15.7716H9.75C9.33579 15.7716 9 15.4422 9 15.0359Z" fill="#475161"/>
<path fillRule="evenodd" clipRule="evenodd" d="M9 20.4312C9 20.0249 9.33579 19.6955 9.75 19.6955H15.75C16.1642 19.6955 16.5 20.0249 16.5 20.4312C16.5 20.8376 16.1642 21.167 15.75 21.167H9.75C9.33579 21.167 9 20.8376 9 20.4312Z" fill="#475161"/>
<path d="M27.5 22.7698C28.1667 23.1474 28.1667 24.0914 27.5 24.4689L21.5 27.8671C20.8333 28.2447 20 27.7727 20 27.0176V20.2212C20 19.4661 20.8333 18.9941 21.5 19.3717L27.5 22.7698Z" fill="#475161"/>
</svg>

);


Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ export interface UpdatedSettings {

Multiple?: boolean;

EmbedObjects?: any
EmbedObjects?: any;

Default_value?: boolean;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions ui/src/components/AdvancePropertise/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,12 @@
z-index: 10000;
}
}
.Radio-class{
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 20px;
grid-template-columns: 1fr;

}
Loading