From 3b6ea5bd09848336bea039bf3661255913435474 Mon Sep 17 00:00:00 2001 From: mansurskTarento Date: Tue, 6 Aug 2024 19:17:12 +0530 Subject: [PATCH 1/4] fixing designations list issue --- .../components/designations/designations.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts b/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts index 303f18aab..b5143b5ab 100644 --- a/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts @@ -135,7 +135,7 @@ export class DesignationsComponent implements OnInit { } else { setTimeout(() => { this.getOrgReadData() - }, 10000) + }, 10000) } // console.log('orgFramework Details', res) }) @@ -179,7 +179,7 @@ export class DesignationsComponent implements OnInit { } getDesignations() { - this.designationsList = this.getTermsByCode('designation') + this.designationsList = _.get(this.organisationsList, '[0].children') this.designationsService.setCurrentOrgDesignationsList(this.designationsList) this.filterDesignations() } From 2218521b70746688b0dd285962b348e98fb6afcc Mon Sep 17 00:00:00 2001 From: mansurskTarento Date: Wed, 7 Aug 2024 11:11:23 +0530 Subject: [PATCH 2/4] fixing designations list issue --- .../designations/designations.component.ts | 12 ++++---- .../services/designations.service.ts | 29 +++++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts b/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts index b5143b5ab..23b893498 100644 --- a/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts @@ -135,7 +135,7 @@ export class DesignationsComponent implements OnInit { } else { setTimeout(() => { this.getOrgReadData() - }, 10000) + }, 10000) } // console.log('orgFramework Details', res) }) @@ -328,10 +328,12 @@ export class DesignationsComponent implements OnInit { this.designationsService.publishFramework(frameworkName).subscribe({ next: response => { if (response) { - this.getFrameworkInfo(this.frameworkDetails.code) - if (action && action === 'delete') { - this.openSnackbar('Deleted Successfully') - } + setTimeout(() => { + this.getFrameworkInfo(this.frameworkDetails.code) + if (action && action === 'delete') { + this.openSnackbar('Deleted Successfully') + } + }, 10000) } }, error: (error: HttpErrorResponse) => { diff --git a/project/ws/app/src/lib/routes/home/routes/designation/services/designations.service.ts b/project/ws/app/src/lib/routes/home/routes/designation/services/designations.service.ts index 93e851a14..570adad9a 100644 --- a/project/ws/app/src/lib/routes/home/routes/designation/services/designations.service.ts +++ b/project/ws/app/src/lib/routes/home/routes/designation/services/designations.service.ts @@ -132,18 +132,7 @@ export class DesignationsService { category: a.category, associations: a.associations, // config: this.getConfig(a.code), - children: (a.terms || []).map((c: any) => { - const associations = c.associations || [] - if (associations.length > 0) { - Object.assign(c, { children: associations }) - } - const importedBy = _.get(c, 'additionalProperties.importedById', null) === _.get(this.userProfile, 'userId', '') - ? 'You' : _.get(c, 'additionalProperties.importedByName', null) - c['importedByName'] = importedBy, - c['importedOn'] = _.get(c, 'additionalProperties.importedOn'), - c['importedById'] = _.get(c, 'additionalProperties.importedById') - return c - }), + children: this.formateChildren(a.terms || []), }) }) @@ -163,6 +152,22 @@ export class DesignationsService { } + formateChildren(terms: any[]): any[] { + return terms.map((c: any) => { + const associations = c.associations || [] + if (associations.length > 0) { + Object.assign(c, { children: associations }) + this.formateChildren(c.associations) + } + const importedBy = _.get(c, 'additionalProperties.importedById', null) === _.get(this.userProfile, 'userId', '') + ? 'You' : _.get(c, 'additionalProperties.importedByName', null) + c['importedByName'] = importedBy, + c['importedOn'] = _.get(c, 'additionalProperties.importedOn'), + c['importedById'] = _.get(c, 'additionalProperties.importedById') + return c + }) + } + get getUuid() { return uuidv4() } From 2cc85f3415511d602f8774fa89e9a8f5ec72904f Mon Sep 17 00:00:00 2001 From: mansurskTarento Date: Thu, 8 Aug 2024 11:55:21 +0530 Subject: [PATCH 3/4] fixing navigation and api fail and message changes --- .../designations/designations.component.ts | 42 ++------- .../import-designation.component.ts | 93 +++++++++---------- .../routes/designation/designation.module.ts | 8 +- .../confirmation-box.component.html | 8 +- 4 files changed, 58 insertions(+), 93 deletions(-) diff --git a/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts b/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts index 23b893498..0c640d1d9 100644 --- a/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts @@ -4,7 +4,6 @@ import { ITableData } from '@sunbird-cb/collection/lib/ui-org-table/interface/in import { DesignationsService } from '../../services/designations.service' import { FormControl } from '@angular/forms' import { delay } from 'rxjs/operators' -import { HttpErrorResponse } from '@angular/common/http' import { MatDialog, MatSnackBar } from '@angular/material' import { ConformationPopupComponent } from '../../dialog-boxes/conformation-popup/conformation-popup.component' import { ActivatedRoute } from '@angular/router' @@ -103,9 +102,7 @@ export class DesignationsComponent implements OnInit { this.designationConfig = data.pageData.data }) - // console.log('this.configSvc', this.configSvc.orgReadData) if (this.configSvc.orgReadData && this.configSvc.orgReadData.frameworkid) { - // this.environmentVal.frameworkName = this.configSvc.orgReadData.frameworkid this.getFrameworkInfo(this.configSvc.orgReadData.frameworkid) } else { this.createFreamwork() @@ -135,7 +132,7 @@ export class DesignationsComponent implements OnInit { } else { setTimeout(() => { this.getOrgReadData() - }, 10000) + }, _.get(this.designationConfig, 'refreshDelayTime', 10000)) } // console.log('orgFramework Details', res) }) @@ -153,9 +150,9 @@ export class DesignationsComponent implements OnInit { this.getOrganisations() }, - error: (error: HttpErrorResponse) => { + error: () => { this.showLoader = false - const errorMessage = _.get(error, 'error.message', 'Some thing went wrong') + const errorMessage = _.get(this.designationConfig, 'internalErrorMsg') this.openSnackbar(errorMessage) }, @@ -217,26 +214,6 @@ export class DesignationsComponent implements OnInit { //#region (ui interactions like click) - // openDesignationCreatPopup(event?: any) { - // console.log('event', event) - // const dialogData = { - // mode: 'create', - // columnInfo: { - // code: 'designation', - // name: 'Designation', - // children: this.designationsList, - // }, - // frameworkId: 'organisation_fw', - // selectedDesignation: null - // } - // if (event && event.action) { - // dialogData.mode = event.action - // dialogData.selectedDesignation = event.row - // } - // } - - // upload() { } - menuSelected(event: any) { switch (event.action) { // case 'edit': @@ -252,7 +229,6 @@ export class DesignationsComponent implements OnInit { } openConformationPopup(event: any) { - // console.log('envent data', event) const dialogData = { dialogType: 'warning', descriptions: [ @@ -314,9 +290,9 @@ export class DesignationsComponent implements OnInit { this.showLoader = false } }, - error: (error: HttpErrorResponse) => { + error: () => { this.showLoader = false - const errorMessage = _.get(error, 'error.message', 'Some thing went wrong') + const errorMessage = _.get(this.designationConfig, 'internalErrorMsg') this.openSnackbar(errorMessage) }, }) @@ -331,14 +307,14 @@ export class DesignationsComponent implements OnInit { setTimeout(() => { this.getFrameworkInfo(this.frameworkDetails.code) if (action && action === 'delete') { - this.openSnackbar('Deleted Successfully') + this.openSnackbar(_.get(this.designationConfig, 'termRemoveMsg')) } - }, 10000) + }, _.get(this.designationConfig, 'refreshDelayTime', 10000)) } }, - error: (error: HttpErrorResponse) => { + error: () => { this.showLoader = false - const errorMessage = _.get(error, 'error.message', 'Some thing went wrong') + const errorMessage = _.get(this.designationConfig, 'internalErrorMsg') this.openSnackbar(errorMessage) }, }) diff --git a/project/ws/app/src/lib/routes/home/routes/designation/components/import-designation/import-designation.component.ts b/project/ws/app/src/lib/routes/home/routes/designation/components/import-designation/import-designation.component.ts index 76b2b39bb..2597eeccb 100644 --- a/project/ws/app/src/lib/routes/home/routes/designation/components/import-designation/import-designation.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/designation/components/import-designation/import-designation.component.ts @@ -5,7 +5,6 @@ import { FormControl } from '@angular/forms' import { catchError, delay, map } from 'rxjs/operators' import { SelectedDesignationPopupComponent } from '../../dialog-boxes/selected-designation-popup/selected-designation-popup.component' import { forkJoin, of, Subscription } from 'rxjs' -import { HttpErrorResponse } from '@angular/common/http' import * as _ from 'lodash' import { LoaderService } from '../../../../../../../../../../../src/app/services/loader.service' import { ActivatedRoute, Router } from '@angular/router' @@ -42,6 +41,7 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { designationsImportFailed: any = [] frameworkInfo: any = {} dialogRef: any + progressDialogData: any constructor( private designationsService: DesignationsService, @@ -51,14 +51,15 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { private snackBar: MatSnackBar, private datePipe: DatePipe, private activateRoute: ActivatedRoute - ) { } + ) { + this.getFrameWorkDetails() + } ngOnInit() { this.configSvc = this.activateRoute.snapshot.data['configService'] this.loadDesignations() - this.valudChangeSubscribers() - - this.getFrameWorkDetails() + this.valueChangeSubscription() + this.getRoutesData() } getFrameWorkDetails() { @@ -108,7 +109,7 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { return this.selectedDesignationsList } - valudChangeSubscribers() { + valueChangeSubscription() { if (this.searchControl) { this.searchControl.valueChanges.pipe(delay(500)).subscribe((value: string) => { this.loadDesignations(value) @@ -116,6 +117,12 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { } } + getRoutesData() { + this.activateRoute.data.subscribe(data => { + this.designationConfig = data.pageData.data + }) + } + selectDesignation(checked: Boolean, id: number) { const index = this.igotDesignationsList.findIndex((e: any) => e.id === id) const designation = this.igotDesignationsList[index] @@ -224,22 +231,25 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { this.updateTerms(orgCategorie) } }, - error: (error: HttpErrorResponse) => { + error: () => { this.dialogRef.close() - const errorMessage = _.get(error, 'error.message', 'Some thing went wrong') + const errorMessage = _.get(this.designationConfig, 'internalErrorMsg') this.openSnackbar(errorMessage) }, }) } } - updateTerms(orgCategorie: any) { + updateTerms(orgCategorie: any, retry = false) { if (this.selectedDesignationsList.length === this.designationsImportFailed.length) { this.dialogRef.close(false) - const errorMessage = 'Import failed' + const errorMessage = _.get(this.designationConfig, 'internalErrorMsg') this.openSnackbar(errorMessage) this.designationsImportFailed = [] } else { + if (retry === false) { + this.progressDialogData['subTitle'] = _.get(this.designationConfig, 'associationUpdateMsg') + } const framework = _.get(this.frameworkInfo, 'code') const category = _.get(orgCategorie, 'terms[0].category') const categoryTermCode = _.get(orgCategorie, 'terms[0].code') @@ -256,10 +266,16 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { this.publishFrameWork() } }, - error: (error: HttpErrorResponse) => { - const errorMessage = _.get(error, 'error.message', 'Some thing went wrong') - this.dialogRef.close() - this.openSnackbar(errorMessage) + error: () => { + if (retry) { + const errorMessage = _.get(this.designationConfig, 'internalErrorMsg') + this.dialogRef.close() + this.openSnackbar(errorMessage) + } else { + this.progressDialogData['subTitle'] = _.get(this.designationConfig, 'associationRetryMsg') + const traiagain = true + this.updateTerms(orgCategorie, traiagain) + } }, }) } @@ -267,16 +283,17 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { publishFrameWork() { const frameworkName = _.get(this.frameworkInfo, 'code') + this.progressDialogData['subTitle'] = _.get(this.designationConfig, 'publishingMsg') this.designationsService.publishFramework(frameworkName).subscribe({ next: response => { if (response) { setTimeout(() => { - this.dialogRef.close() - }, 10000) + this.dialogRef.close(true) + }, _.get(this.designationConfig, 'refreshDelayTime', 10000)) } }, - error: (error: HttpErrorResponse) => { - const errorMessage = _.get(error, 'error.message', 'Some thing went wrong') + error: () => { + const errorMessage = _.get(this.designationConfig, 'internalErrorMsg') this.dialogRef.close() this.openSnackbar(errorMessage) }, @@ -284,19 +301,20 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { } openProcessingBox() { - const dialogData = { + this.progressDialogData = { type: 'progress', icon: 'vega', - title: 'Importing your designation.', - subTitle: 'Please wait a moment, your import is in progress.', + title: _.get(this.designationConfig, 'importingDesignation'), + subTitle: _.get(this.designationConfig, 'termCreationMsg'), + showLoader: true } this.dialogRef = this.dialog.open(ConfirmationBoxComponent, { disableClose: true, - data: dialogData, + data: this.progressDialogData, autoFocus: false, }) - this.dialogRef.afterClosed().subscribe((res: boolean = true) => { + this.dialogRef.afterClosed().subscribe((res: boolean = false) => { if (res) { this.openConforamtionPopup() } @@ -318,33 +336,6 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { ], } descriptions.push(description) - // if (this.importedDesignationNames.length > 0) { - // const designationNames = this.importedDesignationNames.join(', ') - // const description = { - // header: 'Designations imported successfully', - // messages: [ - // { - // msgClass: 'textBold', - // msg: `${designationNames}`, - // }, - // { - // msgClass: '', - // msg: ' are imported successfully', - // }, - // ], - // } - // descriptions.push(description) - // } - - // descriptions.push({ - - // messages: [ - // { - // msgClass: '', - // msg: 'The changes will reflect shortly.', - // }, - // ], - // }) const dialogData = { descriptions, dialogType: 'warning', @@ -370,7 +361,7 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { this.navigateToMyDesignations() }) } else { - const successMessage = 'Imported Successfully ' + const successMessage = _.get(this.designationConfig, 'successMsg') this.openSnackbar(successMessage, 10000) this.navigateToMyDesignations() } diff --git a/project/ws/app/src/lib/routes/home/routes/designation/designation.module.ts b/project/ws/app/src/lib/routes/home/routes/designation/designation.module.ts index e31743d6e..ed579eab4 100644 --- a/project/ws/app/src/lib/routes/home/routes/designation/designation.module.ts +++ b/project/ws/app/src/lib/routes/home/routes/designation/designation.module.ts @@ -30,17 +30,11 @@ const routes: Routes = [ { path: 'import-designation', pathMatch: 'full', - // data: { - // pageId: 'home/org-designations/import-designation', - // module: 'manage-designations', - // pageType: 'feature', - // pageKey: 'import-designations', - // }, data: { pageId: 'home/odcs-mapping', module: 'odcs-mapping', pageType: 'feature', - pageKey: 'odcs', + pageKey: 'my_designations', }, component: ImportDesignationComponent, resolve: { diff --git a/project/ws/app/src/lib/routes/training-plan/components/confirmation-box/confirmation-box.component.html b/project/ws/app/src/lib/routes/training-plan/components/confirmation-box/confirmation-box.component.html index ff4c7ca95..7e58bfbd2 100644 --- a/project/ws/app/src/lib/routes/training-plan/components/confirmation-box/confirmation-box.component.html +++ b/project/ws/app/src/lib/routes/training-plan/components/confirmation-box/confirmation-box.component.html @@ -36,8 +36,12 @@ {{data?.subTitle}}
- - + + + + + +
From 4531f0e2c1ca3b9a9089c071f8f0c03069a278a4 Mon Sep 17 00:00:00 2001 From: mansurskTarento Date: Thu, 8 Aug 2024 12:17:13 +0530 Subject: [PATCH 4/4] lint issue fixes --- .../components/designations/designations.component.ts | 4 ++-- .../import-designation/import-designation.component.ts | 6 +++--- src/app/app.module.ts | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts b/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts index 0c640d1d9..c2d96b1e3 100644 --- a/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/designation/components/designations/designations.component.ts @@ -132,7 +132,7 @@ export class DesignationsComponent implements OnInit { } else { setTimeout(() => { this.getOrgReadData() - }, _.get(this.designationConfig, 'refreshDelayTime', 10000)) + }, _.get(this.designationConfig, 'refreshDelayTime', 10000)) } // console.log('orgFramework Details', res) }) @@ -309,7 +309,7 @@ export class DesignationsComponent implements OnInit { if (action && action === 'delete') { this.openSnackbar(_.get(this.designationConfig, 'termRemoveMsg')) } - }, _.get(this.designationConfig, 'refreshDelayTime', 10000)) + }, _.get(this.designationConfig, 'refreshDelayTime', 10000)) } }, error: () => { diff --git a/project/ws/app/src/lib/routes/home/routes/designation/components/import-designation/import-designation.component.ts b/project/ws/app/src/lib/routes/home/routes/designation/components/import-designation/import-designation.component.ts index 2597eeccb..13e301be6 100644 --- a/project/ws/app/src/lib/routes/home/routes/designation/components/import-designation/import-designation.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/designation/components/import-designation/import-designation.component.ts @@ -247,7 +247,7 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { this.openSnackbar(errorMessage) this.designationsImportFailed = [] } else { - if (retry === false) { + if (!retry) { this.progressDialogData['subTitle'] = _.get(this.designationConfig, 'associationUpdateMsg') } const framework = _.get(this.frameworkInfo, 'code') @@ -289,7 +289,7 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { if (response) { setTimeout(() => { this.dialogRef.close(true) - }, _.get(this.designationConfig, 'refreshDelayTime', 10000)) + }, _.get(this.designationConfig, 'refreshDelayTime', 10000)) } }, error: () => { @@ -306,7 +306,7 @@ export class ImportDesignationComponent implements OnInit, OnDestroy { icon: 'vega', title: _.get(this.designationConfig, 'importingDesignation'), subTitle: _.get(this.designationConfig, 'termCreationMsg'), - showLoader: true + showLoader: true, } this.dialogRef = this.dialog.open(ConfirmationBoxComponent, { disableClose: true, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 201538852..1e6e66986 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -25,6 +25,7 @@ import { MatCheckboxModule, MatNativeDateModule, MatSortModule, + MatProgressSpinnerModule, } from '@angular/material' import { BrowserModule, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser' import { BrowserAnimationsModule } from '@angular/platform-browser/animations' @@ -145,6 +146,7 @@ const getBaseHref = (platformLocation: PlatformLocation): string => { PipeSafeSanitizerModule, TourModule, PublicLogoutModule, + MatProgressSpinnerModule, ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }), ], exports: [