{
+ if (type == MESSAGEKEY.SUCCESS) {
+ return this.translate.get([code, "SUC_APP_F_SUM"], params)
+ } else if (type == MESSAGEKEY.ERROR) {
+ return this.translate.get([code, "ERR_APP_F_SUM"], params)
+ } else if (type == MESSAGEKEY.WARN) {
+ return this.translate.get([code, "WRN_APP_F_SUM"], params)
+ } else if (type == MESSAGEKEY.INFO) {
+ return this.translate.get([code, "INF_APP_F_SUM"], params)
+ } else if (type == MESSAGEKEY.NOTIFICATION) {
+ return this.translate.get([code, "NTF_APP_F_SUM"], params)
+ } else {
+ return this.translate.get([code, code], params)
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/app/shared/components/header/header.component.ts b/src/app/shared/components/header/header.component.ts
index 1d9e8e6..b6dd633 100644
--- a/src/app/shared/components/header/header.component.ts
+++ b/src/app/shared/components/header/header.component.ts
@@ -3,8 +3,8 @@ import { ActivatedRoute, Router } from '@angular/router';
import { SidebarService } from '../../../services/sidebar.service';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { StorageService } from '../../services/storage.service';
-import { AuthService } from '../../../services/auth.service';
import { isPlatformBrowser, formatDate, CommonModule } from '@angular/common';
+import { AuthenticationService } from '../../../services/authenticate.service';
@Component({
selector: 'app-header',
@@ -34,12 +34,10 @@ export class HeaderComponent {
vacName: any;
allVacs: any;
constructor(
- private router: Router,
public sidebarService: SidebarService,
- private translate: TranslateService,
@Inject(PLATFORM_ID) private platformId: Object,
private storageService: StorageService,
- public authService: AuthService
+ public authService: AuthenticationService
) {
this.isDropdownVisible = false;
this.isVacDropdownVisible = false;
diff --git a/src/app/shared/components/notifications/notifications.component.html b/src/app/shared/components/notifications/notifications.component.html
new file mode 100644
index 0000000..09559e0
--- /dev/null
+++ b/src/app/shared/components/notifications/notifications.component.html
@@ -0,0 +1,4 @@
+
+ {{ notification.message }}
+
+
\ No newline at end of file
diff --git a/src/app/shared/components/notifications/notifications.component.scss b/src/app/shared/components/notifications/notifications.component.scss
new file mode 100644
index 0000000..6444de6
--- /dev/null
+++ b/src/app/shared/components/notifications/notifications.component.scss
@@ -0,0 +1,88 @@
+.notification {
+ position: fixed;
+ top: 20px;
+ right: 20px;
+ max-width: 400px;
+ padding: 16px 48px 16px 20px;
+ border-radius: 6px;
+ z-index: 10000;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
+ background-color: #ffffff;
+ color: #333333;
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
+ font-size: 14px;
+ line-height: 1.4;
+ transition: opacity 0.4s ease, transform 0.3s ease;
+ animation: fadeIn 0.3s ease forwards;
+ border-left: 8px solid #c9c9c9;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+
+ &.success {
+ background-color: #e8f5e9;
+ border-color: #4caf50;
+ color: #2e7d32;
+ }
+
+ &.error {
+ background-color: #ffebee;
+ border-color: #f44336;
+ color: #c62828;
+ }
+
+ &.warning {
+ background-color: #fffde7;
+ border-color: #ffeb3b;
+ color: #fbc02d;
+ }
+
+ &.info {
+ background-color: #e3f2fd;
+ border-color: #2196f3;
+ color: #1976d2;
+ }
+
+ &.fade-out {
+ animation: fadeOut 0.4s ease forwards;
+ }
+}
+
+.close-btn {
+ position: absolute;
+ top: 12px;
+ right: 16px;
+ width: 20px;
+ height: 20px;
+ background: none;
+ border: none;
+ font-size: 20px;
+ color: inherit;
+ cursor: pointer;
+ transition: color 0.3s;
+ line-height: 1;
+ font-weight: bold;
+
+ &:hover {
+ color: #000000;
+ }
+}
+
+/* Animations */
+@keyframes fadeIn {
+ from {
+ opacity: 0;
+ transform: translateX(100px);
+ }
+ to {
+ opacity: 1;
+ transform: translateX(0);
+ }
+}
+
+@keyframes fadeOut {
+ to {
+ opacity: 0;
+ transform: translateX(100px);
+ }
+}
\ No newline at end of file
diff --git a/src/app/shared/components/notifications/notifications.component.spec.ts b/src/app/shared/components/notifications/notifications.component.spec.ts
new file mode 100644
index 0000000..108e3f2
--- /dev/null
+++ b/src/app/shared/components/notifications/notifications.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { NotificationsComponent } from './notifications.component';
+
+describe('NotificationsComponent', () => {
+ let component: NotificationsComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [NotificationsComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(NotificationsComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/shared/components/notifications/notifications.component.ts b/src/app/shared/components/notifications/notifications.component.ts
new file mode 100644
index 0000000..4608fe9
--- /dev/null
+++ b/src/app/shared/components/notifications/notifications.component.ts
@@ -0,0 +1,21 @@
+import { Component } from '@angular/core';
+import { Observable } from 'rxjs';
+import { NotificationService } from '../../services/notification.service';
+import { CommonModule } from '@angular/common';
+
+@Component({
+ selector: 'app-notifications',
+ imports: [CommonModule],
+ templateUrl: './notifications.component.html',
+ styleUrl: './notifications.component.scss'
+})
+export class NotificationsComponent {
+notifications$: Observable<{ type: string; message: string; } | null>
+
+ constructor(private notificationService: NotificationService) {
+ this.notifications$ = this.notificationService.notifications$;
+ }
+ clearNotification() {
+ this.notificationService.clearNotification();
+ }
+}
diff --git a/src/app/shared/guards/authentication.guard.ts b/src/app/shared/guards/authentication.guard.ts
new file mode 100644
index 0000000..2e21bbe
--- /dev/null
+++ b/src/app/shared/guards/authentication.guard.ts
@@ -0,0 +1,40 @@
+import { LocationStrategy } from '@angular/common';
+import { Injectable } from '@angular/core';
+import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
+import { AuthenticationResponse } from '../../authenticate/authenticate';
+import { AuthenticationService } from '../../services/authenticate.service';
+import { CredentialService } from '../../services/credential.service';
+import { FormConstants } from '../../utils/enums';
+import { ButtonManagementService } from '../../services/button-management.service';
+
+
+@Injectable(
+ { providedIn: 'root' }
+)
+export class AuthenticationGuard implements CanActivate {
+
+ constructor(private router: Router, private authService: AuthenticationService, private location: LocationStrategy, private credentialService: CredentialService,private buttonManagementService: ButtonManagementService) { }
+
+ canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
+ if (typeof window !== 'undefined' && window.localStorage) {
+ let data = JSON.parse(window.localStorage.getItem('user') || '{}') as AuthenticationResponse;
+ let permission = JSON.parse(window.localStorage.getItem('permission') || '[]');
+ if (this.authService.isAuthenticated()) {
+ this.credentialService.setPorOrgacode(window.localStorage.getItem(FormConstants.POR_ORGACODE) || '');
+ this.credentialService.setUserId(window.localStorage.getItem(FormConstants.USER_ID) || '');
+ this.credentialService.setPassword(window.localStorage.getItem(FormConstants.PASSWORD) || '');
+ this.credentialService.setToken(data.token);
+ this.credentialService.setUserType(data.userType);
+ this.credentialService.setPermission(permission);
+ this.buttonManagementService.setButtonPermissions(this.credentialService.getPermission(), this.authService.isSuperAdminUser());
+ this.authService.onAuthenticationComplete.next(true);
+ return true;
+ } else {
+ this.authService.logout();
+ return false;
+ }
+ }
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/src/app/shared/guards/gauth.guard.ts b/src/app/shared/guards/gauth.guard.ts
deleted file mode 100644
index 92e1e66..0000000
--- a/src/app/shared/guards/gauth.guard.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
-import { CanActivate, Router } from '@angular/router';
-import { isPlatformBrowser } from '@angular/common';
-
-import { AuthService } from '../../services/auth.service';
-
-
-@Injectable({
- providedIn: 'root'
-})
-export class GAuth implements CanActivate {
-
- constructor(private authservice: AuthService, private router: Router, @Inject(PLATFORM_ID) private platformId: object) { }
-
- canActivate() {
- if (this.authservice.IsLoggedIn()){
- return true;
- }
- else {
- if(isPlatformBrowser(this.platformId))
- this.router.navigate(['login']);
- return false;
- }
- }
-
-}
diff --git a/src/app/shared/interceptors/auth.interceptor.ts b/src/app/shared/interceptors/auth.interceptor.ts
index b9d139e..4f9e110 100644
--- a/src/app/shared/interceptors/auth.interceptor.ts
+++ b/src/app/shared/interceptors/auth.interceptor.ts
@@ -1,113 +1,133 @@
import { Injectable, Injector } from '@angular/core';
import {HttpRequest,HttpHandler,HttpEvent,HttpInterceptor,HttpErrorResponse} from '@angular/common/http';
import { BehaviorSubject, Observable, throwError } from 'rxjs';
-import { AuthService } from '../../services/auth.service';
-import { catchError, filter, switchMap, take, timeout } from 'rxjs/operators';
-import { MiscService } from '../services/misc.service';
-import { ServerException } from '../../services/app.server.response';
+import { catchError, filter, switchMap, take } from 'rxjs/operators';
import { ErrorMessages } from '../../utils/enums';
+import { environment } from '../../../environments/environment';
+import { CredentialService } from '../../services/credential.service';
+import { EncryptionService } from '../../services/encryption.service';
+import { NotificationService } from '../services/notification.service';
+import { I18NService } from '../../services/i18n.service';
+import { AuthenticationService } from '../../services/authenticate.service';
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
- private isRefreshing = false;
- token: any;
- private refreshTokenSubject: BehaviorSubject = new BehaviorSubject(null);
- private logoutChannel = new BroadcastChannel('logout_channel');
-
- constructor(private injector: Injector,private authService:AuthService) {}
+ private isRefreshing = false;
+ private refreshTokenSubject: BehaviorSubject = new BehaviorSubject(null);
+ private enableEncryption = environment.enableEncryption;
+ constructor(private injector: Injector, private credentialService: CredentialService, private encryptionService: EncryptionService, private notificationService: NotificationService, private i18nService: I18NService) {}
intercept(request: HttpRequest, handler: HttpHandler): Observable> {
- this.logoutChannel.onmessage = async (event) => {
- if (event.data === 'logout') {
- localStorage.clear();
- window.location.href = '/#/auth';
- }
- };
- if (this.authService.getToken()) {
- request = this.addToken(request, this.authService.getToken());
+ if (this.credentialService.getPorOrgacode()!= undefined){
+ request = this.setDefaultHeaders(request);
+ }
+ // FOR BIOMETRIC SECUGEN WE BYPASS THESE URIS AS SECUGEN DRIVERS IS USING LOCAL ENDPOINTS.
+ if (this.credentialService.getToken()&& !request.url.endsWith("/SGIFPCapture")&& !request.url.endsWith("/CreateTemplate")&& !request.url.endsWith("/verifyUserBiometric")) {
+ request = this.addToken(request, this.credentialService.getToken());
+ }
+ if(this.enableEncryption && (request.method === "POST" || request.method === "PATCH" ) && !request.url.endsWith("/SGIFPCapture")&& !request.url.endsWith("/createTemplate")&& !request.url.endsWith("/verifyUserBiometric"))
+ {
+ request = this.setEncryptionHeader(request);
+ request = this.encryptRequestBody(request);
}
return handler.handle(request).pipe(catchError(error => {
- if (error instanceof HttpErrorResponse && error.status === 401) {
- return this.handleAuthError(request, handler);
- } else {
- this.handleServerError(error);
- return throwError(error);
- }
- }))as Observable>;
- }
- private handleAuthError(request: HttpRequest, handler: HttpHandler) {
- if (!this.isRefreshing) {
- this.isRefreshing = true;
- this.refreshTokenSubject.next(null);
- let authService: AuthService = this.injector.get(AuthService);
- return authService.refreshToken().pipe(
- switchMap((response: any) => {
- this.isRefreshing = false;
- this.refreshTokenSubject.next(response.token);
- return handler.handle(this.addToken(request, response.token)).pipe(catchError(error => {
+ if (error instanceof HttpErrorResponse && error.status === 401) {
+ return this.handleAuthError(request, handler);
+ } else {
this.handleServerError(error);
return throwError(error);
- }));
- }));
+ }
+ }));
+
+}
+
+private encryptRequestBody(request: HttpRequest): HttpRequest {
+ if (Object.keys(request.body).length > 0) {
+ const encryptedData: object = this.encryptionService.encryptData(request.body);
+ const encryptedRequest: any = request.clone({ body: encryptedData });
+ return encryptedRequest;
+ }
+ return request;
+}
+
+private handleAuthError(request: HttpRequest, handler: HttpHandler) {
+ if (!this.isRefreshing) {
+ this.isRefreshing = true;
+ this.refreshTokenSubject.next(null);
+ let authService: AuthenticationService = this.injector.get(AuthenticationService);
+ return authService.refreshToken().pipe(
+ switchMap((response: any) => {
+ this.isRefreshing = false;
+ this.refreshTokenSubject.next(response.token);
+ return handler.handle(this.addToken(request, response.token)).pipe(catchError(error => {
+ this.handleServerError(error);
+ return throwError(error);
+ }));
+ }));
} else {
- return this.refreshTokenSubject.pipe(
- filter(token => token != null),
- take(1),
- switchMap(token => {
- return handler.handle(this.addToken(request, token));
- }));
+ return this.refreshTokenSubject.pipe(
+ filter(token => token != null),
+ take(1),
+ switchMap(token => {
+ return handler.handle(this.addToken(request, token));
+ }));
}
- }
- private handleServerError(error: HttpErrorResponse) {
+}
+
+private handleServerError(error: HttpErrorResponse) {
let url: string = error.url as string;
let moduleName: string = "";
- if (url != null && url != undefined) {
- moduleName = url.split(':').length > 2 ?
- url.split(':')[2].split('/')[1] :
- url.split('/')[3];
+ if (url != null && url != undefined) {
+ moduleName = url.split(':').length>2 ?
+ url.split(':')[2].split('/')[1]:
+ url.split('/')[3];
}
- let authService: AuthService = this.injector.get(AuthService);
- let miscService: MiscService = this.injector.get(MiscService);
+ let authService: AuthenticationService = this.injector.get(AuthenticationService);
switch (error.status) {
- case 400:
- let errorResponse: ServerException = error as ServerException;
- if (errorResponse.error && errorResponse.error.errorCode != null) {
- errorResponse.error.arguments.forEach((argument, index) => {
- if (miscService.getErrorMessageTranslation(argument) != argument) {
- errorResponse.error.arguments[index] = miscService.getErrorMessageTranslation(argument);
+ case 400:
+ let errorResponse:any = error ;
+ if (errorResponse.error && errorResponse.error.errorCode != null) {
+ this.i18nService.error(errorResponse.error.errorCode, errorResponse.error.arguments);
+ } else {
+ this.i18nService.error(ErrorMessages.BAD_REQUEST,[moduleName.toUpperCase()]);
}
- });
- miscService.handleError(errorResponse.error.errorCode);
- } else {
- miscService.handleError(ErrorMessages.BAD_REQUEST, [moduleName.toUpperCase()]);
- }
- break;
-
- case 401:
- miscService.handleError(ErrorMessages.UNAUTHORIZED_REQUEST,[error.error.message]);
- authService.logout();
- break;
+ break;
+ case 401:
+ this.i18nService.error(ErrorMessages.UNAUTHORIZED_REQUEST,[]);
+ authService.logout();
+ break;
- case 403:
- miscService.handleError(ErrorMessages.FORBIDDEN_REQUEST,[]);
- authService.logout();
- break;
+ case 403:
+ this.i18nService.error(ErrorMessages.FORBIDDEN_REQUEST,[]);
+ authService.logout();
+ break;
- case 500:
- miscService.handleError(ErrorMessages.INTERNAL_SERVER_ERROR,[]);
- break;
+ case 500:
+ this.i18nService.error(ErrorMessages.INTERNAL_SERVER_ERROR,[moduleName.toUpperCase()]);
+ break;
- case 0:
- miscService.handleError(ErrorMessages.CONNECTION_ERROR,[]);
- break;
+ case 0:
+ this.i18nService.error(ErrorMessages.CONNECTION_ERROR,[moduleName.toUpperCase()]);
+ break;
}
- }
- private addToken(request: HttpRequest, token: string) {
+}
+
+private addToken(request: HttpRequest, token: string) {
return request.clone({
- setHeaders: {
- 'Authorization': `Bearer ${token}`
- }
+ setHeaders: {
+ 'Authorization': `Bearer ${token}`
+ }
});
- }
+}
+
+private setDefaultHeaders(request: HttpRequest): HttpRequest {
+ const modifiedHeaders = request.headers.set('userId', this.credentialService.getUserId())
+ .append('porOrgacode', this.credentialService.getPorOrgacode())
+ return request.clone({ headers: modifiedHeaders });
+}
+private setEncryptionHeader(request: HttpRequest): HttpRequest {
+ const modifiedHeaders = request.headers.set('X-Encrypted', this.enableEncryption.toString());
+ return request.clone({ headers: modifiedHeaders });
+}
}
diff --git a/src/app/shared/services/http.service.ts b/src/app/shared/services/http.service.ts
index 75f6b18..b778c1e 100644
--- a/src/app/shared/services/http.service.ts
+++ b/src/app/shared/services/http.service.ts
@@ -1,192 +1,108 @@
+import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
-import { CONSTANTS } from '../../utils/app.constants';
-import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http';
-import { MiscService } from './misc.service';
-import { TranslateService } from '@ngx-translate/core';
-import { environment } from '../../../environments/environment';
-import { APP_URL_KEY } from '../../utils/enums';
+import { BehaviorSubject, Observable } from 'rxjs';
+import { FormConstants, HiddenValues } from '../../utils/enums';
-@Injectable({
- providedIn: 'root'
-})
+@Injectable(
+ { providedIn: 'root' }
+)
export class HttpService {
-
- API_PATH = environment.apiPath.get(APP_URL_KEY.API_PATH)
+ private loadingSubject = new BehaviorSubject(false);
+ loading$ = this.loadingSubject.asObservable();
- constructor(private translateService: TranslateService,
- private miscService: MiscService, private http: HttpClient
- ) { }
-
- getRequest(url: string, queryParams?: HttpParams, pathParams?: any, showLoader = true, options?: any) {
-
- const custId: any = localStorage.getItem("userId");
- let headers = new HttpHeaders().set("Content-Type", "application/json");
-
- const authorization = "Bearer " + localStorage.getItem('token');
- headers = headers.set("Authorization", authorization);
- headers = headers.set("cmpUserId", custId);
- let apiUrl = this.API_PATH + url;
- this.miscService.showLoader();
- apiUrl = this.replaceParamsWithValues(apiUrl, pathParams);
-
- try {
- let response = this.http.get(apiUrl, { headers: headers });
-
- if (!(response instanceof HttpErrorResponse)) {
- if (showLoader) {
- this.miscService.hideLoader();
- }
- return response;
- }
- else {
- this.miscService.handleError(this.translateService.instant('ServerError'));
- return null;
- }
- }
- catch (e) {
- console.log(e);
- return null;
+ private setLoading(loading: boolean) {
+ this.loadingSubject.next(loading);
}
- }
+
+ constructor(private http: HttpClient) {
- postRequest(url: string, data?: any, pathParams?: any, isMultipart = false, showLoader = true) {
- const custId = localStorage.getItem("userId");
- let headers = new HttpHeaders().set("Content-Type", "application/json");
- let apiUrl = this.API_PATH + url;
- this.miscService.showLoader();
- headers = headers.set("Authorization", "Bearer " + localStorage.getItem('token'));
- if (custId != null) {
- headers = headers.set("cmpUserId", custId);
}
- apiUrl = this.replaceParamsWithValues(apiUrl, pathParams);
- let formData = data;
- formData = this.setCommonParams(formData);
- if (isMultipart) {
- formData = this.convertToFormData(data);
- }
- try {
- let response = this.http.post(apiUrl, formData, { headers: headers });
-
- if (!(response instanceof HttpErrorResponse)) {
- if (showLoader) {
- this.miscService.hideLoader();
+ requestPOST(url: string, body: any, headers?: HttpHeaders, params?: HttpParams): Observable {
+ this.setLoading(true);
+ if (headers == undefined) {
+ headers = new HttpHeaders().set('Content-Type', 'application/json');
}
- return response;
- }
- else {
- this.miscService.handleError(this.translateService.instant('ServerError'));
- return null;
- }
- }
- catch (e) {
- console.log(e);
- return null;
- }
- }
-
- putRequest(url: string, data: any, pathParams?: any, isMultipart = false, showLoader = true) {
- const custId: any = localStorage.getItem("userId");
- let headers = new HttpHeaders().set("Content-Type", "application/json");
- headers = headers.set("cmpUserId", custId);
- headers = headers.set("Authorization", "Bearer " + localStorage.getItem('token'));
- let apiUrl = this.API_PATH + url;
- apiUrl = this.replaceParamsWithValues(apiUrl, pathParams);
- this.miscService.showLoader();
- let formData = data;
- formData = this.setCommonParams(formData);
- if (isMultipart) {
- formData = this.convertToFormData(data);
- }
-
- try {
- let response = this.http.put(apiUrl, formData, { headers: headers });
-
- if (!(response instanceof HttpErrorResponse)) {
- if (showLoader) {
- this.miscService.hideLoader();
+ headers = headers.set(FormConstants.POR_ORGACODE, HiddenValues.POR_ORGACODE).set(FormConstants.CHANNEL_CODE, HiddenValues.CHANNEL_CODE)
+ if (params == undefined) {
+ return this.http.post(url, body, { headers: headers })
+ } else {
+ url = this.substituePathVariables(url, params);
+ return this.http.post(url, body, { params: params, headers: headers });
}
- return response;
- }
- else {
- this.miscService.handleError(this.translateService.instant('ServerError'));
- return null;
- }
}
- catch (e) {
- console.log(e);
- return null;
+ requestPOSTMultipart(url: string, body: any, headers?: HttpHeaders, params?: HttpParams): Observable {
+ this.setLoading(true);
+ if (headers == undefined) {
+ headers = new HttpHeaders();
+ }
+ headers = headers.set(FormConstants.POR_ORGACODE, HiddenValues.POR_ORGACODE).set(FormConstants.CHANNEL_CODE, HiddenValues.CHANNEL_CODE)
+ if (params == undefined) {
+ return this.http.post(url, body, { headers: headers })
+ } else {
+ url = this.substituePathVariables(url, params);
+ return this.http.post(url, body, { params: params, headers: headers });
+ }
}
- }
-
- deleteRequest(url: any, data: any, pathParams?: any, isMultipart = false, showLoader = true) {
- const custId: any = localStorage.getItem("userId");
- let apiUrl = this.API_PATH + url;
- let headers = new HttpHeaders().set("Content-Type", "application/json");
- headers = headers.set("Authorization", "Bearer " + localStorage.getItem('token'));
- headers = headers.set("cmpUserId", custId);
- apiUrl = this.replaceParamsWithValues(apiUrl, pathParams);
+ requestGET(url: string, reqParams?: HttpParams): Observable {
+ this.setLoading(true);
+ let httpHeaders: HttpHeaders = new HttpHeaders();
+ httpHeaders = httpHeaders.set(FormConstants.POR_ORGACODE,HiddenValues.POR_ORGACODE).set(FormConstants.CHANNEL_CODE,HiddenValues.CHANNEL_CODE);
+ if (reqParams == undefined) {
+ return this.http.get(url, { headers: httpHeaders })
+ } else {
+ url = this.substituePathVariables(url, reqParams);
+ return this.http.get(url, { params: reqParams, headers: httpHeaders });
+ }
- this.miscService.showLoader();
- let formData = data;
- formData = this.setCommonParams(formData);
- if (isMultipart) {
- formData = this.convertToFormData(data);
}
- try {
- let response = this.http.delete(apiUrl, { headers: headers, body: formData });
-
- if (!(response instanceof HttpErrorResponse)) {
- if (showLoader) {
- this.miscService.hideLoader();
+ requestDELETE(url: string, reqParams: HttpParams): Observable {
+ this.setLoading(true);
+ url = this.substituePathVariables(url, reqParams);
+ let httpHeaders: HttpHeaders = new HttpHeaders().set(FormConstants.POR_ORGACODE,HiddenValues.POR_ORGACODE).set(FormConstants.CHANNEL_CODE,HiddenValues.CHANNEL_CODE);
+ if (reqParams.keys().length > 0) {
+ return this.http.delete(url, { params: reqParams, headers: httpHeaders });
+ }
+ else {
+ return this.http.delete(url, { headers: httpHeaders });
}
- return response;
- }
- else {
- this.miscService.handleError(this.translateService.instant('ServerError'));
- return null;
- }
- }
- catch (e) {
- console.log(e);
- return null;
}
- }
- addQueryParamsToUrl(url: any, queryParams: any) {
- if (queryParams && Object.keys(queryParams).length > 0) {
- let toReturn = url + '?';
- Object.keys(queryParams).forEach((key, index, arr) => {
- toReturn += `${key}=${queryParams[key]}`;
- toReturn += index === arr.length - 1 ? '' : '&';
- });
- return toReturn;
+
+ requestPATCH(url: string, body: any, headers?: HttpHeaders, params?: HttpParams): Observable {
+ this.setLoading(true);
+ if (headers == undefined) {
+ headers = new HttpHeaders().set('Content-Type', 'application/json');
+ }
+ if (params != undefined) {
+ url = this.substituePathVariables(url, params);
+ }
+ headers = headers.set(FormConstants.POR_ORGACODE,HiddenValues.POR_ORGACODE).set(FormConstants.CHANNEL_CODE, HiddenValues.CHANNEL_CODE);
+ return this.http.patch(url, body, { headers: headers, params: params });
}
- return url;
- }
- convertToFormData(data: any) {
- const formData = new FormData();
- Object.keys(data).forEach((k) => {
- formData.append(k, data[k]);
- });
- return formData;
- }
- replaceParamsWithValues(url: any, data: any) {
- data = data ?? {};
- data['porOrgacode'] = CONSTANTS.POR_ORGACODE;
- if (data && Object.keys(data).length > 0) {
- Object.keys(data).forEach((k) => {
- url = url.replace(`{${k}}`, data[k]);
- });
+ requestPUT(url: string, body: any, headers?: HttpHeaders, params?: HttpParams): Observable {
+ this.setLoading(true);
+ if (headers == undefined) {
+ headers = new HttpHeaders().set('Content-Type', 'application/json');
+ }
+ if (params != undefined) {
+ url = this.substituePathVariables(url, params);
+ }
+ headers = headers.set(FormConstants.POR_ORGACODE,HiddenValues.POR_ORGACODE).set(FormConstants.CHANNEL_CODE, HiddenValues.CHANNEL_CODE);
+ return this.http.put(url, body, { headers: headers, params: params });
}
- return url;
- }
- setCommonParams(data: any = {}) {
- data = data ?? {};
- data['porOrgacode'] = CONSTANTS.POR_ORGACODE;
- return data;
- }
-}
+ private substituePathVariables(url: string, params: HttpParams): string {
+ params.keys().forEach(param => {
+ let pathVariable: string = `{${param}}`;
+ let pathValue = params.get(param);
+ if (url.includes(pathVariable) && pathValue != null) {
+ url = url.replace(pathVariable, pathValue);
+ params.delete(param);
+ }
+ });
+ return url;
+ }
+}
\ No newline at end of file
diff --git a/src/app/shared/services/notification.service.ts b/src/app/shared/services/notification.service.ts
new file mode 100644
index 0000000..56ca38b
--- /dev/null
+++ b/src/app/shared/services/notification.service.ts
@@ -0,0 +1,40 @@
+import { Injectable } from '@angular/core';
+import { BehaviorSubject, timer } from 'rxjs';
+import { switchMap, startWith } from 'rxjs/operators';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class NotificationService {
+ private notificationSubject = new BehaviorSubject<{ type: string, message: string } | null>(null);
+ notifications$ = this.notificationSubject.asObservable();
+
+ success(message: string) {
+ this.notify('success', 'Success: ' + message);
+ }
+
+ error(message: string) {
+ this.notify('error', 'Error: ' + message);
+ }
+
+ warning(message: string) {
+ this.notify('warning', 'Warning: ' + message);
+ }
+
+ info(message: string) {
+ this.notify('info', 'Info: ' + message);
+ }
+
+ private notify(type: string, message: string) {
+ this.notificationSubject.next({ type, message });
+
+ // Automatically clear notification after 3 seconds using RxJS timer
+ this.notifications$.pipe(
+ startWith(null),
+ switchMap(() => timer(5000))
+ ).subscribe(() => this.notificationSubject.next(null));
+ }
+ clearNotification() {
+ this.notificationSubject.next(null);
+ }
+}
diff --git a/src/app/utils/app.constants.ts b/src/app/utils/app.constants.ts
index cab96e5..57635f7 100644
--- a/src/app/utils/app.constants.ts
+++ b/src/app/utils/app.constants.ts
@@ -7,3 +7,11 @@ export const pageSizeOptions = [
{ label: '10 items', value: 10 },
{ label: '20 items', value: 20 }
];
+
+export interface PermissionNode {
+ name: string;
+ checked: boolean;
+ expanded: boolean;
+ children?: PermissionNode[];
+ buttons?: PermissionNode[];
+ }
diff --git a/src/app/utils/enums.ts b/src/app/utils/enums.ts
index 076b4cc..961aa22 100644
--- a/src/app/utils/enums.ts
+++ b/src/app/utils/enums.ts
@@ -4,6 +4,7 @@ export enum ErrorMessages{
BAD_REQUEST = "ERR_APP_B_0003",
FORBIDDEN_REQUEST = "ERR_APP_B_0004",
UNAUTHORIZED_REQUEST = "ERR_APP_B_0005",
+ ALREADY_LOGGED_IN = "ALREADY_LOGGED_IN",
}
export enum supportedLanguages{
@@ -24,4 +25,45 @@ export enum selectedGatewayType{
SYRIATEL = 'Syriatel',
TWILIO = 'Twilio',
JAZZ = 'Jazz'
+}
+
+export enum FormConstants{
+ POR_ORGACODE = "POR_ORGACODE",
+ USER_ID = "USER_ID",
+ PASSWORD = "PASSWORD",
+ CHANNEL_CODE = "CHANNEL_CODE"
+}
+
+export enum HiddenValues {
+ POR_ORGACODE = "0005",
+ CHANNEL_CODE = "01",
+ ORGANIZATION_USER = "O",
+ VAC_USER = "V",
+ SUPERADMIN_USER = "S",
+ DEFAULT_PASSWORD = "12345678",
+ REVOLVING_FUND_PRODUCT = "101",
+ INTERNAL_LENDING_PRODUCT = "102",
+ REVOLVING = "R",
+ CREDIT = "C",
+ CASH_GL = "11100001"
+}
+
+export enum SuccessMessages {
+
+SAVED_SUCESSFULLY = "SUC_APP_F_0001",
+LOGIN_SUCCESSFULLY = "LOGIN_SUCCESSFULLY",
+TRANSACTION_SUCCESSFUL = "TRANSACTION_SUCCESSFUL",
+SAVED_SUCCESSFULLY = "SAVED_SUCCESSFULLY",
+RECORD_DELETED_SUCCESSFULY = "RECORD_DELETED_SUCCESSFULY",
+ACCOUNT_CLOSED_SUCCESSFULLY = "ACCOUNT_CLOSED_SUCCESSFULLY",
+SUCCESS_MESSAGE = "SUCCESS_MESSAGE"
+}
+
+export enum MESSAGEKEY {
+ SUCCESS = "SUCCESS",
+ ERROR = "ERROR",
+ WARN = "WARN",
+ INFO = "INFO",
+ NOTIFICATION = "NOTIFICATION",
+ FORM = "FORM"
}
\ No newline at end of file
diff --git a/src/app/utils/uri-enums.ts b/src/app/utils/uri-enums.ts
new file mode 100644
index 0000000..87b31be
--- /dev/null
+++ b/src/app/utils/uri-enums.ts
@@ -0,0 +1,5 @@
+
+export enum URIKey {
+ USER_LOGIN_URI = "USER_LOGIN_URI",
+ USER_REFRESH_TOKEN = "USER_REFRESH_TOKEN"
+}
\ No newline at end of file
diff --git a/src/assets/data/app.uri.json b/src/assets/data/app.uri.json
new file mode 100644
index 0000000..6442eac
--- /dev/null
+++ b/src/assets/data/app.uri.json
@@ -0,0 +1,25 @@
+[
+ {
+ "Id": "ACONNECT_DOMAIN_URI",
+ "URI": "",
+ "Modules": [
+ {
+ "Id": "ACONNECT_URI",
+ "URI": "/aconnect",
+ "Pages": [
+ {
+ "Id": "ENTITY_USER_LOGIN_URI",
+ "URI": "/authentication/login",
+ "UUID": "USER_LOGIN_URI"
+ },
+ {
+ "Id": "ENTITY_USER_REFRESH_TOKEN",
+ "URI": "/refreshtoken",
+ "UUID": "USER_REFRESH_TOKEN"
+ }
+ ]
+ }
+ ]
+ }
+
+]
\ No newline at end of file
diff --git a/src/assets/i18n/Arabic.json b/src/assets/i18n/Arabic.json
index 62bcfcf..f01d0ec 100644
--- a/src/assets/i18n/Arabic.json
+++ b/src/assets/i18n/Arabic.json
@@ -212,5 +212,7 @@
"totalItems": "السجلات",
"record": "سِجِلّ",
"previous": "سابق",
- "next": "التالي"
+ "next": "التالي",
+ "LOGIN_SUCCESSFULLY":"تم تسجيل الدخول بنجاح",
+ "ALREADY_LOGGED_IN": "المستخدم مسجل دخوله بالفعل"
}
\ No newline at end of file
diff --git a/src/assets/i18n/English.json b/src/assets/i18n/English.json
index 23d2076..35b7bcb 100644
--- a/src/assets/i18n/English.json
+++ b/src/assets/i18n/English.json
@@ -211,5 +211,7 @@
"totalItems": "Records",
"record": "Record",
"previous": "Previous",
- "next": "Next"
+ "next": "Next",
+ "LOGIN_SUCCESSFULLY":"Login SucessFully",
+ "ALREADY_LOGGED_IN": "User Already Logged In"
}
\ No newline at end of file
diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts
index ff7051f..758cb57 100644
--- a/src/environments/environment.prod.ts
+++ b/src/environments/environment.prod.ts
@@ -3,7 +3,8 @@ export const environment = {
versionNumber: '1.0.0.0',
buildNumber: '1.0',
buildDate: '27-11-2025',
- apiPath: new Map([
- ["API_PATH", "http://localhost:8080/aconnect"]
+ enableEncryption: true,
+ moduleHost: new Map([
+ ["ACONNECT_DOMAIN_URI", "http://localhost:8080"]
])
};
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index 18dfbfe..c22709a 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -3,7 +3,8 @@ export const environment = {
versionNumber: '1.0.0.0',
buildNumber: '1.0',
buildDate: '27-11-2025',
- apiPath: new Map([
- ["API_PATH", "http://localhost:8080/aconnect"]
+ enableEncryption: false,
+ moduleHost: new Map([
+ ["ACONNECT_DOMAIN_URI", "http://localhost:8080"]
])
};