Open loan-mgt opened 1 year ago
Hi @Qypol342 i would like to contribute to this issue Can you please elaborate more about what things should be added in the json file
Hi @Qypol342 , I want to contribute to this issue under hacktoberfest 2023. Please let me know what needs to be added in the README. Thank you!
Please add an example.json file to the repo, and include a link in the readme to make it easily downloadable for new users, along with a brief guide on how to use it. Here is an example of the JSON format:
[
{
"filePath": "/src/app/pages/crm/collaborator/collaborator-contracts/collaborator-contracts-table/collaborator-contracts-table.component.html",
"messages": [],
"suppressedMessages": [],
"errorCount": 0,
"fatalErrorCount": 0,
"warningCount": 0,
"fixableErrorCount": 0,
"fixableWarningCount": 0,
"usedDeprecatedRules": []
},
{
"filePath": "/src/app/pages/crm/collaborator-request/transport-costs-table/transport-costs-table.component.ts",
"messages": [
{
"ruleId": "@typescript-eslint/explicit-function-return-type",
"severity": 2,
"message": "Missing return type on function.",
"line": 235,
"column": 5,
"nodeType": "FunctionExpression",
"messageId": "missingReturnType",
"endLine": 235,
"endColumn": 16
},
{
"ruleId": "unused-imports/no-unused-vars",
"severity": 1,
"message": "'i' is defined but never used. Allowed unused args must match /^_/u.",
"line": 321,
"column": 15,
"nodeType": "Identifier",
"messageId": "unusedVar",
"endLine": 321,
"endColumn": 24
},
{
"ruleId": "@typescript-eslint/no-unused-vars",
"severity": 2,
"message": "'i' is defined but never used.",
"line": 321,
"column": 15,
"nodeType": "Identifier",
"messageId": "unusedVar",
"endLine": 321,
"endColumn": 24
},
{
"ruleId": "@typescript-eslint/explicit-function-return-type",
"severity": 2,
"message": "Missing return type on function.",
"line": 330,
"column": 5,
"nodeType": "FunctionExpression",
"messageId": "missingReturnType",
"endLine": 330,
"endColumn": 23
},
{
"ruleId": "unused-imports/no-unused-vars",
"severity": 1,
"message": "'response' is defined but never used. Allowed unused args must match /^_/u.",
"line": 373,
"column": 24,
"nodeType": "Identifier",
"messageId": "unusedVar",
"endLine": 373,
"endColumn": 32
},
{
"ruleId": "@typescript-eslint/no-unused-vars",
"severity": 2,
"message": "'response' is defined but never used.",
"line": 373,
"column": 24,
"nodeType": "Identifier",
"messageId": "unusedVar",
"endLine": 373,
"endColumn": 32
},
{
"ruleId": "@typescript-eslint/explicit-function-return-type",
"severity": 2,
"message": "Missing return type on function.",
"line": 383,
"column": 5,
"nodeType": "FunctionExpression",
"messageId": "missingReturnType",
"endLine": 383,
"endColumn": 22
},
{
"ruleId": "@typescript-eslint/explicit-function-return-type",
"severity": 2,
"message": "Missing return type on function.",
"line": 409,
"column": 5,
"nodeType": "FunctionExpression",
"messageId": "missingReturnType",
"endLine": 409,
"endColumn": 24
}
],
"suppressedMessages": [],
"errorCount": 6,
"fatalErrorCount": 0,
"warningCount": 2,
"fixableErrorCount": 0,
"fixableWarningCount": 0,
"source": "import {\n AfterViewInit,\n Component,\n DestroyRef,\n inject,\n ViewChild,\n} from '@angular/core';\nimport { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';\nimport { MatTableDataSource, MatTableModule } from '@angular/material/table';\nimport { TransportSubscriptionWebservice } from '../../../../core/webservice/transport-subscription.webservice';\nimport { ActivatedRoute } from '@router';\nimport { Observable, take } from 'rxjs';\nimport { TransportCostsDTO } from '../../../../core/domain/dto/transport-costs/transport-costs.dto';\nimport {\n animate,\n state,\n style,\n transition,\n trigger,\n} from '@animations';\nimport { TransportCostsDetailDTO } from '../../../../core/domain/dto/transport-costs/transport-costs-detail.dto';\nimport { MatDialog } from '@material/dialog';\nimport { TransportReceiptDialogComponent } from '../transport-receipt-dialog/transport-receipt-dialog.component';\nimport { TranslocoModule, TranslocoService } from '@ngneat/transloco';\nimport { SnackbarService } from '../../../../core/services/snackbar.service';\nimport { DocumentWebservice } from '../../../../core/webservice/document.webservice';\nimport { HttpResponse } from '@common/http';\nimport { BlobService } from '../../../../core/services/blob.service';\nimport { FileViewerDialogComponent } from '../../../../shared/components/file-viewer-dialog/file-viewer-dialog.component';\nimport { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';\nimport { map } from 'rxjs/operators';\nimport { DatePipe, NgClass, NgIf } from '@common';\nimport { MatIconModule } from '@material/icon';\nimport { MatButtonModule } from '@material/button';\nimport { DatePickerDialogComponent } from '../../../../shared/components/date-picker-dialog/date-picker-dialog.component';\nimport { TransportReceiptLightDTO } from '../../../../core/domain/dto/transport-costs/transport-receipt-light.dto';\nimport { TransportReceiptWebservice } from '../../../../core/webservice/transport-receipt.webservice';\nimport { FuseConfirmationService } from '../../../../../@fuse/services/confirmation';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n\ntype TransportSubscriptionTableDataSource = {\n expended: boolean;\n isCurrentPeriodFulfill: boolean;\n subTable: MatTableDataSource<TransportReceiptLightDataSource>;\n} & TransportCostsDetailDTO;\n\ntype TransportReceiptLightDataSource = {\n srclink: SafeResourceUrl;\n file: Blob;\n} & TransportReceiptLightDTO;\n\n// firefox pdf viewer doesn't allow for preview\nconst displayReceiptPreview = !navigator.userAgent.includes('Firefox');\n\n@Component({\n selector: 'app-transport-costs-table',\n templateUrl: './transport-costs-table.component.html',\n styleUrls: ['./transport-costs-table.component.scss'],\n animations: [\n trigger('detailExpand', [\n state('collapsed', style({ maxHeight: '0px', minHeight: '0' })),\n state(\n 'expanded',\n style({\n maxHeight: '300px', // animate the max-height instead of the height\n }),\n ),\n transition(\n 'expanded <=> collapsed',\n animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)'),\n ),\n ]),\n ],\n standalone: true,\n imports: [\n MatTableModule,\n TranslocoModule,\n DatePipe,\n MatIconModule,\n MatPaginatorModule,\n NgIf,\n NgClass,\n NgIf,\n MatButtonModule,\n ],\n})\nexport class TransportCostsTableComponent implements AfterViewInit {\n @ViewChild(MatPaginator)\n paginator: MatPaginator;\n datasource: MatTableDataSource<TransportSubscriptionTableDataSource> =\n new MatTableDataSource<TransportSubscriptionTableDataSource>();\n currentDate = new Date();\n displayReceiptPreview = displayReceiptPreview;\n displayedColumns: string[] = [\n 'transportType',\n 'subscriptionPeriodType',\n 'subscriptionPeriod',\n 'dateOfLastReceipt',\n 'lastStatus',\n 'expand',\n ];\n expendableColumn: string[] = ['expendable'];\n subTableColumn: string[] = [\n 'submitDate',\n 'paymentDate',\n 'receipt',\n 'amount',\n 'status',\n 'action',\n ];\n transportCostEndDateUpdated = {\n successMessage: this._translocoService.translate(\n 'crm.collaborator.request.transportCostEndDateUpdateSuccess',\n ),\n failedMessage: this._translocoService.translate('errors.generalError'),\n };\n confirmRemoveTransportCost = {\n title: this._translocoService.translate(\n 'crm.collaborator.request.removeTransportCost.title',\n ),\n desc: this._translocoService.translate(\n 'crm.collaborator.request.removeTransportCost.desc',\n ),\n };\n\n confirmRemoveTransportReceipt = {\n title: this._translocoService.translate(\n 'crm.collaborator.request.removeTransportReceipt.title',\n ),\n desc: this._translocoService.translate(\n 'crm.collaborator.request.removeTransportReceipt.desc',\n ),\n };\n\n private readonly _destroyRef = inject(DestroyRef);\n\n constructor(\n private readonly _transportReceiptWebservice: TransportReceiptWebservice,\n private readonly _transportSubscriptionWebservice: TransportSubscriptionWebservice,\n private readonly _documentWebservice: DocumentWebservice,\n private readonly _activatedRoute: ActivatedRoute,\n private readonly _dialog: MatDialog,\n private readonly _snack: SnackbarService,\n private readonly _blob: BlobService,\n private readonly _translocoService: TranslocoService,\n private readonly _domSanitizer: DomSanitizer,\n private readonly _fuseConfirmationService: FuseConfirmationService,\n ) {}\n\n ngAfterViewInit(): void {\n this.update();\n }\n\n update(): void {\n this.datasource.paginator = this.paginator;\n\n this._transportSubscriptionWebservice\n .findByCollaboratorIdDetail(\n this.paginator.pageIndex,\n this.paginator.pageSize,\n this._activatedRoute.snapshot.data.collaborator?.main?.id,\n )\n .pipe(takeUntilDestroyed(this._destroyRef))\n .subscribe((data) => {\n this.datasource.data =\n this.mapToDatasourceType(data.content) ?? [];\n this.paginator.length = data?.totalElements ?? 0;\n });\n }\n\n mapToDatasourceType(\n content: TransportCostsDetailDTO[],\n ): TransportSubscriptionTableDataSource[] {\n return content.map((value) => {\n const subTableSource =\n new MatTableDataSource<TransportReceiptLightDataSource>();\n subTableSource.data =\n this.mapToDatasourceTypeReceipt(value.transportReceipt) ?? [];\n\n return {\n ...value,\n expended: false,\n isCurrentPeriodFulfill:\n value.subscriptionType.code === 'MONTH'\n ? this.isCurrentMonth(\n value.transportReceipt[0]?.paymentDate,\n )\n : this.isCurrentYear(\n value.transportReceipt[0]?.paymentDate,\n ),\n subTable: subTableSource,\n };\n });\n }\n\n mapToDatasourceTypeReceipt(\n content: TransportReceiptLightDTO[],\n ): TransportReceiptLightDataSource[] {\n return content.map((value) => {\n return {\n ...value,\n srclink: null,\n file: null,\n };\n });\n }\n\n isCurrentMonth(date: string): boolean {\n return new Date(date).getMonth() === new Date().getMonth();\n }\n\n isCurrentYear(date: string): boolean {\n return new Date(date).getFullYear() === new Date().getFullYear();\n }\n\n addReceipt(\n transportSubscription: TransportCostsDTO,\n transportReceiptLightDTO?: TransportReceiptLightDTO,\n ): void {\n const dialogRef = this._dialog.open(TransportReceiptDialogComponent, {\n data: {\n transportSubscriptionId: transportSubscription.id,\n readonly: false,\n transportReceiptLightDTO,\n },\n });\n dialogRef\n .afterClosed()\n .pipe(takeUntilDestroyed(this._destroyRef))\n .subscribe((reponse) => {\n this.handelSnack(reponse);\n });\n }\n\n handelSnack(reponse: boolean) {\n switch (reponse) {\n case true:\n this._snack.handleHttpResponse(200);\n this.update();\n break;\n case false:\n this._snack.handleHttpResponse(0);\n break;\n default:\n break;\n }\n }\n\n editReceipt(\n transportSubscription: TransportSubscriptionTableDataSource,\n transportReceipt: TransportReceiptLightDataSource,\n ): void {\n this.addReceipt(transportSubscription, transportReceipt);\n }\n\n deleteReceiptDialog(\n element: TransportReceiptLightDataSource,\n e: Event,\n ): void {\n e.stopPropagation();\n\n const dialogRef = this._fuseConfirmationService.open({\n title: this.confirmRemoveTransportReceipt.title,\n message: this.confirmRemoveTransportReceipt.desc,\n });\n\n dialogRef\n .afterClosed()\n .pipe(takeUntilDestroyed(this._destroyRef), take(1))\n .subscribe((result) => {\n if (result === 'confirmed') {\n this.deleteReceipt(element.id);\n }\n });\n }\n\n deleteReceipt(id: number): void {\n this._transportReceiptWebservice.delete(id).subscribe({\n next: (response) => {\n this._snack.handleHttpResponse(response.status);\n this.update();\n },\n error: (error) => {\n this._snack.handleHttpResponse(error.status);\n },\n });\n }\n\n loadFile(element: TransportSubscriptionTableDataSource, i: number): void {\n const transportReceipt = element.subTable.data[i];\n const file = transportReceipt.file;\n\n if (file) {\n this.openFileViewerDialog(file);\n } else {\n const receiptId = transportReceipt.receipt.id;\n this.getReceipt(receiptId).subscribe(\n (response: HttpResponse<Blob>) => {\n const blob = this._blob.create(\n response,\n transportReceipt.receipt.mimeType,\n );\n this.openFileViewerDialog(blob);\n },\n );\n }\n }\n\n openFileViewerDialog(file: Blob): void {\n this._dialog.open(FileViewerDialogComponent, {\n data: { file },\n });\n }\n\n getReceipt(id: number): Observable<HttpResponse<Blob>> {\n return this._documentWebservice\n .download(id)\n .pipe(takeUntilDestroyed(this._destroyRef));\n }\n\n rowChange(i: number): void {\n if (displayReceiptPreview) {\n const data = this.datasource.data[0];\n data.subTable.data.forEach((value) => {\n this.loadFileForPreview(value);\n });\n }\n }\n\n loadFileForPreview(transportReceipt: TransportReceiptLightDataSource) {\n if (transportReceipt.srclink) {\n return;\n }\n\n if (!transportReceipt.file) {\n this.getReceipt(transportReceipt.receipt.id)\n .pipe(\n map((response: HttpResponse<Blob>) => {\n const file = this._blob.create(\n response,\n transportReceipt.receipt.mimeType,\n );\n return {\n file,\n srclink: this.getFileUrl(file),\n };\n }),\n )\n .subscribe((transformedData) => {\n transportReceipt.file = transformedData.file;\n transportReceipt.srclink = transformedData.srclink;\n });\n } else {\n transportReceipt.srclink = this.getFileUrl(transportReceipt.file);\n }\n }\n\n getFileUrl(file: Blob): SafeResourceUrl {\n return this._domSanitizer.bypassSecurityTrustResourceUrl(\n URL.createObjectURL(file) +\n '#toolbar=0&navpanes=0&scrollbar=0&statusbar=0&messages=0&scrollbar=0&view=FitV&zoom=page-fit&page=1',\n );\n }\n\n editEndDate(date: Date, id: number): void {\n this._transportSubscriptionWebservice\n .updateEndDate({\n id,\n endDate: date,\n })\n .pipe(takeUntilDestroyed(this._destroyRef), take(1))\n .subscribe({\n next: (response) => {\n this._snack.handleHttpResponse(200);\n this.update();\n },\n error: (error) => {\n this._snack.handleHttpResponse(error.status);\n },\n });\n }\n\n editEndDateDialog(element: TransportSubscriptionTableDataSource, e: Event) {\n if (element.subscriptionType.code !== 'MONTH') {\n return;\n }\n e.stopPropagation();\n const minDate = new Date(element.startDate);\n minDate.setMonth(minDate.getMonth() + 1);\n\n const dialogRef = this._dialog.open(DatePickerDialogComponent, {\n data: {\n title: this._translocoService.translate('Date de fin'),\n desc: this._translocoService.translate(\n 'Sélectionner une nouvelle date de fin',\n ),\n minDate,\n },\n });\n\n dialogRef\n .afterClosed()\n .pipe(takeUntilDestroyed(this._destroyRef))\n .subscribe((result) => {\n this.editEndDate(result, element.id);\n });\n }\n\n deleteTransportCost(element) {\n const dialogRef = this._fuseConfirmationService.open({\n title: this.confirmRemoveTransportCost.title,\n message: this.confirmRemoveTransportCost.desc,\n });\n\n dialogRef\n .afterClosed()\n .pipe(takeUntilDestroyed(this._destroyRef), take(1))\n .subscribe((result) => {\n if (result === 'confirmed') {\n this._transportSubscriptionWebservice\n .delete(element.id)\n .pipe(takeUntilDestroyed(this._destroyRef))\n .subscribe(() => {\n this.update();\n });\n }\n });\n }
}
]
@Vidhanvyrs You've been assigned 👍
@ISaumya1011 I've also assigned you
I've removed the assignment for inactivity.
Can you attribute me this issue please ?
add in the readme a exemple json file for people to download and easily try the project out