Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
314 changes: 178 additions & 136 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@angular/core": "^16.2.0",
"@angular/forms": "^16.2.0",
"@angular/material": "^16.2.12",
"@angular/material-moment-adapter": "^18.2.3",
"@angular/material-moment-adapter": "^16.2.12",
"@angular/platform-browser": "^16.2.0",
"@angular/platform-browser-dynamic": "^16.2.0",
"@angular/router": "^16.2.0",
Expand All @@ -54,7 +54,7 @@
"ng-cryptostore": "^16.0.0",
"ng2-charts": "^5.0.4",
"ng2-completer": "^9.0.1",
"ngx-bootstrap": "^12.0.0",
"ngx-bootstrap": "^11.0.0",
"ngx-cookie-service": "^16.1.0",
"ngx-pagination": "^6.0.3",
"ngx-webcam": "^0.4.1",
Expand Down
10 changes: 9 additions & 1 deletion src/app/app-modules/core/services/http-interceptor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@
catchError((error: HttpErrorResponse) => {
console.error(error);

if (isLoginRequest) {
return throwError(() => error.error || error);
}

let sessionExpired = false;

if (!this.isHandlingSessionExpiry) {
Expand All @@ -133,7 +137,7 @@
return EMPTY;
}

return throwError(error);
return throwError(() => error.error || error);
}),

finalize(() => {
Expand All @@ -149,6 +153,10 @@
return this.isHandlingSessionExpiry;
}

private isLoginRequest(url: string): boolean {
return url.indexOf('user/userAuthenticate') >= 0;

Check warning on line 157 in src/app/app-modules/core/services/http-interceptor.service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use `.includes()`, rather than `.indexOf()`, when checking for existence.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-UI-NEXT&issues=AZ0Jo6Aont4r1UpcBlQ-&open=AZ0Jo6Aont4r1UpcBlQ-&pullRequest=263
}

private getErrorMessage(error: any): string {
try {
if (typeof error === 'string') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ export class DoctorWorklistComponent implements OnInit, DoCheck, OnDestroy {
}

redirectToCHOReport() {
const token = JSON.parse(
this.sessionstorage.getItem('loginDataResponse'),
)?.dhistoken;
const loginDataResponse =
this.sessionstorage.getItem('loginDataResponse') ?? 'null';
const token = JSON.parse(loginDataResponse)?.dhistoken;

const url = `${environment.dhisURL}${token}`;

Expand Down
11 changes: 11 additions & 0 deletions src/app/app-modules/registrar/shared/services/registrar.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@ export class RegistrarService {
getHealthIdDetails(reqObj: any) {
return this.http.post(environment.gethealthIdDetailsUrl, reqObj);
}

getMappedFacility(workLocationId: any) {
return this.http.get(
`${environment.getAbdmMappedFacility}${workLocationId}`,
);
}

saveAbdmFacilityForVisit(reqObj: any) {
return this.http.post(environment.saveAbdmFacilityIdForVisit, reqObj);
}

generateOtpForMappingCareContext(reqObjForMapping: any) {
return this.http.post(
environment.careContextGenerateOtpUrl,
Expand Down
149 changes: 91 additions & 58 deletions src/app/user-login/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,80 +207,113 @@
.userLogoutPreviousSession(
this.loginForm.controls.userName.value,
)
.subscribe((userlogoutPreviousSession: any) => {
if (userlogoutPreviousSession.statusCode === 200) {
this.authService
.login(
this.loginForm.controls.userName.value,
encryptPassword,
true,
this.enableCaptcha
? this.captchaToken
: undefined,
)
.subscribe((userLoggedIn: any) => {
if (userLoggedIn.statusCode === 200) {
if (userLoggedIn?.data?.previlegeObj[0]) {
this.sessionstorage.setItem(
'loginDataResponse',
JSON.stringify(userLoggedIn.data),
);
this.trackingService.setUserId(
userLoggedIn.data.userID,
);
this.authService.sessionExpiredHandled =
false;
this.sessionstorage.setItem(
'loginDataResponse',
JSON.stringify(userLoggedIn.data),
);
this.getServicesAuthdetails(
userLoggedIn.data,
);
} else {
this.resetCaptcha();
this.confirmationService.alert(
'Seems you are logged in from somewhere else, Logout from there & try back in.',
'error',
);
}
} else {
this.resetCaptcha();
this.confirmationService.alert(
userLoggedIn.errorMessage,
'error',
);
}
});
} else {
this.resetCaptcha();
this.confirmationService.alert(
userlogoutPreviousSession.errorMessage,
'error',
);
}
});
.subscribe(
(userlogoutPreviousSession: any) => {
if (userlogoutPreviousSession.statusCode === 200) {
this.authService
.login(
this.loginForm.controls.userName.value,
encryptPassword,
true,
this.enableCaptcha
? this.captchaToken
: undefined,
)
.subscribe(
(userLoggedIn: any) => {

Check failure on line 223 in src/app/user-login/login/login.component.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest functions more than 4 levels deep.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-UI-NEXT&issues=AZ0Jo6EAnt4r1UpcBlQ_&open=AZ0Jo6EAnt4r1UpcBlQ_&pullRequest=263
if (userLoggedIn.statusCode === 200) {
if (userLoggedIn?.data?.previlegeObj[0]) {
this.sessionstorage.setItem(
'loginDataResponse',
JSON.stringify(userLoggedIn.data),
);
this.trackingService.setUserId(
userLoggedIn.data.userID,
);
this.authService.sessionExpiredHandled =
false;
this.sessionstorage.setItem(
'loginDataResponse',
JSON.stringify(userLoggedIn.data),
);
this.getServicesAuthdetails(
userLoggedIn.data,
);
} else {
this.resetCaptcha();
this.confirmationService.alert(
'Seems you are logged in from somewhere else, Logout from there & try back in.',
'error',
);
}
} else {
this.resetCaptcha();
this.showLoginError(userLoggedIn);
}
},
(error) => {

Check failure on line 254 in src/app/user-login/login/login.component.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest functions more than 4 levels deep.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-UI-NEXT&issues=AZ0Jo6EAnt4r1UpcBlRA&open=AZ0Jo6EAnt4r1UpcBlRA&pullRequest=263
this.showLoginError(error);
},
);
} else {
this.showLoginError(userlogoutPreviousSession);
}
},
(error) => {
this.showLoginError(error);
},
);
} else {
this.resetCaptcha();
sessionStorage.clear();
this.router.navigate(['/login']);
this.confirmationService.alert(res.errorMessage, 'error');
this.showLoginError(res);
}
});
} else {
this.resetCaptcha();
this.confirmationService.alert(res.errorMessage, 'error');
this.showLoginError(res);
}
}
},
(err) => {
this.resetCaptcha();
this.confirmationService.alert(err, 'error');
this.showLoginError(err);
},
);
}
}

