Skip to content

Commit

Permalink
Merge pull request #153 from mansurskTarento/cios-via-api
Browse files Browse the repository at this point in the history
Cios via api
  • Loading branch information
sureshece16 authored Jan 7, 2025
2 parents b169538 + a783801 commit 80e3f10
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class ProviderDetailsComponent implements OnInit, OnChanges {
lastModified: Date.now(),
})
}
}, 'image/png')
}, 'image/png')

this.imageUrl = canvas.toDataURL('image/png')
}
Expand Down Expand Up @@ -316,10 +316,12 @@ export class ProviderDetailsComponent implements OnInit, OnChanges {
contentPartnerName: formDetails.contentPartnerName,
providerTips: formDetails.providerTips,
link: this.thumbNailUrl,
documentUrl: this.uploadedPdfUrl,
documentUploadedDate: this.fileUploadedDate,
partnerCode: formDetails.partnerCode.toUpperCase(),
}
if (this.uploadedPdfUrl) {
formBody['documentUrl'] = this.uploadedPdfUrl
formBody['documentUploadedDate'] = this.fileUploadedDate
}

this.marketPlaceSvc.createProvider(formBody).subscribe({
next: (responce: any) => {
Expand All @@ -330,7 +332,7 @@ export class ProviderDetailsComponent implements OnInit, OnChanges {
this.showSnackBar(successMsg)
const providerId = _.get(responce, 'result.id')
this.router.navigate([`/app/home/marketplace-providers/onboard-partner/${providerId}`])
}, 1000)
}, 1000)
}
},
error: (error: HttpErrorResponse) => {
Expand All @@ -353,8 +355,13 @@ export class ProviderDetailsComponent implements OnInit, OnChanges {
this.providerDetalsBeforUpdate['data']['contentPartnerName'] = formDetails.contentPartnerName
this.providerDetalsBeforUpdate['data']['providerTips'] = formDetails.providerTips
this.providerDetalsBeforUpdate['data']['link'] = this.thumbNailUrl
this.providerDetalsBeforUpdate['data']['documentUrl'] = this.uploadedPdfUrl
this.providerDetalsBeforUpdate['data']['documentUploadedDate'] = this.fileUploadedDate
if (this.uploadedPdfUrl) {
this.providerDetalsBeforUpdate['data']['documentUrl'] = this.uploadedPdfUrl
this.providerDetalsBeforUpdate['data']['documentUploadedDate'] = this.fileUploadedDate
} else {
delete this.providerDetalsBeforUpdate['data']['documentUrl']
delete this.providerDetalsBeforUpdate['data']['documentUploadedDate']
}

this.marketPlaceSvc.updateProvider(this.providerDetalsBeforUpdate).subscribe({
next: (responce: any) => {
Expand All @@ -364,7 +371,7 @@ export class ProviderDetailsComponent implements OnInit, OnChanges {
const successMsg = 'Provider details updated successfully.'
this.showSnackBar(successMsg)
this.sendDetailsUpdateEvent()
}, 1000)
}, 1000)
}
},
error: (error: HttpErrorResponse) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,43 @@
</div>
<div class="flex flex-col gap-4 transformation-box"
[ngClass]="{'transformation-required': (!transformationsUpdated && executed)}">
<form [formGroup]="transforamtionForm">
<div class="flex flex-col gap-2">
<ng-container *ngFor="let transFormControl of transFormContentKeysAndControls">
<div class="flex gap-4 items-center">
<span class="lable">{{transFormControl.lable}}</span>
<span class="colun">:</span>
<mat-form-field appearance="outline" class="w-full"
[matTooltip]="availableHeadrsList.length ? null : 'Please upload file'">
<mat-select formControlName="{{transFormControl.controlName}}" (selectionChange)="onSelectChange()"
[placeholder]=transFormControl.lable>
<ng-container *ngFor="let header of availableHeadrsList">
<mat-option [value]="header">
{{header}}
</mat-option>
</ng-container>
<ng-container *ngIf="transforamtionForm.value[transFormControl.controlName]">
<mat-option [value]="transforamtionForm.value[transFormControl.controlName]">
{{transforamtionForm.value[transFormControl.controlName]}}
</mat-option>
</ng-container>
</mat-select>
</mat-form-field>
</div>
</ng-container>
</div>
</form>
<mat-radio-group [(ngModel)]="transforamtionType" class="flex gap-4 mb-4">
<mat-radio-button value="viaForm">Map Form</mat-radio-button>
<mat-radio-button value="viaSpec">Spec</mat-radio-button>
</mat-radio-group>
<ng-container *ngIf="transforamtionType === 'viaForm'; else specForm">
<form [formGroup]="transforamtionForm">
<div class="flex flex-col gap-2">
<ng-container *ngFor="let transFormControl of transFormContentKeysAndControls">
<div class="flex gap-4 items-center">
<mat-form-field appearance="outline" class="w-full"
[matTooltip]="availableHeadrsList.length ? null : 'Please upload file'">
<mat-select formControlName="{{transFormControl.controlName}}" (selectionChange)="onSelectChange()"
[placeholder]=transFormControl.lable>
<ng-container *ngFor="let header of availableHeadrsList">
<mat-option [value]="header">
{{header}}
</mat-option>
</ng-container>
<ng-container *ngIf="transforamtionForm.value[transFormControl.controlName]">
<mat-option [value]="transforamtionForm.value[transFormControl.controlName]">
{{transforamtionForm.value[transFormControl.controlName]}}
</mat-option>
</ng-container>
</mat-select>
</mat-form-field>
<span class="colun">:</span>
<span class="lable">{{transFormControl.lable}}</span>
</div>
</ng-container>
</div>
</form>
</ng-container>
<ng-template #specForm>
<json-editor [options]="editorOptions" [formControl]="transformationSpecForm" class="transformationEditor"
[ngClass]="{'has-error': transformationSpecForm.invalid && transformationSpecForm.touched}">
</json-editor>
</ng-template>
<div class="flex w-full justify-end mt-4">
<button mat-button class="save-properties" (click)="upDateTransforamtionDetails()">
{{getUpdateBtnText}}</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
font: 700 14px Lato;
/* stylelint-disable */
color: #212529;
width: 180px;
width: 50%;
}

