Skip to content
Merged

Dev #191

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
added comments on some UI files and looger windows functionality
  • Loading branch information
RohitKini committed Jul 11, 2024
commit 978b9d40baf52b19a08094eca4da3314e315da36
9 changes: 6 additions & 3 deletions api/src/controllers/projects.contentMapper.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ const resetContentType = async (req: Request, res: Response): Promise<void> => {
// res.status(200).json(resp);
// };

const removeContentMapper = async (req: Request, res: Response): Promise<void> => {
const removeContentMapper = async (
req: Request,
res: Response
): Promise<void> => {
const resp = await contentMapperService.removeContentMapper(req);
res.status(200).json(resp);
}
};

const getSingleContentTypes = async (
req: Request,
Expand All @@ -59,5 +62,5 @@ export const contentMapperController = {
resetContentType,
// removeMapping,
getSingleContentTypes,
removeContentMapper
removeContentMapper,
};
25 changes: 13 additions & 12 deletions api/src/services/contentMapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ContentTypesMapper } from "../models/contentTypesMapper-lowdb.js";
// Developer service to create dummy contentmapping data
const putTestData = async (req: Request) => {
const projectId = req.params.projectId;
const contentTypes = req.body.contentTypes;
const contentTypes = req.body.contentTypes;

await FieldMapperModel.read();
contentTypes.map((type: any, index: any) => {
Expand All @@ -45,7 +45,7 @@ const putTestData = async (req: Request) => {
await ContentTypesMapperModelLowdb.read();
const contentIds: string[] = [];
const contentType = contentTypes.map((item: any) => {
const id = item?.id || uuidv4();
const id = item?.id || uuidv4();
contentIds.push(id);
return { ...item, id };
});
Expand Down Expand Up @@ -532,7 +532,7 @@ const resetAllContentTypesMapping = async (projectId: string) => {
try {
const contentTypes = cData;
for (const contentType of contentTypes) {
if (contentType && !isEmpty(contentType.fieldMapping)) {
if (contentType && !isEmpty(contentType.fieldMapping)) {
for (const field of contentType.fieldMapping) {
await FieldMapperModel.read();
const fieldData = FieldMapperModel.chain
Expand Down Expand Up @@ -569,10 +569,8 @@ const resetAllContentTypesMapping = async (projectId: string) => {
});
}
}

}


return projectDetails;
} catch (error: any) {
logger.error(
Expand Down Expand Up @@ -735,13 +733,16 @@ const removeContentMapper = async (req: Request) => {
throw new BadRequestError(HTTP_TEXTS.PROJECT_NOT_FOUND);
}
await ContentTypesMapperModelLowdb.read();
const cData: ContentTypesMapper[] = projectDetails?.content_mapper.map((cId: string) => {
const contentTypeData: ContentTypesMapper = ContentTypesMapperModelLowdb.chain
.get("ContentTypesMappers")
.find({ id: cId })
.value();
return contentTypeData;
});
const cData: ContentTypesMapper[] = projectDetails?.content_mapper.map(
(cId: string) => {
const contentTypeData: ContentTypesMapper =
ContentTypesMapperModelLowdb.chain
.get("ContentTypesMappers")
.find({ id: cId })
.value();
return contentTypeData;
}
);

try {
const contentTypes: ContentTypesMapper[] = cData;
Expand Down
4 changes: 2 additions & 2 deletions api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const getAllProjects = async (req: Request) => {
const orgId = req?.params?.orgId;

const decodedToken = req.body.token_payload;
const { user_id = "", region = "" } = decodedToken;
const { user_id = "", region = "" } = decodedToken;

await ProjectModelLowdb.read();
const projects = ProjectModelLowdb.chain
.get("projects")
Expand Down