private showLoginError(error: any) {
this.resetCaptcha();
this.confirmationService.alert(this.getLoginErrorMessage(error), 'error');
}

private getLoginErrorMessage(error: any): string {
if (typeof error === 'string' && error.trim()) {
return error;
}

if (error?.errorMessage && typeof error.errorMessage === 'string') {
return error.errorMessage;
}

if (error?.message && typeof error.message === 'string') {
return error.message;
}

if (
error?.error?.errorMessage &&
typeof error.error.errorMessage === 'string'
) {
return error.error.errorMessage;
}

if (error?.error?.message && typeof error.error.message === 'string') {
return error.error.message;
}

return 'Unable to login. Please try again.';
}

getServicesAuthdetails(loginDataResponse: any) {
const userName: any = this.loginForm.controls.userName.value;
sessionStorage.setItem('key', loginDataResponse.key);
Expand Down
3 changes: 2 additions & 1 deletion src/app/user-login/service/service.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ export class ServiceComponent implements OnInit, DoCheck {
const serviceProviderId: any =
this.sessionstorage.getItem('providerServiceID');
const userId: any = this.sessionstorage.getItem('userID');
const loginData = this.sessionstorage.getItem('loginDataResponse');
const loginData =
this.sessionstorage.getItem('loginDataResponse') ?? '{}';
const parsedLoginData = JSON.parse(loginData);
const designation = parsedLoginData.designation?.designationName;
this.servicePointService
Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ export const environment = {
siteKey: siteKey,
captchaChallengeURL: captchaChallengeURL,
enableCaptcha: enableCaptcha,
getUserId: `${COMMON_API}user/userName/`,
enableCHOReportBtn: enableCHOReportBtn,
dhisURL: dhisURL,
elasticSearchUrl: `${HWC_API}registrar/quickSearchES`,
Expand Down
8 changes: 8 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"paths": {
"Common-UI/*": [
"Common-UI/*"
],
"Common-UI/src/*": [
"Common-UI/src/*"
]
},
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
Expand Down