.colun {
Expand Down Expand Up @@ -184,6 +184,16 @@
}
}

:host ::ng-deep .transformationEditor {
.jsoneditor {
height: 400px;
}
}

:host ::ng-deep .has-error .jsoneditor {
border: 1px solid red;
}

:host ::ng-deep .transformation-box {
.mat-form-field-flex {
height: 50px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ConformationPopupComponent } from '../../dialogs/conformation-popup/con
import { HttpErrorResponse } from '@angular/common/http'
import * as XLSX from 'xlsx'
import { environment } from '../../../../../../../../../../../src/environments/environment'
import { JsonEditorOptions } from 'ang-jsoneditor'

@Component({
selector: 'ws-app-transformations',
Expand All @@ -35,7 +36,9 @@ export class TransformationsComponent implements OnInit, OnChanges {
dialogRef: any

//#region (transformation variables)
transforamtionType = 'viaForm'
transforamtionForm!: FormGroup
transformationSpecForm!: FormControl
providerDetalsBeforUpdate: any
transFormContentKeysAndControls: {
lable: string,
Expand All @@ -47,6 +50,7 @@ export class TransformationsComponent implements OnInit, OnChanges {
executed = false
uploadedFileHeadersList: string[] = []
availableHeadrsList: string[] = []
editorOptions = new JsonEditorOptions()
//#endregion
//#endregion

Expand Down Expand Up @@ -84,7 +88,15 @@ export class TransformationsComponent implements OnInit, OnChanges {
}

initializTransforamtionControls() {
this.transformationSpecForm = new FormControl(
_.get(this.providerDetalsBeforUpdate, this.transformationType, {}), Validators.required)
this.transforamtionForm = this.formBuilder.group({})
this.editorOptions.mode = 'text'
this.editorOptions.mainMenuBar = false
this.editorOptions.navigationBar = false
this.editorOptions.statusBar = false
this.editorOptions.enableSort = false
this.editorOptions.enableTransform = false
this.providerDetalsBeforUpdate['certificateTemplateUrl'] =
_.get(this.providerDetalsBeforUpdate, 'certificateTemplateUrl', '').replace(' ', '')
let trasformationJson: any = {}
Expand Down Expand Up @@ -162,7 +174,8 @@ export class TransformationsComponent implements OnInit, OnChanges {
reader.onload = () => {
const csvData = reader.result
const csvRecordsArray = (<string>csvData).split(/\r\n|\n/)
this.availableHeadrsList = this.getHeaderArray(csvRecordsArray)
this.uploadedFileHeadersList = this.getHeaderArray(csvRecordsArray)
this.availableHeadrsList = JSON.parse(JSON.stringify(this.uploadedFileHeadersList))
}
const that = this.showSnackBar
reader.onerror = function () {
Expand All @@ -189,20 +202,27 @@ export class TransformationsComponent implements OnInit, OnChanges {
this.providerDetalsBeforUpdate['data']['isActive'] = true
const hasTransformationAlready = this.providerDetalsBeforUpdate[this.transformationType] ? true : false
this.transforamtionForm.markAllAsTouched()
if (this.transforamtionForm.valid) {
this.transformationSpecForm.markAsTouched()
if ((this.transforamtionType === 'viaForm' && this.transforamtionForm.valid) ||
(this.transforamtionType === 'viaSpec' && this.transformationSpecForm.valid && this.transformationSpecForm.value !== '{}')) {
if (this.transformationType !== 'certificateTemplateUrl') {
const trasformContentSpec: any = {} // contains maped transform spec for db
const specValues = this.transforamtionForm.value
this.transFormContentKeysAndControls.forEach((transFormContent: any) => {
trasformContentSpec[specValues[transFormContent.controlName]] = transFormContent.path
})

if (hasTransformationAlready) {
this.providerDetalsBeforUpdate[this.transformationType][0]['spec'] = trasformContentSpec
if (this.transforamtionType === 'viaForm') {
const trasformContentSpec: any = {} // contains maped transform spec for db
const specValues = this.transforamtionForm.value
this.transFormContentKeysAndControls.forEach((transFormContent: any) => {
trasformContentSpec[specValues[transFormContent.controlName]] = transFormContent.path
})

if (hasTransformationAlready && _.get(this.providerDetalsBeforUpdate, `${this.transformationType}[0].spec`)) {
this.providerDetalsBeforUpdate[this.transformationType]['0']['spec'] = trasformContentSpec
} else {
const trasformContentJson = this.providerConfiguration.trasformContentJson
trasformContentJson[0]['spec'] = trasformContentSpec
this.providerDetalsBeforUpdate[this.transformationType] = trasformContentJson
this.transformationSpecForm.patchValue(trasformContentJson)
}
} else {
const trasformContentJson = this.providerConfiguration.trasformContentJson
trasformContentJson[0]['spec'] = trasformContentSpec
this.providerDetalsBeforUpdate[this.transformationType] = trasformContentJson
this.providerDetalsBeforUpdate[this.transformationType] = this.transformationSpecForm.value
}
}
this.marketPlaceSvc.updateProvider(this.providerDetalsBeforUpdate).subscribe({
Expand Down

0 comments on commit 80e3f10

Please sign in to comment.