Skip to content

Commit

Permalink
Merge pull request #2 from venkykandagaddala/cbrelease-4.8.16
Browse files Browse the repository at this point in the history
Fixed the API error - Domains, Designations and Organisations
  • Loading branch information
vishnubansaltarento authored Aug 16, 2024
2 parents a91ed83 + 02cc729 commit 7467c80
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Resolve } from '@angular/router'
import { Observable, of } from 'rxjs'
import { of } from 'rxjs'
import { map, catchError } from 'rxjs/operators'
// import { IResolveResponse } from '@sunbird-cb/utils'
// import { RequestsService } from '../services/onboarding-requests.service'
Expand All @@ -14,7 +14,7 @@ export class ApprovedRequestsResolve
url: any
pageLimit = 1000
constructor(private http: HttpClient) { }
resolve(): Observable<any> {
resolve(): any {
const reqArray = window.location.pathname.split('requests/')
this.requestType = reqArray[1]
if (this.requestType === 'designation') {
Expand All @@ -36,11 +36,13 @@ export class ApprovedRequestsResolve
offset: 0,
deptName: 'iGOT',
}
return this.http.post(this.url, reqbody).pipe(
map((datanew: any) => ({
data: this.requestType === 'domain' ? datanew.result : datanew.result.data, error: null,
})),
catchError(error => of({ error, data: null })),
)
setTimeout(() => {
return this.http.post(this.url, reqbody).pipe(
map((datanew: any) => ({
data: this.requestType === 'domain' ? datanew.result : datanew.result.data, error: null,
})),
catchError(error => of({ error, data: null })),
)
}, 1000)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Resolve } from '@angular/router'
import { Observable, of } from 'rxjs'
import { of } from 'rxjs'
import { map, catchError } from 'rxjs/operators'

@Injectable()
Expand All @@ -12,7 +12,7 @@ export class RejectedRequestsResolve
url: any
pageLimit = 1000
constructor(private http: HttpClient) { }
resolve(): Observable<any> {
resolve(): any {
const reqArray = window.location.pathname.split('requests/')
this.requestType = reqArray[1]
if (this.requestType === 'designation') {
Expand All @@ -34,11 +34,14 @@ export class RejectedRequestsResolve
offset: 0,
deptName: 'iGOT',
}
return this.http.post(this.url, reqbody).pipe(
map((datanew: any) => ({
data: this.requestType === 'domain' ? datanew.result : datanew.result.data, error: null,
})),
catchError(error => of({ error, data: null })),
)
setTimeout(() => {
return this.http.post(this.url, reqbody).pipe(
map((datanew: any) => ({
data: this.requestType === 'domain' ? datanew.result : datanew.result.data, error: null,
})),
catchError(error => of({ error, data: null })),
)
}, 1000)

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Resolve } from '@angular/router'
import { Observable, of } from 'rxjs'
import { of } from 'rxjs'
import { map, catchError } from 'rxjs/operators'
// import { IResolveResponse } from '@sunbird-cb/utils'
// import { RequestsService } from '../services/onboarding-requests.service'
Expand All @@ -14,7 +14,7 @@ export class RequestsResolve
url: any
pageLimit = 1000
constructor(private http: HttpClient) { }
resolve(): Observable<any> {
resolve(): any {
const reqArray = window.location.pathname.split('requests/')
this.requestType = reqArray[1]

Expand All @@ -37,11 +37,14 @@ export class RequestsResolve
offset: 0,
deptName: 'iGOT',
}
return this.http.post(this.url, reqbody).pipe(
map((datanew: any) => ({
data: this.requestType === 'domain' ? datanew.result : datanew.result.data, error: null,
})),
catchError(error => of({ error, data: null })),
)
setTimeout(() => {
return this.http.post(this.url, reqbody).pipe(
map((datanew: any) => ({
data: this.requestType === 'domain' ? datanew.result : datanew.result.data, error: null,
})),
catchError(error => of({ error, data: null })),
)
}, 1000)

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core'
import { AfterViewChecked, ChangeDetectorRef, Component, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { RequestsService } from '../../services/onboarding-requests.service'
import { PageEvent } from '@angular/material'
Expand All @@ -9,7 +9,7 @@ import * as _ from 'lodash'
templateUrl: './onboarding-requests.component.html',
styleUrls: ['./onboarding-requests.component.scss'],
})
export class OnboardingRequestsComponent implements OnInit {
export class OnboardingRequestsComponent implements OnInit, AfterViewChecked {
tabledata: any = []
tabledataApproved: any = []
tabledataPositions: any = []
Expand All @@ -25,7 +25,10 @@ export class OnboardingRequestsComponent implements OnInit {
pendingListRecord?: number | 0
totalRecords?: number | 0

constructor(private route: Router, private activatedRoute: ActivatedRoute, private requestService: RequestsService) {
constructor(private route: Router,
private activatedRoute: ActivatedRoute,
private requestService: RequestsService,
private cdr: ChangeDetectorRef) {
// this.requestType = this.activatedRoute.snapshot.params.type
}

Expand All @@ -43,7 +46,8 @@ export class OnboardingRequestsComponent implements OnInit {
this.currentFilter = 'pending'
}
if (this.requestType === 'position') {
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.positionsList.data) {
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.positionsList
&& this.activatedRoute.snapshot.data.positionsList.data) {
const resData = this.activatedRoute.snapshot.data.positionsList.data
resData.forEach((req: any) => {
this.data.push(req)
Expand All @@ -53,7 +57,8 @@ export class OnboardingRequestsComponent implements OnInit {
this.data = []
}
} else if (this.requestType === 'organisation') {
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.requestsList.data) {
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.requestsList
&& this.activatedRoute.snapshot.data.requestsList.data) {
const resData = this.activatedRoute.snapshot.data.requestsList.data
this.formatData(resData, this.currentFilter)
} else {
Expand Down Expand Up @@ -111,6 +116,10 @@ export class OnboardingRequestsComponent implements OnInit {
})
}

ngAfterViewChecked(): void {
this.cdr.detectChanges()
}

getDisplayName() {
return this.displayType.charAt(0).toUpperCase() + this.displayType.substr(1).toLowerCase()
}
Expand Down Expand Up @@ -183,7 +192,8 @@ export class OnboardingRequestsComponent implements OnInit {
case 'pending':
this.data = []
this.currentFilter = 'pending'
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.requestsList.data && this.requestType === 'organisation') {
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.requestsList
&& this.activatedRoute.snapshot.data.requestsList.data && this.requestType === 'organisation') {
const resData = this.activatedRoute.snapshot.data.requestsList.data
this.formatData(resData, 'pending')
} else {
Expand All @@ -193,7 +203,8 @@ export class OnboardingRequestsComponent implements OnInit {
case 'approved':
this.data = []
this.currentFilter = 'approved'
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.aprovedrequestsList.data && this.requestType === 'organisation') {
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.aprovedrequestsList
&& this.activatedRoute.snapshot.data.aprovedrequestsList.data && this.requestType === 'organisation') {
const resData = this.activatedRoute.snapshot.data.aprovedrequestsList.data
this.formatData(resData, 'approved')
} else {
Expand All @@ -203,7 +214,8 @@ export class OnboardingRequestsComponent implements OnInit {
case 'rejected':
this.data = []
this.currentFilter = 'rejected'
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.rejectedList.data && this.requestType === 'organisation') {
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.rejectedList
&& this.activatedRoute.snapshot.data.rejectedList.data && this.requestType === 'organisation') {
const resData = this.activatedRoute.snapshot.data.rejectedList.data
this.formatData(resData, 'rejected')
} else {
Expand All @@ -213,7 +225,8 @@ export class OnboardingRequestsComponent implements OnInit {
case 'designations':
this.data = []
this.currentFilter = 'designations'
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.positionsList.data) {
if (this.activatedRoute.snapshot.data && this.activatedRoute.snapshot.data.positionsList
&& this.activatedRoute.snapshot.data.positionsList.data) {
const resData = this.activatedRoute.snapshot.data.positionsList.data
resData.forEach((req: any) => {
this.data.push(req)
Expand Down

0 comments on commit 7467c80

Please sign in to comment.