Skip to content

Commit

Permalink
Merge branch 'next' into parsu_ci_testing
Browse files Browse the repository at this point in the history
Signed-off-by: Purshottam Patidar <parsuboy666@gmail.com>
  • Loading branch information
Techpurshottam authored Jun 24, 2024
2 parents 0ec0dd2 + 02bfb12 commit 0176fd8
Show file tree
Hide file tree
Showing 19 changed files with 4,775 additions and 7,536 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
secrets:
GH_PACKAGES:
required: true
workflow_dispatch:

jobs:
publish_prod_api:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-embed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
# The type of runner that the job will run on
runs-on: ubuntu-latest
timeout-minutes: 80
# environment: Production
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -41,4 +42,4 @@ jobs:
- name: Set build status
id: set_build_status
run: echo "::set-output name=build_status::success"
run: echo "::set-output name=build_status::success"
25 changes: 25 additions & 0 deletions .github/workflows/build-queuemanager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Publish Queue Manager to Production

on:
workflow_call:
workflow_dispatch:

jobs:
build_queuemanager:
Expand All @@ -15,6 +16,30 @@ jobs:
packages: write
deployments: write
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Setup kernel for react native, increase watchers
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

- uses: actions/setup-node@v2
with:
node-version: '20.13.1'

- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@v2.0.1
env:
CI: false
with:
version: 8.9.0
run_install: true

- name: Build, tag, and push image to Github Container Registry
id: build-image
env:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/build-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Publish Web app to Production

on:
workflow_call:
workflow_dispatch:

jobs:
build_web:
Expand All @@ -15,6 +16,30 @@ jobs:
packages: write
deployments: write
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Setup kernel for react native, increase watchers
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

- uses: actions/setup-node@v2
with:
node-version: '20.13.1'

- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@v2.0.1
env:
CI: false
with:
version: 8.9.0
run_install: true

- name: Build, tag, and push image to Github container registry
id: build-image
env:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/build-widget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Publish Widget to Production

on:
workflow_call:
workflow_dispatch:

jobs:
build_widget:
Expand All @@ -15,6 +16,30 @@ jobs:
packages: write
deployments: write
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Setup kernel for react native, increase watchers
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

- uses: actions/setup-node@v2
with:
node-version: '20.13.1'

- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@v2.0.1
env:
CI: false
with:
version: 8.9.0
run_install: true

- name: Envsetup
working-directory: apps/widget
run: npm run envsetup
Expand Down
22 changes: 22 additions & 0 deletions apps/api/src/app/review/dtos/update-cell.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsDefined } from 'class-validator';

export class UpdateCellDto {
@ApiProperty({
description: 'Record index',
})
@IsDefined()
index: number;

@ApiProperty({
description: 'Record values to update',
})
@IsDefined()
record: Record<string, any>;

@ApiProperty({
description: 'Update value flags',
})
@IsDefined()
updated: Record<string, boolean>;
}
5 changes: 3 additions & 2 deletions apps/api/src/app/review/review.controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ApiOperation, ApiTags, ApiSecurity, ApiQuery, ApiOkResponse } from '@nestjs/swagger';
import { BadRequestException, Body, Controller, Delete, Get, Param, Post, Put, Query, UseGuards } from '@nestjs/common';

import { UploadEntity } from '@impler/dal';
import { APIMessages } from '@shared/constants';
import { RecordEntity, UploadEntity } from '@impler/dal';
import { JwtAuthGuard } from '@shared/framework/auth.gaurd';
import { validateUploadStatus } from '@shared/helpers/upload.helpers';
import { Defaults, ACCESS_KEY_NAME, UploadStatusEnum, ReviewDataTypesEnum } from '@impler/shared';
Expand All @@ -19,6 +19,7 @@ import {
UpdateImportCountCommand,
} from './usecases';

