Skip to content

Commit

Permalink
handling when ui-properties API taking time to fetch data
Browse files Browse the repository at this point in the history
  • Loading branch information
Madhuravas committed Sep 28, 2023
1 parent 7c153ec commit 4bf8193
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 117 deletions.
5 changes: 3 additions & 2 deletions resident-ui/src/app/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { HttpClient } from '@angular/common/http';
})
export class AppConfigService {
appConfig: any;

constructor(public http: HttpClient) { }

async loadAppConfig() {
localStorage.setItem("isDataLoaded", 'false')
this.appConfig = await this.http.get('./assets/config.json').toPromise();
this.http.get(this.appConfig.baseUrl + '/proxy/config/ui-properties').subscribe(
(response) => {
Expand Down Expand Up @@ -67,6 +67,7 @@ export class AppConfigService {
this.appConfig["mosip.kernel.rid.length"] = responseData["mosip.kernel.rid.length"];
this.appConfig["mosip.resident.transliteration.transliterate.id"] = responseData["mosip.resident.transliteration.transliterate.id"];
this.appConfig["resident.contact.details.update.id"] = responseData["resident.contact.details.update.id"]
localStorage.setItem("isDataLoaded", 'true')
},
(error) => {
console.log(error);
Expand Down
4 changes: 3 additions & 1 deletion resident-ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export class AppComponent {
if(window.location.href.includes('error=invalid_transaction')){
this.router.navigate(['error']);
}else{
this.router.navigate(['dashboard']);
if (window.location.href.includes('uinservices')) {
this.router.navigate(['dashboard']);
}
};
}
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<a (click)="onItemSelected('home')">{{popupMessages.uinservices.home }} &nbsp;&nbsp;</a> >&nbsp;&nbsp;<span
class="active">{{popupMessages.uinservices.label}}</span>
</span>
<mat-card class="login-card">
<div class="spinner" *ngIf="isLoading">
<mat-spinner></mat-spinner>
</div>
<mat-card class="login-card" *ngIf="!isLoading">
<div *ngIf="getUinData" class="form-container" [style.width]="width">
<div class="form-card" >
<div class="uin-login-title-card">
Expand Down
35 changes: 26 additions & 9 deletions resident-ui/src/app/feature/getuin/getuin/getuin.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ export class GetuinComponent implements OnInit {
"FAILURE":"failure-position-icon position-icon",
"IN-PROGRESS":"inactive-position-icon position-icon"
}
vidLength:string = "0";
uinLength:string = "0";
aidLength:string = "0";
vidLength:string;
uinLength:string;
aidLength:string;
isLoading:boolean = true;

constructor(
private router: Router,
Expand Down Expand Up @@ -80,12 +81,24 @@ export class GetuinComponent implements OnInit {
});
}

ngOnInit() {
this.siteKey = this.appConfigService.getConfig()["mosip.resident.captcha.sitekey"];
this.captchaEnable = this.appConfigService.getConfig()["mosip.resident.captcha.enable"];
this.vidLength = this.appConfigService.getConfig()["mosip.kernel.vid.length"];
this.uinLength = this.appConfigService.getConfig()["mosip.kernel.uin.length"];
this.aidLength = this.appConfigService.getConfig()["mosip.kernel.rid.length"];
getConfigData(){
if(localStorage.getItem('isDataLoaded') === 'true'){
this.siteKey = this.appConfigService.getConfig()["mosip.resident.captcha.sitekey"];
this.captchaEnable = this.appConfigService.getConfig()["mosip.resident.captcha.enable"];
this.vidLength = this.appConfigService.getConfig()["mosip.kernel.vid.length"];
this.uinLength = this.appConfigService.getConfig()["mosip.kernel.uin.length"];
this.aidLength = this.appConfigService.getConfig()["mosip.kernel.rid.length"];
this.getLangData()
this.isLoading = false;
return
}else{
setTimeout(()=>{
this.getConfigData()
},500)
}
}

getLangData(){
this.translateService.use(localStorage.getItem("langCode"));
this.translateService
.getTranslation(this.userPreferredLangCode)
Expand All @@ -98,6 +111,10 @@ export class GetuinComponent implements OnInit {
});
}

ngOnInit() {
this.getConfigData()
}

onItemSelected(item: any) {
if (item === "home") {
this.router.navigate(["dashboard"]);
Expand Down
34 changes: 22 additions & 12 deletions resident-ui/src/app/shared/captcha/captcha.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,36 @@ export class CaptchaComponent implements OnInit {
captchaLangCode:any;
constructor(private activatedRoute: ActivatedRoute,private translateService: TranslateService,) {}

ngOnInit() {
this.translateService
.getTranslation('default')
.subscribe(response => {
this.captchaLangCode = response.keyboardMapping[this.langCode]
})

setTimeout(() => {
changeCaptchLang(){
if(this.captchaLangCode){
const iframeGoogleCaptcha = document.getElementById("recaptcha-container").querySelector('iframe');
// const currentLang = iframeGoogleCaptcha.getAttribute("src").match(/hl=(.*?)&/).pop();
// if (currentLang !== lang) {
const currentLang = iframeGoogleCaptcha.getAttribute("src").match(/hl=(.*?)&/).pop();
if (currentLang !== this.captchaLangCode) {
iframeGoogleCaptcha.setAttribute(
"src",
iframeGoogleCaptcha.getAttribute("src").replace(
/hl=(.*?)&/,
'hl=' + this.captchaLangCode + '&'
)
);
// }
}, 200);
}
return
}else{
setTimeout(() => {
this.changeCaptchLang()
},100)

}
}

ngOnInit() {
this.translateService
.getTranslation('default')
.subscribe(response => {
this.captchaLangCode = response.keyboardMapping[this.langCode]
})
let count = 0;
this.changeCaptchLang()
}

ngOnChanges(): void {
Expand Down
72 changes: 25 additions & 47 deletions resident-ui/src/app/shared/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export class HeaderComponent implements OnInit, OnDestroy {
textDir = localStorage.getItem("dir");
defaultJsonValue: any;
selectedLanguage: any;
supportedLanguages: Array<string>;
selectLanguagesArr: any = [];
zoomLevel:any = [{"fontSize":"12", "label":"Small"},{"fontSize":"14", "label":"Normal"},{"fontSize":"16", "label":"Large"},{"fontSize":"18", "label":"Huge"}];
fullName: string;
Expand Down Expand Up @@ -66,57 +65,41 @@ export class HeaderComponent implements OnInit, OnDestroy {
})
}

onScroll() {
console.log("scroll down>>>");
/*this.dataStorageService
.getNotificationData(this.langCode)
.subscribe((response) => {
if(response["response"])
this.notificationList = response["response"]["data"];
console.log(this.notificationList)
});*/
}

onScrollUp() {
console.log("scroll up>>>");
/*this.dataStorageService
.getNotificationData(this.langCode)
.subscribe((response) => {
if(response["response"])
this.notificationList = response["response"]["data"];
console.log(this.notificationList)
});*/
}

async ngOnInit() {
this.defaultJsonValue = defaultJson;
let self = this;
setTimeout(()=>{
if(!localStorage.getItem("langCode")){
localStorage.setItem("langCode", "eng");
self.selectedLanguage = defaultJson["languages"][0].nativeName;
}else{
Object.keys(defaultJson["languages"]).forEach(function(key) {
if(localStorage.getItem("langCode") === key){
self.selectedLanguage = defaultJson["languages"][key].nativeName;
}
});
}

getConfigData(){
if(localStorage.getItem('isDataLoaded') === 'true'){
let supportedLanguages = this.appConfigService.getConfig()['supportedLanguages'].split(',');
if(supportedLanguages.length > 1){
supportedLanguages.map((language) => {
supportedLanguages.forEach((language) => {
this.selectLanguagesArr.push({
code: language.trim(),
value: defaultJson.languages[language.trim()].nativeName,
});
});
}

self.translateService.use(localStorage.getItem("langCode"));
self.textDir = localStorage.getItem("dir");
}, 1000);
this.translateService.use(localStorage.getItem("langCode"));
this.textDir = localStorage.getItem("dir");
return
}else{
setTimeout(()=>{
this.getConfigData()
},400)
}
}


async ngOnInit() {
this.defaultJsonValue = defaultJson;
let self = this;
this.getConfigData();

if(!localStorage.getItem("langCode")){
localStorage.setItem("langCode", "eng");
this.selectedLanguage = defaultJson["languages"]['eng'].nativeName;
}else{
let key = localStorage.getItem("langCode")
this.selectedLanguage = defaultJson["languages"][key].nativeName;
}
self.getProfileInfo();

await this.translateService
Expand All @@ -143,11 +126,6 @@ export class HeaderComponent implements OnInit, OnDestroy {
localStorage.removeItem('logOut');
}
this.activeUrl = window.location.hash
// if(localStorage.getItem("zoomLevel")){
// document.body.style["zoom"] = localStorage.getItem("zoomLevel");
// }

//window.addEventListener('scroll', this.scroll, true); //third parameter
}

getNotificationInfo(){
Expand Down
Loading

0 comments on commit 4bf8193

Please sign in to comment.