import { UpdateCellDto } from './dtos/update-cell.dto';
import { validateNotFound } from '@shared/helpers/common.helper';
import { PaginationResponseDto } from '@shared/dtos/pagination-response.dto';
import { ValidateMongoId } from '@shared/validations/valid-mongo-id.validation';
Expand Down Expand Up @@ -143,7 +144,7 @@ export class ReviewController {
@ApiOperation({
summary: 'Update review record for ongoing import',
})
async updateReviewData(@Param('uploadId', ValidateMongoId) _uploadId: string, @Body() body: RecordEntity) {
async updateReviewData(@Param('uploadId', ValidateMongoId) _uploadId: string, @Body() body: UpdateCellDto) {
await this.updateRecord.execute(_uploadId, body);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/review/usecases/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UpdateRecord } from './update-cell';
import { DoReview } from './do-review/do-review.usecase';
import { UpdateRecord } from './update-cell/update-cell.usecase';
import { DeleteRecord } from './delete-record/delete-record.usecase';
import { DoReReview } from './do-review/re-review-data.usecase';
import { StartProcess } from './start-process/start-process.usecase';
Expand Down
1 change: 0 additions & 1 deletion apps/api/src/app/review/usecases/update-cell/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export class UpdateCellCommand {
index: number;

record: Record<string, any>;

updated: Record<string, boolean>;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Injectable } from '@nestjs/common';
import { DalService, RecordEntity } from '@impler/dal';
import { DalService } from '@impler/dal';
import { UpdateCellCommand } from './update-cell.command';

@Injectable()
export class UpdateRecord {
constructor(private dalService: DalService) {}

async execute(_uploadId: string, record: RecordEntity) {
await this.dalService.updateRecord(_uploadId, record.index, record);
async execute(_uploadId: string, data: UpdateCellCommand) {
await this.dalService.updateRecord(_uploadId, data.index, data.record, data.updated);
}
}
4 changes: 2 additions & 2 deletions apps/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"dependencies": {
"@craco/craco": "^6.4.5",
"@emotion/react": "^11.10.5",
"@handsontable/react": "^13.1.0",
"@handsontable/react": "^14.1.0",
"@impler/client": "^0.20.0",
"@impler/shared": "^0.20.0",
"@mantine/core": "6.0.21",
Expand All @@ -54,7 +54,7 @@
"cooltipz-css": "^2.3.0",
"cross-env": "^7.0.3",
"file-saver": "^2.0.5",
"handsontable": "^13.1.0",
"handsontable": "^14.1.0",
"http-server": "^14.1.1",
"moment": "^2.29.4",
"react": "18.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
vertical-align: middle !important;
padding: 5px !important;
}
.cell-value {
max-width: 80%;
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.index-cell {
text-align: center;
vertical-align: middle !important;
Expand Down Expand Up @@ -107,9 +114,10 @@
border: 1px solid #ddd;

}
.ht_clone_left {
/* .ht_clone_left {
box-shadow: 2px 0px 6px 0px rgb(0 0 0 / 20%);
}
} */


.dd-searchbox {
padding: 0.5rem;
Expand Down
12 changes: 9 additions & 3 deletions apps/widget/src/components/Common/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Handsontable from 'handsontable';
import { HotItemSchema } from '@types';
import { IRecord } from '@impler/shared';
import { HANDSONTABLE_LICENSE_KEY } from '@config';
import HotTableClass from '@handsontable/react/hotTableClass';
import { registerValidator, dateValidator } from 'handsontable/validators';

registerCellType(NumericCellType);
Expand Down Expand Up @@ -86,7 +87,12 @@ Handsontable.renderers.registerRenderer(
errorSvg.appendChild(errorSvgPath);

TD.innerHTML = '';
TD.appendChild(document.createTextNode(fieldValue));
const valueSpan = document.createElement('span');
if (soureData.updated?.[name] || soureData.errors?.[name]) {
valueSpan.classList.add('cell-value');
}
valueSpan.appendChild(document.createTextNode(fieldValue));
TD.appendChild(valueSpan);
if (soureData.updated && soureData.updated[name]) {
errorSvg.setAttribute('style', 'vertical-align: middle;float: right;cursor: pointer;color:#795e00;');
if (soureData.errors && soureData.errors[name]) {
Expand Down Expand Up @@ -147,7 +153,7 @@ Handsontable.renderers.registerRenderer(
}
);

export const Table = forwardRef<HotTable, TableProps>(
export const Table = forwardRef<HotTableClass, TableProps>(
(
{
afterRender,
Expand Down Expand Up @@ -205,7 +211,7 @@ export const Table = forwardRef<HotTable, TableProps>(
} class="checkbox__control"><svg class="checkbox__control-icon" xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 24 24"><path fill="currentColor" d="M 20.292969 5.2929688 L 9 16.585938 L 4.7070312 12.292969 L 3.2929688 13.707031 L 9 19.414062 L 21.707031 6.7070312 L 20.292969 5.2929688 z"></path></svg></div>`;
}
}}
stretchH="all"
renderAllColumns
columns={columnDefs}
colHeaders={headings}
afterRender={afterRender}
Expand Down
12 changes: 8 additions & 4 deletions apps/widget/src/components/widget/Phases/Phase3/Phase3.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Badge, Flex, Stack } from '@mantine/core';
import { HotTable } from '@handsontable/react';
import { useRef, useState, useEffect } from 'react';
import HotTableClass from '@handsontable/react/hotTableClass';

import { PhasesEnum } from '@types';
import { logAmplitudeEvent } from '@amplitude';
Expand All @@ -11,20 +11,20 @@ import { ReviewConfirmModal } from './ReviewConfirmModal';
import { Table } from 'components/Common/Table';
import { Footer } from 'components/Common/Footer';

import { TEXTS } from '@config';
import { Button } from '@ui/Button';
import { Pagination } from '@ui/Pagination';
import { LoadingOverlay } from '@ui/LoadingOverlay';
import { SegmentedControl } from '@ui/SegmentedControl';
import { ConfirmModal } from 'components/widget/modals/ConfirmModal';
import { TEXTS } from '@config';

interface IPhase3Props {
onNextClick: (uploadData: IUpload) => void;
onPrevClick: () => void;
}

export function Phase3(props: IPhase3Props) {
const tableRef = useRef<HotTable>(null);
const tableRef = useRef<HotTableClass>(null);
const { onNextClick, onPrevClick } = props;
const {
page,
Expand Down Expand Up @@ -119,7 +119,11 @@ export function Phase3(props: IPhase3Props) {
currentData[row].record[name] = newVal;
currentData[row].updated[name] = true;
setReviewData(currentData);
updateRecord(currentData[row]);
updateRecord({
index: currentData[row].index,
record: currentData[row].record,
updated: currentData[row].updated,
});
}
}}
onRowCheck={(rowIndex, recordIndex, checked) => {
Expand Down
5 changes: 3 additions & 2 deletions apps/widget/src/hooks/Phase3/usePhase3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ export function usePhase3({ onNext }: IUsePhase3Props) {
notifier.showError({ message: error.message, title: error.error });
},
});
const { mutate: updateRecord } = useMutation<unknown, IErrorObject, IRecord, [string]>([`update`], (record) =>
api.updateRecord(uploadInfo._id, record)
const { mutate: updateRecord } = useMutation<unknown, IErrorObject, Partial<IRecord>, [string]>(
[`update`],
(record) => api.updateRecord(uploadInfo._id, record)
);
const { mutate: deleteRecords, isLoading: isDeleteRecordLoading } = useMutation<
unknown,
Expand Down
14 changes: 12 additions & 2 deletions libs/dal/src/dal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ export class DalService {
.limit(limit)
.exec();
}
async updateRecord(_uploadId: string, index: number, record: RecordEntity) {
async updateRecord(
_uploadId: string,
index: number,
record: Record<string, string>,
updated: Record<string, boolean>
) {
const model = this.getRecordCollection(_uploadId);
if (!model) return;
if (record._id) delete record._id;
Expand All @@ -71,7 +76,12 @@ export class DalService {
{
index,
},
record
{
$set: {
record,
updated,
},
}
);
}
async deleteRecords(_uploadId: string, index: number[]) {
Expand Down
Loading

0 comments on commit 0176fd8

Please sign in to comment.